String.st
changeset 12763 e19933d3e188
parent 12727 b3d7aebe8c6b
child 13116 467e182438ff
equal deleted inserted replaced
12762:a41a496d8c61 12763:e19933d3e188
  1564     unsigned char *cp1, *cp2;
  1564     unsigned char *cp1, *cp2;
  1565     OBJ cls;
  1565     OBJ cls;
  1566     OBJ myCls;
  1566     OBJ myCls;
  1567 
  1567 
  1568     if (__isNonNilObject(s)) {
  1568     if (__isNonNilObject(s)) {
  1569 	cls = __qClass(s);
  1569         cls = __qClass(s);
  1570 	myCls = __qClass(self);
  1570         myCls = __qClass(self);
  1571 
  1571 
  1572 	if ((cls == String) || (cls == Symbol) || (cls == myCls)) {
  1572         if (__isStringLike(s) || (cls == myCls)) {
  1573 	    cp1 = __stringVal(self);
  1573             cp1 = __stringVal(self);
  1574 
  1574 
  1575 	    /*
  1575             /*
  1576 	     * care for instances of subclasses ...
  1576              * care for instances of subclasses ...
  1577 	     */
  1577              */
  1578 	    if (myCls != String) {
  1578             if (myCls != String) {
  1579 		int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(myCls)->c_ninstvars));
  1579                 int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(myCls)->c_ninstvars));
  1580 
  1580 
  1581 		cp1 += n;
  1581                 cp1 += n;
  1582 	    }
  1582             }
  1583 
  1583 
  1584 	    cp2 = __stringVal(s);
  1584             cp2 = __stringVal(s);
  1585 	    /*
  1585             /*
  1586 	     * care for instances of subclasses ...
  1586              * care for instances of subclasses ...
  1587 	     */
  1587              */
  1588 	    if (cls != String) {
  1588             if (cls != String) {
  1589 		int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
  1589                 int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
  1590 
  1590 
  1591 		cp2 += n;
  1591                 cp2 += n;
  1592 	    }
  1592             }
  1593 
  1593 
  1594 #ifdef HAS_STRCOLL
  1594 #ifdef HAS_STRCOLL
  1595 	    cmp = strcoll(cp1, cp2);
  1595             cmp = strcoll(cp1, cp2);
  1596 #else
  1596 #else
  1597 	    cmp = strcmp(cp1, cp2);
  1597             cmp = strcmp(cp1, cp2);
  1598 #endif
  1598 #endif
  1599 
  1599 
  1600 	    if (cmp > 0) {
  1600             if (cmp > 0) {
  1601 		RETURN ( __mkSmallInteger(1) );
  1601                 RETURN ( __mkSmallInteger(1) );
  1602 	    }
  1602             }
  1603 	    if (cmp < 0) {
  1603             if (cmp < 0) {
  1604 		RETURN ( __mkSmallInteger(-1) );
  1604                 RETURN ( __mkSmallInteger(-1) );
  1605 	    }
  1605             }
  1606 	    RETURN ( __mkSmallInteger(0) );
  1606             RETURN ( __mkSmallInteger(0) );
  1607 	}
  1607         }
  1608     }
  1608     }
  1609 %}.
  1609 %}.
  1610     "
  1610     "
  1611      currently, this operation is only defined for strings, symbols
  1611      currently, this operation is only defined for strings, symbols
  1612      and subclasses.
  1612      and subclasses.
  1668     /*
  1668     /*
  1669      * multiply by large prime to spread values
  1669      * multiply by large prime to spread values
  1670      * This speeds up Set and Dictionary by a factor of 10!
  1670      * This speeds up Set and Dictionary by a factor of 10!
  1671      */
  1671      */
  1672     val *= 31415821;
  1672     val *= 31415821;
  1673     RETURN ( __mkSmallInteger(val & 0x3fffffff));
  1673     RETURN ( __mkSmallInteger(val & _MAX_INT));
  1674 %}
  1674 %}
  1675 !
  1675 !
  1676 
  1676 
  1677 ~= aString
  1677 ~= aString
  1678     "Compare the receiver with the argument and return true if the
  1678     "Compare the receiver with the argument and return true if the
  1961      '{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}' asUUID
  1961      '{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}' asUUID
  1962      'EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B' asUUID
  1962      'EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B' asUUID
  1963     "
  1963     "
  1964 
  1964 
  1965     "Modified: / 02-08-2007 / 16:43:29 / cg"
  1965     "Modified: / 02-08-2007 / 16:43:29 / cg"
  1966 !
       
  1967 
       
  1968 uncapitalized
       
  1969         "Answer a <readableString> which is a copy of the receiver but with
       
  1970         the first character converted to its lowercase equivalent."
       
  1971 
       
  1972         ^ self asLowercaseFirst
       
  1973 "/        | answer |
       
  1974 "/        #swAdded.
       
  1975 "/        (answer := self copy) isEmpty ifFalse: [
       
  1976 "/                answer at: 1 put: (self first asLowercase)].
       
  1977 "/        ^answer
       
  1978 !
  1966 !
  1979 
  1967 
  1980 withTabsExpanded:numSpaces
  1968 withTabsExpanded:numSpaces
  1981     "return a string with the characters of the receiver where all tabulator characters
  1969     "return a string with the characters of the receiver where all tabulator characters
  1982      are expanded into spaces (assuming numSpaces-col tabs).
  1970      are expanded into spaces (assuming numSpaces-col tabs).
  3256 %}.
  3244 %}.
  3257     ^ super reverse
  3245     ^ super reverse
  3258 ! !
  3246 ! !
  3259 
  3247 
  3260 
  3248 
  3261 
       
  3262 !String methodsFor:'substring searching'!
  3249 !String methodsFor:'substring searching'!
  3263 
  3250 
  3264 indexOfSubCollection:aSubString startingAt:startIndex ifAbsent:exceptionValue caseSensitive:caseSensitive
  3251 indexOfSubCollection:aSubString startingAt:startIndex ifAbsent:exceptionValue caseSensitive:caseSensitive
  3265     "redefined as primitive for maximum speed (BM)"
  3252     "redefined as primitive for maximum speed (BM)"
  3266 
  3253 
  3720 ! !
  3707 ! !
  3721 
  3708 
  3722 !String class methodsFor:'documentation'!
  3709 !String class methodsFor:'documentation'!
  3723 
  3710 
  3724 version
  3711 version
  3725     ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.270 2010-02-10 17:47:03 cg Exp $'
  3712     ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.271 2010-03-06 13:31:19 stefan Exp $'
  3726 !
  3713 !
  3727 
  3714 
  3728 version_CVS
  3715 version_CVS
  3729     ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.270 2010-02-10 17:47:03 cg Exp $'
  3716     ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.271 2010-03-06 13:31:19 stefan Exp $'
  3730 ! !
  3717 ! !