String.st
changeset 3734 5d4e741062bd
parent 3712 f93cb659b10d
child 3751 e2913a6c124b
equal deleted inserted replaced
3733:d287d4fc20ae 3734:5d4e741062bd
   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"
  2908 ! !
  2911 ! !
  2909 
  2912 
  2910 !String class methodsFor:'documentation'!
  2913 !String class methodsFor:'documentation'!
  2911 
  2914 
  2912 version
  2915 version
  2913     ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.126 1998-08-03 14:26:12 cg Exp $'
  2916     ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.127 1998-08-05 14:53:13 cg Exp $'
  2914 ! !
  2917 ! !