]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/ubidi_props.c
ICU-57131.0.1.tar.gz
[apple/icu.git] / icuSources / common / ubidi_props.c
index 00255edc48f8ba7b01b3f7de1a22335922da52a6..42d05f1e2600058eb7fa4ec4d77db6414162de2c 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2004-2013, International Business Machines
+*   Copyright (C) 2004-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -32,6 +32,7 @@ struct UBiDiProps {
     const int32_t *indexes;
     const uint32_t *mirrors;
     const uint8_t *jgArray;
+    const uint8_t *jgArray2;
 
     UTrie2 trie;
     uint8_t formatVersion[4];
@@ -84,18 +85,28 @@ ubidi_addPropertyStarts(const UBiDiProps *bdp, const USetAdder *sa, UErrorCode *
     start=bdp->indexes[UBIDI_IX_JG_START];
     limit=bdp->indexes[UBIDI_IX_JG_LIMIT];
     jgArray=bdp->jgArray;
-    prev=0;
-    while(start<limit) {
-        jg=*jgArray++;
-        if(jg!=prev) {
-            sa->add(sa->set, start);
-            prev=jg;
+    for(;;) {
+        prev=0;
+        while(start<limit) {
+            jg=*jgArray++;
+            if(jg!=prev) {
+                sa->add(sa->set, start);
+                prev=jg;
+            }
+            ++start;
+        }
+        if(prev!=0) {
+            /* add the limit code point if the last value was not 0 (it is now start==limit) */
+            sa->add(sa->set, limit);
+        }
+        if(limit==bdp->indexes[UBIDI_IX_JG_LIMIT]) {
+            /* switch to the second Joining_Group range */
+            start=bdp->indexes[UBIDI_IX_JG_START2];
+            limit=bdp->indexes[UBIDI_IX_JG_LIMIT2];
+            jgArray=bdp->jgArray2;
+        } else {
+            break;
         }
-        ++start;
-    }
-    if(prev!=0) {
-        /* add the limit code point if the last value was not 0 (it is now start==limit) */
-        sa->add(sa->set, limit);
     }
 
     /* add code points with hardcoded properties, plus the ones following them */
@@ -204,9 +215,13 @@ ubidi_getJoiningGroup(const UBiDiProps *bdp, UChar32 c) {
     limit=bdp->indexes[UBIDI_IX_JG_LIMIT];
     if(start<=c && c<limit) {
         return (UJoiningGroup)bdp->jgArray[c-start];
-    } else {
-        return U_JG_NO_JOINING_GROUP;
     }
+    start=bdp->indexes[UBIDI_IX_JG_START2];
+    limit=bdp->indexes[UBIDI_IX_JG_LIMIT2];
+    if(start<=c && c<limit) {
+        return (UJoiningGroup)bdp->jgArray2[c-start];
+    }
+    return U_JG_NO_JOINING_GROUP;
 }
 
 U_CFUNC UBidiPairedBracketType