From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20462 invoked by alias); 24 Dec 2014 10:06:34 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 20444 invoked by uid 89); 24 Dec 2014 10:06:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-qg0-f45.google.com Received: from mail-qg0-f45.google.com (HELO mail-qg0-f45.google.com) (209.85.192.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 24 Dec 2014 10:06:32 +0000 Received: by mail-qg0-f45.google.com with SMTP id f51so5526334qge.4; Wed, 24 Dec 2014 02:06:30 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.140.83.8 with SMTP id i8mr49891022qgd.103.1419415590084; Wed, 24 Dec 2014 02:06:30 -0800 (PST) Received: by 10.229.103.8 with HTTP; Wed, 24 Dec 2014 02:06:29 -0800 (PST) In-Reply-To: <1413496497-16369-1-git-send-email-brobecker@adacore.com> References: <1413496497-16369-1-git-send-email-brobecker@adacore.com> Date: Wed, 24 Dec 2014 10:06:00 -0000 Message-ID: Subject: Re: [pushed] Use strtod instead of strtold in libiberty/d-demangle.c From: Iain Buclaw To: Joel Brobecker Cc: gdb-patches@sourceware.org, Binutils Development Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-12/txt/msg00620.txt.bz2 On 16 October 2014 at 22:54, Joel Brobecker wrote: > Hello, > > This is a patch was approved in GCC and pushed immediately, but then > I completely forgot to push it to binutils_gdb.git. Now done. > > strtold is currently used to decode templates which have a floating-point > value encoded inside; but this routine is not available on some systems, > such as Solaris 2.9 for instance. > > This patch fixes the issue by replace the use of strtold by strtod. > It reduces a bit the precision, but it should still remain acceptable > in most cases. > > libiberty/ChangeLog: > > * d-demangle.c: Replace strtold with strtod in global comment. > (strtold): Remove declaration. > (strtod): New declaration. > (dlang_parse_real): Declare value as double instead of long > double. Replace call to strtold by call to strtod. > Update format in call to snprintf. > > Tested on x86_64-linux. > > --- > libiberty/ChangeLog | 9 +++++++++ > libiberty/d-demangle.c | 10 +++++----- > 2 files changed, 14 insertions(+), 5 deletions(-) > > diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog > index 829f684..9e91cce 100644 > --- a/libiberty/ChangeLog > +++ b/libiberty/ChangeLog > @@ -1,3 +1,12 @@ > +2014-10-16 Joel Brobecker > + > + * d-demangle.c: Replace strtold with strtod in global comment. > + (strtold): Remove declaration. > + (strtod): New declaration. > + (dlang_parse_real): Declare value as double instead of long > + double. Replace call to strtold by call to strtod. > + Update format in call to snprintf. > + > 2014-09-26 Jason Merrill > > * cp-demangle.c (d_substitution): Handle abi tags on abbreviation. > diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c > index d31bf94..bb481c0 100644 > --- a/libiberty/d-demangle.c > +++ b/libiberty/d-demangle.c > @@ -28,7 +28,7 @@ If not, see . */ > > /* This file exports one function; dlang_demangle. > > - This file imports strtol and strtold for decoding mangled literals. */ > + This file imports strtol and strtod for decoding mangled literals. */ > > #ifdef HAVE_CONFIG_H > #include "config.h" > @@ -44,7 +44,7 @@ If not, see . */ > #include > #else > extern long strtol (const char *nptr, char **endptr, int base); > -extern long double strtold (const char *nptr, char **endptr); > +extern double strtod (const char *nptr, char **endptr); > #endif > > #include > @@ -810,7 +810,7 @@ dlang_parse_real (string *decl, const char *mangled) > { > char buffer[64]; > int len = 0; > - long double value; > + double value; > char *endptr; > > /* Handle NAN and +-INF. */ > @@ -877,12 +877,12 @@ dlang_parse_real (string *decl, const char *mangled) > > /* Convert buffer from hexadecimal to floating-point. */ > buffer[len] = '\0'; > - value = strtold (buffer, &endptr); > + value = strtod (buffer, &endptr); > > if (endptr == NULL || endptr != (buffer + len)) > return NULL; > > - len = snprintf (buffer, sizeof(buffer), "%#Lg", value); > + len = snprintf (buffer, sizeof(buffer), "%#g", value); > string_appendn (decl, buffer, len); > return mangled; > } > -- > 1.9.1 > Hi Joel, This should be applied to the binutils-2.25 branch too. Regards Iain