[m-dev.] for review: work around lcc bug with `long double'

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Feb 8 23:21:53 AEDT 2001


Any objections to this one?

Estimated hours taken: 1

library/string.m:
	Avoid the use of `long double', because this causes problems
	with lcc on Linux, since lcc does not use the same
	representation for `long double' as gcc and glibc.
	(lcc treats `long double' as 8 bytes, the same as `double',
	whereas `gcc' has a 12-byte `long double'.)
	The code here was using `long double' just in case `MR_Float'
	was `long double', but currently `MR_Float' is only ever
	`double' or `float', not `long double', so that isn't needed.

	This is a bug in lcc on Linux (lcc is not a conforming hosted
	C implementation), but we may as well work around it.

Workspace: /home/venus/fjh/ws-venus2/mercury
Index: library/string.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.141
diff -u -d -r1.141 string.m
--- library/string.m	2001/01/01 04:03:54	1.141
+++ library/string.m	2001/02/08 12:06:50
@@ -1327,27 +1327,27 @@
 			% valid float conversion specifiers
 		Spec = e(Float),
 		String = format_float(
-			make_format(Flags, Width, Prec, "L", "e"), Float)
+			make_format(Flags, Width, Prec, "", "e"), Float)
 	;
 		Spec = cE(Float),
 		String = format_float(
-			make_format(Flags, Width, Prec, "L", "E"), Float)
+			make_format(Flags, Width, Prec, "", "E"), Float)
 	;
 		Spec = f(Float),
 		String = format_float(
-			make_format(Flags, Width, Prec, "L", "f"), Float)
+			make_format(Flags, Width, Prec, "", "f"), Float)
 	;
 		Spec = cF(Float),
 		String = format_float(
-			make_format(Flags, Width, Prec, "L", "F"), Float)
+			make_format(Flags, Width, Prec, "", "F"), Float)
 	;
 		Spec = g(Float),
 		String = format_float(
-			make_format(Flags, Width, Prec, "L", "g"), Float)
+			make_format(Flags, Width, Prec, "", "g"), Float)
 	;
 		Spec = cG(Float),
 		String = format_float(
-			make_format(Flags, Width, Prec, "L", "G"), Float)
+			make_format(Flags, Width, Prec, "", "G"), Float)
 	;
 			% valid char conversion Specifiers
 		Spec = c(Char),
@@ -1410,7 +1410,7 @@
 	format_float(FormatStr::in, Val::in) = (Str::out),
 		[will_not_call_mercury, thread_safe], "{
 	MR_save_transient_hp();
-	Str = MR_make_string(MR_PROC_LABEL, FormatStr, (long double) Val);
+	Str = MR_make_string(MR_PROC_LABEL, FormatStr, (double) Val);
 	MR_restore_transient_hp();
 }").
 :- pragma foreign_code("MC++",

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list