String.st
branchjv
changeset 17938 e2aad1d7c317
parent 17911 a99f15c5efa5
child 17939 9ea58e0aad5a
--- a/String.st	Fri Apr 13 00:04:07 2012 +0100
+++ b/String.st	Fri Apr 13 14:18:13 2012 +0100
@@ -11,7 +11,7 @@
 "
 "{ Package: 'stx:libbasic' }"
 
-CharacterArray variableByteSubclass:#String
+CharacterArray subclass:#String
 	instanceVariableNames:''
 	classVariableNames:'CRLF LF'
 	poolDictionaries:''
@@ -44,56 +44,6 @@
 %}
 ! !
 
-!String primitiveFunctions!
-%{
-
-static int
-nextOnKeyboard(char1, char2)
-{
-    /* compare two characters if they are next to each other on a (US-) keyboard */
-
-    static char *us_keys[] = { "1234567890-",
-			    "*qwertyuiop",
-			    "**asdfghjkl:",
-			    "***zxcvbnm",
-			    0 };
-    static char *de_keys[] = { "1234567890-",
-			    "*qwertzuiop",
-			    "**asdfghjkl:",
-			    "***yxcvbnm",
-			    0 };
-    char **keys = us_keys;
-    char **line1, **line2;
-    char *col1, *col2;
-    int diff;
-
-    for (line1 = keys; *line1 != 0; line1++) {
-	for (col1 = *line1; *col1 != 0 && *col1 != char1; col1++)
-	    continue;
-    }
-    if (*col1 == 0)
-	return(0);
-
-    for (line2 = keys; *line2 != 0; line2++) {
-	for (col2 = *line2; *col2 != 0 && *col2 != char2; col2++)
-	    continue;
-    }
-    if (*col2 == 0)
-	return(0);
-
-    diff = col1 - col2;
-    if (diff > 1 || diff < -1)
-	return(0);
-
-    diff = line1 - line2;
-    if (diff > 1 || diff < -1)
-	return(0);
-    return(1);
-}
-
-%}
-! !
-
 !String class methodsFor:'documentation'!
 
 copyright
@@ -488,8 +438,6 @@
     ^ Character tab asString
 ! !
 
-
-
 !String class methodsFor:'queries'!
 
 defaultPlatformClass
@@ -509,11 +457,6 @@
     "Modified: 23.4.1996 / 16:00:38 / cg"
 ! !
 
-
-
-
-
-
 !String methodsFor:'Compatibility-VW5.4'!
 
 asGUID
@@ -707,7 +650,6 @@
     "
 ! !
 
-
 !String methodsFor:'character searching'!
 
 identityIndexOf:aCharacter
@@ -2146,8 +2088,7 @@
 !String methodsFor:'copying'!
 
 , aString
-    "return the concatenation of myself and the argument, aString as
-     a String.
+    "return the concatenation of myself and the argument, aString as a String.
      - reimplemented here for speed"
 
 %{
@@ -2157,77 +2098,77 @@
     OBJ myClass, argClass, newString;
 
     if (__isNonNilObject(s)) {
-	myClass = __qClass(self);
-	argClass = __qClass(s);
-	/*
-	 * can do it here if both are Strings/Symbols:
-	 */
-	if (((myClass == _string) || (myClass == Symbol))
-	 && ((argClass == _string) || (argClass == Symbol))) {
-	    l1 = __stringSize(self);
-	    l2 = __stringSize(s);
-
-	    sz = OHDR_SIZE + l1 + l2 + 1;
-	    __qNew(newString, sz);      /* OBJECT ALLOCATION */
-	    if (newString != nil) {
-		char *cp1, *cp2;
-		REGISTER unsigned char *dstp;
-
-		__InstPtr(newString)->o_class = String;
-		__qSTORE(newString, String);
-		dstp = __stringVal(newString);
-		cp1 = (char *) __stringVal(self);
-		cp2 = (char *) __stringVal(aString);
+        myClass = __qClass(self);
+        argClass = __qClass(s);
+        /*
+         * can do it here if both are Strings/Symbols:
+         */
+        if (((myClass == _string) || (myClass == Symbol))
+         && ((argClass == _string) || (argClass == Symbol))) {
+            l1 = __stringSize(self);
+            l2 = __stringSize(s);
+
+            sz = OHDR_SIZE + l1 + l2 + 1;
+            __qNew(newString, sz);      /* OBJECT ALLOCATION */
+            if (newString != nil) {
+                char *cp1, *cp2;
+                REGISTER unsigned char *dstp;
+
+                __InstPtr(newString)->o_class = String;
+                __qSTORE(newString, String);
+                dstp = __stringVal(newString);
+                cp1 = (char *) __stringVal(self);
+                cp2 = (char *) __stringVal(aString);
 
 #ifdef bcopy4
-		/* knowing that allocation is 4-byte aligned and
-		 * size rounded up to next 4-byte, the first copy
-		 * can be done word-wise.
-		 * that speeds up size-10-string , size-10-string
-		 * by 10% on a P5/200.
-		 */
-		{
-		    int nw = l1 >> 2;
-
-		    if (l1 & 3) nw++;
-		    bcopy4(cp1, dstp, nw);
-		    dstp += l1;
-		}
+                /* knowing that allocation is 4-byte aligned and
+                 * size rounded up to next 4-byte, the first copy
+                 * can be done word-wise.
+                 * that speeds up size-10-string , size-10-string
+                 * by 10% on a P5/200.
+                 */
+                {
+                    int nw = l1 >> 2;
+
+                    if (l1 & 3) nw++;
+                    bcopy4(cp1, dstp, nw);
+                    dstp += l1;
+                }
 #else
 # ifdef FAST_MEMCPY
-		memcpy(dstp, cp1, l1);
-		dstp += l1;
+                memcpy(dstp, cp1, l1);
+                dstp += l1;
 # else
-		while (l1 >= 4) {
-		    *(int *)dstp = *(int *)cp1;
-		    dstp += 4; cp1 += 4;
-		    l1 -= 4;
-		}
-		while (l1--) *dstp++ = *cp1++;
+                while (l1 >= 4) {
+                    *(int *)dstp = *(int *)cp1;
+                    dstp += 4; cp1 += 4;
+                    l1 -= 4;
+                }
+                while (l1--) *dstp++ = *cp1++;
 # endif
 #endif
 
 #ifdef bcopy4
-		if (((INT)dstp & 3) == 0) {
-		    int nw = l2 >> 2;
-
-		    if (l2 & 3) nw++;
-		    bcopy4(cp2, dstp, nw);
-		    *(dstp + l2) = '\0';
-		    RETURN ( newString );
-		}
+                if (((INT)dstp & 3) == 0) {
+                    int nw = l2 >> 2;
+
+                    if (l2 & 3) nw++;
+                    bcopy4(cp2, dstp, nw);
+                    *(dstp + l2) = '\0';
+                    RETURN ( newString );
+                }
 #endif
 
 #ifdef FAST_MEMCPY
-		memcpy(dstp, cp2, l2+1);
-		dstp[l2] = '\0';
+                memcpy(dstp, cp2, l2+1);
+                dstp[l2] = '\0';
 #else
-		while (l2--) *dstp++ = *cp2++;
-		*dstp = '\0';
+                while (l2--) *dstp++ = *cp2++;
+                *dstp = '\0';
 #endif
-		RETURN ( newString );
-	    }
-	}
+                RETURN ( newString );
+            }
+        }
     }
 %}.
     ^ super , aString
@@ -2236,6 +2177,8 @@
      'hello' , 'world'
      #[0 0 0 1] asString, #[0 0 0 2 0] asString
     "
+
+    "Modified: / 01-04-2012 / 13:19:44 / cg"
 !
 
 concatenate:string1 and:string2
@@ -2613,7 +2556,6 @@
     ^ super simpleDeepCopy
 ! !
 
-
 !String methodsFor:'filling & replacing'!
 
 atAllPut:aCharacter
@@ -3777,17 +3719,13 @@
 !String class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.280 2012/01/10 16:11:13 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.281 2012/04/01 11:27:41 cg Exp $'
 !
 
 version_CVS
-    ^ 'Header: /cvs/stx/stx/libbasic/String.st,v 1.280 2012/01/10 16:11:13 cg Exp '
+    ^ '§Header: /cvs/stx/stx/libbasic/String.st,v 1.281 2012/04/01 11:27:41 cg Exp §'
 !
 
 version_SVN
-    ^ '$Id: String.st 10761 2012-01-19 11:46:00Z vranyj1 $'
+    ^ '$Id: String.st 10804 2012-04-13 13:18:13Z vranyj1 $'
 ! !
-
-
-
-