diff options
author | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2008-12-14 06:50:53 +0000 |
---|---|---|
committer | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2008-12-14 06:50:53 +0000 |
commit | 07e9d8beb7f6414eae2e5862acc2fb4ddc47a032 (patch) | |
tree | 9e98240a5e8f47645adfeedfcc4b145945980653 /libgfortran/io | |
parent | 7b5be687fcdf079e9cb458484144687841f8a9a5 (diff) | |
download | gcc-07e9d8beb7f6414eae2e5862acc2fb4ddc47a032.tar.gz |
re PR fortran/38504 (double minus sign when printing integer?)
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
Diffstat (limited to 'libgfortran/io')
-rw-r--r-- | libgfortran/io/write.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c index 32c58471bb8..3cd67b39ba7 100644 --- a/libgfortran/io/write.c +++ b/libgfortran/io/write.c @@ -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); |