I'm using GNU Indent to format some code. I have some lines like this one:

port->N[0].BTR.U = (DIV8(0U)    |
                    TSEG2(0x3U) |
                    TSEG1(0xEU) |
                    SJW(0x3U)   |

That are being formatted to code like this:

port->N[0].BTR.U = (DIV8(0U) | TSEG2(0x3U) | TSEG1(0xEU) | SJW(0x3U) | BRP(0x9U));

I am using the -l80 option that, according to the documentation, should break the line at 80 characters. Here the code was originally shorter than that but after the formatting, the resulting line is beyond the 80 characters! So how is indent violating it's own rule? Also as far as I understand I didn't specify any option for doing this, I mean, taking code from several lines and place it in one single line.

And this is really annoying because I don't want this to be modified. So, does anybody know what command or combination of commands can I use to avoid this?

These are the options I'm already using:

-ndj -nbad -bap -nbc -nbbo -hnl -bl -bli0 -bls -blf -ncdb -nce -cp1 
-ncs -di2 -nfc1 -nfca -hnl -i4 -ip0 -lp -npcs -nprs -psl -saf -sai 
-saw -nsc -nsob -cli4 -cbi0 -nut -nbs -npsl -l80 -c90 -cd90


  • 1
    Can't reproduce. My version of indent (GNU 2.2.9) adds a line break after DIV8(0U) |. – Thomas Erker Sep 8 '15 at 18:23
  • 1
    Also not reproducable with GNU indent 2.2.11. – Thomas Erker Sep 8 '15 at 20:34
  • Are you sure there is nothing hiding in your ~/.indent.pro? – Thomas Erker Sep 8 '15 at 20:46
  • @ThomasErker; I'm not using a .pro file. I'm specifying the commands directly when calling indent. – m4l490n Sep 8 '15 at 20:53
  • Quick thought, can you step through each of the options listed and state how those options would alter the given line? gnu.org/software/indent/manual/indent.html#SEC12 has some remarks on how some of your options might apply. – Freiheit Sep 9 '15 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.