X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b75a7d8f3b4adbae880cab104ce2c6a50eee4db2..51004dcb01e06fef634b61be77ed73dd61cb6db9:/icuSources/extra/uconv/uwmsg.c?ds=sidebyside diff --git a/icuSources/extra/uconv/uwmsg.c b/icuSources/extra/uconv/uwmsg.c index 4769d3cc..67c12885 100644 --- a/icuSources/extra/uconv/uwmsg.c +++ b/icuSources/extra/uconv/uwmsg.c @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 1998-2000, International Business Machines Corporation +* Copyright (C) 1998-2012, International Business Machines Corporation * and others. All Rights Reserved. ********************************************************************** * @@ -18,6 +18,7 @@ #include "unicode/umsg.h" #include "unicode/uwmsg.h" #include "unicode/ures.h" +#include "unicode/putil.h" #include "cstring.h" #include @@ -83,12 +84,11 @@ finish: ucnv_close(converter); } -static const char *gPath = 0; static UResourceBundle *gBundle = NULL; U_STRING_DECL(gNoFormatting, " (UCONFIG_NO_FORMATTING see uconfig.h)", 38); -U_CAPI UResourceBundle *u_wmsg_setPath(const char *path, UErrorCode *err) +U_CFUNC UResourceBundle *u_wmsg_setPath(const char *path, UErrorCode *err) { if(U_FAILURE(*err)) { @@ -109,7 +109,6 @@ U_CAPI UResourceBundle *u_wmsg_setPath(const char *path, UErrorCode *err) return 0; } - gPath = uprv_strdup(path); gBundle = b; U_STRING_INIT(gNoFormatting, " (UCONFIG_NO_FORMATTING see uconfig.h)", 38); @@ -119,7 +118,7 @@ U_CAPI UResourceBundle *u_wmsg_setPath(const char *path, UErrorCode *err) } /* Format a message and print it's output to fp */ -U_CAPI int u_wmsg(FILE *fp, const char *tag, ... ) +U_CFUNC int u_wmsg(FILE *fp, const char *tag, ... ) { const UChar *msg; int32_t msgLen; @@ -142,9 +141,6 @@ U_CAPI int u_wmsg(FILE *fp, const char *tag, ... ) if(U_FAILURE(err)) { -#if 0 - fprintf(stderr, "u_wmsg: failed to load tag [%s] [%s] [%s]!!\n", tag, u_errorName(err), gPath); -#endif return -1; } @@ -196,21 +192,27 @@ U_CAPI int u_wmsg(FILE *fp, const char *tag, ... ) } /* these will break if the # of messages change. simply add or remove 0's .. */ -UChar * gInfoMessages[U_ERROR_WARNING_LIMIT-U_ERROR_WARNING_START] = - { 0,0 }; +UChar **gInfoMessages = NULL; -UChar * gErrMessages[U_ERROR_LIMIT] = - { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; +UChar **gErrMessages = NULL; static const UChar *fetchErrorName(UErrorCode err) { + if (!gInfoMessages) { + gInfoMessages = (UChar **)malloc((U_ERROR_WARNING_LIMIT-U_ERROR_WARNING_START)*sizeof(UChar*)); + memset(gInfoMessages, 0, (U_ERROR_WARNING_LIMIT-U_ERROR_WARNING_START)*sizeof(UChar*)); + } + if (!gErrMessages) { + gErrMessages = (UChar **)malloc(U_ERROR_LIMIT*sizeof(UChar*)); + memset(gErrMessages, 0, U_ERROR_LIMIT*sizeof(UChar*)); + } if(err>=0) return gErrMessages[err]; else return gInfoMessages[err-U_ERROR_WARNING_START]; } -U_CAPI const UChar *u_wmsg_errorName(UErrorCode err) +U_CFUNC const UChar *u_wmsg_errorName(UErrorCode err) { UChar *msg; int32_t msgLen;