From d46b08a9748f9515d19cceea8a8ee853861fcfbf Mon Sep 17 00:00:00 2001 From: jvdelisle Date: Sun, 14 Dec 2008 06:50:53 +0000 Subject: 2008-12-13 Jerry DeLisle PR libfortran/38504 io/write.c (write_decimal): Skip extra sign '-' at beginning of string returned by gfc_itoa. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@142747 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgfortran/ChangeLog | 6 ++++++ libgfortran/io/write.c | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'libgfortran') diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index dcc4867882e..3be2b224698 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2008-12-13 Jerry DeLisle + + PR libfortran/38504 + io/write.c (write_decimal): Skip extra sign '-' at beginning of string + returned by gfc_itoa. + 2008-12-08 Jerry DeLisle PR libfortran/38430 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); -- cgit v1.2.1