| OLD | NEW |
| 1 /* | 1 /* |
| 2 *******************************************************************************
* | 2 *******************************************************************************
* |
| 3 * | 3 * |
| 4 * Copyright (C) 1998-2014, International Business Machines | 4 * Copyright (C) 1998-2015, International Business Machines |
| 5 * Corporation and others. All Rights Reserved. | 5 * Corporation and others. All Rights Reserved. |
| 6 * | 6 * |
| 7 *******************************************************************************
* | 7 *******************************************************************************
* |
| 8 * | 8 * |
| 9 * | 9 * |
| 10 * makeconv.c: | 10 * makeconv.cpp: |
| 11 * tool creating a binary (compressed) representation of the conversion mapping | 11 * tool creating a binary (compressed) representation of the conversion mapping |
| 12 * table (IBM NLTC ucmap format). | 12 * table (IBM NLTC ucmap format). |
| 13 * | 13 * |
| 14 * 05/04/2000 helena Added fallback mapping into the picture... | 14 * 05/04/2000 helena Added fallback mapping into the picture... |
| 15 * 06/29/2000 helena Major rewrite of the callback APIs. | 15 * 06/29/2000 helena Major rewrite of the callback APIs. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 #include <stdio.h> | 18 #include <stdio.h> |
| 19 #include "unicode/putil.h" | 19 #include "unicode/putil.h" |
| 20 #include "unicode/ucnv_err.h" | 20 #include "unicode/ucnv_err.h" |
| 21 #include "charstr.h" |
| 21 #include "ucnv_bld.h" | 22 #include "ucnv_bld.h" |
| 22 #include "ucnv_imp.h" | 23 #include "ucnv_imp.h" |
| 23 #include "ucnv_cnv.h" | 24 #include "ucnv_cnv.h" |
| 24 #include "cstring.h" | 25 #include "cstring.h" |
| 25 #include "cmemory.h" | 26 #include "cmemory.h" |
| 26 #include "uinvchar.h" | 27 #include "uinvchar.h" |
| 27 #include "filestrm.h" | 28 #include "filestrm.h" |
| 28 #include "toolutil.h" | 29 #include "toolutil.h" |
| 29 #include "uoptions.h" | 30 #include "uoptions.h" |
| 30 #include "unicode/udata.h" | 31 #include "unicode/udata.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 data->extData=NULL; | 64 data->extData=NULL; |
| 64 } | 65 } |
| 65 ucm_close(data->ucm); | 66 ucm_close(data->ucm); |
| 66 data->ucm=NULL; | 67 data->ucm=NULL; |
| 67 } | 68 } |
| 68 } | 69 } |
| 69 | 70 |
| 70 /* | 71 /* |
| 71 * from ucnvstat.c - static prototypes of data-based converters | 72 * from ucnvstat.c - static prototypes of data-based converters |
| 72 */ | 73 */ |
| 73 extern const UConverterStaticData * ucnv_converterStaticData[UCNV_NUMBER_OF_SUPP
ORTED_CONVERTER_TYPES]; | 74 U_CAPI const UConverterStaticData * ucnv_converterStaticData[UCNV_NUMBER_OF_SUPP
ORTED_CONVERTER_TYPES]; |
| 74 | 75 |
| 75 /* | 76 /* |
| 76 * Global - verbosity | 77 * Global - verbosity |
| 77 */ | 78 */ |
| 78 UBool VERBOSE = FALSE; | 79 UBool VERBOSE = FALSE; |
| 80 UBool QUIET = FALSE; |
| 79 UBool SMALL = FALSE; | 81 UBool SMALL = FALSE; |
| 80 UBool IGNORE_SISO_CHECK = FALSE; | 82 UBool IGNORE_SISO_CHECK = FALSE; |
| 81 | 83 |
| 82 static void | 84 static void |
| 83 createConverter(ConvData *data, const char* converterName, UErrorCode *pErrorCod
e); | 85 createConverter(ConvData *data, const char* converterName, UErrorCode *pErrorCod
e); |
| 84 | 86 |
| 85 /* | 87 /* |
| 86 * Set up the UNewData and write the converter.. | 88 * Set up the UNewData and write the converter.. |
| 87 */ | 89 */ |
| 88 static void | 90 static void |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 169 |
| 168 enum { | 170 enum { |
| 169 OPT_HELP_H, | 171 OPT_HELP_H, |
| 170 OPT_HELP_QUESTION_MARK, | 172 OPT_HELP_QUESTION_MARK, |
| 171 OPT_COPYRIGHT, | 173 OPT_COPYRIGHT, |
| 172 OPT_VERSION, | 174 OPT_VERSION, |
| 173 OPT_DESTDIR, | 175 OPT_DESTDIR, |
| 174 OPT_VERBOSE, | 176 OPT_VERBOSE, |
| 175 OPT_SMALL, | 177 OPT_SMALL, |
| 176 OPT_IGNORE_SISO_CHECK, | 178 OPT_IGNORE_SISO_CHECK, |
| 179 OPT_QUIET, |
| 180 |
| 177 OPT_COUNT | 181 OPT_COUNT |
| 178 }; | 182 }; |
| 179 | 183 |
| 180 static UOption options[]={ | 184 static UOption options[]={ |
| 181 UOPTION_HELP_H, | 185 UOPTION_HELP_H, |
| 182 UOPTION_HELP_QUESTION_MARK, | 186 UOPTION_HELP_QUESTION_MARK, |
| 183 UOPTION_COPYRIGHT, | 187 UOPTION_COPYRIGHT, |
| 184 UOPTION_VERSION, | 188 UOPTION_VERSION, |
| 185 UOPTION_DESTDIR, | 189 UOPTION_DESTDIR, |
| 186 UOPTION_VERBOSE, | 190 UOPTION_VERBOSE, |
| 187 { "small", NULL, NULL, NULL, '\1', UOPT_NO_ARG, 0 }, | 191 { "small", NULL, NULL, NULL, '\1', UOPT_NO_ARG, 0 }, |
| 188 { "ignore-siso-check", NULL, NULL, NULL, '\1', UOPT_NO_ARG, 0 } | 192 { "ignore-siso-check", NULL, NULL, NULL, '\1', UOPT_NO_ARG, 0 }, |
| 193 UOPTION_QUIET, |
| 189 }; | 194 }; |
| 190 | 195 |
| 191 int main(int argc, char* argv[]) | 196 int main(int argc, char* argv[]) |
| 192 { | 197 { |
| 193 ConvData data; | 198 ConvData data; |
| 194 UErrorCode err = U_ZERO_ERROR, localError; | |
| 195 char outFileName[UCNV_MAX_FULL_FILE_NAME_LENGTH]; | |
| 196 const char* destdir, *arg; | |
| 197 size_t destdirlen; | |
| 198 char* dot = NULL, *outBasename; | |
| 199 char cnvName[UCNV_MAX_FULL_FILE_NAME_LENGTH]; | 199 char cnvName[UCNV_MAX_FULL_FILE_NAME_LENGTH]; |
| 200 char cnvNameWithPkg[UCNV_MAX_FULL_FILE_NAME_LENGTH]; | |
| 201 UVersionInfo icuVersion; | |
| 202 UBool printFilename; | |
| 203 | |
| 204 err = U_ZERO_ERROR; | |
| 205 | 200 |
| 206 U_MAIN_INIT_ARGS(argc, argv); | 201 U_MAIN_INIT_ARGS(argc, argv); |
| 207 | 202 |
| 208 /* Set up the ICU version number */ | 203 /* Set up the ICU version number */ |
| 204 UVersionInfo icuVersion; |
| 209 u_getVersion(icuVersion); | 205 u_getVersion(icuVersion); |
| 210 uprv_memcpy(&dataInfo.dataVersion, &icuVersion, sizeof(UVersionInfo)); | 206 uprv_memcpy(&dataInfo.dataVersion, &icuVersion, sizeof(UVersionInfo)); |
| 211 | 207 |
| 212 /* preset then read command line options */ | 208 /* preset then read command line options */ |
| 213 options[OPT_DESTDIR].value=u_getDataDirectory(); | 209 options[OPT_DESTDIR].value=u_getDataDirectory(); |
| 214 argc=u_parseArgs(argc, argv, UPRV_LENGTHOF(options), options); | 210 argc=u_parseArgs(argc, argv, UPRV_LENGTHOF(options), options); |
| 215 | 211 |
| 216 /* error handling, printing usage message */ | 212 /* error handling, printing usage message */ |
| 217 if(argc<0) { | 213 if(argc<0) { |
| 218 fprintf(stderr, | 214 fprintf(stderr, |
| 219 "error in command line argument \"%s\"\n", | 215 "error in command line argument \"%s\"\n", |
| 220 argv[-argc]); | 216 argv[-argc]); |
| 221 } else if(argc<2) { | 217 } else if(argc<2) { |
| 222 argc=-1; | 218 argc=-1; |
| 223 } | 219 } |
| 224 if(argc<0 || options[OPT_HELP_H].doesOccur || options[OPT_HELP_QUESTION_MARK
].doesOccur) { | 220 if(argc<0 || options[OPT_HELP_H].doesOccur || options[OPT_HELP_QUESTION_MARK
].doesOccur) { |
| 225 FILE *stdfile=argc<0 ? stderr : stdout; | 221 FILE *stdfile=argc<0 ? stderr : stdout; |
| 226 fprintf(stdfile, | 222 fprintf(stdfile, |
| 227 "usage: %s [-options] files...\n" | 223 "usage: %s [-options] files...\n" |
| 228 "\tread .ucm codepage mapping files and write .cnv files\n" | 224 "\tread .ucm codepage mapping files and write .cnv files\n" |
| 229 "options:\n" | 225 "options:\n" |
| 230 "\t-h or -? or --help this usage text\n" | 226 "\t-h or -? or --help this usage text\n" |
| 231 "\t-V or --version show a version message\n" | 227 "\t-V or --version show a version message\n" |
| 232 "\t-c or --copyright include a copyright notice\n" | 228 "\t-c or --copyright include a copyright notice\n" |
| 233 "\t-d or --destdir destination directory, followed by the path\n
" | 229 "\t-d or --destdir destination directory, followed by the path\n
" |
| 234 "\t-v or --verbose Turn on verbose output\n", | 230 "\t-v or --verbose Turn on verbose output\n" |
| 231 "\t-q or --quiet do not display warnings and progress\n", |
| 235 argv[0]); | 232 argv[0]); |
| 236 fprintf(stdfile, | 233 fprintf(stdfile, |
| 237 "\t --small Generate smaller .cnv files. They will be\n" | 234 "\t --small Generate smaller .cnv files. They will be\n" |
| 238 "\t significantly smaller but may not be compatib
le with\n" | 235 "\t significantly smaller but may not be compatib
le with\n" |
| 239 "\t older versions of ICU and will require heap m
emory\n" | 236 "\t older versions of ICU and will require heap m
emory\n" |
| 240 "\t allocation when loaded.\n" | 237 "\t allocation when loaded.\n" |
| 241 "\t --ignore-siso-check Use SI/SO other than 0xf/0xe.\n
"); | 238 "\t --ignore-siso-check Use SI/SO other than 0xf/0xe.\n
"); |
| 242 return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR; | 239 return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR; |
| 243 } | 240 } |
| 244 | 241 |
| 245 if(options[OPT_VERSION].doesOccur) { | 242 if(options[OPT_VERSION].doesOccur) { |
| 246 printf("makeconv version %u.%u, ICU tool to read .ucm codepage mapping f
iles and write .cnv files\n", | 243 printf("makeconv version %u.%u, ICU tool to read .ucm codepage mapping f
iles and write .cnv files\n", |
| 247 dataInfo.formatVersion[0], dataInfo.formatVersion[1]); | 244 dataInfo.formatVersion[0], dataInfo.formatVersion[1]); |
| 248 printf("%s\n", U_COPYRIGHT_STRING); | 245 printf("%s\n", U_COPYRIGHT_STRING); |
| 249 exit(0); | 246 exit(0); |
| 250 } | 247 } |
| 251 | 248 |
| 252 /* get the options values */ | 249 /* get the options values */ |
| 253 haveCopyright = options[OPT_COPYRIGHT].doesOccur; | 250 haveCopyright = options[OPT_COPYRIGHT].doesOccur; |
| 254 destdir = options[OPT_DESTDIR].value; | 251 const char *destdir = options[OPT_DESTDIR].value; |
| 255 VERBOSE = options[OPT_VERBOSE].doesOccur; | 252 VERBOSE = options[OPT_VERBOSE].doesOccur; |
| 253 QUIET = options[OPT_QUIET].doesOccur; |
| 256 SMALL = options[OPT_SMALL].doesOccur; | 254 SMALL = options[OPT_SMALL].doesOccur; |
| 257 | 255 |
| 258 if (options[OPT_IGNORE_SISO_CHECK].doesOccur) { | 256 if (options[OPT_IGNORE_SISO_CHECK].doesOccur) { |
| 259 IGNORE_SISO_CHECK = TRUE; | 257 IGNORE_SISO_CHECK = TRUE; |
| 260 } | 258 } |
| 261 | 259 |
| 260 icu::CharString outFileName; |
| 261 UErrorCode err = U_ZERO_ERROR; |
| 262 if (destdir != NULL && *destdir != 0) { | 262 if (destdir != NULL && *destdir != 0) { |
| 263 uprv_strcpy(outFileName, destdir); | 263 outFileName.append(destdir, err).ensureEndsWithFileSeparator(err); |
| 264 destdirlen = uprv_strlen(destdir); | 264 if (U_FAILURE(err)) { |
| 265 outBasename = outFileName + destdirlen; | 265 return err; |
| 266 if (*(outBasename - 1) != U_FILE_SEP_CHAR) { | |
| 267 *outBasename++ = U_FILE_SEP_CHAR; | |
| 268 ++destdirlen; | |
| 269 } | 266 } |
| 270 } else { | |
| 271 destdirlen = 0; | |
| 272 outBasename = outFileName; | |
| 273 } | 267 } |
| 268 int32_t outBasenameStart = outFileName.length(); |
| 274 | 269 |
| 275 #if DEBUG | 270 #if DEBUG |
| 276 { | 271 { |
| 277 int i; | 272 int i; |
| 278 printf("makeconv: processing %d files...\n", argc - 1); | 273 printf("makeconv: processing %d files...\n", argc - 1); |
| 279 for(i=1; i<argc; ++i) { | 274 for(i=1; i<argc; ++i) { |
| 280 printf("%s ", argv[i]); | 275 printf("%s ", argv[i]); |
| 281 } | 276 } |
| 282 printf("\n"); | 277 printf("\n"); |
| 283 fflush(stdout); | 278 fflush(stdout); |
| 284 } | 279 } |
| 285 #endif | 280 #endif |
| 286 | 281 |
| 287 err = U_ZERO_ERROR; | 282 UBool printFilename = (UBool) (argc > 2 || VERBOSE); |
| 288 printFilename = (UBool) (argc > 2 || VERBOSE); | |
| 289 for (++argv; --argc; ++argv) | 283 for (++argv; --argc; ++argv) |
| 290 { | 284 { |
| 291 arg = getLongPathname(*argv); | 285 UErrorCode localError = U_ZERO_ERROR; |
| 292 | 286 const char *arg = getLongPathname(*argv); |
| 293 /* Check for potential buffer overflow */ | |
| 294 if(strlen(arg) >= UCNV_MAX_FULL_FILE_NAME_LENGTH) | |
| 295 { | |
| 296 fprintf(stderr, "%s\n", u_errorName(U_BUFFER_OVERFLOW_ERROR)); | |
| 297 return U_BUFFER_OVERFLOW_ERROR; | |
| 298 } | |
| 299 | 287 |
| 300 /*produces the right destination path for display*/ | 288 /*produces the right destination path for display*/ |
| 301 if (destdirlen != 0) | 289 outFileName.truncate(outBasenameStart); |
| 290 if (outBasenameStart != 0) |
| 302 { | 291 { |
| 303 const char *basename; | |
| 304 | |
| 305 /* find the last file sepator */ | 292 /* find the last file sepator */ |
| 306 basename = findBasename(arg); | 293 const char *basename = findBasename(arg); |
| 307 uprv_strcpy(outBasename, basename); | 294 outFileName.append(basename, localError); |
| 308 } | 295 } |
| 309 else | 296 else |
| 310 { | 297 { |
| 311 uprv_strcpy(outFileName, arg); | 298 outFileName.append(arg, localError); |
| 299 } |
| 300 if (U_FAILURE(localError)) { |
| 301 return localError; |
| 312 } | 302 } |
| 313 | 303 |
| 314 /*removes the extension if any is found*/ | 304 /*removes the extension if any is found*/ |
| 315 dot = uprv_strrchr(outBasename, '.'); | 305 int32_t lastDotIndex = outFileName.lastIndexOf('.'); |
| 316 if (dot) | 306 if (lastDotIndex >= outBasenameStart) { |
| 317 { | 307 outFileName.truncate(lastDotIndex); |
| 318 *dot = '\0'; | |
| 319 } | 308 } |
| 320 | 309 |
| 321 /* the basename without extension is the converter name */ | 310 /* the basename without extension is the converter name */ |
| 322 uprv_strcpy(cnvName, outBasename); | 311 if ((outFileName.length() - outBasenameStart) >= UPRV_LENGTHOF(cnvName))
{ |
| 312 fprintf(stderr, "converter name %s too long\n", outFileName.data() +
outBasenameStart); |
| 313 return U_BUFFER_OVERFLOW_ERROR; |
| 314 } |
| 315 uprv_strcpy(cnvName, outFileName.data() + outBasenameStart); |
| 323 | 316 |
| 324 /*Adds the target extension*/ | 317 /*Adds the target extension*/ |
| 325 uprv_strcat(outBasename, CONVERTER_FILE_EXTENSION); | 318 outFileName.append(CONVERTER_FILE_EXTENSION, localError); |
| 319 if (U_FAILURE(localError)) { |
| 320 return localError; |
| 321 } |
| 326 | 322 |
| 327 #if DEBUG | 323 #if DEBUG |
| 328 printf("makeconv: processing %s ...\n", arg); | 324 printf("makeconv: processing %s ...\n", arg); |
| 329 fflush(stdout); | 325 fflush(stdout); |
| 330 #endif | 326 #endif |
| 331 localError = U_ZERO_ERROR; | |
| 332 initConvData(&data); | 327 initConvData(&data); |
| 333 createConverter(&data, arg, &localError); | 328 createConverter(&data, arg, &localError); |
| 334 | 329 |
| 335 if (U_FAILURE(localError)) | 330 if (U_FAILURE(localError)) |
| 336 { | 331 { |
| 337 /* if an error is found, print out an error msg and keep going */ | 332 /* if an error is found, print out an error msg and keep going */ |
| 338 fprintf(stderr, "Error creating converter for \"%s\" file for \"%s\"
(%s)\n", outFileName, arg, | 333 fprintf(stderr, "Error creating converter for \"%s\" file for \"%s\"
(%s)\n", |
| 339 u_errorName(localError)); | 334 outFileName.data(), arg, u_errorName(localError)); |
| 340 if(U_SUCCESS(err)) { | 335 if(U_SUCCESS(err)) { |
| 341 err = localError; | 336 err = localError; |
| 342 } | 337 } |
| 343 } | 338 } |
| 344 else | 339 else |
| 345 { | 340 { |
| 346 /* Insure the static data name matches the file name */ | 341 /* Insure the static data name matches the file name */ |
| 347 /* Changed to ignore directory and only compare base name | 342 /* Changed to ignore directory and only compare base name |
| 348 LDH 1/2/08*/ | 343 LDH 1/2/08*/ |
| 349 char *p; | 344 char *p; |
| 350 p = strrchr(cnvName, U_FILE_SEP_CHAR); /* Find last file separator *
/ | 345 p = strrchr(cnvName, U_FILE_SEP_CHAR); /* Find last file separator *
/ |
| 351 | 346 |
| 352 if(p == NULL) /* OK, try alternate */ | 347 if(p == NULL) /* OK, try alternate */ |
| 353 { | 348 { |
| 354 p = strrchr(cnvName, U_FILE_ALT_SEP_CHAR); | 349 p = strrchr(cnvName, U_FILE_ALT_SEP_CHAR); |
| 355 if(p == NULL) | 350 if(p == NULL) |
| 356 { | 351 { |
| 357 p=cnvName; /* If no separators, no problem */ | 352 p=cnvName; /* If no separators, no problem */ |
| 358 } | 353 } |
| 359 } | 354 } |
| 360 else | 355 else |
| 361 { | 356 { |
| 362 p++; /* If found separtor, don't include it in compare */ | 357 p++; /* If found separator, don't include it in compare */ |
| 363 } | 358 } |
| 364 if(uprv_stricmp(p,data.staticData.name)) | 359 if(uprv_stricmp(p,data.staticData.name) && !QUIET) |
| 365 { | 360 { |
| 366 fprintf(stderr, "Warning: %s%s claims to be '%s'\n", | 361 fprintf(stderr, "Warning: %s%s claims to be '%s'\n", |
| 367 cnvName, CONVERTER_FILE_EXTENSION, | 362 cnvName, CONVERTER_FILE_EXTENSION, |
| 368 data.staticData.name); | 363 data.staticData.name); |
| 369 } | 364 } |
| 370 | 365 |
| 371 uprv_strcpy((char*)data.staticData.name, cnvName); | 366 uprv_strcpy((char*)data.staticData.name, cnvName); |
| 372 | 367 |
| 373 if(!uprv_isInvariantString((char*)data.staticData.name, -1)) { | 368 if(!uprv_isInvariantString((char*)data.staticData.name, -1)) { |
| 374 fprintf(stderr, | 369 fprintf(stderr, |
| 375 "Error: A converter name must contain only invariant charact
ers.\n" | 370 "Error: A converter name must contain only invariant charact
ers.\n" |
| 376 "%s is not a valid converter name.\n", | 371 "%s is not a valid converter name.\n", |
| 377 data.staticData.name); | 372 data.staticData.name); |
| 378 if(U_SUCCESS(err)) { | 373 if(U_SUCCESS(err)) { |
| 379 err = U_INVALID_TABLE_FORMAT; | 374 err = U_INVALID_TABLE_FORMAT; |
| 380 } | 375 } |
| 381 } | 376 } |
| 382 | 377 |
| 383 uprv_strcpy(cnvNameWithPkg, cnvName); | |
| 384 | |
| 385 localError = U_ZERO_ERROR; | 378 localError = U_ZERO_ERROR; |
| 386 writeConverterData(&data, cnvNameWithPkg, destdir, &localError); | 379 writeConverterData(&data, cnvName, destdir, &localError); |
| 387 | 380 |
| 388 if(U_FAILURE(localError)) | 381 if(U_FAILURE(localError)) |
| 389 { | 382 { |
| 390 /* if an error is found, print out an error msg and keep going*/ | 383 /* if an error is found, print out an error msg and keep going*/ |
| 391 fprintf(stderr, "Error writing \"%s\" file for \"%s\" (%s)\n", o
utFileName, arg, | 384 fprintf(stderr, "Error writing \"%s\" file for \"%s\" (%s)\n", o
utFileName.data(), arg, |
| 392 u_errorName(localError)); | 385 u_errorName(localError)); |
| 393 if(U_SUCCESS(err)) { | 386 if(U_SUCCESS(err)) { |
| 394 err = localError; | 387 err = localError; |
| 395 } | 388 } |
| 396 } | 389 } |
| 397 else if (printFilename) | 390 else if (printFilename) |
| 398 { | 391 { |
| 399 puts(outBasename); | 392 puts(outFileName.data() + outBasenameStart); |
| 400 } | 393 } |
| 401 } | 394 } |
| 402 fflush(stdout); | 395 fflush(stdout); |
| 403 fflush(stderr); | 396 fflush(stderr); |
| 404 | 397 |
| 405 cleanupConvData(&data); | 398 cleanupConvData(&data); |
| 406 } | 399 } |
| 407 | 400 |
| 408 return err; | 401 return err; |
| 409 } | 402 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 422 *pCCSID=(int32_t)uprv_strtoul(name, NULL, 10); | 415 *pCCSID=(int32_t)uprv_strtoul(name, NULL, 10); |
| 423 } else { | 416 } else { |
| 424 *pPlatform=UCNV_UNKNOWN; | 417 *pPlatform=UCNV_UNKNOWN; |
| 425 *pCCSID=0; | 418 *pCCSID=0; |
| 426 } | 419 } |
| 427 } | 420 } |
| 428 | 421 |
| 429 static void | 422 static void |
| 430 readHeader(ConvData *data, | 423 readHeader(ConvData *data, |
| 431 FileStream* convFile, | 424 FileStream* convFile, |
| 432 const char* converterName, | |
| 433 UErrorCode *pErrorCode) { | 425 UErrorCode *pErrorCode) { |
| 434 char line[1024]; | 426 char line[1024]; |
| 435 char *s, *key, *value; | 427 char *s, *key, *value; |
| 436 const UConverterStaticData *prototype; | 428 const UConverterStaticData *prototype; |
| 437 UConverterStaticData *staticData; | 429 UConverterStaticData *staticData; |
| 438 | 430 |
| 439 if(U_FAILURE(*pErrorCode)) { | 431 if(U_FAILURE(*pErrorCode)) { |
| 440 return; | 432 return; |
| 441 } | 433 } |
| 442 | 434 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 } | 562 } |
| 571 | 563 |
| 572 data->ucm=ucm_open(); | 564 data->ucm=ucm_open(); |
| 573 | 565 |
| 574 convFile=T_FileStream_open(converterName, "r"); | 566 convFile=T_FileStream_open(converterName, "r"); |
| 575 if(convFile==NULL) { | 567 if(convFile==NULL) { |
| 576 *pErrorCode=U_FILE_ACCESS_ERROR; | 568 *pErrorCode=U_FILE_ACCESS_ERROR; |
| 577 return FALSE; | 569 return FALSE; |
| 578 } | 570 } |
| 579 | 571 |
| 580 readHeader(data, convFile, converterName, pErrorCode); | 572 readHeader(data, convFile, pErrorCode); |
| 581 if(U_FAILURE(*pErrorCode)) { | 573 if(U_FAILURE(*pErrorCode)) { |
| 582 return FALSE; | 574 return FALSE; |
| 583 } | 575 } |
| 584 | 576 |
| 585 if(data->ucm->baseName[0]==0) { | 577 if(data->ucm->baseName[0]==0) { |
| 586 dataIsBase=TRUE; | 578 dataIsBase=TRUE; |
| 587 baseStates=&data->ucm->states; | 579 baseStates=&data->ucm->states; |
| 588 ucm_processStates(baseStates, IGNORE_SISO_CHECK); | 580 ucm_processStates(baseStates, IGNORE_SISO_CHECK); |
| 589 } else { | 581 } else { |
| 590 dataIsBase=FALSE; | 582 dataIsBase=FALSE; |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 } | 839 } |
| 848 | 840 |
| 849 /* | 841 /* |
| 850 * Hey, Emacs, please set the following: | 842 * Hey, Emacs, please set the following: |
| 851 * | 843 * |
| 852 * Local Variables: | 844 * Local Variables: |
| 853 * indent-tabs-mode: nil | 845 * indent-tabs-mode: nil |
| 854 * End: | 846 * End: |
| 855 * | 847 * |
| 856 */ | 848 */ |
| OLD | NEW |