]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * unicode.c | |
3 | * | |
4 | * PURPOSE | |
5 | * Routines for converting between UTF-8 and OSTA Compressed Unicode. | |
6 | * Also handles filename mangling | |
7 | * | |
8 | * DESCRIPTION | |
9 | * OSTA Compressed Unicode is explained in the OSTA UDF specification. | |
10 | * http://www.osta.org/ | |
11 | * UTF-8 is explained in the IETF RFC XXXX. | |
12 | * ftp://ftp.internic.net/rfc/rfcxxxx.txt | |
13 | * | |
1da177e4 LT |
14 | * COPYRIGHT |
15 | * This file is distributed under the terms of the GNU General Public | |
16 | * License (GPL). Copies of the GPL can be obtained from: | |
17 | * ftp://prep.ai.mit.edu/pub/gnu/GPL | |
18 | * Each contributing author retains all rights to their own work. | |
19 | */ | |
20 | ||
21 | #include "udfdecl.h" | |
22 | ||
23 | #include <linux/kernel.h> | |
24 | #include <linux/string.h> /* for memset */ | |
25 | #include <linux/nls.h> | |
f845fced | 26 | #include <linux/crc-itu-t.h> |
1da177e4 LT |
27 | |
28 | #include "udf_sb.h" | |
29 | ||
30 | static int udf_translate_to_linux(uint8_t *, uint8_t *, int, uint8_t *, int); | |
31 | ||
28de7948 | 32 | static int udf_char_to_ustr(struct ustr *dest, const uint8_t *src, int strlen) |
1da177e4 | 33 | { |
cb00ea35 | 34 | if ((!dest) || (!src) || (!strlen) || (strlen > UDF_NAME_LEN - 2)) |
1da177e4 | 35 | return 0; |
28de7948 | 36 | |
1da177e4 LT |
37 | memset(dest, 0, sizeof(struct ustr)); |
38 | memcpy(dest->u_name, src, strlen); | |
39 | dest->u_cmpID = 0x08; | |
40 | dest->u_len = strlen; | |
28de7948 | 41 | |
1da177e4 LT |
42 | return strlen; |
43 | } | |
44 | ||
45 | /* | |
46 | * udf_build_ustr | |
47 | */ | |
28de7948 | 48 | int udf_build_ustr(struct ustr *dest, dstring *ptr, int size) |
1da177e4 LT |
49 | { |
50 | int usesize; | |
51 | ||
6305a0a9 | 52 | if (!dest || !ptr || !size) |
1da177e4 | 53 | return -1; |
6305a0a9 | 54 | BUG_ON(size < 2); |
1da177e4 | 55 | |
6305a0a9 MS |
56 | usesize = min_t(size_t, ptr[size - 1], sizeof(dest->u_name)); |
57 | usesize = min(usesize, size - 2); | |
cb00ea35 | 58 | dest->u_cmpID = ptr[0]; |
6305a0a9 MS |
59 | dest->u_len = usesize; |
60 | memcpy(dest->u_name, ptr + 1, usesize); | |
61 | memset(dest->u_name + usesize, 0, sizeof(dest->u_name) - usesize); | |
28de7948 | 62 | |
1da177e4 LT |
63 | return 0; |
64 | } | |
65 | ||
66 | /* | |
67 | * udf_build_ustr_exact | |
68 | */ | |
28de7948 | 69 | static int udf_build_ustr_exact(struct ustr *dest, dstring *ptr, int exactsize) |
1da177e4 | 70 | { |
cb00ea35 | 71 | if ((!dest) || (!ptr) || (!exactsize)) |
1da177e4 LT |
72 | return -1; |
73 | ||
74 | memset(dest, 0, sizeof(struct ustr)); | |
cb00ea35 CG |
75 | dest->u_cmpID = ptr[0]; |
76 | dest->u_len = exactsize - 1; | |
77 | memcpy(dest->u_name, ptr + 1, exactsize - 1); | |
28de7948 | 78 | |
1da177e4 LT |
79 | return 0; |
80 | } | |
81 | ||
82 | /* | |
83 | * udf_ocu_to_utf8 | |
84 | * | |
85 | * PURPOSE | |
86 | * Convert OSTA Compressed Unicode to the UTF-8 equivalent. | |
87 | * | |
1da177e4 LT |
88 | * PRE-CONDITIONS |
89 | * utf Pointer to UTF-8 output buffer. | |
90 | * ocu Pointer to OSTA Compressed Unicode input buffer | |
91 | * of size UDF_NAME_LEN bytes. | |
92 | * both of type "struct ustr *" | |
93 | * | |
94 | * POST-CONDITIONS | |
95 | * <return> Zero on success. | |
96 | * | |
97 | * HISTORY | |
98 | * November 12, 1997 - Andrew E. Mileski | |
99 | * Written, tested, and released. | |
100 | */ | |
79cfe0ff | 101 | int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i) |
1da177e4 | 102 | { |
79cfe0ff | 103 | const uint8_t *ocu; |
1da177e4 LT |
104 | uint8_t cmp_id, ocu_len; |
105 | int i; | |
106 | ||
1da177e4 | 107 | ocu_len = ocu_i->u_len; |
cb00ea35 | 108 | if (ocu_len == 0) { |
1da177e4 | 109 | memset(utf_o, 0, sizeof(struct ustr)); |
1da177e4 LT |
110 | return 0; |
111 | } | |
112 | ||
79cfe0ff | 113 | cmp_id = ocu_i->u_cmpID; |
114 | if (cmp_id != 8 && cmp_id != 16) { | |
115 | memset(utf_o, 0, sizeof(struct ustr)); | |
cb00ea35 CG |
116 | printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n", |
117 | cmp_id, ocu_i->u_name); | |
1da177e4 LT |
118 | return 0; |
119 | } | |
120 | ||
79cfe0ff | 121 | ocu = ocu_i->u_name; |
122 | utf_o->u_len = 0; | |
cb00ea35 | 123 | for (i = 0; (i < ocu_len) && (utf_o->u_len <= (UDF_NAME_LEN - 3));) { |
1da177e4 LT |
124 | |
125 | /* Expand OSTA compressed Unicode to Unicode */ | |
79cfe0ff | 126 | uint32_t c = ocu[i++]; |
1da177e4 LT |
127 | if (cmp_id == 16) |
128 | c = (c << 8) | ocu[i++]; | |
129 | ||
130 | /* Compress Unicode to UTF-8 */ | |
79cfe0ff | 131 | if (c < 0x80U) |
28de7948 | 132 | utf_o->u_name[utf_o->u_len++] = (uint8_t)c; |
79cfe0ff | 133 | else if (c < 0x800U) { |
4b11111a MS |
134 | utf_o->u_name[utf_o->u_len++] = |
135 | (uint8_t)(0xc0 | (c >> 6)); | |
136 | utf_o->u_name[utf_o->u_len++] = | |
137 | (uint8_t)(0x80 | (c & 0x3f)); | |
cb00ea35 | 138 | } else { |
4b11111a MS |
139 | utf_o->u_name[utf_o->u_len++] = |
140 | (uint8_t)(0xe0 | (c >> 12)); | |
141 | utf_o->u_name[utf_o->u_len++] = | |
142 | (uint8_t)(0x80 | | |
143 | ((c >> 6) & 0x3f)); | |
144 | utf_o->u_name[utf_o->u_len++] = | |
145 | (uint8_t)(0x80 | (c & 0x3f)); | |
1da177e4 LT |
146 | } |
147 | } | |
cb00ea35 | 148 | utf_o->u_cmpID = 8; |
1da177e4 LT |
149 | |
150 | return utf_o->u_len; | |
151 | } | |
152 | ||
153 | /* | |
154 | * | |
155 | * udf_utf8_to_ocu | |
156 | * | |
157 | * PURPOSE | |
158 | * Convert UTF-8 to the OSTA Compressed Unicode equivalent. | |
159 | * | |
160 | * DESCRIPTION | |
161 | * This routine is only called by udf_lookup(). | |
162 | * | |
163 | * PRE-CONDITIONS | |
164 | * ocu Pointer to OSTA Compressed Unicode output | |
165 | * buffer of size UDF_NAME_LEN bytes. | |
166 | * utf Pointer to UTF-8 input buffer. | |
167 | * utf_len Length of UTF-8 input buffer in bytes. | |
168 | * | |
169 | * POST-CONDITIONS | |
170 | * <return> Zero on success. | |
171 | * | |
172 | * HISTORY | |
173 | * November 12, 1997 - Andrew E. Mileski | |
174 | * Written, tested, and released. | |
175 | */ | |
28de7948 | 176 | static int udf_UTF8toCS0(dstring *ocu, struct ustr *utf, int length) |
1da177e4 LT |
177 | { |
178 | unsigned c, i, max_val, utf_char; | |
179 | int utf_cnt, u_len; | |
180 | ||
181 | memset(ocu, 0, sizeof(dstring) * length); | |
182 | ocu[0] = 8; | |
183 | max_val = 0xffU; | |
184 | ||
28de7948 | 185 | try_again: |
1da177e4 LT |
186 | u_len = 0U; |
187 | utf_char = 0U; | |
188 | utf_cnt = 0U; | |
cb00ea35 | 189 | for (i = 0U; i < utf->u_len; i++) { |
28de7948 | 190 | c = (uint8_t)utf->u_name[i]; |
1da177e4 LT |
191 | |
192 | /* Complete a multi-byte UTF-8 character */ | |
cb00ea35 | 193 | if (utf_cnt) { |
1da177e4 LT |
194 | utf_char = (utf_char << 6) | (c & 0x3fU); |
195 | if (--utf_cnt) | |
196 | continue; | |
cb00ea35 | 197 | } else { |
1da177e4 | 198 | /* Check for a multi-byte UTF-8 character */ |
cb00ea35 | 199 | if (c & 0x80U) { |
1da177e4 | 200 | /* Start a multi-byte UTF-8 character */ |
cb00ea35 | 201 | if ((c & 0xe0U) == 0xc0U) { |
1da177e4 LT |
202 | utf_char = c & 0x1fU; |
203 | utf_cnt = 1; | |
cb00ea35 | 204 | } else if ((c & 0xf0U) == 0xe0U) { |
1da177e4 LT |
205 | utf_char = c & 0x0fU; |
206 | utf_cnt = 2; | |
cb00ea35 | 207 | } else if ((c & 0xf8U) == 0xf0U) { |
1da177e4 LT |
208 | utf_char = c & 0x07U; |
209 | utf_cnt = 3; | |
cb00ea35 | 210 | } else if ((c & 0xfcU) == 0xf8U) { |
1da177e4 LT |
211 | utf_char = c & 0x03U; |
212 | utf_cnt = 4; | |
cb00ea35 | 213 | } else if ((c & 0xfeU) == 0xfcU) { |
1da177e4 LT |
214 | utf_char = c & 0x01U; |
215 | utf_cnt = 5; | |
28de7948 | 216 | } else { |
1da177e4 | 217 | goto error_out; |
28de7948 | 218 | } |
1da177e4 | 219 | continue; |
28de7948 | 220 | } else { |
1da177e4 LT |
221 | /* Single byte UTF-8 character (most common) */ |
222 | utf_char = c; | |
28de7948 | 223 | } |
1da177e4 LT |
224 | } |
225 | ||
226 | /* Choose no compression if necessary */ | |
cb00ea35 | 227 | if (utf_char > max_val) { |
28de7948 | 228 | if (max_val == 0xffU) { |
1da177e4 | 229 | max_val = 0xffffU; |
28de7948 | 230 | ocu[0] = (uint8_t)0x10U; |
1da177e4 LT |
231 | goto try_again; |
232 | } | |
233 | goto error_out; | |
234 | } | |
235 | ||
4b11111a | 236 | if (max_val == 0xffffU) |
28de7948 | 237 | ocu[++u_len] = (uint8_t)(utf_char >> 8); |
28de7948 | 238 | ocu[++u_len] = (uint8_t)(utf_char & 0xffU); |
1da177e4 LT |
239 | } |
240 | ||
cb00ea35 | 241 | if (utf_cnt) { |
28de7948 | 242 | error_out: |
1da177e4 LT |
243 | ocu[++u_len] = '?'; |
244 | printk(KERN_DEBUG "udf: bad UTF-8 character\n"); | |
245 | } | |
246 | ||
28de7948 CG |
247 | ocu[length - 1] = (uint8_t)u_len + 1; |
248 | ||
1da177e4 LT |
249 | return u_len + 1; |
250 | } | |
251 | ||
cb00ea35 | 252 | static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o, |
34f953dd | 253 | const struct ustr *ocu_i) |
1da177e4 | 254 | { |
34f953dd | 255 | const uint8_t *ocu; |
1da177e4 | 256 | uint8_t cmp_id, ocu_len; |
59285c28 | 257 | int i, len; |
1da177e4 | 258 | |
1da177e4 LT |
259 | |
260 | ocu_len = ocu_i->u_len; | |
cb00ea35 | 261 | if (ocu_len == 0) { |
1da177e4 | 262 | memset(utf_o, 0, sizeof(struct ustr)); |
1da177e4 LT |
263 | return 0; |
264 | } | |
265 | ||
34f953dd | 266 | cmp_id = ocu_i->u_cmpID; |
267 | if (cmp_id != 8 && cmp_id != 16) { | |
268 | memset(utf_o, 0, sizeof(struct ustr)); | |
cb00ea35 CG |
269 | printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n", |
270 | cmp_id, ocu_i->u_name); | |
1da177e4 LT |
271 | return 0; |
272 | } | |
273 | ||
34f953dd | 274 | ocu = ocu_i->u_name; |
275 | utf_o->u_len = 0; | |
cb00ea35 | 276 | for (i = 0; (i < ocu_len) && (utf_o->u_len <= (UDF_NAME_LEN - 3));) { |
1da177e4 | 277 | /* Expand OSTA compressed Unicode to Unicode */ |
34f953dd | 278 | uint32_t c = ocu[i++]; |
1da177e4 LT |
279 | if (cmp_id == 16) |
280 | c = (c << 8) | ocu[i++]; | |
281 | ||
59285c28 JK |
282 | len = nls->uni2char(c, &utf_o->u_name[utf_o->u_len], |
283 | UDF_NAME_LEN - utf_o->u_len); | |
284 | /* Valid character? */ | |
285 | if (len >= 0) | |
286 | utf_o->u_len += len; | |
287 | else | |
288 | utf_o->u_name[utf_o->u_len++] = '?'; | |
1da177e4 | 289 | } |
cb00ea35 | 290 | utf_o->u_cmpID = 8; |
1da177e4 LT |
291 | |
292 | return utf_o->u_len; | |
293 | } | |
294 | ||
28de7948 | 295 | static int udf_NLStoCS0(struct nls_table *nls, dstring *ocu, struct ustr *uni, |
cb00ea35 | 296 | int length) |
1da177e4 | 297 | { |
59285c28 JK |
298 | int len; |
299 | unsigned i, max_val; | |
1da177e4 LT |
300 | uint16_t uni_char; |
301 | int u_len; | |
302 | ||
303 | memset(ocu, 0, sizeof(dstring) * length); | |
304 | ocu[0] = 8; | |
305 | max_val = 0xffU; | |
306 | ||
28de7948 | 307 | try_again: |
1da177e4 | 308 | u_len = 0U; |
cb00ea35 CG |
309 | for (i = 0U; i < uni->u_len; i++) { |
310 | len = nls->char2uni(&uni->u_name[i], uni->u_len - i, &uni_char); | |
59285c28 | 311 | if (!len) |
1da177e4 | 312 | continue; |
59285c28 JK |
313 | /* Invalid character, deal with it */ |
314 | if (len < 0) { | |
315 | len = 1; | |
316 | uni_char = '?'; | |
317 | } | |
1da177e4 | 318 | |
cb00ea35 | 319 | if (uni_char > max_val) { |
1da177e4 | 320 | max_val = 0xffffU; |
28de7948 | 321 | ocu[0] = (uint8_t)0x10U; |
1da177e4 LT |
322 | goto try_again; |
323 | } | |
cb00ea35 | 324 | |
1da177e4 | 325 | if (max_val == 0xffffU) |
28de7948 CG |
326 | ocu[++u_len] = (uint8_t)(uni_char >> 8); |
327 | ocu[++u_len] = (uint8_t)(uni_char & 0xffU); | |
1da177e4 LT |
328 | i += len - 1; |
329 | } | |
330 | ||
28de7948 | 331 | ocu[length - 1] = (uint8_t)u_len + 1; |
1da177e4 LT |
332 | return u_len + 1; |
333 | } | |
334 | ||
28de7948 | 335 | int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname, |
cb00ea35 | 336 | int flen) |
1da177e4 | 337 | { |
530f1a5e MS |
338 | struct ustr *filename, *unifilename; |
339 | int len = 0; | |
1da177e4 | 340 | |
530f1a5e MS |
341 | filename = kmalloc(sizeof(struct ustr), GFP_NOFS); |
342 | if (!filename) | |
1da177e4 | 343 | return 0; |
1da177e4 | 344 | |
530f1a5e MS |
345 | unifilename = kmalloc(sizeof(struct ustr), GFP_NOFS); |
346 | if (!unifilename) | |
347 | goto out1; | |
348 | ||
349 | if (udf_build_ustr_exact(unifilename, sname, flen)) | |
350 | goto out2; | |
351 | ||
cb00ea35 | 352 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { |
530f1a5e | 353 | if (!udf_CS0toUTF8(filename, unifilename)) { |
4b11111a MS |
354 | udf_debug("Failed in udf_get_filename: sname = %s\n", |
355 | sname); | |
530f1a5e | 356 | goto out2; |
1da177e4 | 357 | } |
cb00ea35 | 358 | } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { |
530f1a5e MS |
359 | if (!udf_CS0toNLS(UDF_SB(sb)->s_nls_map, filename, |
360 | unifilename)) { | |
4b11111a MS |
361 | udf_debug("Failed in udf_get_filename: sname = %s\n", |
362 | sname); | |
530f1a5e | 363 | goto out2; |
1da177e4 | 364 | } |
4b11111a | 365 | } else |
530f1a5e MS |
366 | goto out2; |
367 | ||
368 | len = udf_translate_to_linux(dname, filename->u_name, filename->u_len, | |
369 | unifilename->u_name, unifilename->u_len); | |
370 | out2: | |
371 | kfree(unifilename); | |
372 | out1: | |
373 | kfree(filename); | |
374 | return len; | |
1da177e4 LT |
375 | } |
376 | ||
28de7948 CG |
377 | int udf_put_filename(struct super_block *sb, const uint8_t *sname, |
378 | uint8_t *dname, int flen) | |
1da177e4 LT |
379 | { |
380 | struct ustr unifilename; | |
381 | int namelen; | |
382 | ||
4b11111a | 383 | if (!udf_char_to_ustr(&unifilename, sname, flen)) |
1da177e4 | 384 | return 0; |
1da177e4 | 385 | |
cb00ea35 | 386 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { |
28de7948 | 387 | namelen = udf_UTF8toCS0(dname, &unifilename, UDF_NAME_LEN); |
4b11111a | 388 | if (!namelen) |
1da177e4 | 389 | return 0; |
cb00ea35 | 390 | } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { |
4b11111a MS |
391 | namelen = udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname, |
392 | &unifilename, UDF_NAME_LEN); | |
393 | if (!namelen) | |
1da177e4 | 394 | return 0; |
4b11111a | 395 | } else |
1da177e4 LT |
396 | return 0; |
397 | ||
398 | return namelen; | |
399 | } | |
400 | ||
401 | #define ILLEGAL_CHAR_MARK '_' | |
28de7948 CG |
402 | #define EXT_MARK '.' |
403 | #define CRC_MARK '#' | |
404 | #define EXT_SIZE 5 | |
1da177e4 | 405 | |
4b11111a MS |
406 | static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, |
407 | int udfLen, uint8_t *fidName, | |
408 | int fidNameLen) | |
1da177e4 | 409 | { |
cb00ea35 | 410 | int index, newIndex = 0, needsCRC = 0; |
1da177e4 LT |
411 | int extIndex = 0, newExtIndex = 0, hasExt = 0; |
412 | unsigned short valueCRC; | |
413 | uint8_t curr; | |
414 | const uint8_t hexChar[] = "0123456789ABCDEF"; | |
415 | ||
28de7948 CG |
416 | if (udfName[0] == '.' && |
417 | (udfLen == 1 || (udfLen == 2 && udfName[1] == '.'))) { | |
1da177e4 LT |
418 | needsCRC = 1; |
419 | newIndex = udfLen; | |
420 | memcpy(newName, udfName, udfLen); | |
cb00ea35 CG |
421 | } else { |
422 | for (index = 0; index < udfLen; index++) { | |
1da177e4 | 423 | curr = udfName[index]; |
cb00ea35 | 424 | if (curr == '/' || curr == 0) { |
1da177e4 LT |
425 | needsCRC = 1; |
426 | curr = ILLEGAL_CHAR_MARK; | |
4b11111a MS |
427 | while (index + 1 < udfLen && |
428 | (udfName[index + 1] == '/' || | |
429 | udfName[index + 1] == 0)) | |
1da177e4 | 430 | index++; |
4b11111a MS |
431 | } |
432 | if (curr == EXT_MARK && | |
433 | (udfLen - index - 1) <= EXT_SIZE) { | |
434 | if (udfLen == index + 1) | |
1da177e4 | 435 | hasExt = 0; |
4b11111a | 436 | else { |
1da177e4 LT |
437 | hasExt = 1; |
438 | extIndex = index; | |
439 | newExtIndex = newIndex; | |
440 | } | |
441 | } | |
442 | if (newIndex < 256) | |
443 | newName[newIndex++] = curr; | |
444 | else | |
445 | needsCRC = 1; | |
446 | } | |
447 | } | |
cb00ea35 | 448 | if (needsCRC) { |
1da177e4 LT |
449 | uint8_t ext[EXT_SIZE]; |
450 | int localExtIndex = 0; | |
451 | ||
cb00ea35 | 452 | if (hasExt) { |
1da177e4 | 453 | int maxFilenameLen; |
4b11111a MS |
454 | for (index = 0; |
455 | index < EXT_SIZE && extIndex + index + 1 < udfLen; | |
456 | index++) { | |
1da177e4 LT |
457 | curr = udfName[extIndex + index + 1]; |
458 | ||
cb00ea35 | 459 | if (curr == '/' || curr == 0) { |
1da177e4 LT |
460 | needsCRC = 1; |
461 | curr = ILLEGAL_CHAR_MARK; | |
4b11111a MS |
462 | while (extIndex + index + 2 < udfLen && |
463 | (index + 1 < EXT_SIZE && | |
464 | (udfName[extIndex + index + 2] == '/' || | |
465 | udfName[extIndex + index + 2] == 0))) | |
1da177e4 LT |
466 | index++; |
467 | } | |
468 | ext[localExtIndex++] = curr; | |
469 | } | |
470 | maxFilenameLen = 250 - localExtIndex; | |
471 | if (newIndex > maxFilenameLen) | |
472 | newIndex = maxFilenameLen; | |
473 | else | |
474 | newIndex = newExtIndex; | |
4b11111a | 475 | } else if (newIndex > 250) |
1da177e4 LT |
476 | newIndex = 250; |
477 | newName[newIndex++] = CRC_MARK; | |
f845fced | 478 | valueCRC = crc_itu_t(0, fidName, fidNameLen); |
1da177e4 LT |
479 | newName[newIndex++] = hexChar[(valueCRC & 0xf000) >> 12]; |
480 | newName[newIndex++] = hexChar[(valueCRC & 0x0f00) >> 8]; | |
481 | newName[newIndex++] = hexChar[(valueCRC & 0x00f0) >> 4]; | |
482 | newName[newIndex++] = hexChar[(valueCRC & 0x000f)]; | |
483 | ||
cb00ea35 | 484 | if (hasExt) { |
1da177e4 | 485 | newName[newIndex++] = EXT_MARK; |
cb00ea35 | 486 | for (index = 0; index < localExtIndex; index++) |
1da177e4 LT |
487 | newName[newIndex++] = ext[index]; |
488 | } | |
489 | } | |
28de7948 | 490 | |
1da177e4 LT |
491 | return newIndex; |
492 | } |