]> granicus.if.org Git - icu/commitdiff
ICU-9456 Reduce writable/relocatable data.
authorGeorge Rhoten <grhoten@users.noreply.github.com>
Fri, 10 Aug 2012 16:41:38 +0000 (16:41 +0000)
committerGeorge Rhoten <grhoten@users.noreply.github.com>
Fri, 10 Aug 2012 16:41:38 +0000 (16:41 +0000)
X-SVN-Rev: 32149

icu4c/source/common/uloc_tag.c
icu4c/source/common/usprep.cpp
icu4c/source/i18n/alphaindex.cpp
icu4c/source/i18n/csrsbcs.cpp
icu4c/source/i18n/ucol_bld.cpp

index d62346f27f8b6540abb4a3ea7d5fe67e552f31a5..a0ea97d722eaaed0a1187180cdc2fc2d3d926a56 100644 (file)
@@ -17,6 +17,8 @@
 #include "ulocimp.h"
 #include "uassert.h"
 
+#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
+
 /* struct holding a single variant */
 typedef struct VariantListEntry {
     const char              *variant;
@@ -62,19 +64,19 @@ typedef struct ULanguageTag {
 #define ISALPHA(c) uprv_isASCIILetter(c)
 #define ISNUMERIC(c) ((c)>='0' && (c)<='9')
 
-static const char* EMPTY = "";
-static const char* LANG_UND = "und";
-static const char* PRIVATEUSE_KEY = "x";
-static const char* _POSIX = "_POSIX";
-static const char* POSIX_KEY = "va";
-static const char* POSIX_VALUE = "posix";
-static const char* LOCALE_ATTRIBUTE_KEY = "attribute";
-static const char* PRIVUSE_VARIANT_PREFIX = "lvariant";
-static const char* LOCALE_TYPE_YES = "yes";
+static const char EMPTY[] = "";
+static const char LANG_UND[] = "und";
+static const char PRIVATEUSE_KEY[] = "x";
+static const char _POSIX[] = "_POSIX";
+static const char POSIX_KEY[] = "va";
+static const char POSIX_VALUE[] = "posix";
+static const char LOCALE_ATTRIBUTE_KEY[] = "attribute";
+static const char PRIVUSE_VARIANT_PREFIX[] = "lvariant";
+static const char LOCALE_TYPE_YES[] = "yes";
 
 #define LANG_UND_LEN 3
 
-static const char* GRANDFATHERED[] = {
+static const char* const GRANDFATHERED[] = {
 /*  grandfathered   preferred */
     "art-lojban",   "jbo",
     "cel-gaulish",  "xtg-x-cel-gaulish",
@@ -105,12 +107,11 @@ static const char* GRANDFATHERED[] = {
     NULL,           NULL
 };
 
-static const char* DEPRECATEDLANGS[] = {
+static const char DEPRECATEDLANGS[][4] = {
 /*  deprecated  new */
     "iw",       "he",
     "ji",       "yi",
-    "in",       "id",
-    NULL,       NULL
+    "in",       "id"
 };
 
 /*
@@ -1028,7 +1029,7 @@ _appendLanguageToLanguageTag(const char* localeID, char* appendAt, int32_t capac
         reslen += LANG_UND_LEN;
     } else {
         /* resolve deprecated */
-        for (i = 0; DEPRECATEDLANGS[i] != NULL; i += 2) {
+        for (i = 0; i < LENGTHOF(DEPRECATEDLANGS); i += 2) {
             if (uprv_compareInvCharsAsAscii(buf, DEPRECATEDLANGS[i]) == 0) {
                 uprv_strcpy(buf, DEPRECATEDLANGS[i + 1]);
                 len = (int32_t)uprv_strlen(buf);
index 415253c332e31277d29873f41f0da0a3e47a4558..925ed38b717a334377b7b54df4c2ab9800e0ef28 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *******************************************************************************
  *
- *   Copyright (C) 2003-2010, International Business Machines
+ *   Copyright (C) 2003-2012, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *
  *******************************************************************************
@@ -46,13 +46,13 @@ static UHashtable *SHARED_DATA_HASHTABLE = NULL;
 static UMTX usprepMutex = NULL;
 
 /* format version of spp file */
-static uint8_t formatVersion[4]={ 0, 0, 0, 0 };
+//static uint8_t formatVersion[4]={ 0, 0, 0, 0 };
 
 /* the Unicode version of the sprep data */
 static UVersionInfo dataVersion={ 0, 0, 0, 0 };
 
 /* Profile names must be aligned to UStringPrepProfileType */
-static const char *PROFILE_NAMES[] = {
+static const char * const PROFILE_NAMES[] = {
     "rfc3491",      /* USPREP_RFC3491_NAMEPREP */
     "rfc3530cs",    /* USPREP_RFC3530_NFS4_CS_PREP */
     "rfc3530csci",  /* USPREP_RFC3530_NFS4_CS_PREP_CI */
@@ -86,7 +86,7 @@ isSPrepAcceptable(void * /* context */,
         pInfo->formatVersion[2]==UTRIE_SHIFT &&
         pInfo->formatVersion[3]==UTRIE_INDEX_SHIFT
     ) {
-        uprv_memcpy(formatVersion, pInfo->formatVersion, 4);
+        //uprv_memcpy(formatVersion, pInfo->formatVersion, 4);
         uprv_memcpy(dataVersion, pInfo->dataVersion, 4);
         return TRUE;
     } else {
index fadc2f42a6211572d627ac3f0af687140c22f09a..cf51a03fe4e90135fcba16ee3970064456e0c4ec 100644 (file)
@@ -861,7 +861,7 @@ UVector *AlphabeticIndex::firstStringsInScript(Collator *ruleBasedCollator, UErr
 //  Character constants copied from corresponding declaration in ICU4J.
 //  See main/classes/collate/src/com/ibm/icu/text/AlphabeticIndex.java
 
-static UChar HACK_FIRST_CHARS_IN_SCRIPTS[] =  { 0x61, 0, 0x03B1, 0,
+static const UChar HACK_FIRST_CHARS_IN_SCRIPTS[] =  { 0x61, 0, 0x03B1, 0,
             0x2C81, 0, 0x0430, 0, 0x2C30, 0, 0x10D0, 0, 0x0561, 0, 0x05D0, 0, 0xD802, 0xDD00, 0, 0x0800, 0, 0x0621, 0, 0x0710, 0,
             0x0780, 0, 0x07CA, 0, 0x2D30, 0, 0x1200, 0, 0x0950, 0, 0x0985, 0, 0x0A74, 0, 0x0AD0, 0, 0x0B05, 0, 0x0BD0, 0,
             0x0C05, 0, 0x0C85, 0, 0x0D05, 0, 0x0D85, 0,
index 4c387c7d634d64e4952a414afa6c714c899258d1..1aad70e39ae7f532078ee0c1d057083560fad403 100644 (file)
@@ -1164,7 +1164,7 @@ uint8_t *CharsetRecog_IBM420_ar::unshapeLamAlef(const uint8_t *inputBytes, int32
     
     if (bigBuffer != NULL) {
         int32_t bufferIndex;
-        uint8_t unshapedLamAlef[] = { 0xb1, 0x56 };
+        static const uint8_t unshapedLamAlef[] = { 0xb1, 0x56 };
         
         for (int32_t i = bufferIndex = 0; i < inputBytesLength; i++) {
             if (isLamAlef(inputBytes[i])) {
@@ -1199,7 +1199,7 @@ void CharsetRecog_IBM420_ar::matchFinish(InputText *textIn) {
 }
 
 UBool CharsetRecog_IBM420_ar::isLamAlef(uint8_t b) {
-    uint8_t shapedLamAlef[] = {
+    static const uint8_t shapedLamAlef[] = {
         0xb2, 0xb3, 0xb4, 0xb5, 0xb7, 0xb8 
     };
     
index 566812b1abae0c986d9bcf6eef0b9cef5289c28d..d51118f978ab2db974f9ef123df95ad205b3edd6 100644 (file)
@@ -37,6 +37,8 @@
 #include "cmemory.h"
 #include "cstring.h"
 
+#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
+
 static const InverseUCATableHeader* _staticInvUCA = NULL;
 static UDataMemory* invUCA_DATA_MEM = NULL;
 
@@ -1393,13 +1395,12 @@ ucol_initInverseUCA(UErrorCode *status)
 /* This is the data that is used for non-script reordering codes. These _must_ be kept
  * in order that they are to be applied as defaults and in synch with the UColReorderCode enum.
  */
-static const char* ReorderingTokenNames[] = {
+static const char * const ReorderingTokenNames[] = {
     "SPACE",
     "PUNCT",
     "SYMBOL",
     "CURRENCY",
-    "DIGIT",
-    NULL
+    "DIGIT"
 };
 
 static void toUpper(const char* src, char* dst, uint32_t length) {
@@ -1413,7 +1414,7 @@ U_INTERNAL int32_t U_EXPORT2
 ucol_findReorderingEntry(const char* name) {
     char buffer[32];
     toUpper(name, buffer, 32);
-    for (uint32_t entry = 0; ReorderingTokenNames[entry] != NULL; entry++) {
+    for (uint32_t entry = 0; entry < LENGTHOF(ReorderingTokenNames); entry++) {
         if (uprv_strcmp(buffer, ReorderingTokenNames[entry]) == 0) {
             return entry + UCOL_REORDER_CODE_FIRST;
         }