Skip to content

Indenting over multiple #ifdef blocks #177

Description

@Migelo

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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