--- a/ReadStr.st Sat Nov 15 15:06:27 1997 +0100
+++ b/ReadStr.st Sat Nov 15 15:59:21 1997 +0100
@@ -156,6 +156,7 @@
nextAlphaNumericWord
"read the next word (i.e. up to non letter-or-digit).
return a string containing those characters.
+ Skips any non-alphanumeric chars first.
- tuned for speed on String-Streams for faster scanning"
%{
/* speedup, if collection is a string */
@@ -184,9 +185,10 @@
if (pos > limit) break;
ch = *cp;
- if (ch > ' ') break;
- if ((ch != ' ') && (ch != '\t') && (ch != '\r')
- && (ch != '\n') && (ch != 0x0b)) break;
+ if (((ch >= 'a') && (ch <= 'z')) ||
+ ((ch >= 'A') && (ch <= 'Z')) ||
+ ((ch >= '0') && (ch <= '9')))
+ break;
cp++;
pos++;
}
@@ -590,5 +592,5 @@
!ReadStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Attic/ReadStr.st,v 1.35 1997-10-04 17:00:01 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Attic/ReadStr.st,v 1.36 1997-11-15 14:59:21 cg Exp $'
! !
--- a/ReadStream.st Sat Nov 15 15:06:27 1997 +0100
+++ b/ReadStream.st Sat Nov 15 15:59:21 1997 +0100
@@ -156,6 +156,7 @@
nextAlphaNumericWord
"read the next word (i.e. up to non letter-or-digit).
return a string containing those characters.
+ Skips any non-alphanumeric chars first.
- tuned for speed on String-Streams for faster scanning"
%{
/* speedup, if collection is a string */
@@ -184,9 +185,10 @@
if (pos > limit) break;
ch = *cp;
- if (ch > ' ') break;
- if ((ch != ' ') && (ch != '\t') && (ch != '\r')
- && (ch != '\n') && (ch != 0x0b)) break;
+ if (((ch >= 'a') && (ch <= 'z')) ||
+ ((ch >= 'A') && (ch <= 'Z')) ||
+ ((ch >= '0') && (ch <= '9')))
+ break;
cp++;
pos++;
}
@@ -590,5 +592,5 @@
!ReadStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.35 1997-10-04 17:00:01 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.36 1997-11-15 14:59:21 cg Exp $'
! !
--- a/Stream.st Sat Nov 15 15:06:27 1997 +0100
+++ b/Stream.st Sat Nov 15 15:59:21 1997 +0100
@@ -1543,16 +1543,12 @@
nextAlphaNumericWord
"read the next word (i.e. up to non letter-or-digit).
Return a string containing those characters.
- Any leading whitespace is skipped.
- This method does not advance over any non-alphanumeric characters;
- i.e. it will stick and continue to continue to return nil in this case.
- Only call for it in a loop, AFTER you have checked for
- the next character to really be alphanumeric (using #peek)"
+ Any leading non-alphaNumeric chars are skipped."
|s c|
- [self atEnd not
- and:[(c := self peek) isSeparator]] whileTrue:[
+ [self atEnd
+ or:[(c := self peek) isAlphaNumeric]] whileFalse:[
self next
].
@@ -1576,13 +1572,13 @@
[s atEnd] whileFalse:[
Transcript showCR:(s nextAlphaNumericWord).
].
-
+ "
- notice: streams end never reached this way (sticking at the '+'-character:
+ "
|s|
- s := 'hello world 1234 foo1+foo2' readStream.
- 10 timesRepeat:[
+ s := 'hello +++ #world ###123###abc### 1234 foo1 foo2' readStream.
+ [s atEnd] whileFalse:[
Transcript showCR:(s nextAlphaNumericWord).
].
"
@@ -1911,6 +1907,6 @@
!Stream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Stream.st,v 1.65 1997-11-12 16:52:57 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Stream.st,v 1.66 1997-11-15 14:59:17 cg Exp $'
! !
Stream initialize!