From: Jerry DeLisle <jvdelisle@charter.net>
To: gfortran <fortran@gcc.gnu.org>
Cc: gcc patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH] Fix leading zero with g0 editing
Date: Sun, 22 Nov 2015 21:33:00 -0000 [thread overview]
Message-ID: <56523488.8080607@charter.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 1201 bytes --]
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 <jvdelisle@gcc.gnu.org>
* 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.,':'
[-- Attachment #2: write_float.diff --]
[-- Type: text/x-patch, Size: 1169 bytes --]
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. */
next reply other threads:[~2015-11-22 21:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-22 21:33 Jerry DeLisle [this message]
2015-11-22 21:44 ` Steve Kargl
2015-11-22 22:19 ` Jerry DeLisle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56523488.8080607@charter.net \
--to=jvdelisle@charter.net \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).