@@ -542,6 +542,7 @@ def inspect_ffile_format(infile, indent_size, orig_filename=None):
542
542
stream = InputStream (infile , orig_filename )
543
543
prev_offset = 0
544
544
first_indent = - 1
545
+ f77_line_nr = 0
545
546
546
547
while 1 :
547
548
f_line , _ , lines = stream .next_fortran_line ()
@@ -560,12 +561,13 @@ def inspect_ffile_format(infile, indent_size, orig_filename=None):
560
561
indents [- 1 ] = indent_size
561
562
prev_offset = offset
562
563
563
- if F77_STYLE .search (f_line ):
564
+ if not num_labels and F77_STYLE .search (f_line ):
564
565
num_labels = True
566
+ f77_line_nr = stream .line_nr
565
567
566
568
modern_fortran = not num_labels
567
569
568
- return indents , first_indent , modern_fortran
570
+ return indents , first_indent , modern_fortran , f77_line_nr
569
571
570
572
571
573
def format_single_fline (f_line , whitespace , linebreak_pos , ampersand_sep ,
@@ -886,13 +888,13 @@ def reformat_ffile(infile, outfile, indent_size=3, whitespace=2,
886
888
orig_filename = infile .name
887
889
888
890
infile .seek (0 )
889
- req_indents , first_indent , modern = inspect_ffile_format (
891
+ req_indents , first_indent , modern , f77_line_nr = inspect_ffile_format (
890
892
infile , indent_size , orig_filename )
891
893
infile .seek (0 )
892
894
893
895
if not modern :
894
896
raise FprettifyParseException (
895
- "fprettify failed because of fixed format or f77 constructs." , orig_filename , 0 )
897
+ "fprettify failed because of fixed format or f77 constructs." , orig_filename , f77_line_nr )
896
898
897
899
# initialization
898
900
indenter = F90Indenter (first_indent , indent_size , orig_filename )
0 commit comments