# HG changeset patch # User Claus Gittinger # Date 1252965354 -7200 # Node ID e2c2786daab1f3e67709af720e73d1cbe78439c6 # Parent 4d2ef58645dec9007cc01e23f49ab6aabcf3d1b2 *** empty log message *** diff -r 4d2ef58645de -r e2c2786daab1 String.st --- a/String.st Mon Sep 14 22:43:29 2009 +0200 +++ b/String.st Mon Sep 14 23:55:54 2009 +0200 @@ -473,7 +473,6 @@ ! ! - !String class methodsFor:'queries'! defaultPlatformClass @@ -2924,7 +2923,9 @@ "non-standard but sometimes useful. Return a printed representation of the receiver as specified by formatString, which is defined by printf. - This method is NONSTANDARD and may be removed without notice." + This method is NONSTANDARD and may be removed without notice. + WARNNG: this goes directly to the C-printf function and may therefore me inherently unsafe. + Please use the printf: method, which is safe as it is completely implemented in Smalltalk." %{ /* STACK: 1000 */ @@ -2938,44 +2939,44 @@ extern void *malloc(); if (__isString(formatString)) { - cp = (char *)__stringVal(self); - if (__qClass(self) != String) { - cp += __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(self))->c_ninstvars)); - } + cp = (char *)__stringVal(self); + if (__qClass(self) != String) { + cp += __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(self))->c_ninstvars)); + } again: - /* - * actually only needed on sparc: since thisContext is - * in a global register, which gets destroyed by printf, - * manually save it here - very stupid ... - */ - __BEGIN_PROTECT_REGISTERS__ - - len = snprintf(buf, bufsize, (char *)__stringVal(formatString), cp); - - __END_PROTECT_REGISTERS__ - - if ((len < 0) || (len > bufsize)) { - if (len < 0) { - bufsize = bufsize * 2; - } else { - bufsize = len + 1; - } - if (mallocbuf) - free(mallocbuf); - buf = mallocbuf = malloc(bufsize); - if (buf == NULL) - goto fail; - goto again; - } - - s = __MKSTRING_L(buf, len); - - if (mallocbuf) - free(mallocbuf); - - if (s != nil) { - RETURN (s); - } + /* + * actually only needed on sparc: since thisContext is + * in a global register, which gets destroyed by printf, + * manually save it here - very stupid ... + */ + __BEGIN_PROTECT_REGISTERS__ + + len = snprintf(buf, bufsize, (char *)__stringVal(formatString), cp); + + __END_PROTECT_REGISTERS__ + + if ((len < 0) || (len > bufsize)) { + if (len < 0) { + bufsize = bufsize * 2; + } else { + bufsize = len + 1; + } + if (mallocbuf) + free(mallocbuf); + buf = mallocbuf = malloc(bufsize); + if (buf == NULL) + goto fail; + goto again; + } + + s = __MKSTRING_L(buf, len); + + if (mallocbuf) + free(mallocbuf); + + if (s != nil) { + RETURN (s); + } } fail:; %}. @@ -3011,6 +3012,7 @@ ^ self basicStoreString. ! ! + !String methodsFor:'queries'! basicSize @@ -3187,7 +3189,6 @@ ^ super reverse ! ! - !String methodsFor:'substring searching'! indexOfSubCollection:aSubString startingAt:startIndex ifAbsent:exceptionValue caseSensitive:caseSensitive @@ -3652,5 +3653,5 @@ !String class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.262 2009-09-08 17:06:58 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.263 2009-09-14 21:55:54 cg Exp $' ! !