equal
deleted
inserted
replaced
951 |
951 |
952 %{ /* NOCONTEXT */ |
952 %{ /* NOCONTEXT */ |
953 |
953 |
954 REGISTER unsigned char *cp; |
954 REGISTER unsigned char *cp; |
955 REGISTER unsigned byteValue; |
955 REGISTER unsigned byteValue; |
956 REGISTER int count; |
956 REGISTER int count, limit; |
957 OBJ cls; |
957 OBJ cls; |
958 |
958 |
959 if (__isCharacter(aCharacter)) { |
959 if (__isCharacter(aCharacter)) { |
960 count = 0; |
960 limit = __stringSize(self); |
961 byteValue = __intVal(_characterVal(aCharacter)); |
961 count = 0; |
962 cp = __stringVal(self); |
962 byteValue = __intVal(_characterVal(aCharacter)); |
963 if ((cls = __qClass(self)) != String) |
963 cp = __stringVal(self); |
964 cp += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
964 if ((cls = __qClass(self)) != String) { |
965 while (*cp) { |
965 int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
966 if (*cp++ == byteValue) count++; |
966 limit -= n; |
967 } |
967 cp += n; |
968 RETURN ( __MKSMALLINT(count) ); |
968 } |
|
969 while (limit > 0) { |
|
970 limit--; |
|
971 if (*cp++ == byteValue) count++; |
|
972 } |
|
973 RETURN ( __MKSMALLINT(count) ); |
969 } |
974 } |
970 %}. |
975 %}. |
971 ^ super occurrencesOf:aCharacter |
976 ^ super occurrencesOf:aCharacter |
972 |
977 |
973 " |
978 " |
3000 ! ! |
3005 ! ! |
3001 |
3006 |
3002 !String class methodsFor:'documentation'! |
3007 !String class methodsFor:'documentation'! |
3003 |
3008 |
3004 version |
3009 version |
3005 ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.172 2002-09-23 12:38:01 mb Exp $' |
3010 ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.173 2002-11-04 17:41:59 penk Exp $' |
3006 ! ! |
3011 ! ! |