From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27920 invoked by alias); 22 Nov 2015 21:33:00 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 27896 invoked by uid 89); 22 Nov 2015 21:32:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_00,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mtaout001-public.msg.strl.va.charter.net Received: from mtaout001-public.msg.strl.va.charter.net (HELO mtaout001-public.msg.strl.va.charter.net) (68.114.190.26) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 22 Nov 2015 21:32:58 +0000 Received: from impout005 ([68.114.189.20]) by mtaout001.msg.strl.va.charter.net (InterMail vM.9.00.021.00 201-2473-182) with ESMTP id <20151122213257.SUCD1472.mtaout001.msg.strl.va.charter.net@impout005>; Sun, 22 Nov 2015 15:32:57 -0600 Received: from quattro.localdomain ([96.41.215.23]) by impout005 with charter.net id klYw1r0080Wrkg001lYwgB; Sun, 22 Nov 2015 15:32:57 -0600 X-Authority-Analysis: v=2.1 cv=S7lXwecP c=1 sm=1 tr=0 a=salB9WdMPIDduBH7JsZfrA==:117 a=salB9WdMPIDduBH7JsZfrA==:17 a=hOpmn2quAAAA:8 a=r77TgQKjGQsHNAKrUKIA:9 a=mDV3o1hIAAAA:8 a=tcsTXdiTVb84kmLXVqAA:9 a=QEXdDO2ut3YA:10 a=ccKj8OQRD-xPq4ScW9gA:9 X-Auth-id: anZkZWxpc2xlQGNoYXJ0ZXIubmV0 To: gfortran Cc: gcc patches From: Jerry DeLisle Subject: [PATCH] Fix leading zero with g0 editing X-Enigmail-Draft-Status: N1110 Message-ID: <56523488.8080607@charter.net> Date: Sun, 22 Nov 2015 21:44:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------030905000809040205070105" X-SW-Source: 2015-11/txt/msg02626.txt.bz2 This is a multi-part message in MIME format. --------------030905000809040205070105 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 1201 This minor patch brings the leading zero to emitting floats with g0 editing by moving the block of code up a little before the g0 is handled. This has been lurking in my trunk for several moths and I would like to get it out of the way. Updated Test case also. Regression tested on x86-64-linux. OK for trunk? Jerry 2015-11-22 Jerry DeLisle * io/write_float.def (output_float): Move block determining room for leading zero to before checkng g0 formatting. Index: fmt_g0_1.f08 =================================================================== --- fmt_g0_1.f08 (revision 230725) +++ fmt_g0_1.f08 (working copy) @@ -8,9 +8,9 @@ write(buffer, string) ':',0,':' if (buffer.ne.":0:") call abort write(buffer, string) ':',1.0_8/3.0_8,':' - if (buffer.ne.":.33333333333333331:") call abort + if (buffer.ne.":0.33333333333333331:") call abort write(buffer, '(1x,a,g0,a)') ':',1.0_8/3.0_8,':' - if (buffer.ne." :.33333333333333331:") call abort + if (buffer.ne." :0.33333333333333331:") call abort write(buffer, string) ':',"hello",':' if (buffer.ne.":hello:") call abort write(buffer, "(g0,g0,g0,g0)") ':',.true.,.false.,':' --------------030905000809040205070105 Content-Type: text/x-patch; name="write_float.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="write_float.diff" Content-length: 1169 Index: write_float.def =================================================================== --- write_float.def (revision 230709) +++ write_float.def (working copy) @@ -514,12 +514,21 @@ output_float (st_parameter_dt *dtp, const fnode *f w = w == 1 ? 2 : w; } } - + /* Work out how much padding is needed. */ nblanks = w - (nbefore + nzero + nafter + edigits + 1); if (sign != S_NONE) nblanks--; + /* See if we have space for a zero before the decimal point. */ + if (nbefore == 0 && nblanks > 0) + { + leadzero = 1; + nblanks--; + } + else + leadzero = 0; + if (dtp->u.p.g0_no_blanks) { w -= nblanks; @@ -544,15 +553,6 @@ output_float (st_parameter_dt *dtp, const fnode *f return false; } - /* See if we have space for a zero before the decimal point. */ - if (nbefore == 0 && nblanks > 0) - { - leadzero = 1; - nblanks--; - } - else - leadzero = 0; - /* For internal character(kind=4) units, we duplicate the code used for regular output slightly modified. This needs to be maintained consistent with the regular code that follows this block. */ --------------030905000809040205070105--