diff options
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/ChangeLog | 9 | ||||
-rw-r--r-- | libgfortran/io/format.c | 10 |
2 files changed, 16 insertions, 3 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 2437c4f..cf55910 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,12 @@ +2008-07-22 Daniel Kraft <d@domob.eu> + + PR fortran/29835 + * io/format.c (struct format_data): New member error_element. + (unexpected_element): Added '%c' to message. + (next_char): Keep track of last parsed character in fmt->error_element. + (format_error): If the message is unexpected_element, output the + offending character, too. + 2008-07-22 Thomas Koenig <tkoenig@gcc.gnu.org> PR libfortran/36890 diff --git a/libgfortran/io/format.c b/libgfortran/io/format.c index cf299c16..02ce291 100644 --- a/libgfortran/io/format.c +++ b/libgfortran/io/format.c @@ -50,6 +50,7 @@ typedef struct format_data { char *format_string, *string; const char *error; + char error_element; format_token saved_token; int value, format_string_len, reversion_ok; fnode *avail; @@ -67,7 +68,7 @@ static const fnode colon_node = { FMT_COLON, 0, NULL, NULL, {{ 0, 0, 0 }}, 0, static const char posint_required[] = "Positive width required in format", period_required[] = "Period required in format", nonneg_required[] = "Nonnegative width required in format", - unexpected_element[] = "Unexpected element in format", + unexpected_element[] = "Unexpected element '%c' in format\n", unexpected_end[] = "Unexpected end of format string", bad_string[] = "Unterminated character constant in format", bad_hollerith[] = "Hollerith constant extends past the end of the format", @@ -89,7 +90,7 @@ next_char (format_data *fmt, int literal) return -1; fmt->format_string_len--; - c = toupper (*fmt->format_string++); + fmt->error_element = c = toupper (*fmt->format_string++); } while ((c == ' ' || c == '\t') && !literal); @@ -948,7 +949,10 @@ format_error (st_parameter_dt *dtp, const fnode *f, const char *message) if (f != NULL) fmt->format_string = f->source; - sprintf (buffer, "%s\n", message); + if (message == unexpected_element) + sprintf (buffer, message, fmt->error_element); + else + sprintf (buffer, "%s\n", message); j = fmt->format_string - dtp->format; |