873 %{ /* NOCONTEXT */ |
873 %{ /* NOCONTEXT */ |
874 |
874 |
875 #ifndef NON_ASCII /* i.e. not EBCDIC ;-) */ |
875 #ifndef NON_ASCII /* i.e. not EBCDIC ;-) */ |
876 REGISTER unsigned char *cp; |
876 REGISTER unsigned char *cp; |
877 REGISTER unsigned char c; |
877 REGISTER unsigned char c; |
|
878 REGISTER unsigned char *cpEnd; |
878 int len, index; |
879 int len, index; |
879 OBJ cls; |
880 OBJ cls; |
880 |
881 |
881 index = __intVal(start); |
882 index = __intVal(start); |
882 if (index <= 0) { |
883 if (index <= 0) { |
883 index = 1; |
884 index = 1; |
884 } |
885 } |
885 if ((cls = __qClass(self)) != String) |
886 if ((cls = __qClass(self)) != String) |
886 index += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
887 index += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
887 len = __stringSize(self); |
888 len = __stringSize(self); |
888 if (index > len) { |
889 cpEnd = __stringVal(self) + len; |
|
890 cp = __stringVal(self) + index - 1; |
|
891 if (cp < cpEnd) { |
|
892 while (cp < cpEnd) { |
|
893 if (*cp++ < ' ') { |
|
894 RETURN ( __MKSMALLINT(cp - __stringVal(self)) ); |
|
895 } |
|
896 } |
889 RETURN ( __MKSMALLINT(0) ); |
897 RETURN ( __MKSMALLINT(0) ); |
890 } |
898 } |
891 cp = __stringVal(self) + index - 1; |
|
892 while (c = *cp++) { |
|
893 if (c < ' ') { |
|
894 RETURN ( __MKSMALLINT(cp - __stringVal(self)) ); |
|
895 } |
|
896 } |
|
897 RETURN ( __MKSMALLINT(0) ); |
|
898 #endif |
899 #endif |
899 %}. |
900 %}. |
900 ^ super indexOfControlCharacterStartingAt:start |
901 ^ super indexOfControlCharacterStartingAt:start |
901 |
902 |
902 " |
903 " |
903 'hello world' indexOfControlCharacterStartingAt:1 |
904 'hello world' indexOfControlCharacterStartingAt:1 |
904 'hello world\foo' withCRs indexOfControlCharacterStartingAt:1 |
905 'hello world\foo' withCRs indexOfControlCharacterStartingAt:1 |
|
906 '1\' withCRs indexOfControlCharacterStartingAt:1 |
|
907 '1\' withCRs indexOfControlCharacterStartingAt:2 |
905 " |
908 " |
906 ! |
909 ! |
907 |
910 |
908 indexOfNonSeparatorStartingAt:start |
911 indexOfNonSeparatorStartingAt:start |
909 "return the index of the next non-whiteSpace character" |
912 "return the index of the next non-whiteSpace character" |