From 07e9d8beb7f6414eae2e5862acc2fb4ddc47a032 Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Sun, 14 Dec 2008 06:50:53 +0000 Subject: [PATCH] re PR fortran/38504 (double minus sign when printing integer?) 2008-12-13 Jerry DeLisle PR libfortran/38504 io/write.c (write_decimal): Skip extra sign '-' at beginning of string returned by gfc_itoa. From-SVN: r142747 --- libgfortran/ChangeLog | 6 ++++++ libgfortran/io/write.c | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index dcc4867882e5..3be2b2246988 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 32c58471bb8c..3cd67b39ba79 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); -- 2.47.3