running Indent twice produces different output

David Bremner <[email protected]> Mon, 28 Oct 2024 13:34:29 -0700
Newsgroups gmane.comp.gnu.indent.bugs
Message-ID <CABkLCaG+eGLvtaNJV261ZjnoURP236N+rSUjQGzVXk55BAftSw@mail.gmail.com>
--000000000000ff13f606258f6504
Content-Type: text/plain; charset="UTF-8"

To whom it may concern,

Thanks for GNU Indent! I've found it quite helpful for my projects.

I recently came across a source file where running Indent twice
produces different output.
The first pass makes a change and the second pass reverts it.
I'm using version 2.2.13 on macOS; it's installed through Homebrew.

The attached file is a reduced test case from the Gofer Haskell
(https://github.com/haskell-implementations/gofer) implementation.that
exhibits this behavior. The original code is a hash table lookup and
fairly convoluted. I've removed or replaced as much of the logic as
possible, so the code in the test case doesn't make a lot of sense. It
is, however, compilable C.

Steps to Reproduce:
1. Save the attached file to your computer.
2. Run Indent as "indent -kr -i4 -nut testcase.c -o once.c".
The output file will have the break on line 13 merged with line 12.
3. Run Indent as "indent -kr -i4 -nut once.c -o twice.c"
The output file will have the break on line 12 split to line 13 again.
4. Run Diff on "diff testcase.c twice.c"
No output will appear because the two files are identical.

Hopefully the above makes sense; Please let me know if you have any
questions about this issue.

Regards,
David Bremner

--000000000000ff13f606258f6504
Content-Type: application/octet-stream; name="testcase.c"
Content-Disposition: attachment; filename="testcase.c"
Content-Transfer-Encoding: base64
Content-ID: <f_m2th8e6z0>
X-Attachment-Id: f_m2th8e6z0

dm9pZCBmaW5kVGV4dCh2b2lkKQp7CiAgICBpbnQgdGV4dFBvcyA9IDA7CiNkZWZpbmUgVHJ5TWF0
Y2gJe30KI2RlZmluZSBTa2lwCQl7fQoKICAgIHdoaWxlICh0ZXh0UG9zICE9IDApIHsKICAgICAg
ICBUcnlNYXRjaCBpZiAodGV4dFBvcyA8IDApCiAgICAgICAgICAgICB0ZXh0UG9zID0gMDsKICAg
ICAgICBlbHNlIHsKICAgICAgICAgICAgU2tpcCB3aGlsZSAodGV4dFBvcyA8IDApIHsKICAgICAg
ICAgICAgVHJ5TWF0Y2ggU2tpcH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgfQp9
Cg==
--000000000000ff13f606258f6504--