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

Indenting over multiple #ifdef blocks #177

Open
Migelo opened this issue Sep 11, 2024 · 0 comments
Open

Indenting over multiple #ifdef blocks #177

Migelo opened this issue Sep 11, 2024 · 0 comments

Comments

@Migelo
Copy link

Migelo commented Sep 11, 2024

Hi!

I have a question about how fprettify handles indentation over multiple #ifdef blocks. Here is a code snippet formatted with.
$ fprettify --whitespace-comma --enable-decl -i 4 debug.f90

program hello
    implicit none
    integer :: i, j, k
    print *, "Hello, World!"

#ifdef THREEDSIM
    do k = 1, 2
        print *, "Hello, World!"
#elif defined(TWODSIM)
        do j = 1, 2
            print *, "Hello, World!"
#else
            do i = 1, 2
                print *, "Hello, World!"
#endif
#ifdef THREEDSIM
            end do
#elif defined(TWODSIM)
        end do
#else
    end do
#endif

end program hello

You can see that subsequent do loops get indented every time, even though neither THREEDSIM nor TWODSIM are defined.

Is there a flag (I tried most of them and failed) that would result in code like this?

program hello
   implicit none
   integer :: i, j, k
   print *, "Hello, World!"

#ifdef THREEDSIM
   do k = 1, 2
      print *, "Hello, World!"
#elif defined(TWODSIM)
   do j = 1, 2
      print *, "Hello, World!"
#else
   do i = 1, 2
      print *, "Hello, World!"
#endif
#ifdef THREEDSIM
   end do
#elif defined(TWODSIM)
   end do
#else
   end do
#endif

end program hello

If not, please point me to the place in fprettify where I should start looking to make this way of formatting code possible.
Thank you!

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