Skip to content

Conversation

ksromanov
Copy link

@ksromanov ksromanov commented Nov 18, 2022

According to http://fortranwiki.org/fortran/show/Continuation+lines ampersand sign should be placed at column 73 and after, but not at column 72. So that & is ignored in fixed-form and is processed in free-form languages.

This patch fixes old behavior, which sometimes produced lines 73 characters long.

We (D. Beer, R. Hidalgo-Charman and myself) found this bug working on random FORTRAN code autogeneration tool. One of the examples of generated files with too long lines:

.........
      if (- (+ (+ (50 / 38)))) then
        x = + (((y - (z - 48)) * ((z + 62) - z)) + (((- z) * x) / (- x)))
        x = 53
        print *, 24
        print *, + (z - (+ (+ (+ 20))))
        x = + y
        x = + (+ x)
        x = + (42 - (((- 82) / (y - y)) / 45))
        print *, (((- (z / 86)) * ((y + y) - (44 + x))) / (- ((- y) - (-&
     & x)))) - z
        x = + z
      else if (z) then
.........

@RaoulHC RaoulHC requested a review from raehik November 18, 2022 17:20
Copy link
Collaborator

@RaoulHC RaoulHC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I'll let @raehik have a look as well.

@raehik
Copy link
Collaborator

raehik commented Dec 2, 2022

Sorry for the delay in looking at this. Yep, the lookahead I did meant that exactly 73-character lines wouldn't get split. Over-eager splitting doesn't happen here due to newline handling happening earlier. Thanks for the fix and links to docs! Happy to merge.

@raehik raehik merged commit cca921b into camfort:master Dec 2, 2022
@ksromanov ksromanov deleted the fix_73_char_long_lines_in branch December 2, 2022 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants