]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/extra/uconv/uwmsg.c
ICU-511.25.tar.gz
[apple/icu.git] / icuSources / extra / uconv / uwmsg.c
index 4769d3ccf5be67ba47b2c06d3f242e34f2d704be..67c12885953deb18b983531ed312e1fae2ebeb4e 100644 (file)
@@ -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.
 **********************************************************************
 *
 * and others.  All Rights Reserved.
 **********************************************************************
 *
@@ -18,6 +18,7 @@
 #include "unicode/umsg.h"
 #include "unicode/uwmsg.h"
 #include "unicode/ures.h"
 #include "unicode/umsg.h"
 #include "unicode/uwmsg.h"
 #include "unicode/ures.h"
+#include "unicode/putil.h"
 #include "cstring.h"
 
 #include <stdlib.h>
 #include "cstring.h"
 
 #include <stdlib.h>
@@ -83,12 +84,11 @@ finish:
     ucnv_close(converter);
 }
 
     ucnv_close(converter);
 }
 
-static const char *gPath = 0;
 static UResourceBundle *gBundle = NULL;
 
 U_STRING_DECL(gNoFormatting, " (UCONFIG_NO_FORMATTING see uconfig.h)", 38);
 
 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))
   {
 {
   if(U_FAILURE(*err))
   {
@@ -109,7 +109,6 @@ U_CAPI UResourceBundle *u_wmsg_setPath(const char *path, UErrorCode *err)
          return 0;
     }
 
          return 0;
     }
 
-    gPath = uprv_strdup(path);
     gBundle = b;
 
     U_STRING_INIT(gNoFormatting, " (UCONFIG_NO_FORMATTING see uconfig.h)", 38);
     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 */
 }
 
 /* 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;
 {
     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(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;
     }
 
         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 .. */
 }
 
 /* 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)
 {
 
 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];
 }
 
     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;
 {
     UChar *msg;
     int32_t msgLen;