1

I am trying to use gnatpp to improve the layout of some ada code, however when reformatting procedure calls it is putting named parameters on the same line, rather than on separate lines as I prefer. The switches I am using are :

gnatpp $(INCLUDES) -A0 -aM -c0 -kL -nD -M128 -rf test.adb

I understand the -A0 should turn off all alignment issues...

Any idea how I am misreading them ?

T.E.D.
  • 44,016
  • 10
  • 73
  • 134
NWS
  • 3,080
  • 1
  • 19
  • 34
  • 1
    I don't mess around with gnatpp, always just using the default settings as invoked by GPS, but after a quick perusal of the User Guide, did you try -A4: "Align => in associations"? Just a guess on my part... – Marc C Jan 12 '11 at 14:17
  • Thanks Marc, I will try that when i next get back to this problem, but my understanding is that the -A0 should not do anything with alignments (and just leave code as is!, not align or unalign parameters!) – NWS Jan 12 '11 at 14:24
  • Right...which is why the suggestion is to try -A4 instead. – T.E.D. Jan 12 '11 at 14:39

1 Answers1

1

I think the language in the alignment options may be confusing you a little.

The docs for the alignment options say:

Programs can be easier to read if certain constructs are vertically aligned. By default all alignments are set ON. Through the -A0 switch you may reset the default to OFF, and then use one or more of the other -An switches to activate alignment for specific constructs.

-A0 Set all alignments to OFF

The thing you have to realise here is that the text is trying to describe what these switches are doing to gnatpp, not to your own source code.

So what you are doing by setting -A0 is not "turning off all alignment issues" in your source code, but rather you are disabling all the code in gnatpp that would otherwise be looking at and fixing up your source code's alignment.

-A0 is effectively you telling gnatpp "please don't touch the alignment of my source code. I like it just the way it is."

Take that -A0 out of there, and see if you like the result better.

T.E.D.
  • 44,016
  • 10
  • 73
  • 134
  • I Have tried all permutations of A0 & A4 and always it gives me an incorrect output - It does Not vertically align the '=>' – NWS Jan 14 '11 at 16:57
  • @NWS - Hmm. Its just aligning the left side of the argument lines then? That may be the best gratpp will do for you. – T.E.D. Jan 14 '11 at 18:40
  • No, it is putting them on the same line : % more main.adb with Wrong; procedure Main is begin Wrong.Xxx (A => 0, B => 1, C =>2, D => 9, E => 6); end Main; % gnatpp -A0 -A4 -pipe main.adb with Wrong; procedure Main is begin Wrong.Xxx (A => 0, b => 1, c => 2, d => 9, e => 6); end Main; – NWS Jan 17 '11 at 09:17
  • Huh. Are those example parameter names? (God I hope so!) The reason I ask is because they are all so short, I can see why it wants to keep them all on the same line. If there were some long ones, it would have to split it up. Then I'd be curious how it did it. – T.E.D. Jan 17 '11 at 14:06
  • Yes they are examples ;) -- im not one to put commercial software up on the web! Yes, if the names are long enough to break the line length constraint it puts enough of them on separate lines, but not so that there is strictly 1 per line, and aligned :( – NWS Jan 18 '11 at 10:48