]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/unames.c
ICU-461.18.tar.gz
[apple/icu.git] / icuSources / common / unames.c
index f7389e678ce238e5ec01a4844c0559cbc9cbcc14..e02c6a8efd5c463550105e1c553d0b9e3454ee86 100644 (file)
@@ -1,7 +1,7 @@
 /*
 ******************************************************************************
 *
-*   Copyright (C) 1999-2004, International Business Machines
+*   Copyright (C) 1999-2009, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 ******************************************************************************
@@ -37,10 +37,38 @@ static const char DATA_TYPE[] = "icu";
 #define LINES_PER_GROUP (1UL<<GROUP_SHIFT)
 #define GROUP_MASK (LINES_PER_GROUP-1)
 
+/*
+ * This struct was replaced by explicitly accessing equivalent
+ * fields from triples of uint16_t.
+ * The Group struct was padded to 8 bytes on compilers for early ARM CPUs,
+ * which broke the assumption that sizeof(Group)==6 and that the ++ operator
+ * would advance by 6 bytes (3 uint16_t).
+ *
+ * We can't just change the data structure because it's loaded from a data file,
+ * and we don't want to make it less compact, so we changed the access code.
+ *
+ * For details see ICU tickets 6331 and 6008.
 typedef struct {
     uint16_t groupMSB,
-             offsetHigh, offsetLow; /* avoid padding */
+             offsetHigh, offsetLow; / * avoid padding * /
 } Group;
+ */
+enum {
+    GROUP_MSB,
+    GROUP_OFFSET_HIGH,
+    GROUP_OFFSET_LOW,
+    GROUP_LENGTH
+};
+
+/*
+ * Get the 32-bit group offset.
+ * @param group (const uint16_t *) pointer to a Group triple of uint16_t
+ * @return group offset (int32_t)
+ */
+#define GET_GROUP_OFFSET(group) ((int32_t)(group)[GROUP_OFFSET_HIGH]<<16|(group)[GROUP_OFFSET_LOW])
+
+#define NEXT_GROUP(group) ((group)+GROUP_LENGTH)
+#define PREV_GROUP(group) ((group)-GROUP_LENGTH)
 
 typedef struct {
     uint32_t start, end;
@@ -52,6 +80,17 @@ typedef struct {
     uint32_t tokenStringOffset, groupsOffset, groupStringOffset, algNamesOffset;
 } UCharNames;
 
+/*
+ * Get the groups table from a UCharNames struct.
+ * The groups table consists of one uint16_t groupCount followed by
+ * groupCount groups. Each group is a triple of uint16_t, see GROUP_LENGTH
+ * and the comment for the old struct Group above.
+ *
+ * @param names (const UCharNames *) pointer to the UCharNames indexes
+ * @return (const uint16_t *) pointer to the groups table
+ */
+#define GET_GROUPS(names) (const uint16_t *)((const char *)names+names->groupsOffset)
+
 typedef struct {
     const char *otherName;
     UChar32 code;
@@ -65,16 +104,14 @@ static UErrorCode gLoadErrorCode=U_ZERO_ERROR;
 
 /*
  * Maximum length of character names (regular & 1.0).
- * Maximum length of ISO comments.
  */
-static int32_t gMaxNameLength=0, gMaxISOCommentLength=0;
+static int32_t gMaxNameLength=0;
 
 /*
  * Set of chars used in character names (regular & 1.0).
- * Set of chars used in ISO comments.
  * Chars are platform-dependent (can be EBCDIC).
  */
-static uint32_t gNameSet[8]={ 0 }, gISOCommentSet[8]={ 0 };
+static uint32_t gNameSet[8]={ 0 };
 
 #define U_NONCHARACTER_CODE_POINT U_CHAR_CATEGORY_COUNT
 #define U_LEAD_SURROGATE U_CHAR_CATEGORY_COUNT + 1
@@ -82,8 +119,41 @@ static uint32_t gNameSet[8]={ 0 }, gISOCommentSet[8]={ 0 };
 
 #define U_CHAR_EXTENDED_CATEGORY_COUNT (U_CHAR_CATEGORY_COUNT + 3)
 
-static const char * const
-charCatNames[U_CHAR_EXTENDED_CATEGORY_COUNT];
+static const char * const charCatNames[U_CHAR_EXTENDED_CATEGORY_COUNT] = {
+    "unassigned",
+    "uppercase letter",
+    "lowercase letter",
+    "titlecase letter",
+    "modifier letter",
+    "other letter",
+    "non spacing mark",
+    "enclosing mark",
+    "combining spacing mark",
+    "decimal digit number",
+    "letter number",
+    "other number",
+    "space separator",
+    "line separator",
+    "paragraph separator",
+    "control",
+    "format",
+    "private use area",
+    "surrogate",
+    "dash punctuation",   
+    "start punctuation",
+    "end punctuation",
+    "connector punctuation",
+    "other punctuation",
+    "math symbol",
+    "currency symbol",
+    "modifier symbol",
+    "other symbol",
+    "initial punctuation",
+    "final punctuation",
+    "noncharacter",
+    "lead surrogate",
+    "trail surrogate"
+};
 
 /* implementation ----------------------------------------------------------- */
 
@@ -121,9 +191,7 @@ isDataLoaded(UErrorCode *pErrorCode) {
     UBool isCached;
 
     /* do this because double-checked locking is broken */
-    umtx_lock(NULL);
-    isCached=uCharNames!=NULL;
-    umtx_unlock(NULL);
+    UMTX_CHECK(NULL, (uCharNames!=NULL), isCached);
 
     if(!isCached) {
         UCharNames *names;
@@ -148,8 +216,8 @@ isDataLoaded(UErrorCode *pErrorCode) {
         {
             umtx_lock(NULL);
             if(uCharNames==NULL) {
-                uCharNames=names;
                 uCharNamesData=data;
+                uCharNames=names;
                 data=NULL;
                 names=NULL;
                 ucln_common_registerCleanup(UCLN_COMMON_UNAMES, unames_cleanup);
@@ -183,8 +251,8 @@ isDataLoaded(UErrorCode *pErrorCode) {
  * field can contain ';' as part of its contents.
  * In unames.dat, it is marked as token[';']==-1 only if the
  * semicolon is used in the data file - which is iff we
- * have Unicode 1.0 names or ISO comments.
- * So, it will be token[';']==-1 if we store U1.0 names/ISO comments
+ * have Unicode 1.0 names or ISO comments or aliases.
+ * So, it will be token[';']==-1 if we store U1.0 names/ISO comments/aliases
  * although we know that it will never be part of a name.
  */
 static uint16_t
@@ -196,32 +264,26 @@ expandName(UCharNames *names,
     uint8_t *tokenStrings=(uint8_t *)names+names->tokenStringOffset;
     uint8_t c;
 
-    if(nameChoice==U_UNICODE_10_CHAR_NAME || nameChoice==U_ISO_COMMENT) {
+    if(nameChoice!=U_UNICODE_CHAR_NAME && nameChoice!=U_EXTENDED_CHAR_NAME) {
         /*
          * skip the modern name if it is not requested _and_
          * if the semicolon byte value is a character, not a token number
          */
         if((uint8_t)';'>=tokenCount || tokens[(uint8_t)';']==(uint16_t)(-1)) {
-            while(nameLength>0) {
-                --nameLength;
-                if(*name++==';') {
-                    break;
-                }
-            }
-            if(nameChoice==U_ISO_COMMENT) {
-                /* skip the Unicode 1.0 name as well to get the ISO comment */
+            int fieldIndex= nameChoice==U_ISO_COMMENT ? 2 : nameChoice;
+            do {
                 while(nameLength>0) {
                     --nameLength;
                     if(*name++==';') {
                         break;
                     }
                 }
-            }
+            } while(--fieldIndex>0);
         } else {
             /*
              * the semicolon byte value is a token number, therefore
              * only modern names are stored in unames.dat and there is no
-             * such requested Unicode 1.0 name here
+             * such requested alternate name here
              */
             nameLength=0;
         }
@@ -296,23 +358,26 @@ compareName(UCharNames *names,
     uint8_t c;
     const char *origOtherName = otherName;
 
-    if(nameChoice==U_UNICODE_10_CHAR_NAME) {
+    if(nameChoice!=U_UNICODE_CHAR_NAME && nameChoice!=U_EXTENDED_CHAR_NAME) {
         /*
          * skip the modern name if it is not requested _and_
          * if the semicolon byte value is a character, not a token number
          */
         if((uint8_t)';'>=tokenCount || tokens[(uint8_t)';']==(uint16_t)(-1)) {
-            while(nameLength>0) {
-                --nameLength;
-                if(*name++==';') {
-                    break;
+            int fieldIndex= nameChoice==U_ISO_COMMENT ? 2 : nameChoice;
+            do {
+                while(nameLength>0) {
+                    --nameLength;
+                    if(*name++==';') {
+                        break;
+                    }
                 }
-            }
+            } while(--fieldIndex>0);
         } else {
             /*
              * the semicolon byte value is a token number, therefore
              * only modern names are stored in unames.dat and there is no
-             * such requested Unicode 1.0 name here
+             * such requested alternate name here
              */
             nameLength=0;
         }
@@ -374,42 +439,6 @@ compareName(UCharNames *names,
     return (UBool)(*otherName==0);
 }
 
-static const char * const charCatNames[U_CHAR_EXTENDED_CATEGORY_COUNT] = {
-    "unassigned",
-    "uppercase letter",
-    "lowercase letter",
-    "titlecase letter",
-    "modifier letter",
-    "other letter",
-    "non spacing mark",
-    "enclosing mark",
-    "combining spacing mark",
-    "decimal digit number",
-    "letter number",
-    "other number",
-    "space separator",
-    "line separator",
-    "paragraph separator",
-    "control",
-    "format",
-    "private use area",
-    "surrogate",
-    "dash punctuation",   
-    "start punctuation",
-    "end punctuation",
-    "connector punctuation",
-    "other punctuation",
-    "math symbol",
-    "currency symbol",
-    "modifier symbol",
-    "other symbol",
-    "initial punctuation",
-    "final punctuation",
-    "noncharacter",
-    "lead surrogate",
-    "trail surrogate"
-};
-
 static uint8_t getCharCat(UChar32 cp) {
     uint8_t cat;
 
@@ -471,18 +500,18 @@ static uint16_t getExtName(uint32_t code, char *buffer, uint16_t bufferLength) {
  * or else is the highest group before "code".
  * If the lowest group is after "code", then that one is returned.
  */
-static Group *
+static const uint16_t *
 getGroup(UCharNames *names, uint32_t code) {
+    const uint16_t *groups=GET_GROUPS(names);
     uint16_t groupMSB=(uint16_t)(code>>GROUP_SHIFT),
              start=0,
-             limit=*(uint16_t *)((char *)names+names->groupsOffset),
+             limit=*groups++,
              number;
-    Group *groups=(Group *)((char *)names+names->groupsOffset+2);
 
     /* binary search for the group of names that contains the one for code */
     while(start<limit-1) {
         number=(uint16_t)((start+limit)/2);
-        if(groupMSB<groups[number].groupMSB) {
+        if(groupMSB<groups[number*GROUP_LENGTH+GROUP_MSB]) {
             limit=number;
         } else {
             start=number;
@@ -490,7 +519,7 @@ getGroup(UCharNames *names, uint32_t code) {
     }
 
     /* return this regardless of whether it is an exact match */
-    return groups+start;
+    return groups+start*GROUP_LENGTH;
 }
 
 /*
@@ -556,12 +585,11 @@ expandGroupLengths(const uint8_t *s,
 }
 
 static uint16_t
-expandGroupName(UCharNames *names, Group *group,
+expandGroupName(UCharNames *names, const uint16_t *group,
                 uint16_t lineNumber, UCharNameChoice nameChoice,
                 char *buffer, uint16_t bufferLength) {
     uint16_t offsets[LINES_PER_GROUP+2], lengths[LINES_PER_GROUP+2];
-    const uint8_t *s=(uint8_t *)names+names->groupStringOffset+
-                                    (group->offsetHigh<<16|group->offsetLow);
+    const uint8_t *s=(uint8_t *)names+names->groupStringOffset+GET_GROUP_OFFSET(group);
     s=expandGroupLengths(s, offsets, lengths);
     return expandName(names, s+offsets[lineNumber], lengths[lineNumber], nameChoice,
                       buffer, bufferLength);
@@ -570,8 +598,8 @@ expandGroupName(UCharNames *names, Group *group,
 static uint16_t
 getName(UCharNames *names, uint32_t code, UCharNameChoice nameChoice,
         char *buffer, uint16_t bufferLength) {
-    Group *group=getGroup(names, code);
-    if((uint16_t)(code>>GROUP_SHIFT)==group->groupMSB) {
+    const uint16_t *group=getGroup(names, code);
+    if((uint16_t)(code>>GROUP_SHIFT)==group[GROUP_MSB]) {
         return expandGroupName(names, group, (uint16_t)(code&GROUP_MASK), nameChoice,
                                buffer, bufferLength);
     } else {
@@ -589,13 +617,12 @@ getName(UCharNames *names, uint32_t code, UCharNameChoice nameChoice,
  * and either calls the enumerator function or finds a given input name.
  */
 static UBool
-enumGroupNames(UCharNames *names, Group *group,
+enumGroupNames(UCharNames *names, const uint16_t *group,
                UChar32 start, UChar32 end,
                UEnumCharNamesFn *fn, void *context,
                UCharNameChoice nameChoice) {
     uint16_t offsets[LINES_PER_GROUP+2], lengths[LINES_PER_GROUP+2];
-    const uint8_t *s=(uint8_t *)names+names->groupStringOffset+
-                                    (group->offsetHigh<<16|group->offsetLow);
+    const uint8_t *s=(uint8_t *)names+names->groupStringOffset+GET_GROUP_OFFSET(group);
 
     s=expandGroupLengths(s, offsets, lengths);
     if(fn!=DO_FIND_NAME) {
@@ -663,7 +690,7 @@ enumNames(UCharNames *names,
           UEnumCharNamesFn *fn, void *context,
           UCharNameChoice nameChoice) {
     uint16_t startGroupMSB, endGroupMSB, groupCount;
-    Group *group, *groupLimit;
+    const uint16_t *group, *groupLimit;
 
     startGroupMSB=(uint16_t)(start>>GROUP_SHIFT);
     endGroupMSB=(uint16_t)((limit-1)>>GROUP_SHIFT);
@@ -672,15 +699,16 @@ enumNames(UCharNames *names,
     group=getGroup(names, start);
 
     if(startGroupMSB==endGroupMSB) {
-        if(startGroupMSB==group->groupMSB) {
+        if(startGroupMSB==group[GROUP_MSB]) {
             /* if start and limit-1 are in the same group, then enumerate only in that one */
             return enumGroupNames(names, group, start, limit-1, fn, context, nameChoice);
         }
     } else {
-        groupCount=*(uint16_t *)((char *)names+names->groupsOffset);
-        groupLimit=(Group *)((char *)names+names->groupsOffset+2)+groupCount;
+        const uint16_t *groups=GET_GROUPS(names);
+        groupCount=*groups++;
+        groupLimit=groups+groupCount*GROUP_LENGTH;
 
-        if(startGroupMSB==group->groupMSB) {
+        if(startGroupMSB==group[GROUP_MSB]) {
             /* enumerate characters in the partial start group */
             if((start&GROUP_MASK)!=0) {
                 if(!enumGroupNames(names, group,
@@ -688,12 +716,13 @@ enumNames(UCharNames *names,
                                    fn, context, nameChoice)) {
                     return FALSE;
                 }
-                ++group; /* continue with the next group */
+                group=NEXT_GROUP(group); /* continue with the next group */
             }
-        } else if(startGroupMSB>group->groupMSB) {
+        } else if(startGroupMSB>group[GROUP_MSB]) {
             /* make sure that we start enumerating with the first group after start */
-            if (group + 1 < groupLimit && (group + 1)->groupMSB > startGroupMSB && nameChoice == U_EXTENDED_CHAR_NAME) {
-                UChar32 end = (group + 1)->groupMSB << GROUP_SHIFT;
+            const uint16_t *nextGroup=NEXT_GROUP(group);
+            if (nextGroup < groupLimit && nextGroup[GROUP_MSB] > startGroupMSB && nameChoice == U_EXTENDED_CHAR_NAME) {
+                UChar32 end = nextGroup[GROUP_MSB] << GROUP_SHIFT;
                 if (end > limit) {
                     end = limit;
                 }
@@ -701,32 +730,34 @@ enumNames(UCharNames *names,
                     return FALSE;
                 }
             }
-            ++group;
+            group=nextGroup;
         }
 
         /* enumerate entire groups between the start- and end-groups */
-        while(group<groupLimit && group->groupMSB<endGroupMSB) {
-            start=(UChar32)group->groupMSB<<GROUP_SHIFT;
+        while(group<groupLimit && group[GROUP_MSB]<endGroupMSB) {
+            const uint16_t *nextGroup;
+            start=(UChar32)group[GROUP_MSB]<<GROUP_SHIFT;
             if(!enumGroupNames(names, group, start, start+LINES_PER_GROUP-1, fn, context, nameChoice)) {
                 return FALSE;
             }
-            if (group + 1 < groupLimit && (group + 1)->groupMSB > group->groupMSB + 1 && nameChoice == U_EXTENDED_CHAR_NAME) {
-                UChar32 end = (group + 1)->groupMSB << GROUP_SHIFT;
+            nextGroup=NEXT_GROUP(group);
+            if (nextGroup < groupLimit && nextGroup[GROUP_MSB] > group[GROUP_MSB] + 1 && nameChoice == U_EXTENDED_CHAR_NAME) {
+                UChar32 end = nextGroup[GROUP_MSB] << GROUP_SHIFT;
                 if (end > limit) {
                     end = limit;
                 }
-                if (!enumExtNames((group->groupMSB + 1) << GROUP_SHIFT, end - 1, fn, context)) {
+                if (!enumExtNames((group[GROUP_MSB] + 1) << GROUP_SHIFT, end - 1, fn, context)) {
                     return FALSE;
                 }
             }
-            ++group;
+            group=nextGroup;
         }
 
-        /* enumerate within the end group (group->groupMSB==endGroupMSB) */
-        if(group<groupLimit && group->groupMSB==endGroupMSB) {
+        /* enumerate within the end group (group[GROUP_MSB]==endGroupMSB) */
+        if(group<groupLimit && group[GROUP_MSB]==endGroupMSB) {
             return enumGroupNames(names, group, (limit-1)&~GROUP_MASK, limit-1, fn, context, nameChoice);
         } else if (nameChoice == U_EXTENDED_CHAR_NAME && group == groupLimit) {
-            UChar32 next = ((group - 1)->groupMSB + 1) << GROUP_SHIFT;
+            UChar32 next = (PREV_GROUP(group)[GROUP_MSB] + 1) << GROUP_SHIFT;
             if (next > start) {
                 start = next;
             }
@@ -831,13 +862,8 @@ getAlgName(AlgorithmicRange *range, uint32_t code, UCharNameChoice nameChoice,
         char *buffer, uint16_t bufferLength) {
     uint16_t bufferPos=0;
 
-    /*
-     * Do not write algorithmic Unicode 1.0 names because
-     * Unihan names are the same as the modern ones,
-     * extension A was only introduced with Unicode 3.0, and
-     * the Hangul syllable block was moved and changed around Unicode 1.1.5.
-     */
-    if(nameChoice==U_UNICODE_10_CHAR_NAME) {
+    /* Only the normative character name can be algorithmic. */
+    if(nameChoice!=U_UNICODE_CHAR_NAME && nameChoice!=U_EXTENDED_CHAR_NAME) {
         /* zero-terminate */
         if(bufferLength>0) {
             *buffer=0;
@@ -923,7 +949,7 @@ enumAlgNames(AlgorithmicRange *range,
     char buffer[200];
     uint16_t length;
 
-    if(nameChoice==U_UNICODE_10_CHAR_NAME) {
+    if(nameChoice!=U_UNICODE_CHAR_NAME && nameChoice!=U_EXTENDED_CHAR_NAME) {
         return TRUE;
     }
 
@@ -979,7 +1005,7 @@ enumAlgNames(AlgorithmicRange *range,
         uint16_t count=range->variant;
         const char *s=(const char *)(factors+count);
         char *suffix, *t;
-        uint16_t prefixLength, i, index;
+        uint16_t prefixLength, i, idx;
 
         char c;
 
@@ -1009,10 +1035,10 @@ enumAlgNames(AlgorithmicRange *range,
             /* increment the indexes in lexical order bound by the factors */
             i=count;
             for (;;) {
-                index=(uint16_t)(indexes[--i]+1);
-                if(index<factors[i]) {
+                idx=(uint16_t)(indexes[--i]+1);
+                if(idx<factors[i]) {
                     /* skip one index and its element string */
-                    indexes[i]=index;
+                    indexes[i]=idx;
                     s=elements[i];
                     while(*s++!=0) {
                     }
@@ -1061,7 +1087,7 @@ static UChar32
 findAlgName(AlgorithmicRange *range, UCharNameChoice nameChoice, const char *otherName) {
     UChar32 code;
 
-    if(nameChoice==U_UNICODE_10_CHAR_NAME) {
+    if(nameChoice!=U_UNICODE_CHAR_NAME && nameChoice!=U_EXTENDED_CHAR_NAME) {
         return 0xffff;
     }
 
@@ -1108,7 +1134,7 @@ findAlgName(AlgorithmicRange *range, UCharNameChoice nameChoice, const char *oth
         uint16_t count=range->variant;
         const char *s=(const char *)(factors+count), *t;
         UChar32 start, limit;
-        uint16_t i, index;
+        uint16_t i, idx;
 
         char c;
 
@@ -1138,10 +1164,10 @@ findAlgName(AlgorithmicRange *range, UCharNameChoice nameChoice, const char *oth
             /* increment the indexes in lexical order bound by the factors */
             i=count;
             for (;;) {
-                index=(uint16_t)(indexes[--i]+1);
-                if(index<factors[i]) {
+                idx=(uint16_t)(indexes[--i]+1);
+                if(idx<factors[i]) {
                     /* skip one index and its element string */
-                    indexes[i]=index;
+                    indexes[i]=idx;
                     s=elements[i];
                     while(*s++!=0) {}
                     elements[i]=s;
@@ -1331,11 +1357,9 @@ calcGroupNameSetsLengths(int32_t maxNameLength) {
 
     int8_t *tokenLengths;
 
-    uint16_t *groups;
-    Group *group;
+    const uint16_t *group;
     const uint8_t *s, *line, *lineLimit;
 
-    int32_t maxISOCommentLength=0;
     int32_t groupCount, lineNumber, length;
 
     tokenLengths=(int8_t *)uprv_malloc(tokenCount);
@@ -1343,14 +1367,12 @@ calcGroupNameSetsLengths(int32_t maxNameLength) {
         uprv_memset(tokenLengths, 0, tokenCount);
     }
 
-    groups=(uint16_t *)((char *)uCharNames+uCharNames->groupsOffset);
-    groupCount=*groups++;
-    group=(Group *)groups;
+    group=GET_GROUPS(uCharNames);
+    groupCount=*group++;
 
     /* enumerate all groups */
     while(groupCount>0) {
-        s=(uint8_t *)uCharNames+uCharNames->groupStringOffset+
-                                    ((int32_t)group->offsetHigh<<16|group->offsetLow);
+        s=(uint8_t *)uCharNames+uCharNames->groupStringOffset+GET_GROUP_OFFSET(group);
         s=expandGroupLengths(s, offsets, lengths);
 
         /* enumerate all lines in each group */
@@ -1382,13 +1404,10 @@ calcGroupNameSetsLengths(int32_t maxNameLength) {
             }
 
             /* read ISO comment */
-            length=calcNameSetLength(tokens, tokenCount, tokenStrings, tokenLengths, gISOCommentSet, &line, lineLimit);
-            if(length>maxISOCommentLength) {
-                maxISOCommentLength=length;
-            }
+            /*length=calcNameSetLength(tokens, tokenCount, tokenStrings, tokenLengths, gISOCommentSet, &line, lineLimit);*/
         }
 
-        ++group;
+        group=NEXT_GROUP(group);
         --groupCount;
     }
 
@@ -1397,7 +1416,6 @@ calcGroupNameSetsLengths(int32_t maxNameLength) {
     }
 
     /* set gMax... - name length last for threading */
-    gMaxISOCommentLength=maxISOCommentLength;
     gMaxNameLength=maxNameLength;
 }
 
@@ -1696,29 +1714,13 @@ uprv_getMaxCharNameLength() {
     }
 }
 
-#if 0
-/* 
-Currently not used but left for future use. Probably by UnicodeSet. 
-urename.h and uprops.h changed accordingly. 
-*/
-U_CAPI int32_t U_EXPORT2
-uprv_getMaxISOCommentLength() {
-    UErrorCode errorCode=U_ZERO_ERROR;
-    if(calcNameSetsLengths(&errorCode)) {
-        return gMaxISOCommentLength;
-    } else {
-        return 0;
-    }
-}
-#endif
-
 /**
  * Converts the char set cset into a Unicode set uset.
  * @param cset Set of 256 bit flags corresponding to a set of chars.
  * @param uset USet to receive characters. Existing contents are deleted.
  */
 static void
-charSetToUSet(uint32_t cset[8], USetAdder *sa) {
+charSetToUSet(uint32_t cset[8], const USetAdder *sa) {
     UChar us[256];
     char cs[256];
 
@@ -1755,25 +1757,10 @@ charSetToUSet(uint32_t cset[8], USetAdder *sa) {
  * @param set USet to receive characters.
  */
 U_CAPI void U_EXPORT2
-uprv_getCharNameCharacters(USetAdder *sa) {
+uprv_getCharNameCharacters(const USetAdder *sa) {
     charSetToUSet(gNameSet, sa);
 }
 
-#if 0
-/* 
-Currently not used but left for future use. Probably by UnicodeSet. 
-urename.h and uprops.h changed accordingly. 
-*/
-/**
- * Fills set with characters that are used in Unicode character names.
- * @param set USetAdder to receive characters.
- */
-U_CAPI void U_EXPORT2
-uprv_getISOCommentCharacters(USetAdder *sa) {
-    charSetToUSet(gISOCommentSet, sa);
-}
-#endif
-
 /* data swapping ------------------------------------------------------------ */
 
 /*
@@ -1820,8 +1807,8 @@ makeTokenMap(const UDataSwapper *ds,
                 c1=(uint8_t)i;
                 ds->swapInvChars(ds, &c1, 1, &c2, pErrorCode);
                 if(U_FAILURE(*pErrorCode)) {
-                    udata_printError(ds, "unames/makeTokenMap() finds variant character 0x%02x used (input charset family %d) - %s\n",
-                                     i, ds->inCharset, u_errorName(*pErrorCode));
+                    udata_printError(ds, "unames/makeTokenMap() finds variant character 0x%02x used (input charset family %d)\n",
+                                     i, ds->inCharset);
                     return;
                 }
 
@@ -2000,8 +1987,7 @@ uchar_swapNames(const UDataSwapper *ds,
         udata_swapInvStringBlock(ds, inBytes+tokenStringOffset, (int32_t)(groupsOffset-tokenStringOffset),
                                     outBytes+tokenStringOffset, pErrorCode);
         if(U_FAILURE(*pErrorCode)) {
-            udata_printError(ds, "uchar_swapNames(token strings) failed - %s\n",
-                             u_errorName(*pErrorCode));
+            udata_printError(ds, "uchar_swapNames(token strings) failed\n");
             return 0;
         }
 
@@ -2080,31 +2066,19 @@ uchar_swapNames(const UDataSwapper *ds,
                 ds->swapInvChars(ds, inRange+1, (int32_t)uprv_strlen((const char *)(inRange+1)),
                                     outRange+1, pErrorCode);
                 if(U_FAILURE(*pErrorCode)) {
-                    udata_printError(ds, "uchar_swapNames(prefix string of algorithmic range %u) failed - %s\n",
-                                     i, u_errorName(*pErrorCode));
+                    udata_printError(ds, "uchar_swapNames(prefix string of algorithmic range %u) failed\n",
+                                     i);
                     return 0;
                 }
                 break;
             case 1:
                 {
                     /* swap factors and the prefix and factor strings */
-                    uint16_t factors[8];
-                    uint32_t j, factorsCount;
+                    uint32_t factorsCount;
 
                     factorsCount=inRange->variant;
-                    if(factorsCount==0 || factorsCount>LENGTHOF(factors)) {
-                        udata_printError(ds, "uchar_swapNames(): too many factors (%u) in algorithmic range %u\n",
-                                         factorsCount, i);
-                        *pErrorCode=U_INDEX_OUTOFBOUNDS_ERROR;
-                        return 0;
-                    }
-
-                    /* read and swap the factors */
                     p=(const uint16_t *)(inRange+1);
                     q=(uint16_t *)(outRange+1);
-                    for(j=0; j<factorsCount; ++j) {
-                        factors[j]=ds->readUInt16(p[j]);
-                    }
                     ds->swapArray16(ds, p, (int32_t)(factorsCount*2), q, pErrorCode);
 
                     /* swap the strings, up to the last terminating NUL */