This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gfortran,patch] Ignore byte order mark at start of file
Tobias Schlüter wrote:
Brooks Moses wrote:
This part assumes that line[1] and line[2] exist. However, line[] is
allocated in load_line as having length maxlen, which is set to
gfc_option.free_line_length if we have free-form source with limited
line lengths, and there is no guarantee that free_line_length is 3 or
higher.
Thus, these should be conditioned on line_len > 2 or 3 as appropriate.
Exactly this point came up in FX and my discussion on IRC :-)
-ffree-line-length < 3 makes no sense because the END statement may not
be continued, and every program unit will have one of them. I wanted to
craft a patch ensuring that restriction tomorrow. Please be my guest if
you want to submit the obvious patch to options.c yourself.
I submitted the attached patch for this. I couldn't figure out a way to
check for fatal errors in the testsuite, so this comes without a
testcase. In this particular instance, I don't think the omission of a
testcase is that much of a problem, but if anybody knows how to add one,
please feel free to do so.
Built, tested and manually verified on i386-darwin.
Cheers,
- Tobi
Index: ChangeLog
===================================================================
--- ChangeLog (revision 124259)
+++ ChangeLog (working copy)
@@ -1,3 +1,8 @@
+2007-04-28 Tobias Schlüter <tobi@gcc.gnu.org>
+
+ * options.c (gfc_handle_option): Ensure requested free form line
+ length is not too small.
+
2007-04-27 Brooks Moses <brooks.moses@codesourcery.com>
* intrinsic.texi (Transfer): Improve documentation.
Index: options.c
===================================================================
--- options.c (revision 124259)
+++ options.c (working copy)
@@ -538,6 +538,8 @@ gfc_handle_option (size_t scode, const c
break;
case OPT_ffree_line_length_:
+ if (value != 0 && value < 4)
+ gfc_fatal_error ("Free line length must be at least three.");
gfc_option.free_line_length = value;
break;