]> granicus.if.org Git - icu/commitdiff
ICU-9014 make hasScript(c, sc) == sc in scx(c)
authorMarkus Scherer <markus.icu@gmail.com>
Mon, 6 Feb 2012 20:11:43 +0000 (20:11 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Mon, 6 Feb 2012 20:11:43 +0000 (20:11 +0000)
X-SVN-Rev: 31331

icu4j/main/classes/core/src/com/ibm/icu/lang/UScript.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/lang/TestUScript.java

index 773d961cc5d9a91670d5e8b3bd20e6538138c820..c799c8d9746975afb06be0565cc3e046f782c332 100644 (file)
@@ -1027,18 +1027,18 @@ public final class UScript {
     }
 
     /**
-     * Is code point c used in script sc?
-     * That is, does code point c have the Script property value sc,
-     * or do code point c's Script_Extensions include script code sc?
+     * Do the Script_Extensions of code point c contain script sc?
+     * If c does not have explicit Script_Extensions, then this tests whether
+     * c has the Script property value sc.
      *
-     * Some characters are commonly used in multiple scripts.
+     * <p>Some characters are commonly used in multiple scripts.
      * For more information, see UAX #24: http://www.unicode.org/reports/tr24/.
      *
-     * The Script_Extensions property is provisional. It may be modified or removed
+     * <p>The Script_Extensions property is provisional. It may be modified or removed
      * in future versions of the Unicode Standard, and thus in ICU.
      * @param c code point
      * @param sc script code
-     * @return true if Script(c)==sc or sc is in Script_Extensions(c)
+     * @return true if sc is in Script_Extensions(c)
      * @draft ICU 4.6
      * @provisional This API might change or be removed in a future release.
      */
@@ -1050,18 +1050,9 @@ public final class UScript {
 
         char[] scriptExtensions=UCharacterProperty.INSTANCE.m_scriptExtensions_;
         int scx=scriptX&UCharacterProperty.SCRIPT_MASK_;  // index into scriptExtensions
-        int script;
-        if(scriptX<UCharacterProperty.SCRIPT_X_WITH_INHERITED) {
-            script=UScript.COMMON;
-        } else if(scriptX<UCharacterProperty.SCRIPT_X_WITH_OTHER) {
-            script=UScript.INHERITED;
-        } else {
-            script=scriptExtensions[scx];
+        if(scriptX>=UCharacterProperty.SCRIPT_X_WITH_OTHER) {
             scx=scriptExtensions[scx+1];
         }
-        if(sc==script) {
-            return true;
-        }
         if(sc>0x7fff) {
             // Guard against bogus input that would
             // make us go past the Script_Extensions terminator.
index 89154dbf89237a63a68f5bd3a67b2dc7f14b2dfc..06614e0b38b89c232c1845ba5b106a25e1e75708 100644 (file)
@@ -341,7 +341,7 @@ public class TestUScript extends TestFmwk {
             errln("UScript.hasScript(U+063F, ...) is wrong");
         }
         if(!(
-            UScript.hasScript(0x0640, UScript.COMMON) &&  /* main Script value */
+            !UScript.hasScript(0x0640, UScript.COMMON) &&  /* main Script value */
             UScript.hasScript(0x0640, UScript.ARABIC) &&
             UScript.hasScript(0x0640, UScript.SYRIAC) &&
             !UScript.hasScript(0x0640, UScript.THAANA))
@@ -349,7 +349,7 @@ public class TestUScript extends TestFmwk {
             errln("UScript.hasScript(U+0640, ...) is wrong");
         }
         if(!(
-            UScript.hasScript(0x0650, UScript.INHERITED) &&  /* main Script value */
+            !UScript.hasScript(0x0650, UScript.INHERITED) &&  /* main Script value */
             UScript.hasScript(0x0650, UScript.ARABIC) &&
             UScript.hasScript(0x0650, UScript.SYRIAC) &&
             !UScript.hasScript(0x0650, UScript.THAANA))
@@ -357,7 +357,7 @@ public class TestUScript extends TestFmwk {
             errln("UScript.hasScript(U+0650, ...) is wrong");
         }
         if(!(
-            UScript.hasScript(0x0660, UScript.COMMON) &&  /* main Script value */
+            !UScript.hasScript(0x0660, UScript.COMMON) &&  /* main Script value */
             UScript.hasScript(0x0660, UScript.ARABIC) &&
             !UScript.hasScript(0x0660, UScript.SYRIAC) &&
             UScript.hasScript(0x0660, UScript.THAANA))