This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, libfortran] PR36857 Non-English locale breaks gfortran float formatting ("printf is broken")


This patch fixes this by commenting out the locale dependent code.

The commented out code actually could solve the problem by testing for a ',' as well as a '.'.

After thinking about it a bit, the code in question does not do anything useful except when debugging. So I thought, why not just comment it out and leave a note so that it can be used in the future if needed.

The patch also cleans up some comments about what we are doing with the sprintf function and I relocated these notes to where it is applicable in the file.

No test case really needed here. Regression tested on x86-64.

OK to commit?

Jerry

2008-07-20 Jerry DeLisle <jvdelisle@gcc.gnu.org>

	PR fortran/36857
	* io/write_float.def: Comment out locale dependent code and fix general
	comments.
Index: write_float.def
===================================================================
--- write_float.def	(revision 138012)
+++ write_float.def	(working copy)
@@ -99,32 +99,13 @@ output_float (st_parameter_dt *dtp, cons
   if (d < 0)
     internal_error (&dtp->common, "Unspecified precision");
 
-  /* Use sprintf to print the number in the format +D.DDDDe+ddd
-     For an N digit exponent, this gives us (MIN_FIELD_WIDTH-5)-N digits
-     after the decimal point, plus another one before the decimal point.  */
-
   sign = calculate_sign (dtp, sign_bit);
-
-  /* #   The result will always contain a decimal point, even if no
-   *     digits follow it
-   *
-   * -   The converted value is to be left adjusted on the field boundary
-   *
-   * +   A sign (+ or -) always be placed before a number
-   *
-   * MIN_FIELD_WIDTH  minimum field width
-   *
-   * *   (ndigits-1) is used as the precision
-   *
-   *   e format: [-]d.ddde�±dd where there is one digit before the
-   *   decimal-point character and the number of digits after it is
-   *   equal to the precision. The exponent always contains at least two
-   *   digits; if the value is zero, the exponent is 00.
-   */
-
-  /* Check the given string has punctuation in the correct places.  */
-  if (d != 0 && (buffer[2] != '.' || buffer[ndigits + 2] != 'e'))
-      internal_error (&dtp->common, "printf is broken");
+  
+  /* The following code checks the given string has punctuation in the correct
+     places.  Uncomment if needed for debugging.
+     if (d != 0 && ((buffer[2] != '.' && buffer[2] != ',')
+		    || buffer[ndigits + 2] != 'e'))
+       internal_error (&dtp->common, "printf is broken");  */
 
   /* Read the exponent back in.  */
   e = atoi (&buffer[ndigits + 3]) + 1;
@@ -702,8 +683,30 @@ OUTPUT_FLOAT_FMT_G(16)
 
 #undef OUTPUT_FLOAT_FMT_G
 
+
 /* Define a macro to build code for write_float.  */
 
+  /* Note: Before output_float is called, sprintf is used to print to buffer the
+     number in the format +D.DDDDe+ddd. For an N digit exponent, this gives us
+     (MIN_FIELD_WIDTH-5)-N digits after the decimal point, plus another one
+     before the decimal point.
+
+     #   The result will always contain a decimal point, even if no
+	 digits follow it
+
+     -   The converted value is to be left adjusted on the field boundary
+
+     +   A sign (+ or -) always be placed before a number
+
+     MIN_FIELD_WIDTH  minimum field width
+
+     *   (ndigits-1) is used as the precision
+
+     e format: [-]d.ddde�±dd where there is one digit before the
+       decimal-point character and the number of digits after it is
+       equal to the precision. The exponent always contains at least two
+       digits; if the value is zero, the exponent is 00.  */
+
 #ifdef HAVE_SNPRINTF
 
 #define DTOA \

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]