Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: source/tools/gencfu/gencfu.cpp

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/tools/genccode/genccode.vcxproj.filters ('k') | source/tools/gencfu/gencfu.vcxproj » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ********************************************************************** 2 **********************************************************************
3 * Copyright (C) 2009-2011, International Business Machines 3 * Copyright (C) 2009-2015, International Business Machines
4 * Corporation and others. All Rights Reserved. 4 * Corporation and others. All Rights Reserved.
5 ********************************************************************** 5 **********************************************************************
6 * 6 *
7 * File gencfu.c 7 * File gencfu.c
8 */ 8 */
9 9
10 //-------------------------------------------------------------------- 10 //--------------------------------------------------------------------
11 // 11 //
12 // Tool for generating Unicode Confusable data files (.cfu files). 12 // Tool for generating Unicode Confusable data files (.cfu files).
13 // .cfu files contain the compiled of the confusable data 13 // .cfu files contain the compiled of the confusable data
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 static UOption options[]={ 49 static UOption options[]={
50 UOPTION_HELP_H, /* 0 */ 50 UOPTION_HELP_H, /* 0 */
51 UOPTION_HELP_QUESTION_MARK, /* 1 */ 51 UOPTION_HELP_QUESTION_MARK, /* 1 */
52 UOPTION_VERBOSE, /* 2 */ 52 UOPTION_VERBOSE, /* 2 */
53 { "rules", NULL, NULL, NULL, 'r', UOPT_REQUIRES_ARG, 0 }, /* 3 */ 53 { "rules", NULL, NULL, NULL, 'r', UOPT_REQUIRES_ARG, 0 }, /* 3 */
54 { "wsrules", NULL, NULL, NULL, 'w', UOPT_REQUIRES_ARG, 0}, /* 4 */ 54 { "wsrules", NULL, NULL, NULL, 'w', UOPT_REQUIRES_ARG, 0}, /* 4 */
55 { "out", NULL, NULL, NULL, 'o', UOPT_REQUIRES_ARG, 0 }, /* 5 */ 55 { "out", NULL, NULL, NULL, 'o', UOPT_REQUIRES_ARG, 0 }, /* 5 */
56 UOPTION_ICUDATADIR, /* 6 */ 56 UOPTION_ICUDATADIR, /* 6 */
57 UOPTION_DESTDIR, /* 7 */ 57 UOPTION_DESTDIR, /* 7 */
58 UOPTION_COPYRIGHT, /* 8 */ 58 UOPTION_COPYRIGHT, /* 8 */
59 UOPTION_QUIET, /* 9 */
59 }; 60 };
60 61
61 void usageAndDie(int retCode) { 62 void usageAndDie(int retCode) {
62 printf("Usage: %s [-v] [-options] -r confusablesRules.txt -w wholeScript Confusables.txt -o output-file\n", progName); 63 printf("Usage: %s [-v] [-options] -r confusablesRules.txt -w wholeScript Confusables.txt -o output-file\n", progName);
63 printf("\tRead in Unicode confusable character definitions and write out the binary data\n" 64 printf("\tRead in Unicode confusable character definitions and write out the binary data\n"
64 "options:\n" 65 "options:\n"
65 "\t-h or -? or --help this usage text\n" 66 "\t-h or -? or --help this usage text\n"
66 "\t-V or --version show a version message\n" 67 "\t-V or --version show a version message\n"
67 "\t-c or --copyright include a copyright notice\n" 68 "\t-c or --copyright include a copyright notice\n"
68 "\t-v or --verbose turn on verbose output\n" 69 "\t-v or --verbose turn on verbose output\n"
70 "\t-q or --quiet do not display warnings and progress\n"
69 "\t-i or --icudatadir directory for locating any needed intermediat e data files,\n" 71 "\t-i or --icudatadir directory for locating any needed intermediat e data files,\n"
70 "\t followed by path, defaults to %s\n" 72 "\t followed by path, defaults to %s\n"
71 "\t-d or --destdir destination directory, followed by the path\n ", 73 "\t-d or --destdir destination directory, followed by the path\n ",
72 u_getDataDirectory()); 74 u_getDataDirectory());
73 exit (retCode); 75 exit (retCode);
74 } 76 }
75 77
76 78
77 #if UCONFIG_NO_REGULAR_EXPRESSIONS || UCONFIG_NO_NORMALIZATION || UCONFIG_NO_FIL E_IO 79 #if UCONFIG_NO_REGULAR_EXPRESSIONS || UCONFIG_NO_NORMALIZATION || UCONFIG_NO_FIL E_IO
78 80
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 status = U_ZERO_ERROR; 169 status = U_ZERO_ERROR;
168 170
169 /* Combine the directory with the file name */ 171 /* Combine the directory with the file name */
170 if(options[7].doesOccur) { 172 if(options[7].doesOccur) {
171 outDir = options[7].value; 173 outDir = options[7].value;
172 } 174 }
173 if (options[8].doesOccur) { 175 if (options[8].doesOccur) {
174 copyright = U_COPYRIGHT_STRING; 176 copyright = U_COPYRIGHT_STRING;
175 } 177 }
176 178
179 UBool quiet = FALSE;
180 if (options[9].doesOccur) {
181 quiet = TRUE;
182 }
183
177 #if UCONFIG_NO_REGULAR_EXPRESSIONS || UCONFIG_NO_NORMALIZATION || UCONFIG_NO_FIL E_IO 184 #if UCONFIG_NO_REGULAR_EXPRESSIONS || UCONFIG_NO_NORMALIZATION || UCONFIG_NO_FIL E_IO
178 // spoof detection data file parsing is dependent on regular expressions. 185 // spoof detection data file parsing is dependent on regular expressions.
179 // TODO: have the tool return an error status. Requires fixing the ICU data build 186 // TODO: have the tool return an error status. Requires fixing the ICU data build
180 // so that it doesn't abort entirely on that error. 187 // so that it doesn't abort entirely on that error.
181 188
182 UNewDataMemory *pData; 189 UNewDataMemory *pData;
183 char msg[1024]; 190 char msg[1024];
184 191
185 /* write message with just the name */ 192 /* write message with just the name */
186 sprintf(msg, "gencfu writes dummy %s because of UCONFIG_NO_REGULAR_EXPRESSIO NS and/or UCONFIG_NO_NORMALIZATION and/or UCONFIG_NO_FILE_IO, see uconfig.h", ou tFileName); 193 sprintf(msg, "gencfu writes dummy %s because of UCONFIG_NO_REGULAR_EXPRESSIO NS and/or UCONFIG_NO_NORMALIZATION and/or UCONFIG_NO_FILE_IO, see uconfig.h", ou tFileName);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 if (bytesWritten != outDataSize) { 290 if (bytesWritten != outDataSize) {
284 fprintf(stderr, "gencfu: Error writing to output file \"%s\"\n", outFile Name); 291 fprintf(stderr, "gencfu: Error writing to output file \"%s\"\n", outFile Name);
285 exit(-1); 292 exit(-1);
286 } 293 }
287 294
288 uspoof_close(sc); 295 uspoof_close(sc);
289 delete [] outData; 296 delete [] outData;
290 delete [] confusables; 297 delete [] confusables;
291 delete [] wsConfsables; 298 delete [] wsConfsables;
292 u_cleanup(); 299 u_cleanup();
293 printf("gencfu: tool completed successfully.\n"); 300 if (!quiet) {
301 printf("gencfu: tool completed successfully.\n");
302 }
294 return 0; 303 return 0;
295 #endif // UCONFIG_NO_REGULAR_EXPRESSIONS 304 #endif // UCONFIG_NO_REGULAR_EXPRESSIONS
296 } 305 }
297 306
298 307
299 // 308 //
300 // Read in a confusables source file 309 // Read in a confusables source file
301 // 310 //
302 static const char *readFile(const char *fileName, int32_t *len) { 311 static const char *readFile(const char *fileName, int32_t *len) {
303 char *result; 312 char *result;
(...skipping 17 matching lines...) Expand all
321 if (t != fileSize) { 330 if (t != fileSize) {
322 delete [] result; 331 delete [] result;
323 fclose(file); 332 fclose(file);
324 return NULL; 333 return NULL;
325 } 334 }
326 result[fileSize]=0; 335 result[fileSize]=0;
327 *len = static_cast<int32_t>(fileSize); 336 *len = static_cast<int32_t>(fileSize);
328 fclose(file); 337 fclose(file);
329 return result; 338 return result;
330 } 339 }
OLDNEW
« no previous file with comments | « source/tools/genccode/genccode.vcxproj.filters ('k') | source/tools/gencfu/gencfu.vcxproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698