--- a/AbstractOperatingSystem.st Fri Jun 23 10:18:11 2000 +0200
+++ b/AbstractOperatingSystem.st Fri Jun 23 10:21:17 2000 +0200
@@ -10,6 +10,8 @@
hereby transferred.
"
+"{ Package: 'stx:libbasic' }"
+
Object subclass:#AbstractOperatingSystem
instanceVariableNames:''
classVariableNames:'ConcreteClass LastErrorNumber LocaleInfo OSSignals PipeFailed
@@ -2848,7 +2850,7 @@
getEnvironment:aStringOrSymbol
"get an environment string"
- self subclassResponsibility
+ ^ self subclassResponsibility
!
getHostName
@@ -4181,6 +4183,6 @@
!AbstractOperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.38 2000-01-12 15:17:21 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.39 2000-06-23 08:20:49 cg Exp $'
! !
AbstractOperatingSystem initialize!
--- a/Character.st Fri Jun 23 10:18:11 2000 +0200
+++ b/Character.st Fri Jun 23 10:21:17 2000 +0200
@@ -10,6 +10,8 @@
hereby transferred.
"
+"{ Package: 'stx:libbasic' }"
+
Magnitude subclass:#Character
instanceVariableNames:'asciivalue'
classVariableNames:'CharacterTable'
@@ -565,31 +567,20 @@
val = __intVal(_characterVal(self));
if (val <= 0xFF) {
- buffer[0] = (char) val;
- buffer[1] = '\0';
- s = __MKSTRING_L(buffer, 1 COMMA_SND);
- if (s != nil) {
- RETURN (s);
- }
+ buffer[0] = (char) val;
+ buffer[1] = '\0';
+ s = __MKSTRING_L(buffer, 1 COMMA_SND);
+ if (s != nil) {
+ RETURN (s);
+ }
}
%}.
asciivalue > 255 ifTrue:[
- ^ (TwoByteString new:1) at:1 put:self; yourself
+ ^ (TwoByteString new:1) at:1 put:self; yourself
].
-"/
-"/ ^ (String new:1) at:1 put:self; yourself.
-"/
- "
- memory allocation (for the new string) failed.
- When we arrive here, there was no memory, even after a garbage collect.
- This means, that the VM wanted to get some more memory from the
- OS, which was not kind enough to give it.
- Bad luck - you should increase the swap space on your machine.
- "
-
- ^ ObjectMemory allocationFailureSignal raise.
+ ^ (String new:1) at:1 put:self; yourself.
!
asSymbol
@@ -1082,5 +1073,5 @@
!Character class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Character.st,v 1.57 2000-03-21 21:21:00 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Character.st,v 1.58 2000-06-23 08:19:52 cg Exp $'
! !
--- a/NonPositionableExternalStream.st Fri Jun 23 10:18:11 2000 +0200
+++ b/NonPositionableExternalStream.st Fri Jun 23 10:21:17 2000 +0200
@@ -10,6 +10,8 @@
hereby transferred.
"
+"{ Package: 'stx:libbasic' }"
+
ExternalStream subclass:#NonPositionableExternalStream
instanceVariableNames:''
classVariableNames:'StdInStream StdOutStream StdErrorStream'
@@ -242,6 +244,36 @@
!NonPositionableExternalStream methodsFor:'private'!
+handleForStderr
+ "{ Pragma: +optSpace }"
+
+ "return a stderr handle"
+
+%{
+ RETURN ( __MKOBJ(stderr) );
+%}
+!
+
+handleForStdin
+ "{ Pragma: +optSpace }"
+
+ "return a stdin handle"
+
+%{
+ RETURN ( __MKOBJ(stdin) );
+%}
+!
+
+handleForStdout
+ "{ Pragma: +optSpace }"
+
+ "return a stdout handle"
+
+%{
+ RETURN ( __MKOBJ(stdout) );
+%}
+!
+
initializeForStderr
"{ Pragma: +optSpace }"
@@ -249,19 +281,10 @@
mode := #readwrite.
buffered := false.
-%{
- OBJ fp;
-
- __INST(filePointer) = fp = __MKOBJ(stderr); __STORE(self, fp);
-#ifdef WIN32
- __INST(eolMode) = @symbol(crlf);
-#else
-# ifdef xxx__VMS__ /* XXX: to be tested */
- __INST(eolMode) = @symbol(cr);
-# endif
-#endif
-
-%}
+ filePointer := self handleForStderr.
+ OperatingSystem isMSWINDOWSlike ifTrue:[
+ eolMode := #crlf
+ ]
!
initializeForStdin
@@ -271,11 +294,7 @@
mode := #readonly.
buffered := true.
-%{
- OBJ fp;
-
- __INST(filePointer) = fp = __MKOBJ(stdin); __STORE(self, fp);
-%}
+ filePointer := self handleForStdin.
!
initializeForStdout
@@ -285,18 +304,10 @@
mode := #readwrite.
buffered := false.
-%{
- OBJ fp;
-
- __INST(filePointer) = fp = __MKOBJ(stdout); __STORE(self, fp);
-#ifdef WIN32
- __INST(eolMode) = @symbol(crlf);
-#else
-# ifdef xxx__VMS__ /* XXX: to be tested */
- __INST(eolMode) = @symbol(cr);
-# endif
-#endif
-%}
+ filePointer := self handleForStdout.
+ OperatingSystem isMSWINDOWSlike ifTrue:[
+ eolMode := #crlf
+ ]
!
reOpen
@@ -319,12 +330,6 @@
!NonPositionableExternalStream methodsFor:'queries'!
-isPositionable
- "return true, if the stream supports positioning (this one is not)"
-
- ^ false
-!
-
current
"for compatibility with Transcript - allow Transcript current,
even if redirected to the standardError"
@@ -333,10 +338,16 @@
^ self
].
^ super current
+!
+
+isPositionable
+ "return true, if the stream supports positioning (this one is not)"
+
+ ^ false
! !
!NonPositionableExternalStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/NonPositionableExternalStream.st,v 1.38 1999-10-27 23:58:45 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/NonPositionableExternalStream.st,v 1.39 2000-06-23 08:21:17 cg Exp $'
! !
--- a/String.st Fri Jun 23 10:18:11 2000 +0200
+++ b/String.st Fri Jun 23 10:21:17 2000 +0200
@@ -10,6 +10,8 @@
hereby transferred.
"
+"{ Package: 'stx:libbasic' }"
+
CharacterArray variableByteSubclass:#String
instanceVariableNames:''
classVariableNames:''
@@ -230,7 +232,7 @@
invalid argument, or out-of-memory:
use error handling in superclass
"
- ^ (super basicNew:anInteger) atAllPut:(Character space)
+ ^ (super basicNew:anInteger+1) atAllPut:(Character space)
!
new:n
@@ -404,23 +406,20 @@
REGISTER OBJ slf, cls;
if (__isSmallInteger(index)) {
- slf = self;
- cls = __qClass(slf);
- indx = __intVal(index) - 1;
- if (cls != String) {
- if (indx < 0) goto badIndex;
- indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
- }
- if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
- RETURN ( __MKCHARACTER(__stringVal(slf)[indx] & 0xFF) );
- }
+ slf = self;
+ cls = __qClass(slf);
+ indx = __intVal(index) - 1;
+ if (cls != String) {
+ if (indx < 0) goto badIndex;
+ indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+ }
+ if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
+ RETURN ( __MKCHARACTER(__stringVal(slf)[indx] & 0xFF) );
+ }
}
badIndex: ;
%}.
- index isInteger ifFalse:[
- ^ self indexNotInteger:index
- ].
- ^ self subscriptBoundsError:index
+ ^ self basicAt:index
!
at:index put:aCharacter
@@ -438,44 +437,20 @@
slf = self;
if (__isString(slf)) {
- if (__isCharacter(aCharacter)) {
- value = __intVal(_characterVal(aCharacter));
- if (((unsigned)value <= 0xFF)
- && __isSmallInteger(index)) {
- indx = __intVal(index) - 1;
- if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
- __stringVal(slf)[indx] = value;
- RETURN ( aCharacter );
- }
- }
- }
+ if (__isCharacter(aCharacter)) {
+ value = __intVal(_characterVal(aCharacter));
+ if (((unsigned)value <= 0xFF)
+ && __isSmallInteger(index)) {
+ indx = __intVal(index) - 1;
+ if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
+ __stringVal(slf)[indx] = value;
+ RETURN ( aCharacter );
+ }
+ }
+ }
}
%}.
- (self isMemberOf:String) ifFalse:[
- ^ super at:index put:aCharacter
- ].
-
- (aCharacter isMemberOf:Character) ifFalse:[
- "
- tried to store something which is not a character
- "
- ^ self elementNotCharacter
- ].
- (aCharacter asciiValue between:1 and:255) ifFalse:[
- "
- tried to store a multibyte character
- "
- ^ self elementBoundsError
- ].
- "
- invalid index
- "
- index isInteger ifFalse:[
- ^ self indexNotInteger:index
- ].
- ^ self subscriptBoundsError:index
-
- "Modified: 19.4.1996 / 11:40:27 / cg"
+ ^ self basicAt:index put:aCharacter
!
basicAt:index
@@ -488,23 +463,26 @@
REGISTER OBJ slf, cls;
if (__isSmallInteger(index)) {
- slf = self;
- cls = __qClass(slf);
- indx = __intVal(index) - 1;
- if (cls != String) {
- if (indx < 0) goto badIndex;
- indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
- }
- if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
- RETURN ( __MKCHARACTER(__stringVal(slf)[indx] & 0xFF) );
- }
+ slf = self;
+ cls = __qClass(slf);
+ indx = __intVal(index) - 1;
+ if (cls != String) {
+ if (indx < 0) goto badIndex;
+ indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+ }
+ if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
+ RETURN ( __MKCHARACTER(__stringVal(slf)[indx] & 0xFF) );
+ }
}
badIndex: ;
%}.
index isInteger ifFalse:[
- ^ self indexNotInteger:index
+ ^ self indexNotInteger:index
].
- ^ self subscriptBoundsError:index
+ index == super basicSize ifTrue:[
+ ^ self subscriptBoundsError:index
+ ].
+ ^ Character value:(super basicAt:index)
!
basicAt:index put:aCharacter
@@ -521,44 +499,47 @@
slf = self;
if (__isCharacter(aCharacter)) {
- value = __intVal(_characterVal(aCharacter));
- if (((unsigned)value <= 0xFF)
- && __isSmallInteger(index)) {
- cls = __qClass(slf);
- indx = __intVal(index) - 1;
- if (cls != String) {
- if (indx < 0) goto badIndex;
- indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
- }
- if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
- __stringVal(slf)[indx] = value;
- RETURN ( aCharacter );
- }
- }
+ value = __intVal(_characterVal(aCharacter));
+ if (((unsigned)value <= 0xFF)
+ && __isSmallInteger(index)) {
+ cls = __qClass(slf);
+ indx = __intVal(index) - 1;
+ if (cls != String) {
+ if (indx < 0) goto badIndex;
+ indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+ }
+ if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
+ __stringVal(slf)[indx] = value;
+ RETURN ( aCharacter );
+ }
+ }
}
badIndex: ;
%}.
(aCharacter isMemberOf:Character) ifFalse:[
- "
- tried to store something which is not a character
- "
- ^ self elementNotCharacter
+ "
+ tried to store something which is not a character
+ "
+ ^ self elementNotCharacter
].
(aCharacter asciiValue between:1 and:255) ifFalse:[
- "
- tried to store a multibyte character
- "
- ^ self elementBoundsError
+ "
+ tried to store a multibyte character
+ "
+ ^ self elementBoundsError
].
"
invalid index
"
index isInteger ifFalse:[
- ^ self indexNotInteger:index
+ ^ self indexNotInteger:index
].
- ^ self subscriptBoundsError:index
-
- "Modified: 19.4.1996 / 11:15:48 / cg"
+ index == super basicSize ifTrue:[
+ ^ self subscriptBoundsError:index
+ ].
+ super basicAt:index put:aCharacter asciiValue.
+ ^ aCharacter
+
!
basicSize
@@ -572,11 +553,13 @@
cls = __qClass(slf);
if (cls == String) {
- RETURN ( __MKSMALLINT(__stringSize(slf)) );
+ RETURN ( __MKSMALLINT(__stringSize(slf)) );
}
RETURN ( __MKSMALLINT(__stringSize(slf)
- - __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars))));
-%}
+ - __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars))));
+%}.
+ ^ super basicSize - 1
+
!
size
@@ -591,11 +574,12 @@
slf = self;
cls = __qClass(slf);
if (cls == String) {
- RETURN ( __MKSMALLINT(__stringSize(slf)) );
+ RETURN ( __MKSMALLINT(__stringSize(slf)) );
}
RETURN ( __MKSMALLINT(__stringSize(slf)
- - __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars))));
-%}
+ - __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars))));
+%}.
+ ^ self basicSize
! !
!String methodsFor:'binary storage'!
@@ -650,31 +634,33 @@
OBJ cls;
if (__isCharacter(aCharacter)) {
- cp = __stringVal(self);
- if ((cls = __qClass(self)) != String)
- cp += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+ cp = __stringVal(self);
+ if ((cls = __qClass(self)) != String)
+ cp += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
#ifdef FAST_STRCHR
- cp = (unsigned char *) strchr(cp, __intVal(_characterVal(aCharacter)));
- if (cp) {
- RETURN ( __MKSMALLINT(cp - __stringVal(self) + 1) );
- }
+ cp = (unsigned char *) strchr(cp, __intVal(_characterVal(aCharacter)));
+ if (cp) {
+ RETURN ( __MKSMALLINT(cp - __stringVal(self) + 1) );
+ }
#else
- byteValue = __intVal(_characterVal(aCharacter));
- index = 1;
- while (c = *cp++) {
- if (c == byteValue) { RETURN ( __MKSMALLINT(index) ); }
- index++;
- }
+ byteValue = __intVal(_characterVal(aCharacter));
+ index = 1;
+ while (c = *cp++) {
+ if (c == byteValue) { RETURN ( __MKSMALLINT(index) ); }
+ index++;
+ }
#endif
- RETURN ( __MKSMALLINT(0));
+ RETURN ( __MKSMALLINT(0));
}
+ /* with identity compares, only characters can be in myself */
+ RETURN ( __MKSMALLINT(0));
%}.
- "/ with identity compares, only characters can be in myself
- ^ 0
+ ^ self primitiveFailed
"
'hello world' indexOf:(Character space)
'hello world' indexOf:$A
+ 'hello world' indexOf:1
"
!
@@ -732,21 +718,20 @@
OBJ cls;
if (__isString(aCollection)) {
- matchP = __stringVal(aCollection);
- cp = __stringVal(self);
- if ((cls = __qClass(self)) != String)
- cp += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
-
- while (*cp) {
- if (strchr(matchP, *cp)) {
- RETURN ( true );
- }
- cp++;
- }
- RETURN ( false );
+ matchP = __stringVal(aCollection);
+ cp = __stringVal(self);
+ if ((cls = __qClass(self)) != String)
+ cp += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+
+ while (*cp) {
+ if (strchr(matchP, *cp)) {
+ RETURN ( true );
+ }
+ cp++;
+ }
+ RETURN ( false );
}
-%}
-.
+%}.
^ super includesAny:aCollection
"
@@ -983,26 +968,27 @@
index = __intVal(start);
if (index <= 0) {
- index = 1;
+ index = 1;
}
if ((cls = __qClass(self)) != String)
- index += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+ index += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
len = __stringSize(self);
if (index > len) {
- RETURN ( __MKSMALLINT(0) );
+ RETURN ( __MKSMALLINT(0) );
}
cp = __stringVal(self) + index - 1;
while (c = *cp++) {
#ifndef NON_ASCII /* i.e. EBCDIC ;-) */
- if (c > ' ')
+ if (c > ' ')
#endif
- if ((c != ' ') && (c != '\t') && (c != '\n')
- && (c != '\r') && (c != '\f')) {
- RETURN ( __MKSMALLINT(cp - __stringVal(self)) );
- }
+ if ((c != ' ') && (c != '\t') && (c != '\n')
+ && (c != '\r') && (c != '\f')) {
+ RETURN ( __MKSMALLINT(cp - __stringVal(self)) );
+ }
}
+ RETURN ( __MKSMALLINT(0) );
%}.
- ^ 0
+ ^ super indexOfNonSeparatorStartingAt:start
"
'hello world' indexOfNonWhiteSpaceStartingAt:3
@@ -1022,27 +1008,27 @@
index = __intVal(start);
if (index <= 0) {
- index = 1;
+ index = 1;
}
if ((cls = __qClass(self)) != String)
- index += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+ index += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
len = __stringSize(self);
if (index > len) {
- RETURN ( __MKSMALLINT(0) );
+ RETURN ( __MKSMALLINT(0) );
}
cp = __stringVal(self) + index - 1;
while (c = *cp++) {
#ifndef NON_ASCII /* i.e. EBCDIC ;-) */
- if (c <= ' ')
+ if (c <= ' ')
#endif
- if ((c == ' ') || (c == '\t') || (c == '\n')
- || (c == '\r') || (c == '\f')) {
- RETURN ( __MKSMALLINT(cp - __stringVal(self)) );
- }
+ if ((c == ' ') || (c == '\t') || (c == '\n')
+ || (c == '\r') || (c == '\f')) {
+ RETURN ( __MKSMALLINT(cp - __stringVal(self)) );
+ }
}
-%}
-.
- ^ 0
+ RETURN ( __MKSMALLINT(0) );
+%}.
+ ^ super indexOfSeparatorStartingAt:start
"
'hello world' indexOfSeparatorStartingAt:3
@@ -1494,7 +1480,7 @@
"if a symbol with the receivers characters is already known, return it.
Otherwise, return nil. This can be used to query for an existing
symbol and is the same as
- self knownAsSymbol ifTrue:[self asSymbol] ifFalse:[nil]
+ self knownAsSymbol ifTrue:[self asSymbol] ifFalse:[nil]
but slightly faster, since the symbol lookup operation is only
performed once."
@@ -1504,13 +1490,13 @@
cls = __qClass(self);
if (cls != String) {
- indx = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+ indx = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
} else {
- indx = 0;
+ indx = 0;
}
RETURN ( __SYMBOL_OR_NIL(__stringVal(self) + indx));
-%}
-
+%}.
+ self primitiveFailed
"
'hello' asSymbolIfInterned
'fooBarBaz' asSymbolIfInterned
@@ -2730,12 +2716,13 @@
cls = __qClass(self);
if (cls != String) {
- indx = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+ indx = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
} else {
- indx = 0;
+ indx = 0;
}
RETURN ( __KNOWNASSYMBOL(__stringVal(self) + indx) );
-%}
+%}.
+ self primitiveFailed
"
'hello' knownAsSymbol
@@ -2860,27 +2847,28 @@
src = __stringVal(self);
if ((cls = __qClass(self)) != String)
- src += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+ src += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
#ifndef NON_ASCII
# ifdef UINT64
while (*((UINT64 *)src) == 0x2020202020202020L) {
- src += 8;
+ src += 8;
}
# endif /* UINT64 */
while (*((unsigned *)src) == 0x20202020) {
- src += 4;
+ src += 4;
}
#endif /* ascii */
while (c = *src++) {
- if (c != ' ') {
- RETURN ( false );
- }
+ if (c != ' ') {
+ RETURN ( false );
+ }
}
+ RETURN ( true );
%}.
- ^ true
+ ^ super isBlank
!
levenshteinTo:aString s:substWeight c:caseWeight i:insrtWeight d:deleteWeight
@@ -3105,5 +3093,5 @@
!String class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.151 2000-03-21 12:56:10 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.152 2000-06-23 08:20:15 cg Exp $'
! !
--- a/UnixOperatingSystem.st Fri Jun 23 10:18:11 2000 +0200
+++ b/UnixOperatingSystem.st Fri Jun 23 10:21:17 2000 +0200
@@ -4459,6 +4459,10 @@
}
%}.
^ self primitiveFailed
+
+"/ alternative:
+"/ ^ (self infoOf:aPathName) notNil
+
!
isWritable:aPathName
@@ -5896,9 +5900,10 @@
if (env) {
RETURN ( __MKSTRING(env) );
}
+ RETURN ( nil );
}
%}.
- ^ nil
+ ^ self primitiveFailed
"
OperatingSystem getEnvironment:'LANG'
@@ -8906,6 +8911,6 @@
!UnixOperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.81 2000-06-20 10:50:48 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.82 2000-06-23 08:19:20 cg Exp $'
! !
UnixOperatingSystem initialize!