diff mbox

Fix leading zero with g0 editing

Message ID 56523488.8080607@charter.net
State New
Headers show

Commit Message

Jerry DeLisle Nov. 22, 2015, 9:32 p.m. UTC
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.

Comments

Steve Kargl Nov. 22, 2015, 9:44 p.m. UTC | #1
On Sun, Nov 22, 2015 at 01:32:56PM -0800, Jerry DeLisle wrote:
> 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?
> 

OK.  Thanks for the patch.
Jerry DeLisle Nov. 22, 2015, 10:19 p.m. UTC | #2
On 11/22/2015 01:44 PM, Steve Kargl wrote:
> On Sun, Nov 22, 2015 at 01:32:56PM -0800, Jerry DeLisle wrote:
>> 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?
>>
> 
> OK.  Thanks for the patch.
> 

Thanks Steve.

Committed revision 230728 and revision 230729 for the test case.

Jerry
diff mbox

Patch

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.  */