* DFP build failure
@ 2008-01-09 16:49 Daniel Jacobowitz
2008-01-09 18:31 ` Thiago Jung Bauermann
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2008-01-09 16:49 UTC (permalink / raw)
To: gdb-patches; +Cc: Thiago Jung Bauermann
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.)
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: DFP build failure 2008-01-09 16:49 DFP build failure Daniel Jacobowitz @ 2008-01-09 18:31 ` Thiago Jung Bauermann 2008-01-09 18:36 ` Daniel Jacobowitz 0 siblings, 1 reply; 6+ messages in thread From: Thiago Jung Bauermann @ 2008-01-09 18:31 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: gdb-patches [-- 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. */ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: DFP build failure 2008-01-09 18:31 ` Thiago Jung Bauermann @ 2008-01-09 18:36 ` Daniel Jacobowitz 2008-01-09 19:11 ` Thiago Jung Bauermann 0 siblings, 1 reply; 6+ messages in thread From: Daniel Jacobowitz @ 2008-01-09 18:36 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: gdb-patches On Wed, Jan 09, 2008 at 04:30:45PM -0200, Thiago Jung Bauermann wrote: > 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. OK, with changelog entry. This matches the standard PRIx64 et al, too. Could you update DOUBLEST_SCAN_FORMAT to match? > - ret = asprintf (&buffer, "%.30Lg", value_as_double (from)); > + ret = asprintf (&buffer, "%.30"DOUBLEST_PRINT_FORMAT, value_as_double (from)); Space between " and D. -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: DFP build failure 2008-01-09 18:36 ` Daniel Jacobowitz @ 2008-01-09 19:11 ` Thiago Jung Bauermann 2008-01-09 19:15 ` Daniel Jacobowitz 0 siblings, 1 reply; 6+ messages in thread From: Thiago Jung Bauermann @ 2008-01-09 19:11 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: gdb-patches [-- Attachment #1: Type: text/plain, Size: 741 bytes --] On Wed, 2008-01-09 at 13:35 -0500, Daniel Jacobowitz wrote: > On Wed, Jan 09, 2008 at 04:30:45PM -0200, Thiago Jung Bauermann wrote: > > 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. > > OK, with changelog entry. This matches the standard PRIx64 et al, > too. Could you update DOUBLEST_SCAN_FORMAT to match? > > > - ret = asprintf (&buffer, "%.30Lg", value_as_double (from)); > > + ret = asprintf (&buffer, "%.30"DOUBLEST_PRINT_FORMAT, value_as_double (from)); > > Space between " and D. What about this? -- []'s Thiago Jung Bauermann Software Engineer IBM Linux Technology Center [-- Attachment #2: fix-mingw-build-with-scanf.diff --] [-- Type: text/x-patch, Size: 4101 bytes --] 2008-01-09 Thiago Jung Bauermann <bauerman@br.ibm.com> * doublest.h (DOUBLEST_PRINT_FORMAT): Remove '%' from definition. (DOUBLEST_SCAN_FORMAT): Likewise. * dfp.c (decimal_from_floating): Use DOUBLEST_PRINT_FORMAT. * ada-lex.l (processReal): Prepend "%" to use of DOUBLEST_SCAN_FORMAT. * c-exp.y (parse_number): Likewise. * jv-exp.y (parse_number): Likewise. * objc-exp.y (parse_number): Likewise. * p-exp.y (parse_number): Likewise. diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 6be64ab..cd6de8c 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -373,7 +373,7 @@ processInt (const char *base0, const char *num0, const char *exp0) static int processReal (const char *num0) { - sscanf (num0, DOUBLEST_SCAN_FORMAT, &yylval.typed_val_float.dval); + sscanf (num0, "%" DOUBLEST_SCAN_FORMAT, &yylval.typed_val_float.dval); yylval.typed_val_float.type = type_float (); if (sizeof(DOUBLEST) >= gdbarch_double_bit (current_gdbarch) diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 22bb4c6..b520721 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1125,7 +1125,7 @@ parse_number (p, len, parsed_float, putithere) return (DECFLOAT); } - num = sscanf (p, DOUBLEST_SCAN_FORMAT "%s", + num = sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%s", &putithere->typed_val_float.dval, s); p[len] = saved_char; /* restore the input stream */ diff --git a/gdb/dfp.c b/gdb/dfp.c index bf82114..e184ecd 100644 --- a/gdb/dfp.c +++ b/gdb/dfp.c @@ -237,7 +237,8 @@ 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..247eb5d 100644 --- a/gdb/doublest.h +++ b/gdb/doublest.h @@ -49,12 +49,12 @@ 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_SCAN_FORMAT "%Lg" +# define DOUBLEST_PRINT_FORMAT "Lg" +# define DOUBLEST_SCAN_FORMAT "Lg" #else typedef double DOUBLEST; -# define DOUBLEST_PRINT_FORMAT "%g" -# define DOUBLEST_SCAN_FORMAT "%lg" +# 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. */ # undef HAVE_LONG_DOUBLE diff --git a/gdb/jv-exp.y b/gdb/jv-exp.y index 1db33a6..14a7bf8 100644 --- a/gdb/jv-exp.y +++ b/gdb/jv-exp.y @@ -713,7 +713,7 @@ parse_number (p, len, parsed_float, putithere) char saved_char = p[len]; p[len] = 0; /* null-terminate the token */ - num = sscanf (p, DOUBLEST_SCAN_FORMAT "%c", + num = sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%c", &putithere->typed_val_float.dval, &c); p[len] = saved_char; /* restore the input stream */ if (num != 1) /* check scanf found ONLY a float ... */ diff --git a/gdb/objc-exp.y b/gdb/objc-exp.y index d421441..a4a42d9 100644 --- a/gdb/objc-exp.y +++ b/gdb/objc-exp.y @@ -1023,7 +1023,7 @@ parse_number (p, len, parsed_float, putithere) /* It's a float since it contains a point or an exponent. */ - sscanf (p, DOUBLEST_SCAN_FORMAT "%c", + sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%c", &putithere->typed_val_float.dval, &c); /* See if it has `f' or `l' suffix (float or long double). */ diff --git a/gdb/p-exp.y b/gdb/p-exp.y index 857a69f..9cab7cd 100644 --- a/gdb/p-exp.y +++ b/gdb/p-exp.y @@ -797,7 +797,7 @@ parse_number (p, len, parsed_float, putithere) char saved_char = p[len]; p[len] = 0; /* null-terminate the token */ - num = sscanf (p, DOUBLEST_SCAN_FORMAT "%c", + num = sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%c", &putithere->typed_val_float.dval, &c); p[len] = saved_char; /* restore the input stream */ if (num != 1) /* check scanf found ONLY a float ... */ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: DFP build failure 2008-01-09 19:11 ` Thiago Jung Bauermann @ 2008-01-09 19:15 ` Daniel Jacobowitz 2008-01-09 19:28 ` Thiago Jung Bauermann 0 siblings, 1 reply; 6+ messages in thread From: Daniel Jacobowitz @ 2008-01-09 19:15 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: gdb-patches On Wed, Jan 09, 2008 at 05:11:25PM -0200, Thiago Jung Bauermann wrote: > 2008-01-09 Thiago Jung Bauermann <bauerman@br.ibm.com> > > * doublest.h (DOUBLEST_PRINT_FORMAT): Remove '%' from definition. > (DOUBLEST_SCAN_FORMAT): Likewise. > * dfp.c (decimal_from_floating): Use DOUBLEST_PRINT_FORMAT. > * ada-lex.l (processReal): Prepend "%" to use of DOUBLEST_SCAN_FORMAT. > * c-exp.y (parse_number): Likewise. > * jv-exp.y (parse_number): Likewise. > * objc-exp.y (parse_number): Likewise. > * p-exp.y (parse_number): Likewise. OK, and thanks. -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: DFP build failure 2008-01-09 19:15 ` Daniel Jacobowitz @ 2008-01-09 19:28 ` Thiago Jung Bauermann 0 siblings, 0 replies; 6+ messages in thread From: Thiago Jung Bauermann @ 2008-01-09 19:28 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: gdb-patches On Wed, 2008-01-09 at 14:14 -0500, Daniel Jacobowitz wrote: > On Wed, Jan 09, 2008 at 05:11:25PM -0200, Thiago Jung Bauermann wrote: > > 2008-01-09 Thiago Jung Bauermann <bauerman@br.ibm.com> > > > > * doublest.h (DOUBLEST_PRINT_FORMAT): Remove '%' from definition. > > (DOUBLEST_SCAN_FORMAT): Likewise. > > * dfp.c (decimal_from_floating): Use DOUBLEST_PRINT_FORMAT. > > * ada-lex.l (processReal): Prepend "%" to use of DOUBLEST_SCAN_FORMAT. > > * c-exp.y (parse_number): Likewise. > > * jv-exp.y (parse_number): Likewise. > > * objc-exp.y (parse_number): Likewise. > > * p-exp.y (parse_number): Likewise. > > OK, and thanks. No problem. Committed. -- []'s Thiago Jung Bauermann Software Engineer IBM Linux Technology Center ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-01-09 19:28 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-01-09 16:49 DFP build failure Daniel Jacobowitz 2008-01-09 18:31 ` Thiago Jung Bauermann 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox