[patch 2/2] Wrap-up expression support for DFP.

Thiago Jung Bauermann bauerman@br.ibm.com
Wed Jan 2 20:07:00 GMT 2008


On Sat, 2007-12-29 at 13:18 +0200, Eli Zaretskii wrote:
> > > We have portable substitutes for snprintf, I think.  Take a look at
> > > libiberty, for example.
> > 
> > Yes, it is there. I didn't find any .h, though, so I don't really know
> > the proper way to use them.
> 
> There's include/libiberty.h, where all libiberty functions are
> declared, conditioned by corresponding preprocessor defines.  Those
> preprocessor defines should be defined by the configure script for
> platforms that don't have those functions in their native libraries.

Ok, since libiberty.h is already included by defs.h, I don't need to
worry about it. Thanks for the explanation.

> > > > +  /* This is an ugly way to do the conversion, but libdecnumber does
> > > > +     not offer a direct way to do it.  */
> > > > +  decimal_to_string (from, len, buffer);
> > > > +  return atof (buffer);
> > > 
> > > Isn't strtold better here?
> > 
> > It's C99 and not in libiberty.
> 
> Then how about using strtod?

Fine by me. Thanks for your review, Eli. The attached patch has the
following changes from the one I originally posted:

- includes documentation update to GDB manual, under the "C and C++"
subsection;
- uses asprintf instead of sprintf, with "%.30Lg" in
decimal_from_floating;
- uses strtod instead of atof in decimal_to_double;
- decimal/binary FP conversion tests now accept some rounding variation:

gdb_test "p (_Decimal64) 3.1" " = 3.(0999.*|1000.*)"


Is this version ok?
-- 
[]'s
Thiago Jung Bauermann
Software Engineer
IBM Linux Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: expressions.diff
Type: text/x-patch
Size: 40786 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20080102/4e085e28/attachment.bin>


More information about the Gdb-patches mailing list