Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Thiago Jung Bauermann <bauerman@br.ibm.com>
To: Daniel Jacobowitz <drow@false.org>
Cc: gdb-patches@sourceware.org
Subject: Re: DFP build failure
Date: Wed, 09 Jan 2008 18:31:00 -0000	[thread overview]
Message-ID: <1199903445.15225.50.camel@localhost.localdomain> (raw)
In-Reply-To: <20080109164917.GA10333@caradoc.them.org>

[-- Attachment #1: Type: text/plain, Size: 738 bytes --]

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

[-- Attachment #2: dfp-mingw-build-fix.diff --]
[-- Type: text/x-patch, Size: 1091 bytes --]

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.  */

  reply	other threads:[~2008-01-09 18:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-09 16:49 Daniel Jacobowitz
2008-01-09 18:31 ` Thiago Jung Bauermann [this message]
2008-01-09 18:36   ` Daniel Jacobowitz
2008-01-09 19:11     ` Thiago Jung Bauermann
2008-01-09 19:15       ` Daniel Jacobowitz
2008-01-09 19:28         ` Thiago Jung Bauermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1199903445.15225.50.camel@localhost.localdomain \
    --to=bauerman@br.ibm.com \
    --cc=drow@false.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox