--- a/String.st Fri Aug 22 15:23:44 1997 +0200
+++ b/String.st Fri Aug 22 16:19:59 1997 +0200
@@ -10,6 +10,8 @@
hereby transferred.
"
+'From Smalltalk/X, Version:3.1.9 on 22-aug-1997 at 5:33:16 pm' !
+
CharacterArray subclass:#String
instanceVariableNames:''
classVariableNames:''
@@ -1505,7 +1507,6 @@
if (newString != nil) {
__InstPtr(newString)->o_class = String;
dstp = __stringVal(newString);
-
#ifdef FAST_MEMCPY
bcopy(__stringVal(self) + index1 - 1, dstp, count);
dstp[count] = '\0';
@@ -1620,7 +1621,6 @@
%{ /* NOCONTEXT */
int sz;
- int count;
REGISTER unsigned char *dstp;
OBJ cls, newString;
OBJ myClass;
@@ -1629,8 +1629,7 @@
if (__isCharacter(aCharacter)
&& ((myClass==String) || (myClass==Symbol))) {
- count = __stringSize(self);
- sz = OHDR_SIZE + count + 1 + 1;
+ sz = __qSize(self) + 1;
__PROTECT_CONTEXT__
__qNew(newString, sz);
@@ -1641,12 +1640,13 @@
dstp = __stringVal(newString);
#ifdef FAST_MEMCPY
- bcopy(__stringVal(self), dstp, count);
- dstp += count;
+ sz = sz - OHDR_SIZE - 1 - 1;
+ bcopy(__stringVal(self), dstp, sz);
+ dstp += sz;
#else
# ifdef FAST_STRCPY
- strncpy(dstp, __stringVal(self), count);
- dstp += count;
+ strcpy(dstp, __stringVal(self));
+ dstp += sz - OHDR_SIZE - 1 - 1;
# else
{
REGISTER unsigned char *srcp;
@@ -1669,7 +1669,8 @@
^ super copyWith:aCharacter
!
-return a copy of the receiver"
+deepCopy
+ "return a copy of the receiver"
"
could be an instance of a subclass which needs deepCopy
@@ -1681,7 +1682,7 @@
^ super deepCopy
!
-aDictionary
+deepCopyUsing:aDictionary
"return a copy of the receiver - reimplemented to be a bit faster"
"
@@ -1694,7 +1695,8 @@
^ super deepCopy
!
-"return a copy of the receiver"
+shallowCopy
+ "return a copy of the receiver"
(self isMemberOf:String) ifTrue:[
^ self copyFrom:1
@@ -1702,7 +1704,8 @@
^ super shallowCopy
!
-"return a copy of the receiver"
+simpleDeepCopy
+ "return a copy of the receiver"
"
could be an instance of a subclass which needs deepCopy
@@ -1716,7 +1719,7 @@
!String methodsFor:'filling and replacing'!
-acter
+atAllPut:aCharacter
"replace all elements with aCharacter
- reimplemented here for speed"
@@ -1755,7 +1758,7 @@
"
!
-Character by:newCharacter
+replaceAll:oldCharacter by:newCharacter
"replace all oldCharacters by newCharacter in the receiver"
%{ /* NOCONTEXT */
@@ -1785,7 +1788,7 @@
"
!
-art to:stop with:aString startingAt:repStart
+replaceFrom:start to:stop with:aString startingAt:repStart
"replace the characters starting at index start, anInteger and ending
at stop, anInteger with characters from aString starting at repStart.
@@ -1875,7 +1878,8 @@
!
-"in-place reverse the characters of the string."
+reverse
+ "in-place reverse the characters of the string."
"Q: is there a need to redefine it here ?"
@@ -2046,10 +2050,10 @@
startIndex == 0 ifTrue:[^ super withoutSpaces].
startIndex > endIndex ifTrue:[^ ''].
+ ((startIndex == 1) and:[endIndex == self size]) ifTrue:[^ self].
^ self copyFrom:startIndex to:endIndex
"
- 'hello' withoutSpaces
' hello' withoutSpaces
' hello ' withoutSpaces
' hello ' withoutSpaces
@@ -2061,13 +2065,15 @@
!String methodsFor:'printing & storing'!
-"return true, if the receiver can be used as a literal
+isLiteral
+ "return true, if the receiver can be used as a literal
(i.e. can be used in constant arrays)"
^ true
!
-nt the receiver on standard output.
+print
+ "print the receiver on standard output.
This method does NOT use the stream classes and will therefore work
even in case of emergency."
@@ -2086,7 +2092,7 @@
^ super print
!
-ing:formatString
+printfPrintString:formatString
"non-portable but sometimes useful.
Return a printed representation of the receiver as specified by formatString,
which is defined by printf.
@@ -2132,7 +2138,7 @@
"
!
-m
+storeOn:aStream
"put the storeString of myself on aStream"
aStream nextPut: $'.
@@ -2147,7 +2153,8 @@
aStream nextPut:$'
!
-"return a String for storing myself"
+storeString
+ "return a String for storing myself"
|s n index|
@@ -2172,7 +2179,7 @@
!String methodsFor:'queries'!
-er
+bitsPerCharacter
"return the number of bits each character has.
Here, 8 is returned (storing single byte characters)."
@@ -2181,7 +2188,8 @@
"Modified: 20.4.1996 / 23:08:42 / cg"
!
-eturn true if the receiver is empty (i.e. if size == 0)
+isEmpty
+ "return true if the receiver is empty (i.e. if size == 0)
Redefined here for performance"
%{ /* NOCONTEXT */
@@ -2195,7 +2203,8 @@
^ super isEmpty
!
-"return true, if there is a symbol with same characters in the
+knownAsSymbol
+ "return true, if there is a symbol with same characters in the
system.
Can be used to check for existance of a symbol without creating one"
@@ -2206,7 +2215,8 @@
!String methodsFor:'regular expression matching'!
-ompile the receiver as a regex matcher. May raise RxParser>>syntaxErrorSignal
+asRegex
+ "Compile the receiver as a regex matcher. May raise RxParser>>syntaxErrorSignal
or RxParser>>compilationErrorSignal.
||| This is a part of the Regular Expression Matcher package, (c) Vassili Bykov, 1996.
||| Refer to `documentation' protocol of RxParser class for details."
@@ -2216,7 +2226,7 @@
"Modified: 3.6.1997 / 11:25:25 / cg"
!
-regexString
+matchesRegex: regexString
"Test if the receiver matches a regex. May raise RxParser>>regexErrorSignal or
child signals.
||| This is a part of the Regular Expression Matcher package, (c) Vassili Bykov, 1996.
@@ -2227,7 +2237,7 @@
"Modified: 3.6.1997 / 11:25:30 / cg"
!
-egex: regexString
+prefixMatchesRegex: regexString
"Test if the receiver's prefix matches a regex.
May raise RxParser class>>regexErrorSignal or child signals.
||| This is a part of the Regular Expression Matcher package, (c) Vassili Bykov, 1996.
@@ -2240,7 +2250,7 @@
!String methodsFor:'testing'!
-ngOrChar
+endsWith:aStringOrChar
"return true, if the receiver ends with something, aStringOrChar."
%{ /* NOCONTEXT */
@@ -2281,7 +2291,8 @@
"
!
-eturn true, if the receivers size is 0 or if it contains only spaces.
+isBlank
+ "return true, if the receivers size is 0 or if it contains only spaces.
Q: should we care for whiteSpace in general here ?"
%{ /* NOCONTEXT */
@@ -2314,7 +2325,7 @@
^ true
!
-aString s:substWeight c:caseWeight i:insrtWeight d:deleteWeight
+levenshteinTo:aString s:substWeight c:caseWeight i:insrtWeight d:deleteWeight
"parametrized levenshtein. arguments are the costs for
substitution, case-change, insertion and deletion of a character."
@@ -2417,7 +2428,7 @@
'Computer' levenshteinTo:'computer'"
!
-ringOrChar
+startsWith:aStringOrChar
"return true, if the receiver starts with something, aStringOrChar."
%{ /* NOCONTEXT */
@@ -2465,5 +2476,6 @@
!String class methodsFor:'documentation'!
-'$Header: /cvs/stx/stx/libbasic/String.st,v 1.99 1997-08-22 13:23:44 cg Exp $'
+version
+ ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.100 1997-08-22 14:19:59 cg Exp $'
! !