]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/38504 (double minus sign when printing integer?)
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Sun, 14 Dec 2008 06:50:53 +0000 (06:50 +0000)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Sun, 14 Dec 2008 06:50:53 +0000 (06:50 +0000)
2008-12-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

PR libfortran/38504
io/write.c (write_decimal): Skip extra sign '-' at beginning of string
returned by gfc_itoa.

From-SVN: r142747

libgfortran/ChangeLog
libgfortran/io/write.c

index dcc4867882e5fc3c3ca0a575cce48fdb07f4fa23..3be2b224698861582c88fc3b55537290ad0964f4 100644 (file)
@@ -1,3 +1,9 @@
+2008-12-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       PR libfortran/38504
+       io/write.c (write_decimal): Skip extra sign '-' at beginning of string
+       returned by gfc_itoa.
+
 2008-12-08  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR libfortran/38430
index 32c58471bb8c1b92ca8d4b38a739d3c9a7f30420..3cd67b39ba797f0e070ec1809b5cf038c89c595f 100644 (file)
@@ -600,9 +600,16 @@ write_decimal (st_parameter_dt *dtp, const fnode *f, const char *source,
   sign = calculate_sign (dtp, n < 0);
   if (n < 0)
     n = -n;
-
   nsign = sign == S_NONE ? 0 : 1;
+  
+  /* conv calls gfc_itoa which sets the negative sign needed
+     by write_integer. The sign '+' or '-' is set below based on sign
+     calculated above, so we just point past the sign in the string
+     before proceeding to avoid double signs in corner cases.
+     (see PR38504)  */
   q = conv (n, itoa_buf, sizeof (itoa_buf));
+  if (*q == '-')
+    q++;
 
   digits = strlen (q);