Commit cc186345 by Jerry DeLisle

re PR fortran/55818 (Reading a REAL from a file which doesn't end in a new line fails)

2013-01-02  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/55818
	* io/list_read.c (read_real): Do not call hit_eof when EOF can be
	treated as a value separator.
	(parse_real): Likewise.
	(read_logical): Likewise.
	(read_character): Likewise.
	(read_complex): Likewise.

From-SVN: r194809
parent 8c075fb4
2013-01-02 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/55818
* io/list_read.c (read_real): Do not call hit_eof when EOF can be
treated as a value separator.
(parse_real): Likewise.
(read_logical): Likewise.
(read_character): Likewise.
(read_complex): Likewise.
2012-12-27 Jerry DeLisle <jvdelisle@gcc.gnu.org> 2012-12-27 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/48976 PR libfortran/48976
......
/* Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012 /* Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012
2013
Free Software Foundation, Inc. Free Software Foundation, Inc.
Contributed by Andy Vaught Contributed by Andy Vaught
Namelist input contributed by Paul Thomas Namelist input contributed by Paul Thomas
...@@ -697,6 +698,7 @@ read_logical (st_parameter_dt *dtp, int length) ...@@ -697,6 +698,7 @@ read_logical (st_parameter_dt *dtp, int length)
break; break;
CASE_SEPARATORS: CASE_SEPARATORS:
case EOF:
unget_char (dtp, c); unget_char (dtp, c);
eat_separator (dtp); eat_separator (dtp);
return; /* Null value. */ return; /* Null value. */
...@@ -951,6 +953,7 @@ read_character (st_parameter_dt *dtp, int length __attribute__ ((unused))) ...@@ -951,6 +953,7 @@ read_character (st_parameter_dt *dtp, int length __attribute__ ((unused)))
break; break;
CASE_SEPARATORS: CASE_SEPARATORS:
case EOF:
unget_char (dtp, c); /* NULL value. */ unget_char (dtp, c); /* NULL value. */
eat_separator (dtp); eat_separator (dtp);
return; return;
...@@ -975,8 +978,7 @@ read_character (st_parameter_dt *dtp, int length __attribute__ ((unused))) ...@@ -975,8 +978,7 @@ read_character (st_parameter_dt *dtp, int length __attribute__ ((unused)))
for (;;) for (;;)
{ {
if ((c = next_char (dtp)) == EOF) c = next_char (dtp);
goto eof;
switch (c) switch (c)
{ {
CASE_DIGITS: CASE_DIGITS:
...@@ -984,6 +986,7 @@ read_character (st_parameter_dt *dtp, int length __attribute__ ((unused))) ...@@ -984,6 +986,7 @@ read_character (st_parameter_dt *dtp, int length __attribute__ ((unused)))
break; break;
CASE_SEPARATORS: CASE_SEPARATORS:
case EOF:
unget_char (dtp, c); unget_char (dtp, c);
goto done; /* String was only digits! */ goto done; /* String was only digits! */
...@@ -1041,7 +1044,7 @@ read_character (st_parameter_dt *dtp, int length __attribute__ ((unused))) ...@@ -1041,7 +1044,7 @@ read_character (st_parameter_dt *dtp, int length __attribute__ ((unused)))
the string. */ the string. */
if ((c = next_char (dtp)) == EOF) if ((c = next_char (dtp)) == EOF)
goto eof; goto done_eof;
if (c == quote) if (c == quote)
{ {
push_char (dtp, quote); push_char (dtp, quote);
...@@ -1167,6 +1170,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length) ...@@ -1167,6 +1170,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length)
goto exp2; goto exp2;
CASE_SEPARATORS: CASE_SEPARATORS:
case EOF:
goto done; goto done;
default: default:
...@@ -1202,6 +1206,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length) ...@@ -1202,6 +1206,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length)
break; break;
CASE_SEPARATORS: CASE_SEPARATORS:
case EOF:
unget_char (dtp, c); unget_char (dtp, c);
goto done; goto done;
...@@ -1243,7 +1248,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length) ...@@ -1243,7 +1248,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length)
&& ((c = next_char (dtp)) == 'y' || c == 'Y') && ((c = next_char (dtp)) == 'y' || c == 'Y')
&& (c = next_char (dtp)))) && (c = next_char (dtp))))
{ {
if (is_separator (c)) if (is_separator (c) || (c == EOF))
unget_char (dtp, c); unget_char (dtp, c);
push_char (dtp, 'i'); push_char (dtp, 'i');
push_char (dtp, 'n'); push_char (dtp, 'n');
...@@ -1255,7 +1260,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length) ...@@ -1255,7 +1260,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length)
&& ((c = next_char (dtp)) == 'n' || c == 'N') && ((c = next_char (dtp)) == 'n' || c == 'N')
&& (c = next_char (dtp))) && (c = next_char (dtp)))
{ {
if (is_separator (c)) if (is_separator (c) || (c == EOF))
unget_char (dtp, c); unget_char (dtp, c);
push_char (dtp, 'n'); push_char (dtp, 'n');
push_char (dtp, 'a'); push_char (dtp, 'a');
...@@ -1269,7 +1274,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length) ...@@ -1269,7 +1274,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length)
goto bad; goto bad;
c = next_char (dtp); c = next_char (dtp);
if (is_separator (c)) if (is_separator (c) || (c == EOF))
unget_char (dtp, c); unget_char (dtp, c);
} }
goto done_infnan; goto done_infnan;
...@@ -1315,6 +1320,7 @@ read_complex (st_parameter_dt *dtp, void * dest, int kind, size_t size) ...@@ -1315,6 +1320,7 @@ read_complex (st_parameter_dt *dtp, void * dest, int kind, size_t size)
break; break;
CASE_SEPARATORS: CASE_SEPARATORS:
case EOF:
unget_char (dtp, c); unget_char (dtp, c);
eat_separator (dtp); eat_separator (dtp);
return; return;
...@@ -1369,7 +1375,7 @@ eol_4: ...@@ -1369,7 +1375,7 @@ eol_4:
goto bad_complex; goto bad_complex;
c = next_char (dtp); c = next_char (dtp);
if (!is_separator (c)) if (!is_separator (c) && (c != EOF))
goto bad_complex; goto bad_complex;
unget_char (dtp, c); unget_char (dtp, c);
...@@ -1429,6 +1435,7 @@ read_real (st_parameter_dt *dtp, void * dest, int length) ...@@ -1429,6 +1435,7 @@ read_real (st_parameter_dt *dtp, void * dest, int length)
goto got_sign; goto got_sign;
CASE_SEPARATORS: CASE_SEPARATORS:
case EOF:
unget_char (dtp, c); /* Single null. */ unget_char (dtp, c); /* Single null. */
eat_separator (dtp); eat_separator (dtp);
return; return;
...@@ -1484,6 +1491,7 @@ read_real (st_parameter_dt *dtp, void * dest, int length) ...@@ -1484,6 +1491,7 @@ read_real (st_parameter_dt *dtp, void * dest, int length)
goto got_repeat; goto got_repeat;
CASE_SEPARATORS: CASE_SEPARATORS:
case EOF:
if (c != '\n' && c != ',' && c != '\r' && c != ';') if (c != '\n' && c != ',' && c != '\r' && c != ';')
unget_char (dtp, c); unget_char (dtp, c);
goto done; goto done;
...@@ -1612,6 +1620,7 @@ read_real (st_parameter_dt *dtp, void * dest, int length) ...@@ -1612,6 +1620,7 @@ read_real (st_parameter_dt *dtp, void * dest, int length)
break; break;
CASE_SEPARATORS: CASE_SEPARATORS:
case EOF:
goto done; goto done;
default: default:
...@@ -1647,7 +1656,7 @@ read_real (st_parameter_dt *dtp, void * dest, int length) ...@@ -1647,7 +1656,7 @@ read_real (st_parameter_dt *dtp, void * dest, int length)
goto unwind; goto unwind;
c = next_char (dtp); c = next_char (dtp);
l_push_char (dtp, c); l_push_char (dtp, c);
if (!is_separator (c)) if (!is_separator (c) && (c != EOF))
{ {
if (c != 'i' && c != 'I') if (c != 'i' && c != 'I')
goto unwind; goto unwind;
...@@ -1700,7 +1709,7 @@ read_real (st_parameter_dt *dtp, void * dest, int length) ...@@ -1700,7 +1709,7 @@ read_real (st_parameter_dt *dtp, void * dest, int length)
} }
} }
if (!is_separator (c)) if (!is_separator (c) && (c != EOF))
goto unwind; goto unwind;
if (dtp->u.p.namelist_mode) if (dtp->u.p.namelist_mode)
...@@ -2537,16 +2546,16 @@ nml_read_obj (st_parameter_dt *dtp, namelist_info * nl, index_type offset, ...@@ -2537,16 +2546,16 @@ nml_read_obj (st_parameter_dt *dtp, namelist_info * nl, index_type offset,
switch (nl->type) switch (nl->type)
{ {
case BT_INTEGER: case BT_INTEGER:
read_integer (dtp, len); read_integer (dtp, len);
break; break;
case BT_LOGICAL: case BT_LOGICAL:
read_logical (dtp, len); read_logical (dtp, len);
break; break;
case BT_CHARACTER: case BT_CHARACTER:
read_character (dtp, len); read_character (dtp, len);
break; break;
case BT_REAL: case BT_REAL:
/* Need to copy data back from the real location to the temp in order /* Need to copy data back from the real location to the temp in order
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment