SmallInteger.st
changeset 314 7581a5c57224
parent 305 26b092c71935
child 324 290cfb34ec93
--- a/SmallInteger.st	Sat Mar 25 02:18:31 1995 +0100
+++ b/SmallInteger.st	Sat Mar 25 02:24:37 1995 +0100
@@ -21,7 +21,7 @@
 COPYRIGHT (c) 1988 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.24 1995-03-09 09:45:46 claus Exp $
+$Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.25 1995-03-25 01:24:01 claus Exp $
 '!
 
 !SmallInteger class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.24 1995-03-09 09:45:46 claus Exp $
+$Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.25 1995-03-25 01:24:01 claus Exp $
 "
 !
 
@@ -1652,17 +1652,13 @@
 #ifdef THISCONTEXT_IN_REGISTER
     OBJ sav = __thisContext;
 #endif
-    int sz;
 
     sprintf(buffer, "%d", _intVal(self));
 #ifdef THISCONTEXT_IN_REGISTER
     __thisContext = sav;
 #endif
-    sz = sizeof(struct stringheader) + strlen(buffer) + 1;
-    _qNew(newString, sz, SENDER);
+    newString = _MKSTRING(buffer COMMA_SND);
     if (newString != nil) {
-	_InstPtr(newString)->o_class = String;
-	strcpy(_stringVal(newString), buffer);
 	RETURN (newString);
     }
 %}.
@@ -1684,7 +1680,6 @@
     char *format = (char *)0;
     char buffer[30];
     OBJ newString;
-    int sz;
 
     if (__isSmallInteger(radix)) {
 	switch (_intVal(radix)) {
@@ -1708,17 +1703,15 @@
 #ifdef THISCONTEXT_IN_REGISTER
 	__thisContext = sav;
 #endif
-	sz = sizeof(struct stringheader) + strlen(buffer) + 1;
-	_qNew(newString, sz, SENDER);
-	if (newString != nil) {
-	    _InstPtr(newString)->o_class = String;
-	    strcpy(_stringVal(newString), buffer);
+        newString = _MKSTRING(buffer COMMA_SND);
+        if (newString != nil) {
 	    RETURN (newString);
-	}
+        }
     }
-%}
-.
-    "fall back for seldom used bases"
+%}.
+    "
+     fall back for seldom used bases
+    "
     ^ super printStringRadix:radix
 
     "123 printStringRadix:16"
@@ -1740,6 +1733,7 @@
 %{  /* STACK: 400 */
 
     char buffer[256];
+    OBJ s;
 
     if (__isString(formatString)) {
 #ifdef THISCONTEXT_IN_REGISTER
@@ -1749,10 +1743,12 @@
 #ifdef THISCONTEXT_IN_REGISTER
 	__thisContext = sav;
 #endif
-	RETURN ( _MKSTRING(buffer COMMA_SND) );
+	s = _MKSTRING(buffer COMMA_SND);
+	if (s != nil) {
+	    RETURN (s);
+	}
     }
-%}
-.
+%}.
     self primitiveFailed
 
     "123 printfPrintString:'%%d -> %d'"