Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not possible to both --disable-whitespace and enable intrinsic case formatting #163

Open
stigh opened this issue Feb 19, 2024 · 0 comments

Comments

@stigh
Copy link

stigh commented Feb 19, 2024

An example can be this example file, for reference called test.f90:

PROGRAM TestModule

  implicit none

  call test()

contains

  subroutine test()

    INTEGER i

    DO i = 1, 2
      print *, i
    ENDDO
  end subroutine

end program TestModule

I expected python3 ./fprettify.py test.f90 --case 1 1 1 1 ----disable-whitespace to set all lower cased intrinsics, but it has no effect at all.

During debugging I found out that this formatting is done in format_single_fline(), and is only called when impose_whitespace is True (!= --disable-whitespace).

Doing the following code change will get my expectations fulfilled:

--- a/fprettify/__init__.py
+++ b/fprettify/__init__.py
@@ -1564,10 +1564,10 @@ def reformat_ffile_combined(infile, outfile, impose_indent=True, indent_size=3,
             if impose_case:
                 f_line = replace_keywords_single_fline(f_line, case_dict)
 
-            if impose_whitespace:
+            if True:
                 lines = format_single_fline(
                     f_line, whitespace, whitespace_dict, linebreak_pos, ampersand_sep,
-                    scope_parser, format_decl, orig_filename, stream.line_nr, auto_format)
+                    scope_parser, format_decl, orig_filename, stream.line_nr, impose_whitespace)
 
                 lines = append_comments(lines, comment_lines, is_special)

Then this is the result of python3 ./fprettify.py test.f90 -d -s --disable-whitespace --case 1 1 1 1

 --- test.f90
+++ test.f90
@@ -1,19 +1,19 @@
-PROGRAM TestModule
+program TestModule
 
   implicit none
 
   call test()
 
 contains
 
   subroutine test()
 
-    INTEGER i
+    integer i
 
-    DO i = 1, 2
+    do i = 1, 2
       print *, i
-    ENDDO
+    enddo
   end subroutine
 
 end program TestModule

The code change above is not a fix that can be committed, since it breaks many test cases.

This was referenced Feb 29, 2024
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

No branches or pull requests

1 participant