From 8fcbf88e68b3a8adfc7aaca683af2d04b3797913 Mon Sep 17 00:00:00 2001 From: Andy Heninger Date: Fri, 15 Aug 2003 01:26:22 +0000 Subject: [PATCH] ICU-3014 Remove some u_init() calls from some tools to get UNIXy builds alive. They're using ICU without needing data, and without valid data available X-SVN-Rev: 12832 --- icu4c/source/common/umutex.c | 2 +- icu4c/source/tools/genbrk/genbrk.cpp | 18 +++++++++--------- icu4c/source/tools/genccode/genccode.c | 10 ---------- icu4c/source/tools/gencmn/gencmn.c | 9 --------- icu4c/source/tools/genrb/genrb.c | 24 ++++++++++++------------ icu4c/source/tools/genuca/genuca.cpp | 18 +++++++++--------- icu4c/source/tools/pkgdata/pkgdata.c | 8 -------- 7 files changed, 31 insertions(+), 58 deletions(-) diff --git a/icu4c/source/common/umutex.c b/icu4c/source/common/umutex.c index 724d4ab3adf..34ab4572c36 100644 --- a/icu4c/source/common/umutex.c +++ b/icu4c/source/common/umutex.c @@ -92,7 +92,7 @@ umtx_lock(UMTX *mutex) /* Attempt to lock an uninitialized mutex. Not Supported. * Note that earlier versions of ICU supported lazy mutex initialization. * That was not thread safe on CPUs that reorder memory operations. */ - U_ASSERT(FALSE); + /* U_ASSERT(FALSE); TODO: activate this assert. */ umtx_init(mutex); /* But, in case someone really screwed up, we will * still do the lazy init to try to avoid a crash */ } diff --git a/icu4c/source/tools/genbrk/genbrk.cpp b/icu4c/source/tools/genbrk/genbrk.cpp index 1ebb320faee..6a78ff240c4 100644 --- a/icu4c/source/tools/genbrk/genbrk.cpp +++ b/icu4c/source/tools/genbrk/genbrk.cpp @@ -116,15 +116,6 @@ int main(int argc, char **argv) { char *outFullFileName; int32_t outFullFileNameLen; - /* Initialize ICU */ - u_init(&status); - if (U_FAILURE(status)) { - fprintf(stderr, "%s: can not initialize ICU. status = %s\n", - argv[0], u_errorName(status)); - exit(1); - } - status = U_ZERO_ERROR; - // // Pick up and check the command line arguments, // using the standard ICU tool utils option handling. @@ -155,6 +146,15 @@ int main(int argc, char **argv) { u_setDataDirectory(options[5].value); } + /* Initialize ICU */ + u_init(&status); + if (U_FAILURE(status)) { + fprintf(stderr, "%s: can not initialize ICU. status = %s\n", + argv[0], u_errorName(status)); + exit(1); + } + status = U_ZERO_ERROR; + /* Combine the directory with the file name */ if(options[6].doesOccur) { outDir = options[6].value; diff --git a/icu4c/source/tools/genccode/genccode.c b/icu4c/source/tools/genccode/genccode.c index b98264085f3..c852b7e8311 100644 --- a/icu4c/source/tools/genccode/genccode.c +++ b/icu4c/source/tools/genccode/genccode.c @@ -111,16 +111,6 @@ char symPrefix[100]; extern int main(int argc, char* argv[]) { UBool verbose = TRUE; - UErrorCode status = U_ZERO_ERROR; - - /* Initialize ICU */ - u_init(&status); - if (U_FAILURE(status)) { - fprintf(stderr, "%s: can not initialize ICU. status = %s\n", - argv[0], u_errorName(status)); - exit(1); - } - status = U_ZERO_ERROR; U_MAIN_INIT_ARGS(argc, argv); diff --git a/icu4c/source/tools/gencmn/gencmn.c b/icu4c/source/tools/gencmn/gencmn.c index 965e850e2f6..b2dbb91cf18 100644 --- a/icu4c/source/tools/gencmn/gencmn.c +++ b/icu4c/source/tools/gencmn/gencmn.c @@ -102,15 +102,6 @@ main(int argc, char* argv[]) { UBool sourceTOC, verbose; const char *entrypointName = NULL; - /* Initialize ICU */ - u_init(&errorCode); - if (U_FAILURE(errorCode)) { - fprintf(stderr, "%s: can not initialize ICU. errorCode = %s\n", - argv[0], u_errorName(errorCode)); - exit(1); - } - errorCode = U_ZERO_ERROR; - U_MAIN_INIT_ARGS(argc, argv); /* preset then read command line options */ diff --git a/icu4c/source/tools/genrb/genrb.c b/icu4c/source/tools/genrb/genrb.c index 0b0b8f0e8aa..75ac759b308 100644 --- a/icu4c/source/tools/genrb/genrb.c +++ b/icu4c/source/tools/genrb/genrb.c @@ -99,18 +99,6 @@ main(int argc, const char *encoding = ""; int i; - /* Initialize ICU */ - u_init(&status); - if (U_FAILURE(status) && status != U_FILE_ACCESS_ERROR) { - /* Note: u_init() will try to open ICU property data. - * failures here are expected when building ICU from scratch. - * ignore them. - */ - fprintf(stderr, "%s: can not initialize ICU. status = %s\n", - argv[0], u_errorName(status)); - exit(1); - } - status = U_ZERO_ERROR; U_MAIN_INIT_ARGS(argc, argv); argc = u_parseArgs(argc, argv, (int32_t)(sizeof(options)/sizeof(options[0])), options); @@ -221,6 +209,18 @@ main(int argc, if(options[ICUDATADIR].doesOccur) { u_setDataDirectory(options[ICUDATADIR].value); } + /* Initialize ICU */ + u_init(&status); + if (U_FAILURE(status) && status != U_FILE_ACCESS_ERROR) { + /* Note: u_init() will try to open ICU property data. + * failures here are expected when building ICU from scratch. + * ignore them. + */ + fprintf(stderr, "%s: can not initialize ICU. status = %s\n", + argv[0], u_errorName(status)); + exit(1); + } + status = U_ZERO_ERROR; if(options[WRITE_JAVA].doesOccur) { write_java = TRUE; outputEnc = options[WRITE_JAVA].value; diff --git a/icu4c/source/tools/genuca/genuca.cpp b/icu4c/source/tools/genuca/genuca.cpp index a4430442d58..f2893a2771b 100644 --- a/icu4c/source/tools/genuca/genuca.cpp +++ b/icu4c/source/tools/genuca/genuca.cpp @@ -972,15 +972,6 @@ int main(int argc, char* argv[]) { const char *copyright = NULL; uprv_memset(&UCAVersion, 0, 4); - /* Initialize ICU */ - u_init(&status); - if (U_FAILURE(status) && status != U_FILE_ACCESS_ERROR) { - fprintf(stderr, "%s: can not initialize ICU. status = %s\n", - argv[0], u_errorName(status)); - exit(1); - } - status = U_ZERO_ERROR; - U_MAIN_INIT_ARGS(argc, argv); /* preset then read command line options */ @@ -1040,6 +1031,15 @@ int main(int argc, char* argv[]) { if (options[7].doesOccur) { u_setDataDirectory(options[7].value); } + /* Initialize ICU */ + u_init(&status); + if (U_FAILURE(status) && status != U_FILE_ACCESS_ERROR) { + fprintf(stderr, "%s: can not initialize ICU. status = %s\n", + argv[0], u_errorName(status)); + exit(1); + } + status = U_ZERO_ERROR; + /* prepare the filename beginning with the source dir */ uprv_strcpy(filename, srcDir); diff --git a/icu4c/source/tools/pkgdata/pkgdata.c b/icu4c/source/tools/pkgdata/pkgdata.c index 4a3b8e022fc..a15128fe394 100644 --- a/icu4c/source/tools/pkgdata/pkgdata.c +++ b/icu4c/source/tools/pkgdata/pkgdata.c @@ -127,14 +127,6 @@ main(int argc, char* argv[]) { char tmp[1024]; int32_t i; - /* Initialize ICU */ - u_init(&status); - if (U_FAILURE(status)) { - fprintf(stderr, "%s: can not initialize ICU. status = %s\n", - argv[0], u_errorName(status)); - exit(1); - } - status = U_ZERO_ERROR; U_MAIN_INIT_ARGS(argc, argv); progname = argv[0];