--- a/Float.st Sat Jan 08 17:12:03 1994 +0100
+++ b/Float.st Sat Jan 08 17:18:40 1994 +0100
@@ -22,7 +22,7 @@
COPYRIGHT (c) 1988 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libbasic/Float.st,v 1.6 1993-12-12 20:52:40 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Float.st,v 1.7 1994-01-08 16:18:40 claus Exp $
notice, that Floats are defined as Byte-array to prevent garbage collector
from going into the value ... otherwise I needed a special case in many places.
@@ -781,6 +781,7 @@
f := self basicNew.
bytes := stream next:8.
+
"kludge: assumes IEEE format"
UninterpretedBytes isBigEndian ifTrue:[
"swap the bytes"
@@ -817,9 +818,12 @@
char buffer[64];
REGISTER char *cp;
-#ifdef THISCONTEXT_IN_REGISTER
+ /*
+ * actually only needed on sparc: since thisContext is
+ * in a global register, which gets destroyed by printf,
+ * manually save it here - very stupid ...
+ */
OBJ sav = __thisContext;
-#endif
#ifdef SYSV
sprintf(buffer, "%.6lg", _floatVal(self));
@@ -827,9 +831,7 @@
sprintf(buffer, "%.6G", _floatVal(self));
#endif
-#ifdef THISCONTEXT_IN_REGISTER
__thisContext = sav;
-#endif
/*
* kludge to make integral float f prints as "f.0" (not as "f" as printf does)
* (i.e. look if string contains '.' or 'e' and append '.0' if not)
@@ -855,23 +857,25 @@
printfPrintString:formatString
"non-portable: return a printed representation of the receiver
as specified by formatString, which is defined by printf.
- If you use this, be aware, that specifying doubles differes on
+ If you use this, be aware, that specifying doubles differs on
systems; on SYSV machines you have to give something like %lf,
while on BSD systems the format string has to be %F.
- Also, the resulting string must not be longer than 255 bytes -
+ Also, the resulting string may not be longer than 255 bytes -
since thats the (static) size of the buffer."
%{ /* STACK: 400 */
char buffer[256];
if (_isString(formatString)) {
-#ifdef THISCONTEXT_IN_REGISTER
+ /*
+ * actually only needed on sparc: since thisContext is
+ * in a global register, which gets destroyed by printf,
+ * manually save it here - very stupid ...
+ */
OBJ sav = __thisContext;
-#endif
+
sprintf(buffer, _stringVal(formatString), _floatVal(self));
-#ifdef THISCONTEXT_IN_REGISTER
__thisContext = sav;
-#endif
RETURN ( _MKSTRING(buffer COMMA_SND) );
}
%}