author | Claus Gittinger <cg@exept.de> |
Fri, 10 Nov 1995 17:46:49 +0100 | |
changeset 521 | 70533ec40482 |
parent 384 | cc3d110ea879 |
child 530 | 07d0bce293c9 |
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 |
||
13 |
PositionableStream subclass:#ReadStream |
|
14 |
instanceVariableNames:'' |
|
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Streams' |
|
18 |
! |
|
19 |
||
20 |
ReadStream comment:' |
|
88 | 21 |
COPYRIGHT (c) 1988 by Claus Gittinger |
202 | 22 |
All Rights Reserved |
93 | 23 |
|
521
70533ec40482
use new MKSTRING_L if length is known (avoids a useless strlen)
Claus Gittinger <cg@exept.de>
parents:
384
diff
changeset
|
24 |
$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.17 1995-11-10 16:46:39 cg Exp $ |
88 | 25 |
'! |
1 | 26 |
|
88 | 27 |
!ReadStream class methodsFor:'documentation'! |
28 |
||
29 |
copyright |
|
30 |
" |
|
31 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
202 | 32 |
All Rights Reserved |
1 | 33 |
|
88 | 34 |
This software is furnished under a license and may be used |
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
! |
|
1 | 42 |
|
88 | 43 |
version |
44 |
" |
|
521
70533ec40482
use new MKSTRING_L if length is known (avoids a useless strlen)
Claus Gittinger <cg@exept.de>
parents:
384
diff
changeset
|
45 |
$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.17 1995-11-10 16:46:39 cg Exp $ |
88 | 46 |
" |
47 |
! |
|
48 |
||
49 |
documentation |
|
50 |
" |
|
51 |
ReadStream defines protocol for reading streamwise over collections. |
|
52 |
" |
|
53 |
! ! |
|
1 | 54 |
|
202 | 55 |
!ReadStream methodsFor:'converting'! |
56 |
||
57 |
readStream |
|
58 |
"return a readStream from the receiver. Since this is already |
|
59 |
a readStream, return self." |
|
60 |
||
61 |
^ self |
|
62 |
! ! |
|
63 |
||
345 | 64 |
!ReadStream methodsFor:'queries'! |
65 |
||
66 |
isReadable |
|
67 |
^ true |
|
68 |
! ! |
|
69 |
||
59 | 70 |
!ReadStream methodsFor:'reading'! |
1 | 71 |
|
72 |
peek |
|
73 |
"return the next element; do NOT advance read pointer. |
|
2 | 74 |
return nil, if there is no next element. |
345 | 75 |
- tuned for a bit more speed on String/ByteArray/Array-Streams" |
1 | 76 |
|
77 |
%{ /* NOCONTEXT */ |
|
78 |
||
79 |
REGISTER int pos; |
|
80 |
unsigned ch; |
|
2 | 81 |
OBJ coll; |
252 | 82 |
OBJ cls, p, l; |
2 | 83 |
extern OBJ ByteArray; |
1 | 84 |
|
2 | 85 |
coll = _INST(collection); |
252 | 86 |
p = _INST(position); |
87 |
l = _INST(readLimit); |
|
1 | 88 |
|
252 | 89 |
if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
90 |
||
91 |
pos = _intVal(p); |
|
92 |
if (pos > _intVal(l)) { |
|
202 | 93 |
RETURN ( nil ); |
94 |
} |
|
59 | 95 |
|
202 | 96 |
if (pos > 0) { |
329 | 97 |
cls = __qClass(coll); |
202 | 98 |
if (cls == String) { |
99 |
if (pos <= _stringSize(coll)) { |
|
100 |
ch = _stringVal(coll)[pos-1]; |
|
101 |
RETURN ( _MKCHARACTER(ch) ); |
|
102 |
} |
|
103 |
} else if (cls == ByteArray) { |
|
104 |
if (pos <= _byteArraySize(coll)) { |
|
105 |
ch = _ByteArrayInstPtr(coll)->ba_element[pos-1]; |
|
106 |
RETURN ( _MKSMALLINT(ch) ); |
|
107 |
} |
|
108 |
} else if (cls == Array) { |
|
109 |
if (pos <= _arraySize(coll)) { |
|
110 |
RETURN ( _ArrayInstPtr(coll)->a_element[pos-1]); |
|
111 |
} |
|
112 |
} |
|
113 |
} |
|
1 | 114 |
} |
115 |
%} |
|
116 |
. |
|
117 |
(position > readLimit) ifTrue:[^ nil]. |
|
118 |
^ collection at:position |
|
119 |
! |
|
120 |
||
121 |
next |
|
122 |
"return the next element; advance read pointer. |
|
2 | 123 |
return nil, if there is no next element. |
345 | 124 |
- tuned for a bit more speed on String/ByteArray/Array-Streams" |
1 | 125 |
|
126 |
|ret| |
|
127 |
||
128 |
%{ /* NOCONTEXT */ |
|
129 |
||
130 |
REGISTER int pos; |
|
131 |
unsigned ch; |
|
252 | 132 |
OBJ coll, p, l; |
1 | 133 |
|
2 | 134 |
coll = _INST(collection); |
252 | 135 |
p = _INST(position); |
136 |
l = _INST(readLimit); |
|
1 | 137 |
|
252 | 138 |
if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
139 |
||
140 |
pos = _intVal(p); |
|
141 |
if (pos > _intVal(l)) { |
|
202 | 142 |
RETURN ( nil ); |
143 |
} |
|
144 |
if (pos > 0) { |
|
145 |
OBJ cls; |
|
59 | 146 |
|
329 | 147 |
cls = __qClass(coll); |
202 | 148 |
if (cls == String) { |
149 |
if (pos <= _stringSize(coll)) { |
|
150 |
_INST(position) = _MKSMALLINT(pos + 1); |
|
151 |
ch = _stringVal(coll)[pos-1]; |
|
152 |
RETURN ( _MKCHARACTER(ch) ); |
|
153 |
} |
|
154 |
} else if (cls == ByteArray) { |
|
155 |
if (pos <= _byteArraySize(coll)) { |
|
156 |
_INST(position) = _MKSMALLINT(pos + 1); |
|
157 |
ch = _ByteArrayInstPtr(coll)->ba_element[pos-1]; |
|
158 |
RETURN ( _MKSMALLINT(ch) ); |
|
159 |
} |
|
160 |
} else if (cls == Array) { |
|
161 |
if (pos <= _arraySize(coll)) { |
|
162 |
_INST(position) = _MKSMALLINT(pos + 1); |
|
163 |
RETURN ( _ArrayInstPtr(coll)->a_element[pos-1]); |
|
164 |
} |
|
165 |
} |
|
166 |
} |
|
1 | 167 |
} |
168 |
%} |
|
169 |
. |
|
170 |
(position > readLimit) ifTrue:[^ nil]. |
|
171 |
ret := collection at:position. |
|
172 |
position := position + 1. |
|
173 |
^ ret |
|
174 |
! |
|
175 |
||
176 |
nextPeek |
|
177 |
"advance read pointer return the peek element. |
|
178 |
this is equivalent to (self next; peek). |
|
59 | 179 |
- tuned for speed on String-Streams for faster scanning" |
1 | 180 |
|
181 |
%{ /* NOCONTEXT */ |
|
252 | 182 |
OBJ coll, l, p; |
1 | 183 |
|
59 | 184 |
coll = _INST(collection); |
252 | 185 |
p = _INST(position); |
186 |
l = _INST(readLimit); |
|
187 |
||
188 |
if (__isString(coll) && __bothSmallInteger(p, l)) { |
|
202 | 189 |
REGISTER int pos; |
190 |
unsigned ch; |
|
1 | 191 |
|
252 | 192 |
pos = _intVal(p); |
193 |
if (pos > _intVal(l)) { |
|
202 | 194 |
RETURN ( nil ); |
195 |
} |
|
196 |
if ((pos > 0) && (pos <= _stringSize(coll))) { |
|
197 |
_INST(position) = _MKSMALLINT(pos + 1); |
|
198 |
pos = pos + 1; |
|
199 |
if (pos <= _stringSize(coll)) { |
|
200 |
ch = _stringVal(coll)[pos-1]; |
|
201 |
RETURN ( _MKCHARACTER(ch) ); |
|
202 |
} |
|
203 |
RETURN ( nil ); |
|
204 |
} |
|
1 | 205 |
} |
206 |
%} |
|
207 |
. |
|
208 |
(position > readLimit) ifTrue:[^ nil]. |
|
209 |
position := position + 1. |
|
210 |
(position > readLimit) ifTrue:[^ nil]. |
|
211 |
^ collection at:position |
|
212 |
! |
|
213 |
||
214 |
nextDecimalInteger |
|
215 |
"read the next integer in radix 10. dont skip whitespace. |
|
59 | 216 |
- tuned for speed on String-Streams for faster scanning" |
1 | 217 |
|
59 | 218 |
|value nextOne| |
1 | 219 |
%{ |
220 |
int pos, limit, sz; |
|
13 | 221 |
REGISTER unsigned char *cp; |
222 |
REGISTER unsigned ch; |
|
1 | 223 |
int val = 0; |
252 | 224 |
OBJ coll, p, l; |
1 | 225 |
|
252 | 226 |
coll = _INST(collection); |
227 |
p = _INST(position); |
|
228 |
l = _INST(readLimit); |
|
229 |
||
230 |
if (__isString(coll) && __bothSmallInteger(p, l)) { |
|
231 |
||
232 |
pos = _intVal(p); |
|
233 |
limit = _intVal(l); |
|
329 | 234 |
sz = __qSize(coll) - OHDR_SIZE; |
202 | 235 |
if (sz < limit) |
236 |
limit = sz; |
|
252 | 237 |
cp = _stringVal(coll) + pos - 1; |
1 | 238 |
|
202 | 239 |
for (;;) { |
240 |
if (pos > limit) break; |
|
241 |
ch = *cp; |
|
1 | 242 |
|
202 | 243 |
if ((ch < '0') || (ch > '9')) break; |
244 |
val = val * 10 + (ch - '0'); |
|
245 |
pos++; |
|
246 |
if (val > (_MAX_INT / 10)) goto oops; |
|
247 |
cp++; |
|
248 |
} |
|
249 |
_INST(position) = _MKSMALLINT(pos); |
|
250 |
return _MKSMALLINT(val); |
|
1 | 251 |
} |
252 |
oops: |
|
253 |
value = _MKSMALLINT(val); |
|
254 |
%} |
|
255 |
. |
|
59 | 256 |
"fall-back for non-string streams - we have to continue where |
257 |
above primitive left off, in case of a large integer ... |
|
258 |
(instead of doing a super nextDecimalInteger)" |
|
13 | 259 |
|
59 | 260 |
nextOne := self peek. |
261 |
[nextOne notNil and:[nextOne isDigitRadix:10]] whileTrue:[ |
|
202 | 262 |
value = (value * 10) + nextOne digitValue. |
263 |
nextOne := self nextPeek |
|
1 | 264 |
]. |
265 |
^ value |
|
266 |
! |
|
267 |
||
252 | 268 |
nextAlphaNumericWord |
1 | 269 |
"read the next word (i.e. up to non letter-or-digit). |
270 |
return a string containing those characters. |
|
59 | 271 |
- tuned for speed on String-Streams for faster scanning" |
1 | 272 |
%{ |
273 |
/* speedup, if collection is a string */ |
|
274 |
||
275 |
int pos, limit, sz; |
|
276 |
int len; |
|
13 | 277 |
char buffer[256]; |
278 |
REGISTER unsigned char *cp; |
|
279 |
REGISTER unsigned ch; |
|
252 | 280 |
OBJ coll, p, l; |
521
70533ec40482
use new MKSTRING_L if length is known (avoids a useless strlen)
Claus Gittinger <cg@exept.de>
parents:
384
diff
changeset
|
281 |
OBJ __MKSTRING_L(); |
1 | 282 |
|
252 | 283 |
coll = _INST(collection); |
284 |
p = _INST(position); |
|
285 |
l = _INST(readLimit); |
|
286 |
||
287 |
if (__isString(coll) && __bothSmallInteger(p, l)) { |
|
288 |
||
289 |
pos = _intVal(p); |
|
290 |
limit = _intVal(l); |
|
329 | 291 |
sz = __qSize(coll) - OHDR_SIZE; |
202 | 292 |
if (sz < limit) |
293 |
limit = sz; |
|
252 | 294 |
cp = _stringVal(coll) + pos - 1; |
1 | 295 |
|
202 | 296 |
for (;;) { |
297 |
if (pos > limit) break; |
|
298 |
ch = *cp; |
|
1 | 299 |
|
202 | 300 |
if (ch > ' ') break; |
301 |
if ((ch != ' ') && (ch != '\t') && (ch != '\r') |
|
302 |
&& (ch != '\n') && (ch != 0x0b)) break; |
|
303 |
cp++; |
|
304 |
pos++; |
|
305 |
} |
|
1 | 306 |
|
202 | 307 |
len = 0; |
308 |
for (;;) { |
|
309 |
if (pos > limit) break; |
|
310 |
ch = *cp & 0xFF; |
|
1 | 311 |
|
202 | 312 |
if (! (((ch >= 'a') && (ch <= 'z')) || |
313 |
((ch >= 'A') && (ch <= 'Z')) || |
|
314 |
((ch >= '0') && (ch <= '9')))) |
|
315 |
break; |
|
316 |
buffer[len++] = ch; |
|
317 |
if (len >= (sizeof(buffer)-1)) { |
|
318 |
/* emergency */ |
|
319 |
break; |
|
320 |
} |
|
321 |
pos++; |
|
322 |
cp++; |
|
323 |
} |
|
1 | 324 |
|
202 | 325 |
_INST(position) = _MKSMALLINT(pos); |
326 |
buffer[len] = '\0'; |
|
521
70533ec40482
use new MKSTRING_L if length is known (avoids a useless strlen)
Claus Gittinger <cg@exept.de>
parents:
384
diff
changeset
|
327 |
RETURN ( (len != 0) ? __MKSTRING_L(buffer, len COMMA_CON) : nil ); |
1 | 328 |
} |
329 |
%} |
|
330 |
. |
|
252 | 331 |
^ super nextAlphaNumericWord |
1 | 332 |
! |
333 |
||
334 |
nextSymbol |
|
335 |
"read the next selector-symbol (i.e. up to non letter-or-digit). |
|
336 |
return a string containing those characters. |
|
59 | 337 |
- tuned for speed on String-Streams for faster scanning" |
1 | 338 |
%{ |
339 |
int pos, limit, sz; |
|
340 |
int len; |
|
13 | 341 |
char buffer[256]; |
342 |
REGISTER unsigned char *cp; |
|
343 |
REGISTER unsigned ch; |
|
252 | 344 |
OBJ coll, p, l; |
521
70533ec40482
use new MKSTRING_L if length is known (avoids a useless strlen)
Claus Gittinger <cg@exept.de>
parents:
384
diff
changeset
|
345 |
OBJ __MKSTRING_L(); |
1 | 346 |
|
252 | 347 |
coll = _INST(collection); |
348 |
p = _INST(position); |
|
349 |
l = _INST(readLimit); |
|
350 |
||
351 |
if (__isString(coll) && __bothSmallInteger(p, l)) { |
|
352 |
||
353 |
pos = _intVal(p); |
|
354 |
limit = _intVal(l); |
|
329 | 355 |
sz = __qSize(coll) - OHDR_SIZE; |
202 | 356 |
if (sz < limit) |
357 |
limit = sz; |
|
252 | 358 |
cp = _stringVal(coll) + pos - 1; |
1 | 359 |
|
202 | 360 |
len = 0; |
361 |
for (;;) { |
|
362 |
if (pos > limit) break; |
|
363 |
ch = *cp; |
|
1 | 364 |
|
202 | 365 |
if (! (((ch >= 'a') && (ch <= 'z')) || |
366 |
((ch >= 'A') && (ch <= 'Z')) || |
|
367 |
((ch >= '0') && (ch <= '9')) || |
|
368 |
(ch == ':'))) |
|
369 |
break; |
|
370 |
buffer[len++] = ch; |
|
371 |
if (len >= (sizeof(buffer)-1)) { |
|
372 |
/* emergency */ |
|
373 |
break; |
|
374 |
} |
|
375 |
pos++; |
|
376 |
cp++; |
|
377 |
} |
|
1 | 378 |
|
202 | 379 |
_INST(position) = _MKSMALLINT(pos); |
380 |
buffer[len] = '\0'; |
|
521
70533ec40482
use new MKSTRING_L if length is known (avoids a useless strlen)
Claus Gittinger <cg@exept.de>
parents:
384
diff
changeset
|
381 |
RETURN ( (len != 0) ? __MKSTRING_L(buffer, len COMMA_CON) : nil ); |
1 | 382 |
} |
383 |
%} |
|
384 |
. |
|
385 |
^ super nextSymbol |
|
386 |
! |
|
387 |
||
59 | 388 |
skipThrough:anObject |
2 | 389 |
"skip all objects up-to and including anObject, return anObject on success, |
59 | 390 |
nil if end-of-stream is reached before. |
391 |
On success, the next read operation will return the element after anObject. |
|
2 | 392 |
- reimplemented for speed on String-Streams for faster scanning" |
1 | 393 |
|
394 |
%{ /* NOCONTEXT */ |
|
252 | 395 |
OBJ coll, p, l; |
1 | 396 |
|
59 | 397 |
coll = _INST(collection); |
252 | 398 |
p = _INST(position); |
399 |
l = _INST(readLimit); |
|
400 |
||
59 | 401 |
if (__isString(coll) |
402 |
&& __isCharacter(anObject) |
|
252 | 403 |
&& __bothSmallInteger(p, l)) { |
202 | 404 |
REGISTER unsigned char *chars; |
405 |
REGISTER int pos, limit; |
|
406 |
unsigned ch; |
|
407 |
int sz; |
|
1 | 408 |
|
252 | 409 |
pos = _intVal(p); |
202 | 410 |
if (pos <= 0) { |
411 |
RETURN ( nil ); |
|
412 |
} |
|
1 | 413 |
|
252 | 414 |
limit = _intVal(l); |
202 | 415 |
sz = _stringSize(coll); |
416 |
if (limit > sz) limit = sz; |
|
1 | 417 |
|
202 | 418 |
chars = (unsigned char *)(_stringVal(coll) + pos - 1); |
419 |
ch = _intVal(_characterVal(anObject)) & 0xFF; |
|
420 |
while (pos < limit) { |
|
421 |
if (*chars == ch) { |
|
422 |
ch = *++chars; |
|
423 |
pos++; |
|
424 |
_INST(position) = _MKSMALLINT(pos); |
|
425 |
RETURN ( anObject ); |
|
426 |
} |
|
427 |
chars++; |
|
428 |
pos++; |
|
429 |
} |
|
430 |
RETURN ( nil ); |
|
1 | 431 |
} |
432 |
%} |
|
433 |
. |
|
59 | 434 |
^ super skipThrough:anObject |
1 | 435 |
! |
436 |
||
437 |
skipSeparators |
|
438 |
"skip all whitespace; next will return next non-white-space element. |
|
59 | 439 |
Return the peeked character or nil, if the end-of-stream was reached. |
2 | 440 |
- reimplemented for speed on String-Streams for faster scanning" |
1 | 441 |
|
442 |
%{ /* NOCONTEXT */ |
|
252 | 443 |
OBJ coll, p, l; |
1 | 444 |
|
252 | 445 |
coll = _INST(collection); |
446 |
p = _INST(position); |
|
447 |
l = _INST(readLimit); |
|
448 |
||
449 |
if (__isString(coll) && __bothSmallInteger(p, l)) { |
|
202 | 450 |
REGISTER unsigned char *chars; |
451 |
REGISTER unsigned ch; |
|
452 |
REGISTER int pos; |
|
453 |
int limit; |
|
1 | 454 |
|
252 | 455 |
pos = _intVal(p); |
202 | 456 |
if (pos <= 0) { |
457 |
RETURN ( nil ); |
|
458 |
} |
|
1 | 459 |
|
252 | 460 |
limit = _intVal(l); |
329 | 461 |
if (limit > (__qSize(coll) - OHDR_SIZE)) |
462 |
limit = __qSize(coll) - OHDR_SIZE; |
|
1 | 463 |
|
252 | 464 |
chars = (unsigned char *)(_stringVal(coll) + pos - 1); |
202 | 465 |
while (pos <= limit) { |
466 |
ch = *chars++; |
|
467 |
if ((ch != ' ') && (ch != '\t') && (ch != '\r') |
|
468 |
&& (ch != '\n') && (ch != 0x0B)) { |
|
469 |
_INST(position) = _MKSMALLINT(pos); |
|
470 |
RETURN ( _MKCHARACTER(ch) ); |
|
471 |
} |
|
472 |
pos++; |
|
473 |
} |
|
474 |
_INST(position) = _MKSMALLINT(pos); |
|
475 |
RETURN ( nil ); |
|
1 | 476 |
} |
477 |
%} |
|
478 |
. |
|
479 |
^ super skipSeparators |
|
480 |
! |
|
481 |
||
13 | 482 |
skipSeparatorsExceptCR |
483 |
"skip all whitespace except newlines; |
|
202 | 484 |
next will return next non-white-space element. |
485 |
- reimplemented for speed on String-Streams for faster scanning" |
|
486 |
||
13 | 487 |
%{ /* NOCONTEXT */ |
488 |
||
252 | 489 |
OBJ coll, p, l; |
490 |
||
491 |
coll = _INST(collection); |
|
492 |
p = _INST(position); |
|
493 |
l = _INST(readLimit); |
|
494 |
||
495 |
if (__isString(coll) && __bothSmallInteger(p, l)) { |
|
202 | 496 |
REGISTER unsigned char *chars; |
497 |
REGISTER unsigned ch; |
|
498 |
REGISTER int pos; |
|
499 |
int limit; |
|
13 | 500 |
|
252 | 501 |
pos = _intVal(p); |
202 | 502 |
if (pos <= 0) { |
503 |
RETURN ( nil ); |
|
504 |
} |
|
13 | 505 |
|
252 | 506 |
limit = _intVal(l); |
329 | 507 |
if (limit > (__qSize(coll) - OHDR_SIZE)) |
508 |
limit = __qSize(coll) - OHDR_SIZE; |
|
13 | 509 |
|
252 | 510 |
chars = (unsigned char *)(_stringVal(coll) + pos - 1); |
202 | 511 |
while (pos <= limit) { |
512 |
ch = *chars++; |
|
513 |
if ((ch != ' ') && (ch != '\t') && (ch != '\r') && (ch != 0x0B)) { |
|
514 |
_INST(position) = _MKSMALLINT(pos); |
|
515 |
RETURN ( _MKCHARACTER(ch) ); |
|
516 |
} |
|
517 |
pos++; |
|
518 |
} |
|
519 |
_INST(position) = _MKSMALLINT(pos); |
|
520 |
RETURN ( nil ); |
|
13 | 521 |
} |
522 |
%} |
|
523 |
. |
|
524 |
^ super skipSeparatorsExceptCR |
|
525 |
! |
|
526 |
||
1 | 527 |
skipToAll:aCollection |
528 |
"skip for the sequence given by the argument, aCollection; |
|
529 |
return nil if not found, self otherwise. On a successful match, next read |
|
530 |
will return elements of aCollection." |
|
531 |
||
532 |
|oldPos buffer l first idx| |
|
533 |
||
534 |
oldPos := self position. |
|
535 |
l := aCollection size. |
|
536 |
first := aCollection at:1. |
|
537 |
[self atEnd] whileFalse:[ |
|
202 | 538 |
buffer := self next:l. |
539 |
buffer = aCollection ifTrue:[ |
|
540 |
self position:(self position - l). |
|
541 |
^ self |
|
542 |
]. |
|
543 |
idx := buffer indexOf:first startingAt:2. |
|
544 |
idx == 0 ifFalse:[ |
|
545 |
self position:(self position - l + idx - 1) |
|
546 |
] |
|
1 | 547 |
]. |
548 |
self position:oldPos. |
|
549 |
^ nil |
|
550 |
||
59 | 551 |
" |
552 |
|s| |
|
1 | 553 |
s := ReadStream on:'12345678901234567890'. |
554 |
s skipToAll:'901'. |
|
59 | 555 |
s next:4 |
556 |
" |
|
1 | 557 |
! ! |
558 |
||
59 | 559 |
!ReadStream methodsFor:'writing'! |
1 | 560 |
|
561 |
nextPut:anElement |
|
10 | 562 |
"catch write access to readstreams - report an error" |
563 |
||
564 |
self shouldNotImplement |
|
1 | 565 |
! ! |