This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: DFP build failure


On Wed, 2008-01-09 at 11:49 -0500, Daniel Jacobowitz wrote:
> void
> decimal_from_floating (struct value *from, gdb_byte *to, int len)
> {
>   char *buffer;
>   int ret;
> 
>   ret = asprintf (&buffer, "%.30Lg", value_as_double (from));
>   ...
> 
> value_as_double returns a DOUBLEST, not necessarily a long double as
> specified by %Lg.  And the system printf does not necessarily support
> long double.  Is there some other way to do this?
> 
> (It failed to build on mingw32.)

Mmmm.... sorry about that. What do you think of the attached fix
(dangerous question to ask!)?

DOUBLEST_PRINT_FORMAT is currently not used, so not a big deal to change
it a bit.
-- 
[]'s
Thiago Jung Bauermann
Software Engineer
IBM Linux Technology Center
diff --git a/gdb/dfp.c b/gdb/dfp.c
index bf82114..4915543 100644
--- a/gdb/dfp.c
+++ b/gdb/dfp.c
@@ -237,7 +237,7 @@ decimal_from_floating (struct value *from, gdb_byte *to, int len)
   char *buffer;
   int ret;
 
-  ret = asprintf (&buffer, "%.30Lg", value_as_double (from));
+  ret = asprintf (&buffer, "%.30"DOUBLEST_PRINT_FORMAT, value_as_double (from));
   if (ret < 0)
     error (_("Error in memory allocation for conversion to decimal float."));
 
diff --git a/gdb/doublest.h b/gdb/doublest.h
index f3ab619..52e28df 100644
--- a/gdb/doublest.h
+++ b/gdb/doublest.h
@@ -49,11 +49,11 @@ struct floatformat;
 #if (defined HAVE_LONG_DOUBLE && defined PRINTF_HAS_LONG_DOUBLE \
      && defined SCANF_HAS_LONG_DOUBLE)
 typedef long double DOUBLEST;
-# define DOUBLEST_PRINT_FORMAT "%Lg"
+# define DOUBLEST_PRINT_FORMAT "Lg"
 # define DOUBLEST_SCAN_FORMAT "%Lg"
 #else
 typedef double DOUBLEST;
-# define DOUBLEST_PRINT_FORMAT "%g"
+# define DOUBLEST_PRINT_FORMAT "g"
 # define DOUBLEST_SCAN_FORMAT "%lg"
 /* If we can't scan or print long double, we don't want to use it
    anywhere.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]