--- a/String.st Fri Apr 13 14:18:13 2012 +0100
+++ b/String.st Fri Apr 13 15:03:30 2012 +0100
@@ -11,7 +11,7 @@
"
"{ Package: 'stx:libbasic' }"
-CharacterArray subclass:#String
+CharacterArray variableByteSubclass:#String
instanceVariableNames:''
classVariableNames:'CRLF LF'
poolDictionaries:''
@@ -44,6 +44,55 @@
%}
! !
+!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
@@ -1054,7 +1103,7 @@
'hello world' indexOfAny:'AOE' startingAt:1
'hello world' indexOfAny:'o' startingAt:6
'hello world' indexOfAny:'o' startingAt:6
- 'hello world' indexOfAny:'#$' startingAt:6
+ 'hello world§' indexOfAny:'#§$' startingAt:6
"
!
@@ -3727,5 +3776,5 @@
!
version_SVN
- ^ '$Id: String.st 10804 2012-04-13 13:18:13Z vranyj1 $'
+ ^ '$Id: String.st 10805 2012-04-13 14:03:30Z vranyj1 $'
! !