Skip to content

cpp and continuation lines #72

@hattom

Description

@hattom

I ran two tests in files with cpp style preprocessor statements. In the first (which has been run through fprettify):

program test
   implicit none

   integer ::  a, b, c, e, f, g, h, i

   print *, a, b, c, d, &
#ifdef TEST
      e, f, g, h, i
#else
   e, f, g, h, i
#endif
end program test

you can see, the indentation of the e, f, ...s does not line up.

If the e, f, ... line also has a prepended ampersand, then this gives a parsing error:

$ cat test.F90
program test
   implicit none

   integer ::  a, b, c, e, f, g, h, i

   print *, a, b, c, d, &
#ifdef TEST
      & e, f, g, h, i
#else
   & e, f, g, h, i
#endif
end program test
$ fprettify test.F90 
ERROR: File test.F90, line 8
    Fatal error occured
Traceback (most recent call last):
  File "/home/me/.local/lib/python2.7/site-packages/fprettify/__init__.py", line 1584, in run
    strip_comments=args.strip_comments)
  File "/home/me/.local/lib/python2.7/site-packages/fprettify/__init__.py", line 991, in reformat_inplace
    orig_filename=filename, **kwargs)
  File "/home/me/.local/lib/python2.7/site-packages/fprettify/__init__.py", line 1093, in reformat_ffile
    lines, is_special, orig_filename, stream.line_nr)
  File "/home/me/.local/lib/python2.7/site-packages/fprettify/__init__.py", line 1337, in remove_pre_ampersands
    "Bad continuation line format", filename, line_nr)
FprettifyParseException: Bad continuation line format

I think the latter should be a valid program, although I agree that it's a slightly strange formulation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugnon-critical bug (or with workaround)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions