]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/tools/makeconv/makeconv.c
ICU-531.48.tar.gz
[apple/icu.git] / icuSources / tools / makeconv / makeconv.c
index a2815e8587a7aa7abe89e9620acdd79af8fbbc68..424c962251138ce7dc9de7cb865fe198d689f0d6 100644 (file)
@@ -1,7 +1,7 @@
 /*
  ********************************************************************************
  *
 /*
  ********************************************************************************
  *
- *   Copyright (C) 1998-2008, International Business Machines
+ *   Copyright (C) 1998-2012, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *
  ********************************************************************************
  *   Corporation and others.  All Rights Reserved.
  *
  ********************************************************************************
@@ -79,6 +79,7 @@ extern const UConverterStaticData * ucnv_converterStaticData[UCNV_NUMBER_OF_SUPP
  */
 UBool VERBOSE = FALSE;
 UBool SMALL = FALSE;
  */
 UBool VERBOSE = FALSE;
 UBool SMALL = FALSE;
+UBool IGNORE_SISO_CHECK = FALSE;
 
 static void
 createConverter(ConvData *data, const char* converterName, UErrorCode *pErrorCode);
 
 static void
 createConverter(ConvData *data, const char* converterName, UErrorCode *pErrorCode);
@@ -174,6 +175,7 @@ enum {
     OPT_DESTDIR,
     OPT_VERBOSE,
     OPT_SMALL,
     OPT_DESTDIR,
     OPT_VERBOSE,
     OPT_SMALL,
+    OPT_IGNORE_SISO_CHECK,
     OPT_COUNT
 };
 
     OPT_COUNT
 };
 
@@ -184,7 +186,8 @@ static UOption options[]={
     UOPTION_VERSION,
     UOPTION_DESTDIR,
     UOPTION_VERBOSE,
     UOPTION_VERSION,
     UOPTION_DESTDIR,
     UOPTION_VERBOSE,
-    { "small", NULL, NULL, NULL, '\1', UOPT_NO_ARG, 0 }
+    { "small", NULL, NULL, NULL, '\1', UOPT_NO_ARG, 0 },
+    { "ignore-siso-check", NULL, NULL, NULL, '\1', UOPT_NO_ARG, 0 }
 };
 
 int main(int argc, char* argv[])
 };
 
 int main(int argc, char* argv[])
@@ -236,12 +239,13 @@ int main(int argc, char* argv[])
             "\t      --small       Generate smaller .cnv files. They will be\n"
             "\t                    significantly smaller but may not be compatible with\n"
             "\t                    older versions of ICU and will require heap memory\n"
             "\t      --small       Generate smaller .cnv files. They will be\n"
             "\t                    significantly smaller but may not be compatible with\n"
             "\t                    older versions of ICU and will require heap memory\n"
-            "\t                    allocation when loaded.\n");
+            "\t                    allocation when loaded.\n"
+            "\t      --ignore-siso-check         Use SI/SO other than 0xf/0xe.\n");
         return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR;
     }
 
     if(options[OPT_VERSION].doesOccur) {
         return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR;
     }
 
     if(options[OPT_VERSION].doesOccur) {
-        printf("makeconv version %hu.%hu, ICU tool to read .ucm codepage mapping files and write .cnv files\n",
+        printf("makeconv version %u.%u, ICU tool to read .ucm codepage mapping files and write .cnv files\n",
                dataInfo.formatVersion[0], dataInfo.formatVersion[1]);
         printf("%s\n", U_COPYRIGHT_STRING);
         exit(0);
                dataInfo.formatVersion[0], dataInfo.formatVersion[1]);
         printf("%s\n", U_COPYRIGHT_STRING);
         exit(0);
@@ -253,6 +257,10 @@ int main(int argc, char* argv[])
     VERBOSE = options[OPT_VERBOSE].doesOccur;
     SMALL = options[OPT_SMALL].doesOccur;
 
     VERBOSE = options[OPT_VERBOSE].doesOccur;
     SMALL = options[OPT_SMALL].doesOccur;
 
+    if (options[OPT_IGNORE_SISO_CHECK].doesOccur) {
+        IGNORE_SISO_CHECK = TRUE;
+    }
+
     if (destdir != NULL && *destdir != 0) {
         uprv_strcpy(outFileName, destdir);
         destdirlen = uprv_strlen(destdir);
     if (destdir != NULL && *destdir != 0) {
         uprv_strcpy(outFileName, destdir);
         destdirlen = uprv_strlen(destdir);
@@ -285,7 +293,7 @@ int main(int argc, char* argv[])
         arg = getLongPathname(*argv);
 
         /* Check for potential buffer overflow */
         arg = getLongPathname(*argv);
 
         /* Check for potential buffer overflow */
-        if(strlen(arg) > UCNV_MAX_FULL_FILE_NAME_LENGTH)
+        if(strlen(arg) >= UCNV_MAX_FULL_FILE_NAME_LENGTH)
         {
             fprintf(stderr, "%s\n", u_errorName(U_BUFFER_OVERFLOW_ERROR));
             return U_BUFFER_OVERFLOW_ERROR;
         {
             fprintf(stderr, "%s\n", u_errorName(U_BUFFER_OVERFLOW_ERROR));
             return U_BUFFER_OVERFLOW_ERROR;
@@ -425,7 +433,7 @@ readHeader(ConvData *data,
            FileStream* convFile,
            const char* converterName,
            UErrorCode *pErrorCode) {
            FileStream* convFile,
            const char* converterName,
            UErrorCode *pErrorCode) {
-    char line[200];
+    char line[1024];
     char *s, *key, *value;
     const UConverterStaticData *prototype;
     UConverterStaticData *staticData;
     char *s, *key, *value;
     const UConverterStaticData *prototype;
     UConverterStaticData *staticData;
@@ -552,7 +560,7 @@ readHeader(ConvData *data,
 static UBool
 readFile(ConvData *data, const char* converterName,
          UErrorCode *pErrorCode) {
 static UBool
 readFile(ConvData *data, const char* converterName,
          UErrorCode *pErrorCode) {
-    char line[200];
+    char line[1024];
     char *end;
     FileStream *convFile;
 
     char *end;
     FileStream *convFile;
 
@@ -579,7 +587,7 @@ readFile(ConvData *data, const char* converterName,
     if(data->ucm->baseName[0]==0) {
         dataIsBase=TRUE;
         baseStates=&data->ucm->states;
     if(data->ucm->baseName[0]==0) {
         dataIsBase=TRUE;
         baseStates=&data->ucm->states;
-        ucm_processStates(baseStates);
+        ucm_processStates(baseStates, IGNORE_SISO_CHECK);
     } else {
         dataIsBase=FALSE;
         baseStates=NULL;
     } else {
         dataIsBase=FALSE;
         baseStates=NULL;
@@ -782,7 +790,7 @@ createConverter(ConvData *data, const char *converterName, UErrorCode *pErrorCod
                     fprintf(stderr, "       the substitution character byte sequence is illegal in this codepage structure!\n");
                     *pErrorCode=U_INVALID_TABLE_FORMAT;
 
                     fprintf(stderr, "       the substitution character byte sequence is illegal in this codepage structure!\n");
                     *pErrorCode=U_INVALID_TABLE_FORMAT;
 
-                } else if(1!=ucm_countChars(baseStates, &staticData->subChar1, 1)) {
+                } else if(staticData->subChar1!=0 && 1!=ucm_countChars(baseStates, &staticData->subChar1, 1)) {
                     fprintf(stderr, "       the subchar1 byte is illegal in this codepage structure!\n");
                     *pErrorCode=U_INVALID_TABLE_FORMAT;
 
                     fprintf(stderr, "       the subchar1 byte is illegal in this codepage structure!\n");
                     *pErrorCode=U_INVALID_TABLE_FORMAT;