String.st
changeset 5407 d6729266a95b
parent 5312 ac5719fafe43
child 5556 1056cc5d6ce0
equal deleted inserted replaced
5406:4a6995b61c0e 5407:d6729266a95b
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice.   This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
       
    12 
       
    13 "{ Package: 'stx:libbasic' }"
    12 
    14 
    13 CharacterArray variableByteSubclass:#String
    15 CharacterArray variableByteSubclass:#String
    14 	instanceVariableNames:''
    16 	instanceVariableNames:''
    15 	classVariableNames:''
    17 	classVariableNames:''
    16 	poolDictionaries:''
    18 	poolDictionaries:''
   228 %}.
   230 %}.
   229     "
   231     "
   230      invalid argument, or out-of-memory:
   232      invalid argument, or out-of-memory:
   231      use error handling in superclass
   233      use error handling in superclass
   232     "
   234     "
   233     ^ (super basicNew:anInteger) atAllPut:(Character space)
   235     ^ (super basicNew:anInteger+1) atAllPut:(Character space)
   234 !
   236 !
   235 
   237 
   236 new:n
   238 new:n
   237     "return a new empty string with anInteger characters.
   239     "return a new empty string with anInteger characters.
   238      In contrast to other smalltalks, this returns a string filled
   240      In contrast to other smalltalks, this returns a string filled
   402 
   404 
   403     REGISTER int indx;
   405     REGISTER int indx;
   404     REGISTER OBJ slf, cls;
   406     REGISTER OBJ slf, cls;
   405 
   407 
   406     if (__isSmallInteger(index)) {
   408     if (__isSmallInteger(index)) {
   407 	slf = self;
   409         slf = self;
   408 	cls = __qClass(slf);
   410         cls = __qClass(slf);
   409 	indx = __intVal(index) - 1;
   411         indx = __intVal(index) - 1;
   410 	if (cls != String) {
   412         if (cls != String) {
   411 	    if (indx < 0) goto badIndex;
   413             if (indx < 0) goto badIndex;
   412 	    indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
   414             indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
   413 	}
   415         }
   414 	if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
   416         if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
   415 	    RETURN ( __MKCHARACTER(__stringVal(slf)[indx] & 0xFF) );
   417             RETURN ( __MKCHARACTER(__stringVal(slf)[indx] & 0xFF) );
   416 	}
   418         }
   417     }
   419     }
   418 badIndex: ;
   420 badIndex: ;
   419 %}.
   421 %}.
   420     index isInteger ifFalse:[
   422     ^ self basicAt:index
   421 	^ self indexNotInteger:index
       
   422     ].
       
   423     ^ self subscriptBoundsError:index
       
   424 !
   423 !
   425 
   424 
   426 at:index put:aCharacter
   425 at:index put:aCharacter
   427     "store the argument, aCharacter at position index, an Integer.
   426     "store the argument, aCharacter at position index, an Integer.
   428      Return aCharacter (sigh).
   427      Return aCharacter (sigh).
   436     REGISTER OBJ slf;
   435     REGISTER OBJ slf;
   437 
   436 
   438     slf = self;
   437     slf = self;
   439 
   438 
   440     if (__isString(slf)) {
   439     if (__isString(slf)) {
   441 	if (__isCharacter(aCharacter)) {
   440         if (__isCharacter(aCharacter)) {
   442 	    value = __intVal(_characterVal(aCharacter));
   441             value = __intVal(_characterVal(aCharacter));
   443 	    if (((unsigned)value <= 0xFF)
   442             if (((unsigned)value <= 0xFF)
   444 	     && __isSmallInteger(index)) {
   443              && __isSmallInteger(index)) {
   445 		indx = __intVal(index) - 1;
   444                 indx = __intVal(index) - 1;
   446 		if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
   445                 if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
   447 		    __stringVal(slf)[indx] = value;
   446                     __stringVal(slf)[indx] = value;
   448 		    RETURN ( aCharacter );
   447                     RETURN ( aCharacter );
   449 		}
   448                 }
   450 	    }
   449             }
   451 	}
   450         }
   452     }
   451     }
   453 %}.
   452 %}.
   454     (self isMemberOf:String) ifFalse:[
   453     ^ self basicAt:index put:aCharacter
   455 	^ super at:index put:aCharacter
       
   456     ].
       
   457 
       
   458     (aCharacter isMemberOf:Character) ifFalse:[
       
   459 	"
       
   460 	 tried to store something which is not a character
       
   461 	"
       
   462 	^ self elementNotCharacter
       
   463     ].
       
   464     (aCharacter asciiValue between:1 and:255) ifFalse:[
       
   465 	"
       
   466 	 tried to store a multibyte character
       
   467 	"
       
   468 	^ self elementBoundsError
       
   469     ].
       
   470     "
       
   471      invalid index
       
   472     "
       
   473     index isInteger ifFalse:[
       
   474 	^ self indexNotInteger:index
       
   475     ].
       
   476     ^ self subscriptBoundsError:index
       
   477 
       
   478     "Modified: 19.4.1996 / 11:40:27 / cg"
       
   479 !
   454 !
   480 
   455 
   481 basicAt:index
   456 basicAt:index
   482     "return the character at position index, an Integer
   457     "return the character at position index, an Integer
   483      - reimplemented here since we return characters"
   458      - reimplemented here since we return characters"
   486 
   461 
   487     REGISTER int indx;
   462     REGISTER int indx;
   488     REGISTER OBJ slf, cls;
   463     REGISTER OBJ slf, cls;
   489 
   464 
   490     if (__isSmallInteger(index)) {
   465     if (__isSmallInteger(index)) {
   491 	slf = self;
   466         slf = self;
   492 	cls = __qClass(slf);
   467         cls = __qClass(slf);
   493 	indx = __intVal(index) - 1;
   468         indx = __intVal(index) - 1;
   494 	if (cls != String) {
   469         if (cls != String) {
   495 	    if (indx < 0) goto badIndex;
   470             if (indx < 0) goto badIndex;
   496 	    indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
   471             indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
   497 	}
   472         }
   498 	if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
   473         if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
   499 	    RETURN ( __MKCHARACTER(__stringVal(slf)[indx] & 0xFF) );
   474             RETURN ( __MKCHARACTER(__stringVal(slf)[indx] & 0xFF) );
   500 	}
   475         }
   501     }
   476     }
   502 badIndex: ;
   477 badIndex: ;
   503 %}.
   478 %}.
   504     index isInteger ifFalse:[
   479     index isInteger ifFalse:[
   505 	^ self indexNotInteger:index
   480         ^ self indexNotInteger:index
   506     ].
   481     ].
   507     ^ self subscriptBoundsError:index
   482     index == super basicSize ifTrue:[
       
   483         ^ self subscriptBoundsError:index
       
   484     ].
       
   485     ^ Character value:(super basicAt:index)
   508 !
   486 !
   509 
   487 
   510 basicAt:index put:aCharacter
   488 basicAt:index put:aCharacter
   511     "store the argument, aCharacter at position index, an Integer.
   489     "store the argument, aCharacter at position index, an Integer.
   512      Returns aCharacter (sigh).
   490      Returns aCharacter (sigh).
   519     REGISTER OBJ cls;
   497     REGISTER OBJ cls;
   520 
   498 
   521     slf = self;
   499     slf = self;
   522 
   500 
   523     if (__isCharacter(aCharacter)) {
   501     if (__isCharacter(aCharacter)) {
   524 	value = __intVal(_characterVal(aCharacter));
   502         value = __intVal(_characterVal(aCharacter));
   525 	if (((unsigned)value <= 0xFF)
   503         if (((unsigned)value <= 0xFF)
   526 	 && __isSmallInteger(index)) {
   504          && __isSmallInteger(index)) {
   527 	    cls = __qClass(slf);
   505             cls = __qClass(slf);
   528 	    indx = __intVal(index) - 1;
   506             indx = __intVal(index) - 1;
   529 	    if (cls != String) {
   507             if (cls != String) {
   530 		if (indx < 0) goto badIndex;
   508                 if (indx < 0) goto badIndex;
   531 		indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
   509                 indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
   532 	    }
   510             }
   533 	    if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
   511             if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
   534 		__stringVal(slf)[indx] = value;
   512                 __stringVal(slf)[indx] = value;
   535 		RETURN ( aCharacter );
   513                 RETURN ( aCharacter );
   536 	    }
   514             }
   537 	}
   515         }
   538     }
   516     }
   539 badIndex: ;
   517 badIndex: ;
   540 %}.
   518 %}.
   541     (aCharacter isMemberOf:Character) ifFalse:[
   519     (aCharacter isMemberOf:Character) ifFalse:[
   542 	"
   520         "
   543 	 tried to store something which is not a character
   521          tried to store something which is not a character
   544 	"
   522         "
   545 	^ self elementNotCharacter
   523         ^ self elementNotCharacter
   546     ].
   524     ].
   547     (aCharacter asciiValue between:1 and:255) ifFalse:[
   525     (aCharacter asciiValue between:1 and:255) ifFalse:[
   548 	"
   526         "
   549 	 tried to store a multibyte character
   527          tried to store a multibyte character
   550 	"
   528         "
   551 	^ self elementBoundsError
   529         ^ self elementBoundsError
   552     ].
   530     ].
   553     "
   531     "
   554      invalid index
   532      invalid index
   555     "
   533     "
   556     index isInteger ifFalse:[
   534     index isInteger ifFalse:[
   557 	^ self indexNotInteger:index
   535         ^ self indexNotInteger:index
   558     ].
   536     ].
   559     ^ self subscriptBoundsError:index
   537     index == super basicSize ifTrue:[
   560 
   538         ^ self subscriptBoundsError:index
   561     "Modified: 19.4.1996 / 11:15:48 / cg"
   539     ].
       
   540     super basicAt:index put:aCharacter asciiValue.
       
   541     ^ aCharacter 
       
   542 
   562 !
   543 !
   563 
   544 
   564 basicSize
   545 basicSize
   565     "return the number of characters in myself.
   546     "return the number of characters in myself.
   566      Redefined here to exclude the 0-byte at the end."
   547      Redefined here to exclude the 0-byte at the end."
   570 
   551 
   571     slf = self;
   552     slf = self;
   572 
   553 
   573     cls = __qClass(slf);
   554     cls = __qClass(slf);
   574     if (cls == String) {
   555     if (cls == String) {
   575 	RETURN ( __MKSMALLINT(__stringSize(slf)) );
   556         RETURN ( __MKSMALLINT(__stringSize(slf)) );
   576     }
   557     }
   577     RETURN ( __MKSMALLINT(__stringSize(slf)
   558     RETURN ( __MKSMALLINT(__stringSize(slf)
   578 			  - __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars))));
   559                           - __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars))));
   579 %}
   560 %}.
       
   561     ^ super basicSize - 1
       
   562 
   580 !
   563 !
   581 
   564 
   582 size
   565 size
   583     "return the number of characters in myself.
   566     "return the number of characters in myself.
   584      Reimplemented here to avoid the additional size->basicSize send
   567      Reimplemented here to avoid the additional size->basicSize send
   589     REGISTER OBJ cls, slf;
   572     REGISTER OBJ cls, slf;
   590 
   573 
   591     slf = self;
   574     slf = self;
   592     cls = __qClass(slf);
   575     cls = __qClass(slf);
   593     if (cls == String) {
   576     if (cls == String) {
   594 	RETURN ( __MKSMALLINT(__stringSize(slf)) );
   577         RETURN ( __MKSMALLINT(__stringSize(slf)) );
   595     }
   578     }
   596     RETURN ( __MKSMALLINT(__stringSize(slf)
   579     RETURN ( __MKSMALLINT(__stringSize(slf)
   597 			 - __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars))));
   580                          - __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars))));
   598 %}
   581 %}.
       
   582     ^ self basicSize
   599 ! !
   583 ! !
   600 
   584 
   601 !String methodsFor:'binary storage'!
   585 !String methodsFor:'binary storage'!
   602 
   586 
   603 storeBinaryDefinitionOn:stream manager:manager
   587 storeBinaryDefinitionOn:stream manager:manager
   648     char c;
   632     char c;
   649 #endif
   633 #endif
   650     OBJ cls;
   634     OBJ cls;
   651 
   635 
   652     if (__isCharacter(aCharacter)) {
   636     if (__isCharacter(aCharacter)) {
   653 	cp = __stringVal(self);
   637         cp = __stringVal(self);
   654 	if ((cls = __qClass(self)) != String)
   638         if ((cls = __qClass(self)) != String)
   655 	    cp += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
   639             cp += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
   656 #ifdef FAST_STRCHR
   640 #ifdef FAST_STRCHR
   657 	cp = (unsigned char *) strchr(cp, __intVal(_characterVal(aCharacter)));
   641         cp = (unsigned char *) strchr(cp, __intVal(_characterVal(aCharacter)));
   658 	if (cp) {
   642         if (cp) {
   659 	    RETURN ( __MKSMALLINT(cp - __stringVal(self) + 1) );
   643             RETURN ( __MKSMALLINT(cp - __stringVal(self) + 1) );
   660 	}
   644         }
   661 #else
   645 #else
   662 	byteValue = __intVal(_characterVal(aCharacter));
   646         byteValue = __intVal(_characterVal(aCharacter));
   663 	index = 1;
   647         index = 1;
   664 	while (c = *cp++) {
   648         while (c = *cp++) {
   665 	    if (c == byteValue) { RETURN ( __MKSMALLINT(index) ); }
   649             if (c == byteValue) { RETURN ( __MKSMALLINT(index) ); }
   666 	    index++;
   650             index++;
   667 	}
   651         }
   668 #endif
   652 #endif
   669 	RETURN ( __MKSMALLINT(0));
   653         RETURN ( __MKSMALLINT(0));
   670     }
   654     }
   671 %}.
   655     /* with identity compares, only characters can be in myself */
   672     "/ with identity compares, only characters can be in myself
   656     RETURN ( __MKSMALLINT(0));
   673     ^ 0
   657 %}.
       
   658     ^ self primitiveFailed
   674 
   659 
   675     "
   660     "
   676      'hello world' indexOf:(Character space)                  
   661      'hello world' indexOf:(Character space)                  
   677      'hello world' indexOf:$A                      
   662      'hello world' indexOf:$A                      
       
   663      'hello world' indexOf:1                      
   678     "
   664     "
   679 !
   665 !
   680 
   666 
   681 includes:aCharacter
   667 includes:aCharacter
   682     "return true if the argument, aCharacter is included in the receiver
   668     "return true if the argument, aCharacter is included in the receiver
   730     REGISTER unsigned char *cp;
   716     REGISTER unsigned char *cp;
   731     REGISTER unsigned char *matchP;
   717     REGISTER unsigned char *matchP;
   732     OBJ cls;
   718     OBJ cls;
   733 
   719 
   734     if (__isString(aCollection)) {
   720     if (__isString(aCollection)) {
   735 	matchP = __stringVal(aCollection);
   721         matchP = __stringVal(aCollection);
   736 	cp = __stringVal(self);
   722         cp = __stringVal(self);
   737 	if ((cls = __qClass(self)) != String)
   723         if ((cls = __qClass(self)) != String)
   738 	    cp += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
   724             cp += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
   739 
   725 
   740 	while (*cp) {
   726         while (*cp) {
   741 	    if (strchr(matchP, *cp)) {
   727             if (strchr(matchP, *cp)) {
   742 		RETURN ( true );
   728                 RETURN ( true );
   743 	    }
   729             }
   744 	    cp++;
   730             cp++;
   745 	}
   731         }
   746 	RETURN ( false );
   732         RETURN ( false );
   747     }
   733     }
   748 %}
   734 %}.
   749 .
       
   750     ^ super includesAny:aCollection
   735     ^ super includesAny:aCollection
   751 
   736 
   752     "
   737     "
   753      'hello world' includesAny:'abcd'                      
   738      'hello world' includesAny:'abcd'                      
   754      'hello world' includesAny:'xyz'                      
   739      'hello world' includesAny:'xyz'                      
   981     int len, index;
   966     int len, index;
   982     OBJ cls;
   967     OBJ cls;
   983 
   968 
   984     index = __intVal(start);
   969     index = __intVal(start);
   985     if (index <= 0) {
   970     if (index <= 0) {
   986 	index = 1;
   971         index = 1;
   987     }
   972     }
   988     if ((cls = __qClass(self)) != String)
   973     if ((cls = __qClass(self)) != String)
   989 	index += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
   974         index += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
   990     len = __stringSize(self);
   975     len = __stringSize(self);
   991     if (index > len) {
   976     if (index > len) {
   992 	RETURN ( __MKSMALLINT(0) );
   977         RETURN ( __MKSMALLINT(0) );
   993     }
   978     }
   994     cp = __stringVal(self) + index - 1;
   979     cp = __stringVal(self) + index - 1;
   995     while (c = *cp++) {
   980     while (c = *cp++) {
   996 #ifndef NON_ASCII       /* i.e. EBCDIC ;-) */
   981 #ifndef NON_ASCII       /* i.e. EBCDIC ;-) */
   997 	if (c > ' ')
   982         if (c > ' ')
   998 #endif
   983 #endif
   999 	if ((c != ' ') && (c != '\t') && (c != '\n')
   984         if ((c != ' ') && (c != '\t') && (c != '\n')
  1000 	 && (c != '\r') && (c != '\f')) {
   985          && (c != '\r') && (c != '\f')) {
  1001 	    RETURN ( __MKSMALLINT(cp - __stringVal(self)) );
   986             RETURN ( __MKSMALLINT(cp - __stringVal(self)) );
  1002 	}
   987         }
  1003     }
   988     }
  1004 %}.
   989     RETURN ( __MKSMALLINT(0) );
  1005     ^ 0
   990 %}.
       
   991     ^ super indexOfNonSeparatorStartingAt:start
  1006 
   992 
  1007     "
   993     "
  1008      'hello world' indexOfNonWhiteSpaceStartingAt:3 
   994      'hello world' indexOfNonWhiteSpaceStartingAt:3 
  1009      'hello world' indexOfNonWhiteSpaceStartingAt:7 
   995      'hello world' indexOfNonWhiteSpaceStartingAt:7 
  1010     "
   996     "
  1020     int len, index;
  1006     int len, index;
  1021     OBJ cls;
  1007     OBJ cls;
  1022 
  1008 
  1023     index = __intVal(start);
  1009     index = __intVal(start);
  1024     if (index <= 0) {
  1010     if (index <= 0) {
  1025 	index = 1;
  1011         index = 1;
  1026     }
  1012     }
  1027     if ((cls = __qClass(self)) != String)
  1013     if ((cls = __qClass(self)) != String)
  1028 	index += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
  1014         index += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
  1029     len = __stringSize(self);
  1015     len = __stringSize(self);
  1030     if (index > len) {
  1016     if (index > len) {
  1031 	RETURN ( __MKSMALLINT(0) );
  1017         RETURN ( __MKSMALLINT(0) );
  1032     }
  1018     }
  1033     cp = __stringVal(self) + index - 1;
  1019     cp = __stringVal(self) + index - 1;
  1034     while (c = *cp++) {
  1020     while (c = *cp++) {
  1035 #ifndef NON_ASCII       /* i.e. EBCDIC ;-) */
  1021 #ifndef NON_ASCII       /* i.e. EBCDIC ;-) */
  1036 	if (c <= ' ')
  1022         if (c <= ' ')
  1037 #endif
  1023 #endif
  1038 	if ((c == ' ') || (c == '\t') || (c == '\n')
  1024         if ((c == ' ') || (c == '\t') || (c == '\n')
  1039 	 || (c == '\r') || (c == '\f')) {
  1025          || (c == '\r') || (c == '\f')) {
  1040 	    RETURN ( __MKSMALLINT(cp - __stringVal(self)) );
  1026             RETURN ( __MKSMALLINT(cp - __stringVal(self)) );
  1041 	}
  1027         }
  1042     }
  1028     }
  1043 %}
  1029     RETURN ( __MKSMALLINT(0) );
  1044 .
  1030 %}.
  1045     ^ 0
  1031     ^ super indexOfSeparatorStartingAt:start
  1046 
  1032 
  1047     "
  1033     "
  1048      'hello world' indexOfSeparatorStartingAt:3 
  1034      'hello world' indexOfSeparatorStartingAt:3 
  1049      'hello world' indexOfSeparatorStartingAt:7 
  1035      'hello world' indexOfSeparatorStartingAt:7 
  1050     "
  1036     "
  1492 
  1478 
  1493 asSymbolIfInterned
  1479 asSymbolIfInterned
  1494     "if a symbol with the receivers characters is already known, return it.
  1480     "if a symbol with the receivers characters is already known, return it.
  1495      Otherwise, return nil. This can be used to query for an existing
  1481      Otherwise, return nil. This can be used to query for an existing
  1496      symbol and is the same as
  1482      symbol and is the same as
  1497 	self knownAsSymbol ifTrue:[self asSymbol] ifFalse:[nil]
  1483         self knownAsSymbol ifTrue:[self asSymbol] ifFalse:[nil]
  1498      but slightly faster, since the symbol lookup operation is only
  1484      but slightly faster, since the symbol lookup operation is only
  1499      performed once."
  1485      performed once."
  1500 
  1486 
  1501 %{  /* NOCONTEXT */
  1487 %{  /* NOCONTEXT */
  1502     OBJ cls;
  1488     OBJ cls;
  1503     int indx;
  1489     int indx;
  1504 
  1490 
  1505     cls = __qClass(self);
  1491     cls = __qClass(self);
  1506     if (cls != String) {
  1492     if (cls != String) {
  1507 	indx = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
  1493         indx = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
  1508     } else {
  1494     } else {
  1509 	indx = 0;
  1495         indx = 0;
  1510     }
  1496     }
  1511     RETURN ( __SYMBOL_OR_NIL(__stringVal(self) + indx));
  1497     RETURN ( __SYMBOL_OR_NIL(__stringVal(self) + indx));
  1512 %}
  1498 %}.
  1513 
  1499     self primitiveFailed
  1514     "
  1500     "
  1515      'hello' asSymbolIfInterned
  1501      'hello' asSymbolIfInterned
  1516      'fooBarBaz' asSymbolIfInterned
  1502      'fooBarBaz' asSymbolIfInterned
  1517     "
  1503     "
  1518 !
  1504 !
  2728     OBJ cls;
  2714     OBJ cls;
  2729     int indx;
  2715     int indx;
  2730 
  2716 
  2731     cls = __qClass(self);
  2717     cls = __qClass(self);
  2732     if (cls != String) {
  2718     if (cls != String) {
  2733 	indx = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
  2719         indx = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
  2734     } else {
  2720     } else {
  2735 	indx = 0;
  2721         indx = 0;
  2736     }
  2722     }
  2737     RETURN ( __KNOWNASSYMBOL(__stringVal(self) + indx) );
  2723     RETURN ( __KNOWNASSYMBOL(__stringVal(self) + indx) );
  2738 %}
  2724 %}.
       
  2725     self primitiveFailed
  2739 
  2726 
  2740     "
  2727     "
  2741      'hello' knownAsSymbol     
  2728      'hello' knownAsSymbol     
  2742      'fooBarBaz' knownAsSymbol     
  2729      'fooBarBaz' knownAsSymbol     
  2743     "
  2730     "
  2858     REGISTER unsigned char c;
  2845     REGISTER unsigned char c;
  2859     OBJ cls;
  2846     OBJ cls;
  2860 
  2847 
  2861     src = __stringVal(self);
  2848     src = __stringVal(self);
  2862     if ((cls = __qClass(self)) != String)
  2849     if ((cls = __qClass(self)) != String)
  2863 	src += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
  2850         src += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
  2864 
  2851 
  2865 #ifndef NON_ASCII
  2852 #ifndef NON_ASCII
  2866 # ifdef UINT64
  2853 # ifdef UINT64
  2867     while (*((UINT64 *)src) == 0x2020202020202020L) {
  2854     while (*((UINT64 *)src) == 0x2020202020202020L) {
  2868 	src += 8;
  2855         src += 8;
  2869     }
  2856     }
  2870 # endif /* UINT64 */
  2857 # endif /* UINT64 */
  2871 
  2858 
  2872     while (*((unsigned *)src) == 0x20202020) {
  2859     while (*((unsigned *)src) == 0x20202020) {
  2873 	src += 4;
  2860         src += 4;
  2874     }
  2861     }
  2875 #endif /* ascii */
  2862 #endif /* ascii */
  2876 
  2863 
  2877     while (c = *src++) {
  2864     while (c = *src++) {
  2878 	if (c != ' ') {
  2865         if (c != ' ') {
  2879 	    RETURN ( false );
  2866             RETURN ( false );
  2880 	}
  2867         }
  2881     }
  2868     }
  2882 %}.
  2869     RETURN ( true );
  2883     ^ true
  2870 %}.
       
  2871     ^ super isBlank
  2884 !
  2872 !
  2885 
  2873 
  2886 levenshteinTo:aString s:substWeight c:caseWeight i:insrtWeight d:deleteWeight
  2874 levenshteinTo:aString s:substWeight c:caseWeight i:insrtWeight d:deleteWeight
  2887     "parametrized levenshtein. arguments are the costs for
  2875     "parametrized levenshtein. arguments are the costs for
  2888      substitution, case-change, insertion and deletion of a character."
  2876      substitution, case-change, insertion and deletion of a character."
  3103 ! !
  3091 ! !
  3104 
  3092 
  3105 !String class methodsFor:'documentation'!
  3093 !String class methodsFor:'documentation'!
  3106 
  3094 
  3107 version
  3095 version
  3108     ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.151 2000-03-21 12:56:10 cg Exp $'
  3096     ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.152 2000-06-23 08:20:15 cg Exp $'
  3109 ! !
  3097 ! !