This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[patch, fortran] warnings on truncated lines with \r\n line-endings
- From: Daniel Franke <franke dot daniel at gmail dot com>
- To: fortran at gcc dot gnu dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 18 Feb 2009 16:44:20 +0100
- Subject: [patch, fortran] warnings on truncated lines with \r\n line-endings
There's an issue with lines of maximum length and different line-endings:
1. '\n':
$> cat truncwarn.f
print *, 'long text that stops at column 72......................'
end
$> file truncwarn.f
truncwarn.f: ASCII text
$> gfortran-svn -Wall -W truncwarn.f
[no warning]
2. '\r\n'
$> unix2dos truncwarn.f
unix2dos: converting file truncwarn.f to DOS format ...
$> file truncwarn.f
truncwarn.f: ASCII text, with CRLF line terminators
$> gfortran-svn -Wall -W truncwarn.f
truncwarn.f:1.72:
print *, 'long text that stops at column 72......................'
1
Warning: Line truncated at (1)
Attached mini-patch fixes this by skipping the '\r' character without
setting 'trunc_flag'.
I'd claim it's obvious for 4.5, but would it be ok for 4.4 as well?
Regards
Daniel
Index: scanner.c
===================================================================
--- scanner.c (revision 144250)
+++ scanner.c (working copy)
@@ -1469,6 +1469,9 @@ load_line (FILE *input, gfc_char_t **pbu
for (;;)
{
c = getc (input);
+ if (c == '\r')
+ continue;
+
if (c == '\n' || c == EOF)
break;