From patchwork Wed Oct 8 10:07:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 397583 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 36AD71400D5 for ; Wed, 8 Oct 2014 21:08:15 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=avXLdUvTRMxw+3sGx 9SjNQo7SSIavWfYNz67d41VQ2exvwratJnpmQgxea5xugjJBtteeShQa11jwedrR QqOjUp0Wm/cKXZni5shj2vF94geF8WbPXfsk2SOtbZO3psz+c3QjlaGlluITOeSn 30d5aDjvnhmK58gVUfppjqrRyI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=ufO3FSjy7uFNsApXxz/PRqJ BZ3g=; b=X8fp311QBVy4uG7mq78Mw09n5COB3egbCYw1DcC/Gzcj6YX2Nd4xdkj AW05wypP8L32N+0OeZUJt6AcmDjvcF/51erzik8QQMFq05Xsrp68wxXxQmieu6qW CjTo+BJDJ/v0ztxFfzE9FLoVjl3DBnJqHX1aavHC5x8P6hyl/VnM= Received: (qmail 31876 invoked by alias); 8 Oct 2014 10:07:58 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 31856 invoked by uid 89); 8 Oct 2014 10:07:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 08 Oct 2014 10:07:56 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s98A7nEq026518 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 8 Oct 2014 06:07:50 -0400 Received: from localhost (ovpn-116-121.ams2.redhat.com [10.36.116.121]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s98A7mFG024682; Wed, 8 Oct 2014 06:07:48 -0400 Date: Wed, 8 Oct 2014 11:07:47 +0100 From: Jonathan Wakely To: Andreas Schwab Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org, =?iso-8859-1?Q?R=FCdiger?= Sonderfeld , Luke Allardyce Subject: Re: [PATCH v2] libstdc++: Add hexfloat/defaultfloat io manipulators. Message-ID: <20141008100747.GV4197@redhat.com> References: <20140327133723.GA13599@redhat.com> <1901588.qodTErPe42@descartes> <20140327162714.GA13192@redhat.com> <20141006155615.GN4197@redhat.com> <87k34bwvaj.fsf@igel.home> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87k34bwvaj.fsf@igel.home> User-Agent: Mutt/1.5.23 (2014-03-12) On 07/10/14 21:10 +0200, Andreas Schwab wrote: >That cannot work. std::__convert_from_v always passes __prec before >__v, but the format is "%a". Ah yes. I'm testing this fix now. commit 543771e2db1642715854ae4bec81d803ca8e2e59 Author: Jonathan Wakely Date: Wed Oct 8 10:39:27 2014 +0100 * include/bits/locale_facets.tcc (num_put::_M_insert_float): Do not pass precision when using hexfloat format. * src/c++98/locale_facets.cc (__num_base::_S_format_float): Always output precision if C99 hexfloat conversion specifiers not available. diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc index cf12a08..88adc0d 100644 --- a/libstdc++-v3/include/bits/locale_facets.tcc +++ b/libstdc++-v3/include/bits/locale_facets.tcc @@ -988,20 +988,32 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL __num_base::_S_format_float(__io, __fbuf, __mod); #ifdef _GLIBCXX_USE_C99 + // Precision is always used except for hexfloat format. + const bool __use_prec = + (__io.flags() & ios_base::floatfield) != ios_base::floatfield; + // First try a buffer perhaps big enough (most probably sufficient // for non-ios_base::fixed outputs) int __cs_size = __max_digits * 3; char* __cs = static_cast(__builtin_alloca(__cs_size)); - __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, - __fbuf, __prec, __v); + if (__use_prec) + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + __fbuf, __prec, __v); + else + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + __fbuf, __v); // If the buffer was not large enough, try again with the correct size. if (__len >= __cs_size) { __cs_size = __len + 1; __cs = static_cast(__builtin_alloca(__cs_size)); - __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, - __fbuf, __prec, __v); + if (__use_prec) + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + __fbuf, __prec, __v); + else + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + __fbuf, __v); } #else // Consider the possibility of long ios_base::fixed outputs diff --git a/libstdc++-v3/src/c++98/locale_facets.cc b/libstdc++-v3/src/c++98/locale_facets.cc index 7ed04e6..b3ca5dc 100644 --- a/libstdc++-v3/src/c++98/locale_facets.cc +++ b/libstdc++-v3/src/c++98/locale_facets.cc @@ -71,7 +71,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ios_base::fmtflags __fltfield = __flags & ios_base::floatfield; +#ifdef _GLIBCXX_USE_C99 + // Precision is always used except for hexfloat format. if (__fltfield != (ios_base::fixed | ios_base::scientific)) +#endif { // As per DR 231: not only when __flags & ios_base::fixed || __prec > 0 *__fptr++ = '.';