Commit ba1defa5 by Richard Guenther Committed by Richard Biener

re PR fortran/14569 ([4.0 only] should not warn about truncated comment lines)

2005-04-15  Richard Guenther  <rguenth@gcc.gnu.org>

	PR fortran/14569
	* gfortran.h (gfc_linebuf): Add truncated field.
	* parse.c (next_statement): Handle warning for truncated
	lines.
	* scanner.c (load_line): Return if line was truncated.
	No longer warn for truncated lines.  Remove unused parameters.
	(load_file): Store load_line return value to linebuf.
	(gfc_error_recovery): Do not advance line at the end.

From-SVN: r98210
parent 472573f9
2005-04-15 Richard Guenther <rguenth@gcc.gnu.org>
PR fortran/14569
* gfortran.h (gfc_linebuf): Add truncated field.
* parse.c (next_statement): Handle warning for truncated
lines.
* scanner.c (load_line): Return if line was truncated.
No longer warn for truncated lines. Remove unused parameters.
(load_file): Store load_line return value to linebuf.
(gfc_error_recovery): Do not advance line at the end.
2005-04-14 Steven G. Kargl <kargls@comcast.net> 2005-04-14 Steven G. Kargl <kargls@comcast.net>
* gfortran.h (gfc_real_info): Add subnormal struct member. * gfortran.h (gfc_real_info): Add subnormal struct member.
......
...@@ -481,6 +481,8 @@ typedef struct gfc_linebuf ...@@ -481,6 +481,8 @@ typedef struct gfc_linebuf
struct gfc_file *file; struct gfc_file *file;
struct gfc_linebuf *next; struct gfc_linebuf *next;
int truncated;
char line[1]; char line[1];
} gfc_linebuf; } gfc_linebuf;
......
...@@ -479,7 +479,13 @@ next_statement (void) ...@@ -479,7 +479,13 @@ next_statement (void)
gfc_buffer_error (1); gfc_buffer_error (1);
if (gfc_at_eol ()) if (gfc_at_eol ())
gfc_advance_line (); {
if (gfc_option.warn_line_truncation
&& gfc_current_locus.lb->truncated)
gfc_warning_now ("Line truncated at %C");
gfc_advance_line ();
}
gfc_skip_comments (); gfc_skip_comments ();
......
...@@ -631,21 +631,17 @@ gfc_error_recovery (void) ...@@ -631,21 +631,17 @@ gfc_error_recovery (void)
if (c == delim) if (c == delim)
break; break;
if (c == '\n') if (c == '\n')
goto done; return;
if (c == '\\') if (c == '\\')
{ {
c = next_char (); c = next_char ();
if (c == '\n') if (c == '\n')
goto done; return;
} }
} }
if (gfc_at_eof ()) if (gfc_at_eof ())
break; break;
} }
done:
if (c == '\n')
gfc_advance_line ();
} }
...@@ -677,12 +673,14 @@ gfc_gobble_whitespace (void) ...@@ -677,12 +673,14 @@ gfc_gobble_whitespace (void)
need be. need be.
In fixed mode, we expand a tab that occurs within the statement In fixed mode, we expand a tab that occurs within the statement
label region to expand to spaces that leave the next character in label region to expand to spaces that leave the next character in
the source region. */ the source region.
load_line returns wether the line was truncated. */
static void static int
load_line (FILE * input, char **pbuf, char *filename, int linenum) load_line (FILE * input, char **pbuf)
{ {
int c, maxlen, i, trunc_flag, preprocessor_flag; int c, maxlen, i, preprocessor_flag;
int trunc_flag = 0;
static int buflen = 0; static int buflen = 0;
char *buffer; char *buffer;
...@@ -767,15 +765,6 @@ load_line (FILE * input, char **pbuf, char *filename, int linenum) ...@@ -767,15 +765,6 @@ load_line (FILE * input, char **pbuf, char *filename, int linenum)
c = fgetc (input); c = fgetc (input);
if (c == '\n' || c == EOF) if (c == '\n' || c == EOF)
break; break;
if (gfc_option.warn_line_truncation
&& trunc_flag
&& !gfc_is_whitespace (c))
{
gfc_warning_now ("%s:%d: Line is being truncated",
filename, linenum);
trunc_flag = 0;
}
} }
ungetc ('\n', input); ungetc ('\n', input);
...@@ -791,6 +780,8 @@ load_line (FILE * input, char **pbuf, char *filename, int linenum) ...@@ -791,6 +780,8 @@ load_line (FILE * input, char **pbuf, char *filename, int linenum)
*buffer++ = ' '; *buffer++ = ' ';
*buffer = '\0'; *buffer = '\0';
return trunc_flag;
} }
...@@ -1034,7 +1025,7 @@ load_file (char *filename, bool initial) ...@@ -1034,7 +1025,7 @@ load_file (char *filename, bool initial)
for (;;) for (;;)
{ {
load_line (input, &line, filename, current_file->line); int trunc = load_line (input, &line);
len = strlen (line); len = strlen (line);
if (feof (input) && len == 0) if (feof (input) && len == 0)
...@@ -1066,6 +1057,7 @@ load_file (char *filename, bool initial) ...@@ -1066,6 +1057,7 @@ load_file (char *filename, bool initial)
b->linenum = current_file->line++; b->linenum = current_file->line++;
#endif #endif
b->file = current_file; b->file = current_file;
b->truncated = trunc;
strcpy (b->line, line); strcpy (b->line, line);
if (line_head == NULL) if (line_head == NULL)
......
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