PR libgfortran/25039
* io/io.h: Create a new flag sf_read_comma to control comma
separators in numeric reads.
* io/transfer.c (formatted_transfer_scalar): Initialize the flag.
(read_sf): Check for commas coming in and if the flag is set,
shortcut the read.
* io/read.c (read_a) (read_x): Clear the flag for character reads and
reset it after the reads.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@108271
138bc75d-0d04-0410-961f-
82ee72b054a4
+2005-12-08 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR libgfortran/25039
+ * io/io.h: Create a new flag sf_read_comma to control comma
+ separators in numeric reads.
+ * io/transfer.c (formatted_transfer_scalar): Initialize the flag.
+ (read_sf): Check for commas coming in and if the flag is set,
+ shortcut the read.
+ * io/read.c (read_a) (read_x): Clear the flag for character reads and
+ reset it after the reads.
+
2005-12-04 Francois-Xavier Coudert <coudert@clipper.ens.fr>
* io/format.c: Removing unused code.
to flag read errors and return, so that an attempt can be
made to read a new object name. */
unsigned nml_read_error : 1;
- /* 20 unused bits. */
+ /* A sequential formatted read specific flag used to signal that a
+ character string is being read so don't use commas to shorten a
+ formatted field width. */
+ unsigned sf_read_comma : 1;
+ /* 19 unused bits. */
char last_char;
char nml_delim;
if (w == -1) /* '(A)' edit descriptor */
w = length;
+ dtp->u.p.sf_read_comma = 0;
source = read_block (dtp, &w);
+ dtp->u.p.sf_read_comma = 1;
if (source == NULL)
return;
if (w > length)
&& dtp->u.p.current_unit->bytes_left < n)
n = dtp->u.p.current_unit->bytes_left;
+ dtp->u.p.sf_read_comma = 0;
if (n > 0)
read_block (dtp, &n);
+ dtp->u.p.sf_read_comma = 1;
+
}
dtp->u.p.sf_seen_eor = (crlf ? 2 : 1);
break;
}
+ /* Short circuit the read if a comma is found during numeric input.
+ The flag is set to zero during character reads so that commas in
+ strings are not ignored */
+ if (*q == ',')
+ if (dtp->u.p.sf_read_comma == 1)
+ {
+ notify_std (GFC_STD_GNU, "Comma in formatted numeric read.");
+ *length = n;
+ break;
+ }
n++;
*p++ = *q;
if (dtp->u.p.eor_condition)
return;
+ /* Set this flag so that commas in reads cause the read to complete before
+ the entire field has been read. The next read field will start right after
+ the comma in the stream. (Set to 0 for character reads). */
+ dtp->u.p.sf_read_comma = 1;
+
dtp->u.p.line_buffer = scratch;
for (;;)
{