Skip to content

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

Open
@stigh

Description

@stigh

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions