diff options
Diffstat (limited to 'fs/hfsplus/unicode.c')
-rw-r--r-- | fs/hfsplus/unicode.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/fs/hfsplus/unicode.c b/fs/hfsplus/unicode.c index d800aa0f2c80..a3f0bfcc881e 100644 --- a/fs/hfsplus/unicode.c +++ b/fs/hfsplus/unicode.c | |||
@@ -17,14 +17,14 @@ | |||
17 | /* Returns folded char, or 0 if ignorable */ | 17 | /* Returns folded char, or 0 if ignorable */ |
18 | static inline u16 case_fold(u16 c) | 18 | static inline u16 case_fold(u16 c) |
19 | { | 19 | { |
20 | u16 tmp; | 20 | u16 tmp; |
21 | 21 | ||
22 | tmp = hfsplus_case_fold_table[c >> 8]; | 22 | tmp = hfsplus_case_fold_table[c >> 8]; |
23 | if (tmp) | 23 | if (tmp) |
24 | tmp = hfsplus_case_fold_table[tmp + (c & 0xff)]; | 24 | tmp = hfsplus_case_fold_table[tmp + (c & 0xff)]; |
25 | else | 25 | else |
26 | tmp = c; | 26 | tmp = c; |
27 | return tmp; | 27 | return tmp; |
28 | } | 28 | } |
29 | 29 | ||
30 | /* Compare unicode strings, return values like normal strcmp */ | 30 | /* Compare unicode strings, return values like normal strcmp */ |
@@ -118,7 +118,9 @@ static u16 *hfsplus_compose_lookup(u16 *p, u16 cc) | |||
118 | return NULL; | 118 | return NULL; |
119 | } | 119 | } |
120 | 120 | ||
121 | int hfsplus_uni2asc(struct super_block *sb, const struct hfsplus_unistr *ustr, char *astr, int *len_p) | 121 | int hfsplus_uni2asc(struct super_block *sb, |
122 | const struct hfsplus_unistr *ustr, | ||
123 | char *astr, int *len_p) | ||
122 | { | 124 | { |
123 | const hfsplus_unichr *ip; | 125 | const hfsplus_unichr *ip; |
124 | struct nls_table *nls = HFSPLUS_SB(sb)->nls; | 126 | struct nls_table *nls = HFSPLUS_SB(sb)->nls; |
@@ -171,7 +173,8 @@ int hfsplus_uni2asc(struct super_block *sb, const struct hfsplus_unistr *ustr, c | |||
171 | goto same; | 173 | goto same; |
172 | c1 = be16_to_cpu(*ip); | 174 | c1 = be16_to_cpu(*ip); |
173 | if (likely(compose)) | 175 | if (likely(compose)) |
174 | ce1 = hfsplus_compose_lookup(hfsplus_compose_table, c1); | 176 | ce1 = hfsplus_compose_lookup( |
177 | hfsplus_compose_table, c1); | ||
175 | if (ce1) | 178 | if (ce1) |
176 | break; | 179 | break; |
177 | switch (c0) { | 180 | switch (c0) { |
@@ -199,7 +202,8 @@ int hfsplus_uni2asc(struct super_block *sb, const struct hfsplus_unistr *ustr, c | |||
199 | if (ce2) { | 202 | if (ce2) { |
200 | i = 1; | 203 | i = 1; |
201 | while (i < ustrlen) { | 204 | while (i < ustrlen) { |
202 | ce1 = hfsplus_compose_lookup(ce2, be16_to_cpu(ip[i])); | 205 | ce1 = hfsplus_compose_lookup(ce2, |
206 | be16_to_cpu(ip[i])); | ||
203 | if (!ce1) | 207 | if (!ce1) |
204 | break; | 208 | break; |
205 | i++; | 209 | i++; |
@@ -211,7 +215,7 @@ int hfsplus_uni2asc(struct super_block *sb, const struct hfsplus_unistr *ustr, c | |||
211 | goto done; | 215 | goto done; |
212 | } | 216 | } |
213 | } | 217 | } |
214 | same: | 218 | same: |
215 | switch (c0) { | 219 | switch (c0) { |
216 | case 0: | 220 | case 0: |
217 | cc = 0x2400; | 221 | cc = 0x2400; |
@@ -222,7 +226,7 @@ int hfsplus_uni2asc(struct super_block *sb, const struct hfsplus_unistr *ustr, c | |||
222 | default: | 226 | default: |
223 | cc = c0; | 227 | cc = c0; |
224 | } | 228 | } |
225 | done: | 229 | done: |
226 | res = nls->uni2char(cc, op, len); | 230 | res = nls->uni2char(cc, op, len); |
227 | if (res < 0) { | 231 | if (res < 0) { |
228 | if (res == -ENAMETOOLONG) | 232 | if (res == -ENAMETOOLONG) |
@@ -392,7 +396,9 @@ int hfsplus_compare_dentry(const struct dentry *parent, | |||
392 | astr1 += size; | 396 | astr1 += size; |
393 | len1 -= size; | 397 | len1 -= size; |
394 | 398 | ||
395 | if (!decompose || !(dstr1 = decompose_unichar(c, &dsize1))) { | 399 | if (decompose) |
400 | dstr1 = decompose_unichar(c, &dsize1); | ||
401 | if (!decompose || !dstr1) { | ||
396 | c1 = c; | 402 | c1 = c; |
397 | dstr1 = &c1; | 403 | dstr1 = &c1; |
398 | dsize1 = 1; | 404 | dsize1 = 1; |
@@ -404,7 +410,9 @@ int hfsplus_compare_dentry(const struct dentry *parent, | |||
404 | astr2 += size; | 410 | astr2 += size; |
405 | len2 -= size; | 411 | len2 -= size; |
406 | 412 | ||
407 | if (!decompose || !(dstr2 = decompose_unichar(c, &dsize2))) { | 413 | if (decompose) |
414 | dstr2 = decompose_unichar(c, &dsize2); | ||
415 | if (!decompose || !dstr2) { | ||
408 | c2 = c; | 416 | c2 = c; |
409 | dstr2 = &c2; | 417 | dstr2 = &c2; |
410 | dsize2 = 1; | 418 | dsize2 = 1; |