Character.st
changeset 6527 e6528da50c43
parent 6526 36e1782b7d30
child 6531 8798c9a1d1e6
--- a/Character.st	Fri May 03 20:21:10 2002 +0200
+++ b/Character.st	Mon May 06 08:01:41 2002 +0200
@@ -795,8 +795,9 @@
 
         
     "
-      $a utf8Encoded
-      $ü utf8Encoded
+      $a utf8Encoded   
+      $ü utf8Encoded asByteArray  
+      (Character value:16r1fff) utf8Encoded asByteArray      
     "
 ! !
 
@@ -1046,7 +1047,17 @@
 isDigit
     "return true, if I am a digit (i.e. $0 .. $9)"
 
-    ^ asciivalue between:($0 asciiValue) and:($9 asciiValue)
+%{  /*NOCONTEXT */
+
+    REGISTER int val;
+
+    val = __intVal(__INST(asciivalue));
+    if ((unsigned)(val - '0') <= ('9' - '0')) {
+        RETURN ( true );
+    }
+    RETURN ( false );
+%}.
+    ^ asciivalue between:$0 asciiValue and:$9 asciiValue
 !
 
 isDigitRadix:r
@@ -1054,13 +1065,13 @@
 
     (asciivalue < $0 asciiValue) ifTrue:[^ false]. 
     (r > 10) ifTrue:[
-	(asciivalue between:($0 asciiValue) and:($9 asciiValue)) ifTrue:[
-	    ^ true
-	].
-	((asciivalue - $a asciiValue) between:0 and:(r - 11)) ifTrue:[
-	    ^ true
-	].
-	^ (asciivalue - $A asciiValue) between:0 and:(r - 11)
+        (asciivalue <= $9 asciiValue) ifTrue:[
+            ^ true
+        ].
+        ((asciivalue - $a asciiValue) between:0 and:(r - 11)) ifTrue:[
+            ^ true
+        ].
+        ^ (asciivalue - $A asciiValue) between:0 and:(r - 11)
     ].
     (asciivalue - $0 asciiValue) < r ifTrue:[^ true].
     ^ false
@@ -1107,8 +1118,13 @@
     REGISTER int val;
 
     val = __intVal(__INST(asciivalue));
-    RETURN ( (((val >= 'a') && (val <= 'z')) ||
-              ((val >= 'A') && (val <= 'Z'))) ? true : false );
+    if ((unsigned)(val - 'a') <= ('z' - 'a')) {
+        RETURN ( true );
+    }
+    if ((unsigned)(val - 'A') <= ('Z' - 'A')) {
+        RETURN ( true );
+    }
+    RETURN ( false );
 %}.
     ^ (asciivalue between:($a asciiValue) and:($z asciiValue))
       or:[(asciivalue between:($A asciiValue) and:($Z asciiValue))]
@@ -1123,19 +1139,18 @@
     REGISTER int val;
 
     val = __intVal(__INST(asciivalue));
-    if ((val >= 'a') && (val <= 'z')) {
+    if ((unsigned)(val - 'a') <= ('z' - 'a')) {
         RETURN ( true );
     }
-    if ((val >= 'A') && (val <= 'Z')) {
+    if ((unsigned)(val - 'A') <= ('Z' - 'A')) {
         RETURN ( true );
     }
-    if ((val >= '0') && (val <= '9')) {
+    if ((unsigned)(val - '0') <= ('9' - '0')) {
         RETURN ( true );
     }
     RETURN ( false );
 %}.
     ^ self isLetter or:[self isDigit]
-
 !
 
 isLowercase
@@ -1146,13 +1161,16 @@
     REGISTER int val;
 
     val = __intVal(__INST(asciivalue));
+    if ((unsigned)(val - 'a') <= ('z' - 'a')) {
+        RETURN ( true );
+    }
 #ifndef OLD
     /* iso8859 puts national lower case characters at e0 .. ff */
     if ((val >= 0xE0) && (val <= 0xFF)) {
         RETURN(true);
     }
 #endif
-    RETURN ( ((val >= 'a') && (val <= 'z')) ? true : false );
+    RETURN ( false );
 %}.
     ^ (asciivalue between:($a asciiValue) and:($z asciiValue))
       or:[asciivalue between:16rE0 and:16rFF]
@@ -1210,17 +1228,19 @@
     REGISTER int val;
 
     val = __intVal(__INST(asciivalue));
+    if ((unsigned)(val - 'A') <= ('Z' - 'A')) {
+        RETURN ( true );
+    }
 #ifndef OLD
     /* iso8859 puts national upper case characters at c0 .. df */
     if ((val >= 0xC0) && (val <= 0xDF)) {
         RETURN(true);
     }
 #endif
-    RETURN ( ((val >= 'A') && (val <= 'Z')) ? true : false );
+    RETURN ( false );
 %}.
     ^ (asciivalue between:($A asciiValue) and:($Z asciiValue))
       or:[asciivalue between:16rC0 and:16rDF]
-
 !
 
 isVowel
@@ -1259,5 +1279,5 @@
 !Character class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Character.st,v 1.75 2002-05-03 18:21:10 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Character.st,v 1.76 2002-05-06 06:01:41 cg Exp $'
 ! !