]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/tools/gensprep/gensprep.c
ICU-66108.tar.gz
[apple/icu.git] / icuSources / tools / gensprep / gensprep.c
index c3f1ade5713d0cb8dfd36ea4ac314e51b948bab8..a78a5f3e566e115c7780498071188f33683d0a6a 100644 (file)
@@ -1,12 +1,14 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2003-2009, International Business Machines
+*   Copyright (C) 2003-2016, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
 *   file name:  gensprep.c
-*   encoding:   US-ASCII
+*   encoding:   UTF-8
 *   tab size:   8 (not used)
 *   indentation:4
 *
@@ -31,6 +33,7 @@
 #include "uparse.h"
 #include "sprpimpl.h"
 
+#include "unicode/uclean.h"
 #include "unicode/udata.h"
 #include "unicode/utypes.h"
 #include "unicode/putil.h"
@@ -110,7 +113,7 @@ static int printHelp(int argc, char* argv[]){
     fprintf(stderr,
         "\t-d or --destdir          destination directory, followed by the path\n"
         "\t-s or --sourcedir        source directory of ICU data, followed by the path\n"
-        "\t-b or --bundle-name      generate the ouput data file with the name specified\n"
+        "\t-b or --bundle-name      generate the output data file with the name specified\n"
         "\t-i or --icudatadir       directory for locating any needed intermediate data files,\n"
         "\t                         followed by path, defaults to %s\n",
         u_getDataDirectory());
@@ -152,7 +155,7 @@ main(int argc, char* argv[]) {
     options[BUNDLE_NAME].value = DATA_NAME;
     options[NORMALIZE].value = "";
 
-    argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options);
+    argc=u_parseArgs(argc, argv, UPRV_LENGTHOF(options), options);
 
     /* error handling, printing usage message */
     if(argc<0) {
@@ -200,7 +203,7 @@ main(int argc, char* argv[]) {
 #else
 
     setUnicodeVersion(options[UNICODE_VERSION].value);
-    filename = (char* ) uprv_malloc(uprv_strlen(srcDir) + 300); /* hopefully this should be enough */
+    filename = (char* ) uprv_malloc(uprv_strlen(srcDir) + uprv_strlen(inputFileName) + (icuUniDataDir == NULL ? 0 : uprv_strlen(icuUniDataDir)) + 40); /* hopefully this should be enough */
    
     /* prepare the filename beginning with the source dir */
     if(uprv_strchr(srcDir,U_FILE_SEP_CHAR) == NULL && uprv_strchr(srcDir,U_FILE_ALT_SEP_CHAR) == NULL){
@@ -262,6 +265,8 @@ main(int argc, char* argv[]) {
 
     uprv_free(filename);
 
+    u_cleanup();
+
 #endif
 
     return errorCode;
@@ -273,6 +278,8 @@ static void U_CALLCONV
 normalizationCorrectionsLineFn(void *context,
                     char *fields[][2], int32_t fieldCount,
                     UErrorCode *pErrorCode) {
+    (void)context; // suppress compiler warnings about unused variable
+    (void)fieldCount; // suppress compiler warnings about unused variable
     uint32_t mapping[40];
     char *end, *s;
     uint32_t code;
@@ -336,6 +343,7 @@ static void U_CALLCONV
 strprepProfileLineFn(void *context,
               char *fields[][2], int32_t fieldCount,
               UErrorCode *pErrorCode) {
+    (void)fieldCount; // suppress compiler warnings about unused variable  
     uint32_t mapping[40];
     char *end, *map;
     uint32_t code;
@@ -350,7 +358,7 @@ strprepProfileLineFn(void *context,
     if (*s == '@') {
         /* special directive */
         s++;
-        length = fields[0][1] - s;
+        length = (int32_t)(fields[0][1] - s);
         if (length >= NORMALIZE_DIRECTIVE_LEN
             && uprv_strncmp(s, NORMALIZE_DIRECTIVE, NORMALIZE_DIRECTIVE_LEN) == 0) {
             options[NORMALIZE].doesOccur = TRUE;