--- a/String.st Sat Feb 05 13:24:58 1994 +0100
+++ b/String.st Sat Feb 05 13:27:58 1994 +0100
@@ -22,7 +22,7 @@
COPYRIGHT (c) 1988 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libbasic/String.st,v 1.9 1994-01-12 19:11:34 claus Exp $
+$Header: /cvs/stx/stx/libbasic/String.st,v 1.10 1994-02-05 12:27:25 claus Exp $
'!
%{
@@ -373,15 +373,22 @@
storeString
"return a String for storing myself"
- |s|
+ |s n index|
- (self includes:$') ifTrue:[
- s := ''''.
+ n := self occurrencesOf:$'.
+ n == 0 ifFalse:[
+ s := String new:(n + 2 + self size).
+ s at:1 put:''''.
+ index := 2.
self do:[:thisChar |
- (thisChar == $') ifTrue:[s := s , ''''].
- s := s copyWith:thisChar
+ (thisChar == $') ifTrue:[
+ s at:index put:thisChar.
+ index := index + 1.
+ ].
+ s at:index put:thisChar.
+ index := index + 1.
].
- s := s , ''''.
+ s at:index put:''''.
^ s
].
^ '''' asString , self , '''' asString
@@ -1624,8 +1631,10 @@
RETURN (newString );
}
}
-%}
-.
+%}.
+ "fall back in case of non-character arg;
+ will eventually lead to an bad element signal raise"
+
^ super copyWith:aCharacter
!
@@ -1679,8 +1688,10 @@
}
}
}
-%}
-.
+%}.
+ "fall back in case of non-integer index or out-of-bound index;
+ will eventually lead to an out-of-bound signal raise"
+
^ super copyFrom:start to:stop
!
@@ -1730,8 +1741,10 @@
}
}
}
-%}
-.
+%}.
+ "fall back in case of non-integer index or out-of-bound index;
+ will eventually lead to an out-of-bound signal raise"
+
^ super copyFrom:start
! !
@@ -1915,21 +1928,39 @@
|startIndex "{ Class: SmallInteger }"
endIndex "{ Class: SmallInteger }"
- blank|
+ sz blank|
+
+%{
+ REGISTER unsigned char *cp0;
+ REGISTER unsigned char *cp;
- startIndex := 1.
- endIndex := self size.
- blank := Character space.
- [(startIndex < endIndex) and:[(self at:startIndex) == blank]] whileTrue:[
- startIndex := startIndex + 1
- ].
- [(endIndex > 1) and:[(self at:endIndex) == blank]] whileTrue:[
- endIndex := endIndex - 1
+ /* ignore instances of subclasses ... */
+ if (_qClass(self) == String) {
+ cp = cp0 = _stringVal(self);
+ while (*cp == ' ') cp++;
+ startIndex = _MKSMALLINT(cp - cp0 + 1);
+ cp = cp + strlen(cp) - 1;
+ while ((cp >= cp0) && (*cp == ' ')) cp--;
+ endIndex = _MKSMALLINT(cp - cp0 + 1);
+ }
+%}
+.
+ sz := self size.
+ startIndex isNil ifTrue:[
+ startIndex := 1.
+ endIndex := sz.
+ blank := Character space.
+ [(startIndex < endIndex) and:[(self at:startIndex) == blank]] whileTrue:[
+ startIndex := startIndex + 1
+ ].
+ [(endIndex > 1) and:[(self at:endIndex) == blank]] whileTrue:[
+ endIndex := endIndex - 1
+ ]
].
startIndex > endIndex ifTrue:[
^ ''
].
- ((startIndex == 1) and:[endIndex == self size]) ifTrue:[
+ ((startIndex == 1) and:[endIndex == sz]) ifTrue:[
^ self
].
^ self copyFrom:startIndex to:endIndex
@@ -1939,20 +1970,52 @@
"return a copy of myself without leading and trailing whitespace"
|startIndex "{ Class: SmallInteger }"
- endIndex "{ Class: SmallInteger }" |
+ endIndex "{ Class: SmallInteger }"
+ sz|
+
+%{
+ REGISTER unsigned char *cp0;
+ REGISTER unsigned char *cp;
+ REGISTER unsigned char c;
- startIndex := 1.
- endIndex := self size.
- [(startIndex < endIndex) and:[(self at:startIndex) isSeparator]] whileTrue:[
- startIndex := startIndex + 1
- ].
- [(endIndex > 1) and:[(self at:endIndex) isSeparator]] whileTrue:[
- endIndex := endIndex - 1
+ /* ignore instances of subclasses ... */
+ if (_qClass(self) == String) {
+ cp = cp0 = _stringVal(self);
+ c = *cp;
+ while ((c == ' ') || (c == '\n') || (c == '\t')
+ || (c == '\r') || (c == '\f')) {
+ cp++;
+ c = *cp;
+ }
+ startIndex = _MKSMALLINT(cp - cp0 + 1);
+ cp = cp + strlen(cp) - 1;
+ while ((cp >= cp0) && (*cp == ' ')) cp--;
+ c = *cp;
+ while ((cp >= cp0) &&
+ ((c == ' ') || (c == '\n') || (c == '\t')
+ || (c == '\r') || (c == '\f'))) {
+ cp--;
+ c = *cp;
+ }
+ endIndex = _MKSMALLINT(cp - cp0 + 1);
+ }
+%}
+.
+ sz := self size.
+ startIndex isNil ifTrue:[
+ startIndex := 1.
+ endIndex := self size.
+ [(startIndex < endIndex) and:[(self at:startIndex) isSeparator]] whileTrue:[
+ startIndex := startIndex + 1
+ ].
+ [(endIndex > 1) and:[(self at:endIndex) isSeparator]] whileTrue:[
+ endIndex := endIndex - 1
+ ].
].
startIndex > endIndex ifTrue:[
^ ''
].
- ((startIndex == 1) and:[endIndex == self size]) ifTrue:[
+ ((startIndex == 1) and:[endIndex == sz]) ifTrue:[
^ self
].
^ self copyFrom:startIndex to:endIndex
--- a/UndefObj.st Sat Feb 05 13:24:58 1994 +0100
+++ b/UndefObj.st Sat Feb 05 13:27:58 1994 +0100
@@ -24,7 +24,7 @@
there is only one instance of this class: nil
-$Header: /cvs/stx/stx/libbasic/Attic/UndefObj.st,v 1.6 1994-01-09 21:25:58 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Attic/UndefObj.st,v 1.7 1994-02-05 12:27:47 claus Exp $
'!
!UndefinedObject class methodsFor:'instance creation'!
@@ -41,6 +41,15 @@
^ nil
! !
+!UndefinedObject class methodsFor:'queries'!
+
+canBeSubclassed
+ "return true, if its allowed to create subclasses of the receiver.
+ Return nil here - since it is NOT possible for UndefinedObject"
+
+ ^ false
+! !
+
!UndefinedObject methodsFor:'error catching'!
basicAt:index
--- a/UndefinedObject.st Sat Feb 05 13:24:58 1994 +0100
+++ b/UndefinedObject.st Sat Feb 05 13:27:58 1994 +0100
@@ -24,7 +24,7 @@
there is only one instance of this class: nil
-$Header: /cvs/stx/stx/libbasic/UndefinedObject.st,v 1.6 1994-01-09 21:25:58 claus Exp $
+$Header: /cvs/stx/stx/libbasic/UndefinedObject.st,v 1.7 1994-02-05 12:27:47 claus Exp $
'!
!UndefinedObject class methodsFor:'instance creation'!
@@ -41,6 +41,15 @@
^ nil
! !
+!UndefinedObject class methodsFor:'queries'!
+
+canBeSubclassed
+ "return true, if its allowed to create subclasses of the receiver.
+ Return nil here - since it is NOT possible for UndefinedObject"
+
+ ^ false
+! !
+
!UndefinedObject methodsFor:'error catching'!
basicAt:index
--- a/Unix.st Sat Feb 05 13:24:58 1994 +0100
+++ b/Unix.st Sat Feb 05 13:27:58 1994 +0100
@@ -22,7 +22,7 @@
COPYRIGHT (c) 1988 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libbasic/Attic/Unix.st,v 1.10 1994-01-12 19:11:58 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Attic/Unix.st,v 1.11 1994-02-05 12:27:58 claus Exp $
written 1988 by claus
'!
@@ -1190,14 +1190,14 @@
|rcount wcount ecount|
- (readFdArray isNil or:[readFdArray class == Array]) ifFalse:[
- ^ self error:'argument must be an Array'
+ (readFdArray notNil and:[readFdArray class ~~ Array]) ifTrue:[
+ ^ self error:'argument must be nil or an Array'
].
- (writeFdArray isNil or:[writeFdArray class == Array]) ifFalse:[
- ^ self error:'argument must be an Array'
+ (writeFdArray notNil and:[writeFdArray class ~~ Array]) ifTrue:[
+ ^ self error:'argument must be nil or an Array'
].
- (errorFdArray isNil or:[errorFdArray class == Array]) ifFalse:[
- ^ self error:'argument must be an Array'
+ (errorFdArray notNil and:[errorFdArray class ~~ Array]) ifTrue:[
+ ^ self error:'argument must be nil or an Array'
].
rcount := readFdArray size.
wcount := writeFdArray size.
@@ -1213,7 +1213,7 @@
FD_ZERO(&wset);
FD_ZERO(&eset);
- maxF = 0;
+ maxF = -1;
for (i=0; i<_intVal(rcount);i++) {
fd = _ArrayInstPtr(readFdArray)->a_element[i];
if (fd != nil) {
@@ -1247,6 +1247,7 @@
t = _intVal(millis);
wt.tv_sec = t / 1000;
wt.tv_usec = (t % 1000) * 1000;
+
if (select(maxF+1, &rset, &wset, &eset, &wt)) {
for (i=0; i <= maxF; i++) {
if (FD_ISSET(i, &rset)