author | Claus Gittinger <cg@exept.de> |
Mon, 04 Feb 2002 15:31:14 +0100 | |
changeset 6376 | 6a3ce5694cc9 |
parent 6315 | 11b585e578f5 |
child 6814 | eb7703491da0 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
202 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
5810 | 13 |
"{ Package: 'stx:libbasic' }" |
14 |
||
1 | 15 |
PositionableStream subclass:#ReadStream |
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
16 |
instanceVariableNames:'' |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
17 |
classVariableNames:'' |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
18 |
poolDictionaries:'' |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
19 |
category:'Streams' |
1 | 20 |
! |
21 |
||
2162
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
22 |
!ReadStream class methodsFor:'documentation'! |
88 | 23 |
|
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
202 | 27 |
All Rights Reserved |
1 | 28 |
|
88 | 29 |
This software is furnished under a license and may be used |
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
1 | 37 |
|
88 | 38 |
documentation |
39 |
" |
|
40 |
ReadStream defines protocol for reading streamwise over collections. |
|
1295 | 41 |
|
42 |
[author:] |
|
43 |
Claus Gittinger |
|
44 |
||
88 | 45 |
" |
46 |
! ! |
|
1 | 47 |
|
202 | 48 |
!ReadStream methodsFor:'converting'! |
49 |
||
50 |
readStream |
|
51 |
"return a readStream from the receiver. Since this is already |
|
52 |
a readStream, return self." |
|
53 |
||
54 |
^ self |
|
55 |
! ! |
|
56 |
||
1400 | 57 |
!ReadStream methodsFor:'emphasis'! |
58 |
||
59 |
emphasis |
|
60 |
"return the emphasis of the current (i.e. next returned by #next) |
|
61 |
element. Streams on a string will return nil for all elements. |
|
62 |
Streams on collections which nothing at all about emphasises, |
|
63 |
will report an error." |
|
64 |
||
65 |
^ collection emphasisAt:position. |
|
66 |
||
67 |
" |
|
68 |
|t s| |
|
69 |
||
70 |
t := 'hello world' asText |
|
71 |
emphasizeFrom:1 to:5 with:#bold; |
|
72 |
emphasizeFrom:7 to:11 with:#italic. |
|
73 |
||
74 |
s := t readStream. |
|
75 |
[s atEnd] whileFalse:[ |
|
76 |
Transcript show:(s emphasis); show:' '. |
|
1422 | 77 |
Transcript show:''''; show:(s next); showCR:''''. |
1400 | 78 |
]. |
79 |
" |
|
80 |
||
81 |
"Modified: 15.5.1996 / 17:30:33 / cg" |
|
82 |
! ! |
|
83 |
||
345 | 84 |
!ReadStream methodsFor:'queries'! |
85 |
||
5310 | 86 |
copyFrom:beginning to:end |
87 |
^ collection copyFrom:beginning to:end |
|
88 |
! |
|
89 |
||
345 | 90 |
isReadable |
2997 | 91 |
"return true, if reading is supported by the recevier. |
92 |
Here, true is always returned." |
|
93 |
||
345 | 94 |
^ true |
2997 | 95 |
|
96 |
"Modified: 4.10.1997 / 17:59:21 / cg" |
|
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
97 |
! |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
98 |
|
6315 | 99 |
isWritable |
100 |
"return true, if writing is supported by the recevier. |
|
101 |
This has to be redefined in concrete subclasses." |
|
102 |
||
103 |
^ false |
|
104 |
! |
|
105 |
||
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
106 |
size |
2997 | 107 |
"return the number of elements in the streamed collection." |
108 |
||
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
109 |
^ collection size |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
110 |
|
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
111 |
"Created: 13.9.1996 / 18:14:35 / cg" |
2997 | 112 |
"Modified: 4.10.1997 / 17:59:45 / cg" |
345 | 113 |
! ! |
114 |
||
59 | 115 |
!ReadStream methodsFor:'reading'! |
1 | 116 |
|
117 |
next |
|
118 |
"return the next element; advance read pointer. |
|
2 | 119 |
return nil, if there is no next element. |
345 | 120 |
- tuned for a bit more speed on String/ByteArray/Array-Streams" |
1 | 121 |
|
122 |
|ret| |
|
123 |
||
124 |
%{ /* NOCONTEXT */ |
|
125 |
||
126 |
REGISTER int pos; |
|
127 |
unsigned ch; |
|
252 | 128 |
OBJ coll, p, l; |
1 | 129 |
|
1133 | 130 |
coll = __INST(collection); |
131 |
p = __INST(position); |
|
132 |
l = __INST(readLimit); |
|
1 | 133 |
|
252 | 134 |
if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
135 |
||
1133 | 136 |
pos = __intVal(p); |
137 |
if (pos > 0 && pos <= __intVal(l)) { |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
138 |
OBJ cls; |
59 | 139 |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
140 |
cls = __qClass(coll); |
1133 | 141 |
if (cls == @global(String)) { |
142 |
if (pos <= __stringSize(coll)) { |
|
143 |
__INST(position) = __MKSMALLINT(pos + 1); |
|
144 |
ch = __stringVal(coll)[pos-1]; |
|
145 |
RETURN ( __MKCHARACTER(ch) ); |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
146 |
} |
1133 | 147 |
} else if (cls == @global(ByteArray)) { |
148 |
if (pos <= __byteArraySize(coll)) { |
|
149 |
__INST(position) = __MKSMALLINT(pos + 1); |
|
150 |
ch = __ByteArrayInstPtr(coll)->ba_element[pos-1]; |
|
151 |
RETURN ( __MKSMALLINT(ch) ); |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
152 |
} |
1133 | 153 |
} else if (cls == @global(Array)) { |
154 |
if (pos <= __arraySize(coll)) { |
|
155 |
__INST(position) = __MKSMALLINT(pos + 1); |
|
156 |
RETURN ( __ArrayInstPtr(coll)->a_element[pos-1]); |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
157 |
} |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
158 |
} |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
159 |
} |
1 | 160 |
} |
161 |
%} |
|
162 |
. |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
163 |
(position > readLimit) ifTrue:[^ self pastEnd]. |
1 | 164 |
ret := collection at:position. |
165 |
position := position + 1. |
|
166 |
^ ret |
|
167 |
! |
|
168 |
||
252 | 169 |
nextAlphaNumericWord |
1 | 170 |
"read the next word (i.e. up to non letter-or-digit). |
171 |
return a string containing those characters. |
|
3112
ccf7121ddae8
nextAlphaNumericWord changed
Claus Gittinger <cg@exept.de>
parents:
2997
diff
changeset
|
172 |
Skips any non-alphanumeric chars first. |
59 | 173 |
- tuned for speed on String-Streams for faster scanning" |
1 | 174 |
%{ |
175 |
/* speedup, if collection is a string */ |
|
176 |
||
177 |
int pos, limit, sz; |
|
178 |
int len; |
|
13 | 179 |
char buffer[256]; |
180 |
REGISTER unsigned char *cp; |
|
181 |
REGISTER unsigned ch; |
|
252 | 182 |
OBJ coll, p, l; |
1 | 183 |
|
1133 | 184 |
coll = __INST(collection); |
185 |
p = __INST(position); |
|
186 |
l = __INST(readLimit); |
|
252 | 187 |
|
188 |
if (__isString(coll) && __bothSmallInteger(p, l)) { |
|
189 |
||
1133 | 190 |
pos = __intVal(p); |
191 |
limit = __intVal(l); |
|
329 | 192 |
sz = __qSize(coll) - OHDR_SIZE; |
202 | 193 |
if (sz < limit) |
194 |
limit = sz; |
|
1133 | 195 |
cp = __stringVal(coll) + pos - 1; |
1 | 196 |
|
202 | 197 |
for (;;) { |
198 |
if (pos > limit) break; |
|
199 |
ch = *cp; |
|
1 | 200 |
|
3112
ccf7121ddae8
nextAlphaNumericWord changed
Claus Gittinger <cg@exept.de>
parents:
2997
diff
changeset
|
201 |
if (((ch >= 'a') && (ch <= 'z')) || |
ccf7121ddae8
nextAlphaNumericWord changed
Claus Gittinger <cg@exept.de>
parents:
2997
diff
changeset
|
202 |
((ch >= 'A') && (ch <= 'Z')) || |
ccf7121ddae8
nextAlphaNumericWord changed
Claus Gittinger <cg@exept.de>
parents:
2997
diff
changeset
|
203 |
((ch >= '0') && (ch <= '9'))) |
ccf7121ddae8
nextAlphaNumericWord changed
Claus Gittinger <cg@exept.de>
parents:
2997
diff
changeset
|
204 |
break; |
202 | 205 |
cp++; |
206 |
pos++; |
|
207 |
} |
|
1 | 208 |
|
202 | 209 |
len = 0; |
210 |
for (;;) { |
|
211 |
if (pos > limit) break; |
|
212 |
ch = *cp & 0xFF; |
|
1 | 213 |
|
202 | 214 |
if (! (((ch >= 'a') && (ch <= 'z')) || |
215 |
((ch >= 'A') && (ch <= 'Z')) || |
|
216 |
((ch >= '0') && (ch <= '9')))) |
|
217 |
break; |
|
218 |
buffer[len++] = ch; |
|
219 |
if (len >= (sizeof(buffer)-1)) { |
|
220 |
/* emergency */ |
|
221 |
break; |
|
222 |
} |
|
223 |
pos++; |
|
224 |
cp++; |
|
225 |
} |
|
1 | 226 |
|
1133 | 227 |
__INST(position) = __MKSMALLINT(pos); |
202 | 228 |
buffer[len] = '\0'; |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1665
diff
changeset
|
229 |
RETURN ( (len != 0) ? __MKSTRING_L(buffer, len) : nil ); |
1 | 230 |
} |
231 |
%} |
|
232 |
. |
|
252 | 233 |
^ super nextAlphaNumericWord |
1 | 234 |
! |
235 |
||
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
236 |
nextByte |
4826
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
237 |
"return the next element; advance read pointer. |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
238 |
return nil, if there is no next element. |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
239 |
- tuned for a bit more speed on String/ByteArray/Array-Streams" |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
240 |
|
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
241 |
|ret| |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
242 |
|
4826
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
243 |
%{ /* NOCONTEXT */ |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
244 |
|
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
245 |
REGISTER int pos; |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
246 |
unsigned ch; |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
247 |
OBJ coll, p, l; |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
248 |
|
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
249 |
coll = __INST(collection); |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
250 |
p = __INST(position); |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
251 |
l = __INST(readLimit); |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
252 |
|
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
253 |
if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
254 |
|
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
255 |
pos = __intVal(p); |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
256 |
if (pos > 0 && pos <= __intVal(l)) { |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
257 |
OBJ cls; |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
258 |
|
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
259 |
cls = __qClass(coll); |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
260 |
if (cls == @global(String)) { |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
261 |
if (pos <= __stringSize(coll)) { |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
262 |
__INST(position) = __MKSMALLINT(pos + 1); |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
263 |
ch = __stringVal(coll)[pos-1]; |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
264 |
RETURN ( __MKSMALLINT(ch) ); |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
265 |
} |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
266 |
} else if (cls == @global(ByteArray)) { |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
267 |
if (pos <= __byteArraySize(coll)) { |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
268 |
__INST(position) = __MKSMALLINT(pos + 1); |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
269 |
ch = __ByteArrayInstPtr(coll)->ba_element[pos-1]; |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
270 |
RETURN ( __MKSMALLINT(ch) ); |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
271 |
} |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
272 |
} else if (cls == @global(Array)) { |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
273 |
if (pos <= __arraySize(coll)) { |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
274 |
__INST(position) = __MKSMALLINT(pos + 1); |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
275 |
RETURN ( __ArrayInstPtr(coll)->a_element[pos-1]); |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
276 |
} |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
277 |
} |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
278 |
} |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
279 |
} |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
280 |
%} |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
281 |
. |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
282 |
(position > readLimit) ifTrue:[^ self pastEnd]. |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
283 |
ret := collection at:position. |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
284 |
position := position + 1. |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
285 |
^ ret |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
286 |
! |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
287 |
|
611 | 288 |
nextDecimalInteger |
289 |
"read the next integer in radix 10. dont skip whitespace. |
|
290 |
- tuned for speed on String-Streams for faster scanning" |
|
291 |
||
292 |
|value nextOne| |
|
293 |
%{ |
|
294 |
int pos, limit, sz; |
|
295 |
REGISTER unsigned char *cp; |
|
296 |
REGISTER unsigned ch; |
|
297 |
int val = 0; |
|
298 |
OBJ coll, p, l; |
|
299 |
||
1133 | 300 |
coll = __INST(collection); |
301 |
p = __INST(position); |
|
302 |
l = __INST(readLimit); |
|
611 | 303 |
|
304 |
if (__isString(coll) && __bothSmallInteger(p, l)) { |
|
305 |
||
1133 | 306 |
pos = __intVal(p); |
307 |
limit = __intVal(l); |
|
611 | 308 |
sz = __qSize(coll) - OHDR_SIZE; |
309 |
if (sz < limit) |
|
310 |
limit = sz; |
|
1133 | 311 |
cp = __stringVal(coll) + pos - 1; |
611 | 312 |
|
313 |
for (;;) { |
|
314 |
if (pos > limit) break; |
|
315 |
ch = *cp; |
|
316 |
||
317 |
if ((ch < '0') || (ch > '9')) break; |
|
318 |
val = val * 10 + (ch - '0'); |
|
319 |
pos++; |
|
320 |
if (val > (_MAX_INT / 10)) goto oops; |
|
321 |
cp++; |
|
322 |
} |
|
1133 | 323 |
__INST(position) = __MKSMALLINT(pos); |
4271
d1878c9dc428
oops - return instead of RETURN macro
Claus Gittinger <cg@exept.de>
parents:
3316
diff
changeset
|
324 |
RETURN (__MKSMALLINT(val)); |
611 | 325 |
} |
326 |
oops: |
|
1133 | 327 |
value = __MKSMALLINT(val); |
611 | 328 |
%} |
329 |
. |
|
330 |
"fall-back for non-string streams - we have to continue where |
|
331 |
above primitive left off, in case of a large integer ... |
|
332 |
(instead of doing a super nextDecimalInteger)" |
|
333 |
||
334 |
nextOne := self peek. |
|
335 |
[nextOne notNil and:[nextOne isDigitRadix:10]] whileTrue:[ |
|
336 |
value = (value * 10) + nextOne digitValue. |
|
337 |
nextOne := self nextPeek |
|
338 |
]. |
|
339 |
^ value |
|
340 |
! |
|
341 |
||
342 |
nextPeek |
|
343 |
"advance read pointer return the peek element. |
|
344 |
this is equivalent to (self next; peek). |
|
345 |
- tuned for speed on String-Streams for faster scanning" |
|
346 |
||
347 |
%{ /* NOCONTEXT */ |
|
348 |
OBJ coll, l, p; |
|
349 |
||
1133 | 350 |
coll = __INST(collection); |
351 |
p = __INST(position); |
|
352 |
l = __INST(readLimit); |
|
611 | 353 |
|
354 |
if (__isString(coll) && __bothSmallInteger(p, l)) { |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
355 |
REGISTER int pos; |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
356 |
unsigned ch; |
611 | 357 |
|
1133 | 358 |
pos = __intVal(p); |
359 |
if ((pos > 0) && (pos < __intVal(l)) && (pos < __stringSize(coll))) { |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
360 |
pos += 1; |
1133 | 361 |
__INST(position) = __MKSMALLINT(pos); |
362 |
ch = __stringVal(coll)[pos-1]; |
|
363 |
RETURN ( __MKCHARACTER(ch) ); |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
364 |
} |
611 | 365 |
} |
366 |
%} |
|
367 |
. |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
368 |
(position > readLimit) ifTrue:[^ self pastEnd]. |
611 | 369 |
position := position + 1. |
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
370 |
(position > readLimit) ifTrue:[^ self pastEnd]. |
611 | 371 |
^ collection at:position |
372 |
! |
|
373 |
||
1 | 374 |
nextSymbol |
375 |
"read the next selector-symbol (i.e. up to non letter-or-digit). |
|
376 |
return a string containing those characters. |
|
59 | 377 |
- tuned for speed on String-Streams for faster scanning" |
1 | 378 |
%{ |
379 |
int pos, limit, sz; |
|
380 |
int len; |
|
13 | 381 |
char buffer[256]; |
382 |
REGISTER unsigned char *cp; |
|
383 |
REGISTER unsigned ch; |
|
252 | 384 |
OBJ coll, p, l; |
1 | 385 |
|
1133 | 386 |
coll = __INST(collection); |
387 |
p = __INST(position); |
|
388 |
l = __INST(readLimit); |
|
252 | 389 |
|
390 |
if (__isString(coll) && __bothSmallInteger(p, l)) { |
|
391 |
||
1133 | 392 |
pos = __intVal(p); |
393 |
limit = __intVal(l); |
|
329 | 394 |
sz = __qSize(coll) - OHDR_SIZE; |
202 | 395 |
if (sz < limit) |
396 |
limit = sz; |
|
1133 | 397 |
cp = __stringVal(coll) + pos - 1; |
1 | 398 |
|
202 | 399 |
len = 0; |
400 |
for (;;) { |
|
401 |
if (pos > limit) break; |
|
402 |
ch = *cp; |
|
1 | 403 |
|
202 | 404 |
if (! (((ch >= 'a') && (ch <= 'z')) || |
405 |
((ch >= 'A') && (ch <= 'Z')) || |
|
406 |
((ch >= '0') && (ch <= '9')) || |
|
407 |
(ch == ':'))) |
|
408 |
break; |
|
409 |
buffer[len++] = ch; |
|
410 |
if (len >= (sizeof(buffer)-1)) { |
|
411 |
/* emergency */ |
|
412 |
break; |
|
413 |
} |
|
414 |
pos++; |
|
415 |
cp++; |
|
416 |
} |
|
1 | 417 |
|
1133 | 418 |
__INST(position) = __MKSMALLINT(pos); |
202 | 419 |
buffer[len] = '\0'; |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1665
diff
changeset
|
420 |
RETURN ( (len != 0) ? __MKSTRING_L(buffer, len) : nil ); |
1 | 421 |
} |
422 |
%} |
|
423 |
. |
|
424 |
^ super nextSymbol |
|
425 |
! |
|
426 |
||
611 | 427 |
peek |
428 |
"return the next element; do NOT advance read pointer. |
|
429 |
return nil, if there is no next element. |
|
430 |
- tuned for a bit more speed on String/ByteArray/Array-Streams" |
|
1 | 431 |
|
432 |
%{ /* NOCONTEXT */ |
|
611 | 433 |
|
434 |
REGISTER int pos; |
|
435 |
unsigned ch; |
|
436 |
OBJ coll; |
|
437 |
OBJ cls, p, l; |
|
1 | 438 |
|
1133 | 439 |
coll = __INST(collection); |
440 |
p = __INST(position); |
|
441 |
l = __INST(readLimit); |
|
252 | 442 |
|
611 | 443 |
if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
1 | 444 |
|
1133 | 445 |
pos = __intVal(p); |
446 |
if (pos <= __intVal(l) && pos > 0) { |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
447 |
cls = __qClass(coll); |
1133 | 448 |
if (cls == @global(String)) { |
449 |
if (pos <= __stringSize(coll)) { |
|
450 |
ch = __stringVal(coll)[pos-1]; |
|
451 |
RETURN ( __MKCHARACTER(ch) ); |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
452 |
} |
1133 | 453 |
} else if (cls == @global(ByteArray)) { |
454 |
if (pos <= __byteArraySize(coll)) { |
|
455 |
ch = __ByteArrayInstPtr(coll)->ba_element[pos-1]; |
|
456 |
RETURN ( __MKSMALLINT(ch) ); |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
457 |
} |
1133 | 458 |
} else if (cls == @global(Array)) { |
459 |
if (pos <= __arraySize(coll)) { |
|
460 |
RETURN ( __ArrayInstPtr(coll)->a_element[pos-1]); |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
461 |
} |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
462 |
} |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
463 |
} |
1 | 464 |
} |
465 |
%} |
|
466 |
. |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
467 |
(position > readLimit) ifTrue:[^ self pastEnd]. |
611 | 468 |
^ collection at:position |
1 | 469 |
! |
470 |
||
3316 | 471 |
peekOrNil |
472 |
"return the next element; do NOT advance read pointer. |
|
473 |
return nil, if there is no next element. |
|
474 |
This is much like #peek - |
|
475 |
However, unlike #peek, this does not raise an atEnd-query signal - even |
|
476 |
if handled. Instead, nil is returned immediately." |
|
477 |
||
478 |
%{ /* NOCONTEXT */ |
|
479 |
||
480 |
REGISTER int pos; |
|
481 |
unsigned ch; |
|
482 |
OBJ coll; |
|
483 |
OBJ cls, p, l; |
|
484 |
||
485 |
coll = __INST(collection); |
|
486 |
p = __INST(position); |
|
487 |
l = __INST(readLimit); |
|
488 |
||
489 |
if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
|
490 |
||
491 |
pos = __intVal(p); |
|
492 |
if (pos <= __intVal(l) && pos > 0) { |
|
493 |
cls = __qClass(coll); |
|
494 |
if (cls == @global(String)) { |
|
495 |
if (pos <= __stringSize(coll)) { |
|
496 |
ch = __stringVal(coll)[pos-1]; |
|
497 |
RETURN ( __MKCHARACTER(ch) ); |
|
498 |
} |
|
499 |
RETURN ( nil ); |
|
500 |
} else if (cls == @global(ByteArray)) { |
|
501 |
if (pos <= __byteArraySize(coll)) { |
|
502 |
ch = __ByteArrayInstPtr(coll)->ba_element[pos-1]; |
|
503 |
RETURN ( __MKSMALLINT(ch) ); |
|
504 |
} |
|
505 |
RETURN ( nil ); |
|
506 |
} else if (cls == @global(Array)) { |
|
507 |
if (pos <= __arraySize(coll)) { |
|
508 |
RETURN ( __ArrayInstPtr(coll)->a_element[pos-1]); |
|
509 |
} |
|
510 |
RETURN ( nil ); |
|
511 |
} |
|
512 |
} |
|
513 |
} |
|
514 |
%} |
|
515 |
. |
|
516 |
(position > readLimit) ifTrue:[^ nil]. |
|
517 |
^ collection at:position |
|
518 |
! |
|
519 |
||
1 | 520 |
skipSeparators |
521 |
"skip all whitespace; next will return next non-white-space element. |
|
59 | 522 |
Return the peeked character or nil, if the end-of-stream was reached. |
2 | 523 |
- reimplemented for speed on String-Streams for faster scanning" |
1 | 524 |
|
525 |
%{ /* NOCONTEXT */ |
|
252 | 526 |
OBJ coll, p, l; |
1 | 527 |
|
1133 | 528 |
coll = __INST(collection); |
529 |
p = __INST(position); |
|
530 |
l = __INST(readLimit); |
|
252 | 531 |
|
532 |
if (__isString(coll) && __bothSmallInteger(p, l)) { |
|
1406 | 533 |
REGISTER unsigned char *chars; |
534 |
REGISTER unsigned ch; |
|
535 |
REGISTER int pos; |
|
536 |
int limit; |
|
537 |
int sz; |
|
1 | 538 |
|
1406 | 539 |
pos = __intVal(p); |
540 |
if (pos <= 0) { |
|
541 |
RETURN ( nil ); |
|
542 |
} |
|
1 | 543 |
|
1406 | 544 |
limit = __intVal(l); |
545 |
sz = __qSize(coll) - OHDR_SIZE; |
|
546 |
if (limit > sz) { |
|
547 |
limit = sz; |
|
548 |
} |
|
1 | 549 |
|
1406 | 550 |
chars = (unsigned char *)(__stringVal(coll) + pos - 1); |
551 |
while (pos <= limit) { |
|
552 |
pos++; |
|
553 |
ch = *chars++; |
|
554 |
if ((ch > 0x20) |
|
555 |
|| ((ch != ' ') |
|
556 |
&& (ch != '\t') |
|
557 |
&& (ch != '\r') |
|
558 |
&& (ch != '\n') |
|
2162
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
559 |
&& (ch != '\f') |
1406 | 560 |
&& (ch != 0x0B))) { |
561 |
__INST(position) = __MKSMALLINT(pos-1); |
|
562 |
RETURN ( __MKCHARACTER(ch) ); |
|
563 |
} |
|
564 |
} |
|
565 |
__INST(position) = __MKSMALLINT(pos); |
|
566 |
RETURN ( nil ); |
|
1 | 567 |
} |
1406 | 568 |
%}. |
1 | 569 |
^ super skipSeparators |
1406 | 570 |
|
571 |
" |
|
572 |
|s| |
|
573 |
||
574 |
s := ' hello world ' readStream. |
|
575 |
s skipSeparators. |
|
576 |
s next. |
|
577 |
" |
|
1 | 578 |
! |
579 |
||
13 | 580 |
skipSeparatorsExceptCR |
581 |
"skip all whitespace except newlines; |
|
202 | 582 |
next will return next non-white-space element. |
583 |
- reimplemented for speed on String-Streams for faster scanning" |
|
584 |
||
13 | 585 |
%{ /* NOCONTEXT */ |
586 |
||
252 | 587 |
OBJ coll, p, l; |
588 |
||
1133 | 589 |
coll = __INST(collection); |
590 |
p = __INST(position); |
|
591 |
l = __INST(readLimit); |
|
252 | 592 |
|
593 |
if (__isString(coll) && __bothSmallInteger(p, l)) { |
|
2162
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
594 |
REGISTER unsigned char *chars; |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
595 |
REGISTER unsigned ch; |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
596 |
REGISTER int pos; |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
597 |
int limit; |
13 | 598 |
|
2162
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
599 |
pos = __intVal(p); |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
600 |
if (pos <= 0) { |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
601 |
RETURN ( nil ); |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
602 |
} |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
603 |
|
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
604 |
limit = __intVal(l); |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
605 |
if (limit > (__qSize(coll) - OHDR_SIZE)) |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
606 |
limit = __qSize(coll) - OHDR_SIZE; |
13 | 607 |
|
2162
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
608 |
chars = (unsigned char *)(__stringVal(coll) + pos - 1); |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
609 |
while (pos <= limit) { |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
610 |
ch = *chars++; |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
611 |
if (((int)ch > 0x20) |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
612 |
|| ( |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
613 |
(ch != ' ') |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
614 |
&& (ch != '\t') |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
615 |
&& (ch != '\f') |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
616 |
&& (ch != '\b') |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
617 |
&& (ch != 0x0B))) { |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
618 |
__INST(position) = __MKSMALLINT(pos); |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
619 |
RETURN ( __MKCHARACTER(ch) ); |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
620 |
} |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
621 |
pos++; |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
622 |
} |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
623 |
__INST(position) = __MKSMALLINT(pos); |
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
624 |
RETURN ( nil ); |
13 | 625 |
} |
626 |
%} |
|
627 |
. |
|
628 |
^ super skipSeparatorsExceptCR |
|
629 |
! |
|
630 |
||
611 | 631 |
skipThrough:anObject |
6011
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
632 |
"skip all objects up-to and including anObject. |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
633 |
Return the receiver if skip was successful, |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
634 |
otherwise (i.e. if not found) return nil and leave the stream positioned at the end. |
611 | 635 |
On success, the next read operation will return the element after anObject. |
636 |
- reimplemented for speed on String-Streams for faster scanning" |
|
637 |
||
638 |
%{ /* NOCONTEXT */ |
|
639 |
OBJ coll, p, l; |
|
640 |
||
1133 | 641 |
coll = __INST(collection); |
642 |
p = __INST(position); |
|
643 |
l = __INST(readLimit); |
|
611 | 644 |
|
645 |
if (__isString(coll) |
|
646 |
&& __isCharacter(anObject) |
|
647 |
&& __bothSmallInteger(p, l)) { |
|
6011
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
648 |
REGISTER unsigned char *chars; |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
649 |
REGISTER int pos, limit; |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
650 |
unsigned ch; |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
651 |
int sz; |
611 | 652 |
|
6011
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
653 |
pos = __intVal(p); |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
654 |
if (pos <= 0) { |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
655 |
RETURN ( nil ); |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
656 |
} |
611 | 657 |
|
6011
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
658 |
limit = __intVal(l); |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
659 |
sz = __stringSize(coll); |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
660 |
if (limit > sz) limit = sz; |
611 | 661 |
|
6011
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
662 |
chars = (unsigned char *)(__stringVal(coll) + pos - 1); |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
663 |
ch = __intVal(_characterVal(anObject)) & 0xFF; |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
664 |
while (pos < limit) { |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
665 |
if (*chars == ch) { |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
666 |
ch = *++chars; |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
667 |
pos++; |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
668 |
__INST(position) = __MKSMALLINT(pos); |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
669 |
RETURN ( self ); |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
670 |
} |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
671 |
chars++; |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
672 |
pos++; |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
673 |
} |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
674 |
__INST(position) = __MKSMALLINT(pos+1); |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
675 |
RETURN ( nil ); |
611 | 676 |
} |
6011
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
677 |
%}. |
611 | 678 |
^ super skipThrough:anObject |
1 | 679 |
! ! |
680 |
||
59 | 681 |
!ReadStream methodsFor:'writing'! |
1 | 682 |
|
683 |
nextPut:anElement |
|
10 | 684 |
"catch write access to readstreams - report an error" |
685 |
||
686 |
self shouldNotImplement |
|
1 | 687 |
! ! |
611 | 688 |
|
2162
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
689 |
!ReadStream class methodsFor:'documentation'! |
701 | 690 |
|
691 |
version |
|
6315 | 692 |
^ '$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.44 2001-12-13 19:05:04 stefan Exp $' |
701 | 693 |
! ! |