ICU-3014 Add explicit u_init() calls to tools and tests in anticipation of static init changes

X-SVN-Rev: 12826
This commit is contained in:
Andy Heninger 2003-08-14 21:34:54 +00:00
parent 5c707607e7
commit 78ca2fdfc9
21 changed files with 267 additions and 99 deletions

View file

@ -25,10 +25,10 @@
static const int32_t zeroMem[] = {0, 0, 0, 0, 0, 0};
/* Function Pointers for user-supplied heap functions */
static const void *pContext;
static UMemAlloc *pAlloc;
static UMemRealloc *pRealloc;
static UMemFree *pFree;
static const void *pContext;
static UMemAllocFn *pAlloc;
static UMemReallocFn *pRealloc;
static UMemFreeFn *pFree;
/* Flag indicating whether any heap allocations have happened.
* Used to prevent changing out the heap functions after allocations have been made */
@ -81,7 +81,7 @@ uprv_free(void *buffer) {
}
U_CAPI void U_EXPORT2
u_setMemoryFunctions(const void *context, UMemAlloc *a, UMemRealloc *r, UMemFree *f, UErrorCode *status)
u_setMemoryFunctions(const void *context, UMemAllocFn *a, UMemReallocFn *r, UMemFreeFn *f, UErrorCode *status)
{
if (U_FAILURE(*status)) {
return;

View file

@ -70,11 +70,11 @@ static int32_t gRecursionCount = 0;
* directly using the system (Posix or Windows) APIs.
* (declarations are in uclean.h)
*/
static UMtxInit *pMutexInit = NULL;
static UMtxFunc *pMutexDestroy = NULL;
static UMtxFunc *pMutexLock = NULL;
static UMtxFunc *pMutexUnlock = NULL;
static const void *gMutexContext = NULL;
static UMtxInitFn *pMutexInitFn = NULL;
static UMtxFn *pMutexDestroyFn = NULL;
static UMtxFn *pMutexLockFn = NULL;
static UMtxFn *pMutexUnlockFn = NULL;
static const void *gMutexContext = NULL;
@ -97,8 +97,8 @@ umtx_lock(UMTX *mutex)
* still do the lazy init to try to avoid a crash */
}
if (pMutexLock != NULL) {
(*pMutexLock)(gMutexContext, mutex);
if (pMutexLockFn != NULL) {
(*pMutexLockFn)(gMutexContext, mutex);
} else {
#if (ICU_USE_THREADS == 1)
@ -144,8 +144,8 @@ umtx_unlock(UMTX* mutex)
}
#endif
if (pMutexUnlock) {
(*pMutexUnlock)(gMutexContext, mutex);
if (pMutexUnlockFn) {
(*pMutexUnlockFn)(gMutexContext, mutex);
} else {
#if (ICU_USE_THREADS==1)
#if defined (WIN32)
@ -163,9 +163,9 @@ umtx_unlock(UMTX* mutex)
* umtx_raw_init Do the platform specific mutex allocation and initialization
*/
static void umtx_raw_init(UMTX *mutex) {
if (pMutexInit != NULL) {
if (pMutexInitFn != NULL) {
UErrorCode status = U_ZERO_ERROR;
(*pMutexInit)(gMutexContext, mutex, &status);
(*pMutexInitFn)(gMutexContext, mutex, &status);
if (U_FAILURE(status)) {
/* TODO: how should errors here be handled? */
return;
@ -271,8 +271,8 @@ umtx_destroy(UMTX *mutex) {
return;
}
if (pMutexDestroy != NULL) {
(*pMutexDestroy)(gMutexContext, mutex);
if (pMutexDestroyFn != NULL) {
(*pMutexDestroyFn)(gMutexContext, mutex);
} else {
#if (ICU_USE_THREADS == 1)
#if defined (WIN32)
@ -297,7 +297,7 @@ umtx_destroy(UMTX *mutex) {
U_CAPI void U_EXPORT2
u_setMutexFunctions(const void *context, UMtxInit *i, UMtxFunc *d, UMtxFunc *l, UMtxFunc *u,
u_setMutexFunctions(const void *context, UMtxInitFn *i, UMtxFn *d, UMtxFn *l, UMtxFn *u,
UErrorCode *status) {
if (U_FAILURE(*status)) {
return;
@ -315,22 +315,13 @@ u_setMutexFunctions(const void *context, UMtxInit *i, UMtxFunc *d, UMtxFunc *l,
return;
}
/* Destroy the mutexes that C++ static initialization creates */
u_ICUStaticUnInitFunc();
/* Swap in the mutex function pointers. */
pMutexInit = i;
pMutexDestroy = d;
pMutexLock = l;
pMutexUnlock = u;
gMutexContext = context;
pMutexInitFn = i;
pMutexDestroyFn = d;
pMutexLockFn = l;
pMutexUnlockFn = u;
gMutexContext = context;
/*
* Re-do the equivalent of ICU's static initialization,
* which will recreate the default, resource bundle and converter mutexes.
* TODO: remove this when remove all ICU static init.
*/
u_ICUStaticInitFunc();
}
@ -344,16 +335,16 @@ u_setMutexFunctions(const void *context, UMtxInit *i, UMtxFunc *d, UMtxFunc *l,
*----------------------------------------------------------------*/
/* Pointers to user-supplied inc/dec functions. Null if not funcs have been set. */
static UMtxAtomicF *pIncF = NULL;
static UMtxAtomicF *pDecF = NULL;
static UMtxAtomicFn *pIncFn = NULL;
static UMtxAtomicFn *pDecFn = NULL;
static void *gIncDecContext;
U_CAPI int32_t U_EXPORT2
umtx_atomic_inc(int32_t *p) {
int32_t retVal;
if (pIncF) {
retVal = (*pIncF)(gIncDecContext, p);
if (pIncFn) {
retVal = (*pIncFn)(gIncDecContext, p);
} else {
#if defined (WIN32) && ICU_USE_THREADS == 1
retVal = InterlockedIncrement(p);
@ -373,8 +364,8 @@ umtx_atomic_inc(int32_t *p) {
U_CAPI int32_t U_EXPORT2
umtx_atomic_dec(int32_t *p) {
int32_t retVal;
if (pDecF) {
retVal = (*pDecF)(gIncDecContext, p);
if (pDecFn) {
retVal = (*pDecFn)(gIncDecContext, p);
} else {
#if defined (WIN32) && ICU_USE_THREADS == 1
retVal = InterlockedDecrement(p);
@ -398,7 +389,7 @@ umtx_atomic_dec(int32_t *p) {
U_CAPI void U_EXPORT2
u_setAtomicIncDecFunctions(const void *context, UMtxAtomicF *ip, UMtxAtomicF *dp,
u_setAtomicIncDecFunctions(const void *context, UMtxAtomicFn *ip, UMtxAtomicFn *dp,
UErrorCode *status) {
int32_t testInt;
if (U_FAILURE(*status)) {
@ -415,8 +406,8 @@ u_setAtomicIncDecFunctions(const void *context, UMtxAtomicF *ip, UMtxAtomicF *dp
return;
}
pIncF = ip;
pDecF = dp;
pIncFn = ip;
pDecFn = dp;
testInt = 0;
U_ASSERT(umtx_atomic_inc(&testInt) == 1); /* Sanity Check. Do the functions work at all? */
@ -434,14 +425,14 @@ u_setAtomicIncDecFunctions(const void *context, UMtxAtomicF *ip, UMtxAtomicF *dp
*/
U_CFUNC UBool umtx_cleanup(void) {
umtx_destroy(NULL);
pMutexInit = NULL;
pMutexDestroy = NULL;
pMutexLock = NULL;
pMutexUnlock = NULL;
gMutexContext = NULL;
pMutexInitFn = NULL;
pMutexDestroyFn = NULL;
pMutexLockFn = NULL;
pMutexUnlockFn = NULL;
gMutexContext = NULL;
pIncF = NULL;
pDecF = NULL;
pIncFn = NULL;
pDecFn = NULL;
return TRUE;
}

View file

@ -114,7 +114,7 @@ typedef void *UMTX;
* @param status Error status. Report errors back to ICU by setting this variable
* with an error code.
*/
typedef void U_CALLCONV UMtxInit (const void *context, UMTX *mutex, UErrorCode* pError);
typedef void U_CALLCONV UMtxInitFn (const void *context, UMTX *mutex, UErrorCode* status);
/**
@ -126,7 +126,7 @@ typedef void U_CALLCONV UMtxInit (const void *context, UMTX *mutex, UErrorCod
* @draft ICU 2.8
* @system
*/
typedef void U_CALLCONV UMtxFunc (const void *context, UMTX *mutex);
typedef void U_CALLCONV UMtxFn (const void *context, UMTX *mutex);
/**
@ -147,7 +147,7 @@ typedef void U_CALLCONV UMtxFunc (const void *context, UMTX *mutex);
* @system
*/
U_CAPI void U_EXPORT2
u_setMutexFunctions(const void *context, UMtxInit *i, UMtxFunc *d, UMtxFunc *l, UMtxFunc *u,
u_setMutexFunctions(const void *context, UMtxInitFn *init, UMtxFn *destroy, UMtxFn *lock, UMtxFn *unlock,
UErrorCode *status);
@ -159,7 +159,7 @@ u_setMutexFunctions(const void *context, UMtxInit *i, UMtxFunc *d, UMtxFunc *l,
* @draft ICU 2.8
* @system
*/
typedef int32_t U_CALLCONV UMtxAtomicF (const void *context, int32_t *p);
typedef int32_t U_CALLCONV UMtxAtomicFn(const void *context, int32_t *p);
/**
* Set the functions that ICU will use for atomic increment and decrement of int32_t values.
@ -177,7 +177,7 @@ typedef int32_t U_CALLCONV UMtxAtomicF (const void *context, int32_t *p);
* @system
*/
U_CAPI void U_EXPORT2
u_setAtomicIncDecFunctions(const void *context, UMtxAtomicF *inc, UMtxAtomicF *dec,
u_setAtomicIncDecFunctions(const void *context, UMtxAtomicFn *inc, UMtxAtomicFn *dec,
UErrorCode *status);
@ -190,7 +190,7 @@ u_setAtomicIncDecFunctions(const void *context, UMtxAtomicF *inc, UMtxAtomicF *d
* @draft ICU 2.8
* @system
*/
typedef void *U_CALLCONV UMemAlloc (const void *context, size_t size);
typedef void *U_CALLCONV UMemAllocFn(const void *context, size_t size);
/**
* Pointer type for a user supplied memory re-allocation function.
* @param context user supplied value, obtained from from u_setMemoryFunctions().
@ -199,7 +199,7 @@ typedef void *U_CALLCONV UMemAlloc (const void *context, size_t size);
* @draft ICU 2.8
* @system
*/
typedef void *U_CALLCONV UMemRealloc(const void *context, void *mem, size_t size);
typedef void *U_CALLCONV UMemReallocFn(const void *context, void *mem, size_t size);
/**
* Pointer type for a user supplied memory free function. Behavior should be
* similar the standard C library free().
@ -210,7 +210,7 @@ typedef void *U_CALLCONV UMemRealloc(const void *context, void *mem, size_t size
* @draft ICU 2.8
* @system
*/
typedef void U_CALLCONV UMemFree (const void *context, void *mem);
typedef void U_CALLCONV UMemFreeFn (const void *context, void *mem);
/**
* Set the functions that ICU will use for memory allocation.
@ -229,7 +229,7 @@ typedef void U_CALLCONV UMemFree (const void *context, void *mem);
* @system
*/
U_CAPI void U_EXPORT2
u_setMemoryFunctions(const void *context, UMemAlloc *a, UMemRealloc *r, UMemFree *f,
u_setMemoryFunctions(const void *context, UMemAllocFn *a, UMemReallocFn *r, UMemFreeFn *f,
UErrorCode *status);
#endif

View file

@ -20,6 +20,7 @@
#include <unicode/ucnv.h>
#include <unicode/unistr.h>
#include <unicode/translit.h>
#include <unicode/uclean.h>
#include <stdio.h>
#include <errno.h>
@ -796,6 +797,15 @@ int main(int argc, char **argv)
int printTranslits = 0;
int verbose = 0;
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);
}
// Get and prettify pname.
pname = uprv_strrchr(*argv, U_FILE_SEP_CHAR);

View file

@ -70,6 +70,10 @@ int main(int argc, const char* const argv[])
UResourceBundle *rb;
UConverter *cnv;
#ifdef XP_MAC_CONSOLE
argc = ccommand((char***)&argv);
#endif
/* Checkargs */
for(i=1;i<argc;i++) {
if(!strcmp(argv[i],"-w")) {
@ -83,42 +87,31 @@ int main(int argc, const char* const argv[])
#ifdef CTST_LEAK_CHECK
ctst_init();
#endif
/* try opening the data from dll instead of the dat file */
cnv = ucnv_open(TRY_CNV_1, &errorCode);
if(cnv != 0) {
/* ok */
ucnv_close(cnv);
} else {
/* Initialize ICU */
u_init(&errorCode);
if (U_FAILURE(errorCode)) {
fprintf(stderr,
"#### WARNING! The converter for " TRY_CNV_1 " cannot be loaded from data dll/so."
"Proceeding to load data from dat file.\n");
"#### WARNING! u_init() failed with status = \"%s\".\n"
"Trying again with additional data locations...\n", u_errorName(errorCode));
errorCode = U_ZERO_ERROR;
ctest_setICU_DATA();
}
/* If no ICU_DATA environment was set, try to fake up one. */
/* fprintf(stderr, "u_getDataDirectory() = %s\n", u_getDataDirectory()); */
#ifdef XP_MAC_CONSOLE
argc = ccommand((char***)&argv);
#endif
cnv = ucnv_open(NULL, &errorCode);
if(cnv != NULL) {
/* ok */
ucnv_close(cnv);
} else {
fprintf(stderr,
"*** %s! The default converter cannot be opened.\n"
"*** Check the ICU_DATA environment variable and \n"
"*** check that the data files are present.\n", warnOrErr);
if(warnOnMissingData == 0) {
fprintf(stderr, "*** Exitting. Use the '-w' option if data files were\n*** purposely removed, to continue test anyway.\n");
return 1;
u_init(&errorCode);
if (U_FAILURE(errorCode)) {
fprintf(stderr,
"*** %s! ICU Can not be initialized.\n"
"*** Check the ICU_DATA environment variable and \n"
"*** check that the data files are present.\n", warnOrErr, u_errorName(errorCode));
if(warnOnMissingData == 0) {
fprintf(stderr, "*** Exiting. Use the '-w' option if data files were\n*** purposely removed, to continue test anyway.\n");
u_cleanup();
return 1;
}
}
}
/* try more data */
cnv = ucnv_open(TRY_CNV_2, &errorCode);
if(cnv != 0) {
@ -131,6 +124,7 @@ int main(int argc, const char* const argv[])
"*** check that the data files are present.\n", warnOrErr);
if(warnOnMissingData == 0) {
fprintf(stderr, "*** Exitting. Use the '-w' option if data files were\n*** purposely removed, to continue test anyway.\n");
u_cleanup();
return 1;
}
}
@ -146,6 +140,7 @@ int main(int argc, const char* const argv[])
"*** check that the data files are present.\n", warnOrErr);
if(warnOnMissingData == 0) {
fprintf(stderr, "*** Exitting. Use the '-w' option if data files were\n*** purposely removed, to continue test anyway.\n");
u_cleanup();
return 1;
}
}

View file

@ -974,19 +974,19 @@ main(int argc, char* argv[])
argc = ccommand( &argv );
#endif
/* try opening the data from dll instead of the dat file */
cnv = ucnv_open(TRY_CNV_1, &errorCode);
if(cnv != 0) {
/* ok */
ucnv_close(cnv);
} else {
/* Initialize ICU */
u_init(&errorCode);
if (U_FAILURE(errorCode)) {
fprintf(stderr,
"#### WARNING! The converter for " TRY_CNV_1 " cannot be loaded from data dll/so."
"Proceeding to load data from dat file.\n");
"#### WARNING! u_init() failed."
"Trying again with a synthesized ICU_DATA setting.\n");
IntlTest::setICU_DATA();
errorCode = U_ZERO_ERROR;
}
// If user didn't set ICU_DATA, attempt to generate one.
// Do this whether or not the u_init(), above, succeeded because we need the
// data path to find some of the test data.
IntlTest::setICU_DATA();
for (int i = 1; i < argc; ++i) {

View file

@ -116,6 +116,15 @@ 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.

View file

@ -49,6 +49,7 @@
#include "cstring.h"
#include "filestrm.h"
#include "toolutil.h"
#include "unicode/uclean.h"
#include "uoptions.h"
#define MAX_COLUMN ((uint32_t)(0xFFFFFFFFU))
@ -110,6 +111,16 @@ 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);

View file

@ -25,6 +25,7 @@
#include "cstring.h"
#include "filestrm.h"
#include "toolutil.h"
#include "unicode/uclean.h"
#include "unewdata.h"
#include "uoptions.h"
@ -101,6 +102,15 @@ 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 */

View file

@ -29,6 +29,7 @@
#include "cmemory.h"
#include "cstring.h"
#include "filestrm.h"
#include "unicode/uclean.h"
#include "unewdata.h"
#include "uoptions.h"
@ -210,6 +211,15 @@ main(int argc, char* argv[]) {
UNewDataMemory *out;
UErrorCode errorCode=U_ZERO_ERROR;
/* 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 */

View file

@ -124,6 +124,7 @@
#include "unicode/putil.h"
#include "cmemory.h"
#include "cstring.h"
#include "unicode/uclean.h"
#include "unicode/udata.h"
#include "unewdata.h"
#include "uoptions.h"
@ -282,9 +283,22 @@ extern int
main(int argc, char* argv[]) {
UVersionInfo version;
UBool store10Names=FALSE;
UErrorCode errorCode = U_ZERO_ERROR;
U_MAIN_INIT_ARGS(argc, argv);
/* Initialize ICU */
u_init(&errorCode);
if (U_FAILURE(errorCode) && errorCode != 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. errorCode = %s\n",
argv[0], u_errorName(errorCode));
exit(1);
}
/* preset then read command line options */
options[5].value=u_getDataDirectory();
options[6].value="3.2";
@ -340,6 +354,7 @@ main(int argc, char* argv[]) {
compress();
generateData(options[5].value);
u_cleanup();
return 0;
}

View file

@ -26,6 +26,7 @@
#include "unicode/putil.h"
#include "cmemory.h"
#include "cstring.h"
#include "unicode/uclean.h"
#include "unicode/udata.h"
#include "unewdata.h"
#include "uoptions.h"
@ -71,6 +72,19 @@ main(int argc, char* argv[]) {
char *basename=NULL;
UErrorCode errorCode=U_ZERO_ERROR;
/* Initialize ICU */
u_init(&errorCode);
if (U_FAILURE(errorCode) && errorCode != 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. 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 */

View file

@ -923,9 +923,22 @@ private:
};
int main(int argc, char *argv[]) {
UErrorCode status = U_ZERO_ERROR;
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, "genpname: can not initialize ICU. Status = %s\n",
u_errorName(status));
exit(1);
}
genpname app;
U_MAIN_INIT_ARGS(argc, argv);
return app.MMain(argc, argv);
int retVal = app.MMain(argc, argv);
u_cleanup();
return retVal;
}
static UOption options[]={
@ -1047,10 +1060,12 @@ int genpname::MMain(int argc, char* argv[])
UErrorCode status = U_ZERO_ERROR;
u_init(&status);
if (U_FAILURE(status)) {
if (U_FAILURE(status) && status != U_FILE_ACCESS_ERROR) {
fprintf(stderr, "Error: u_init returned %s\n", u_errorName(status));
status = U_ZERO_ERROR;
}
/* preset then read command line options */
options[3].value=u_getDataDirectory();
argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options);

View file

@ -26,6 +26,7 @@
#include "unicode/uchar.h"
#include "unicode/uset.h"
#include "unicode/putil.h"
#include "unicode/uclean.h"
#include "cmemory.h"
#include "cstring.h"
#include "unewdata.h"
@ -83,6 +84,19 @@ main(int argc, char* argv[]) {
char *basename=NULL;
UErrorCode errorCode=U_ZERO_ERROR;
/* Initialize ICU */
u_init(&errorCode);
if (U_FAILURE(errorCode) && errorCode != 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. 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 */
@ -124,6 +138,7 @@ main(int argc, char* argv[]) {
return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR;
}
/* get the options values */
beVerbose=options[2].doesOccur;
haveCopyright=options[3].doesOccur;
@ -178,6 +193,7 @@ main(int argc, char* argv[]) {
generateData(destDir);
}
u_cleanup();
return errorCode;
}

View file

@ -17,6 +17,7 @@
*/
#include "genrb.h"
#include "unicode/uclean.h"
/* Protos */
static void processFile(const char *filename, const char* cp, const char *inputDir, const char *outputDir, const char *packageName, UErrorCode *status);
@ -98,6 +99,18 @@ 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);

View file

@ -130,6 +130,15 @@ main(int argc, char* argv[]) {
UErrorCode errorCode=U_ZERO_ERROR;
/* 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 */

View file

@ -20,6 +20,7 @@
#include <stdlib.h>
#include "unicode/utypes.h"
#include "unicode/putil.h"
#include "unicode/uclean.h"
#include "unicode/udata.h"
#include "unewdata.h"
#include "cmemory.h"
@ -55,6 +56,16 @@ static UOption options[]={
extern int
main(int argc, char* argv[]) {
UErrorCode errorCode = U_ZERO_ERROR;
/* 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;
/* preset then read command line options */
options[2].value=u_getDataDirectory();
argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options);

View file

@ -29,6 +29,7 @@
#include <stdlib.h>
#include "unicode/utypes.h"
#include "unicode/putil.h"
#include "unicode/uclean.h"
#include "cmemory.h"
#include "cstring.h"
#include "filestrm.h"
@ -167,6 +168,15 @@ private:
};
int main(int argc, char *argv[]) {
UErrorCode errorCode = U_ZERO_ERROR;
/* 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);
}
gentz x;
U_MAIN_INIT_ARGS(argc, argv);

View file

@ -26,6 +26,7 @@
#include <stdio.h>
#include "unicode/utypes.h"
#include "unicode/udata.h"
#include "unicode/uclean.h"
#include "ucol_imp.h"
#include "genuca.h"
#include "uoptions.h"
@ -971,6 +972,15 @@ int main(int argc, char* argv[]) {
const char *copyright = NULL;
uprv_memset(&UCAVersion, 0, 4);
/* 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);
/* preset then read command line options */

View file

@ -32,6 +32,7 @@
#include "ucmpwrit.h"
#include "makeconv.h"
#include "genmbcs.h"
#include "unicode/uclean.h"
#define DEBUG 0
@ -267,6 +268,15 @@ int main(int argc, char* argv[])
char cnvNameWithPkg[UCNV_MAX_FULL_FILE_NAME_LENGTH];
UVersionInfo icuVersion;
/* Initialize ICU */
u_init(&err);
if (U_FAILURE(err)) {
fprintf(stderr, "%s: can not initialize ICU. err = %s\n",
argv[0], u_errorName(err));
exit(1);
}
err = U_ZERO_ERROR;
U_MAIN_INIT_ARGS(argc, argv);
/* Set up the ICU version number */

View file

@ -24,6 +24,7 @@
#include "cstring.h"
#include "filestrm.h"
#include "toolutil.h"
#include "unicode/uclean.h"
#include "unewdata.h"
#include "uoptions.h"
@ -126,6 +127,14 @@ 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];