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