On Mon, Aug 08, 2005 at 02:14:42PM -0700, Steve Kargl wrote: >On Mon, Aug 08, 2005 at 09:23:07AM +0200, Bernhard Fischer wrote:
>> + if (gfc_option.fixed_line_length == 72) /* default */ >> + maxlen = GFC_MAX_LINE; >Unless I misunderstand the above, the following > > gfortran -ffixed_line_length=72 test.f90 > >will use GFC_MAX_LINE, which is 132 (not the requested >length of 72). right. Corrected patch attached. gcc-line-length.diff: PR 21302 * gcc/fortran/options.c: initialize fixed_line_length to -1. * gcc/fortran/scanner.c (load_line): default fixed_line_length to GFC_MAX_LINE for FORM_FREE else default to 72. If a line length was given, use it. Perhaps also check that the line-length given is not too big? Something like gcc-line-length-max.diff: * gcc/fortran/options.c: make sure that -ffixed-line-length is less than 1048577. ok? -- Bernhard
Index: gcc/fortran/options.c =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/fortran/options.c,v retrieving revision 1.22 diff -u -p -r1.22 options.c --- gcc/fortran/options.c 25 Jun 2005 00:40:35 -0000 1.22 +++ gcc/fortran/options.c 10 Aug 2005 13:20:22 -0000 @@ -45,7 +45,7 @@ gfc_init_options (unsigned int argc ATTR gfc_option.source = NULL; gfc_option.module_dir = NULL; gfc_option.source_form = FORM_UNKNOWN; - gfc_option.fixed_line_length = 72; + gfc_option.fixed_line_length = -1; gfc_option.max_identifier_length = GFC_MAX_SYMBOL_LEN; gfc_option.verbose = 0; Index: gcc/fortran/scanner.c =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/fortran/scanner.c,v retrieving revision 1.23 diff -u -p -r1.23 scanner.c --- gcc/fortran/scanner.c 9 Aug 2005 08:08:28 -0000 1.23 +++ gcc/fortran/scanner.c 10 Aug 2005 13:20:22 -0000 @@ -690,8 +690,11 @@ load_line (FILE * input, char **pbuf, in char *buffer; /* Determine the maximum allowed line length. */ - if (gfc_current_form == FORM_FREE) - maxlen = GFC_MAX_LINE; + if (gfc_option.fixed_line_length == -1) + if (gfc_current_form == FORM_FREE) + maxlen = GFC_MAX_LINE; + else + maxlen = 72; /* GFC_DEFAULT_LINE */ else maxlen = gfc_option.fixed_line_length;
Index: gcc/fortran/options.c =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/fortran/options.c,v retrieving revision 1.22 diff -u -p -r1.22 options.c --- gcc/fortran/options.c 25 Jun 2005 00:40:35 -0000 1.22 +++ gcc/fortran/options.c 10 Aug 2005 14:51:53 -0000 @@ -289,6 +289,9 @@ gfc_handle_option (size_t scode, const c case OPT_ffixed_line_length_: if (value != 0 && value < 7) gfc_fatal_error ("Fixed line length must be at least seven."); + else + if (value > 1048576) + gfc_fatal_error ("Fixed line length must be at most 1048576."); gfc_option.fixed_line_length = value; break;