diff options
author | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2006-04-17 02:33:51 +0000 |
---|---|---|
committer | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2006-04-17 02:33:51 +0000 |
commit | 9855448d2240ff1e81395ea45fb7820aacc58038 (patch) | |
tree | 0fe585a7085a7f9c87845982bda7cc878bcd0894 /libgfortran | |
parent | b12cbf2cc559fa466b854d89bc4069d7282a881f (diff) | |
download | gcc-9855448d2240ff1e81395ea45fb7820aacc58038.zip gcc-9855448d2240ff1e81395ea45fb7820aacc58038.tar.gz gcc-9855448d2240ff1e81395ea45fb7820aacc58038.tar.bz2 |
re PR fortran/27138 (gfortran: read(*,*) myInt advances only one character on error)
2006-04-14 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/27138
* io/list_read.c (eat_line): New function.
(parse_repeat): Use new function and free_saved.
(read_logical): Same.
(read_integer): Use new function.
(parse_real): Use nml_bad_return and new function.
(read_complex): Use new function and free_saved.
(read_real): Same.
From-SVN: r112999
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/ChangeLog | 11 | ||||
-rw-r--r-- | libgfortran/io/list_read.c | 41 |
2 files changed, 44 insertions, 8 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 190d4a2..160188d 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,14 @@ +2006-04-14 Jerry DeLisle <jvdelisle@gcc.gnu.org> + + PR libgfortran/27138 + * io/list_read.c (eat_line): New function. + (parse_repeat): Use new function and free_saved. + (read_logical): Same. + (read_integer): Use new function. + (parse_real): Use nml_bad_return and new function. + (read_complex): Use new function and free_saved. + (read_real): Same. + 2006-04-12 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libgfortran/26766 diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c index ab9b25d..0d1969b 100644 --- a/libgfortran/io/list_read.c +++ b/libgfortran/io/list_read.c @@ -375,6 +375,21 @@ finish_separator (st_parameter_dt *dtp) } } + +/* This function reads characters through to the end of the current line and + just ignores them. */ + +static void +eat_line (st_parameter_dt *dtp) +{ + char c; + if (!is_internal_unit (dtp)) + do + c = next_char (dtp); + while (c != '\n'); +} + + /* This function is needed to catch bad conversions so that namelist can attempt to see if dtp->u.p.saved_string contains a new object name rather than a bad value. */ @@ -534,9 +549,11 @@ parse_repeat (st_parameter_dt *dtp) return 0; bad_repeat: + + eat_line (dtp); + free_saved (dtp); st_sprintf (message, "Bad repeat count in item %d of list input", dtp->u.p.item_count); - generate_error (&dtp->common, ERROR_READ_VALUE, message); return 1; } @@ -550,8 +567,6 @@ parse_repeat (st_parameter_dt *dtp) static void l_push_char (st_parameter_dt *dtp, char c) { - char *new; - if (dtp->u.p.line_buffer == NULL) { dtp->u.p.line_buffer = get_mem (SCRATCH_SIZE); @@ -677,9 +692,12 @@ read_logical (st_parameter_dt *dtp, int length) if (nml_bad_return (dtp, c)) return; + eat_line (dtp); + free_saved (dtp); + if (dtp->u.p.line_buffer != NULL) + free_mem (dtp->u.p.line_buffer); st_sprintf (message, "Bad logical value while reading item %d", dtp->u.p.item_count); - generate_error (&dtp->common, ERROR_READ_VALUE, message); return; @@ -805,9 +823,9 @@ read_integer (st_parameter_dt *dtp, int length) if (nml_bad_return (dtp, c)) return; - + + eat_line (dtp); free_saved (dtp); - st_sprintf (message, "Bad integer for item %d in list input", dtp->u.p.item_count); generate_error (&dtp->common, ERROR_READ_VALUE, message); @@ -1085,6 +1103,11 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length) return m; bad: + + if (nml_bad_return (dtp, c)) + return 0; + + eat_line (dtp); free_saved (dtp); st_sprintf (message, "Bad floating point number for item %d", dtp->u.p.item_count); @@ -1167,9 +1190,10 @@ eol_2: if (nml_bad_return (dtp, c)) return; + eat_line (dtp); + free_saved (dtp); st_sprintf (message, "Bad complex value in item %d of list input", dtp->u.p.item_count); - generate_error (&dtp->common, ERROR_READ_VALUE, message); } @@ -1381,9 +1405,10 @@ read_real (st_parameter_dt *dtp, int length) if (nml_bad_return (dtp, c)) return; + eat_line (dtp); + free_saved (dtp); st_sprintf (message, "Bad real number in item %d of list input", dtp->u.p.item_count); - generate_error (&dtp->common, ERROR_READ_VALUE, message); } |