Commit df3c4c81 by Jerry DeLisle

re PR fortran/24268 (gfortran rejects valid format statement)

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

	PR fortran/24268
	* io.c (next_char_not_space): New function that returns the next
	character that is not white space.
	(format_lex): Use the new function to skip whitespace within
	a format string.

From-SVN: r109402
parent 1058a848
2006-01-01 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/24268
* io.c (next_char_not_space): New function that returns the next
character that is not white space.
(format_lex): Use the new function to skip whitespace within
a format string.
2006-01-05 Erik Edelmann <eedelman@gcc.gnu.org> 2006-01-05 Erik Edelmann <eedelman@gcc.gnu.org>
PR fortran/23675 PR fortran/23675
......
...@@ -154,6 +154,20 @@ unget_char (void) ...@@ -154,6 +154,20 @@ unget_char (void)
use_last_char = 1; use_last_char = 1;
} }
/* Eat up the spaces and return a character. */
static char
next_char_not_space(void)
{
char c;
do
{
c = next_char (0);
}
while (gfc_is_whitespace (c));
return c;
}
static int value = 0; static int value = 0;
/* Simple lexical analyzer for getting the next token in a FORMAT /* Simple lexical analyzer for getting the next token in a FORMAT
...@@ -174,11 +188,7 @@ format_lex (void) ...@@ -174,11 +188,7 @@ format_lex (void)
return token; return token;
} }
do c = next_char_not_space ();
{
c = next_char (0);
}
while (gfc_is_whitespace (c));
negative_flag = 0; negative_flag = 0;
switch (c) switch (c)
...@@ -186,7 +196,7 @@ format_lex (void) ...@@ -186,7 +196,7 @@ format_lex (void)
case '-': case '-':
negative_flag = 1; negative_flag = 1;
case '+': case '+':
c = next_char (0); c = next_char_not_space ();
if (!ISDIGIT (c)) if (!ISDIGIT (c))
{ {
token = FMT_UNKNOWN; token = FMT_UNKNOWN;
...@@ -197,7 +207,7 @@ format_lex (void) ...@@ -197,7 +207,7 @@ format_lex (void)
do do
{ {
c = next_char (0); c = next_char_not_space ();
if(ISDIGIT (c)) if(ISDIGIT (c))
value = 10 * value + c - '0'; value = 10 * value + c - '0';
} }
...@@ -227,13 +237,13 @@ format_lex (void) ...@@ -227,13 +237,13 @@ format_lex (void)
do do
{ {
c = next_char (0); c = next_char_not_space ();
if (c != '0') if (c != '0')
zflag = 0; zflag = 0;
if (ISDIGIT (c)) if (ISDIGIT (c))
value = 10 * value + c - '0'; value = 10 * value + c - '0';
} }
while (ISDIGIT (c) || gfc_is_whitespace(c)); while (ISDIGIT (c));
unget_char (); unget_char ();
token = zflag ? FMT_ZERO : FMT_POSINT; token = zflag ? FMT_ZERO : FMT_POSINT;
...@@ -260,7 +270,7 @@ format_lex (void) ...@@ -260,7 +270,7 @@ format_lex (void)
break; break;
case 'T': case 'T':
c = next_char (0); c = next_char_not_space ();
if (c != 'L' && c != 'R') if (c != 'L' && c != 'R')
unget_char (); unget_char ();
...@@ -280,7 +290,7 @@ format_lex (void) ...@@ -280,7 +290,7 @@ format_lex (void)
break; break;
case 'S': case 'S':
c = next_char (0); c = next_char_not_space ();
if (c != 'P' && c != 'S') if (c != 'P' && c != 'S')
unget_char (); unget_char ();
...@@ -288,7 +298,7 @@ format_lex (void) ...@@ -288,7 +298,7 @@ format_lex (void)
break; break;
case 'B': case 'B':
c = next_char (0); c = next_char_not_space ();
if (c == 'N' || c == 'Z') if (c == 'N' || c == 'Z')
token = FMT_BLANK; token = FMT_BLANK;
else else
...@@ -350,7 +360,7 @@ format_lex (void) ...@@ -350,7 +360,7 @@ format_lex (void)
break; break;
case 'E': case 'E':
c = next_char (0); c = next_char_not_space ();
if (c == 'N' || c == 'S') if (c == 'N' || c == 'S')
token = FMT_EXT; token = FMT_EXT;
else else
......
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