--- a/String.st Fri Apr 04 23:35:03 1997 +0200
+++ b/String.st Sat Apr 05 01:20:08 1997 +0200
@@ -617,13 +617,24 @@
cp = __stringVal(self);
if ((cls = __qClass(self)) != String)
cp += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+
+ byteValue = __intVal(_characterVal(aCharacter));
+ if (byteValue == 0) {
+ index = strlen(cp);
+ if (index >= __stringSize(self)) {
+ index = 0;
+ } else {
+ index++;
+ }
+ RETURN ( __MKSMALLINT(index) );
+ }
+
#ifdef FAST_STRCHR
- cp = (unsigned char *) strchr(cp, __intVal(_characterVal(aCharacter)));
+ cp = (unsigned char *) strchr(cp, byteValue);
if (cp) {
RETURN ( __MKSMALLINT(cp - __stringVal(self) + 1) );
}
#else
- byteValue = __intVal(_characterVal(aCharacter));
index = 1;
while (c = *cp++) {
if (c == byteValue) { RETURN ( __MKSMALLINT(index) ); }
@@ -659,32 +670,41 @@
OBJ cls;
if (__isSmallInteger(start)) {
- if (__isCharacter(aCharacter)) {
- byteValue = __intVal(_characterVal(aCharacter));
- index = __intVal(start);
- if (index <= 0)
- index = 1;
- if ((cls = __qClass(self)) != String)
- index += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
- len = __stringSize(self);
- if (index <= len) {
- cp = __stringVal(self) + index - 1;
+ if (__isCharacter(aCharacter)) {
+ byteValue = __intVal(_characterVal(aCharacter));
+ index = __intVal(start);
+ if (index <= 0)
+ index = 1;
+ if ((cls = __qClass(self)) != String)
+ index += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+ len = __stringSize(self);
+ if (index <= len) {
+ cp = __stringVal(self) + index - 1;
+
+ if (byteValue == 0) {
+ index += strlen(cp);
+ if (index > len) {
+ index = 0;
+ }
+ RETURN ( __MKSMALLINT(index) );
+ }
+
#ifdef FAST_STRCHR
- cp = (unsigned char *) strchr(cp, byteValue);
- if (cp) {
- RETURN ( __MKSMALLINT(cp - __stringVal(self) + 1) );
- }
+ cp = (unsigned char *) strchr(cp, byteValue);
+ if (cp) {
+ RETURN ( __MKSMALLINT(cp - __stringVal(self) + 1) );
+ }
#else
- while (c = *cp++) {
- if (c == byteValue) {
- RETURN ( __MKSMALLINT(index) );
- }
- index++;
- }
+ while (c = *cp++) {
+ if (c == byteValue) {
+ RETURN ( __MKSMALLINT(index) );
+ }
+ index++;
+ }
#endif
- }
- }
- RETURN ( __MKSMALLINT(0) );
+ }
+ }
+ RETURN ( __MKSMALLINT(0) );
}
%}.
^ super indexOf:aCharacter startingAt:start
@@ -2274,5 +2294,5 @@
!String class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.88 1997-02-25 18:19:52 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.89 1997-04-04 23:20:08 cg Exp $'
! !