PDA

View Full Version : "diff" for reformatted code



FillYourBrain
07-15-2004, 10:45 AM
some of you guys actually work in the field so I figure this might not be a bad place to ask.

Here's the deal. I have been working on a compiler port project (Ada). The new compiler has a nasty little habit of reformatting code.

diff can be case insensitive and ignore whitespace, but that's not enough. This compiler causes some things to drop down to the next line as well. needless to say, diff spits out everything of that type as a difference.

has anyone seen a diff utility that understands code to some degree?

SilentStrike
07-17-2004, 10:33 PM
Is there someway that you could reformat either the original or the modified code to use the same coding convention? Something like running indent on the code before diff'ing?

Thantos
07-17-2004, 11:04 PM
Don't know if this'll help but:
http://cboard.cprogramming.com/showthread.php?t=54485&highlight=glint

Perspective
07-18-2004, 09:39 AM
there are a few visual diffs that may help. Meld for example allows you to see the diffed files and move code back and fouth between them.

http://www.icewalkers.com/Linux/Software/518580/Meld.html

Salem
07-18-2004, 09:51 AM
> The new compiler has a nasty little habit of reformatting code.
What - no "leave_my_code_alone" compiler option flag?

Failing that, use "make" to copy all your proper source code to some temp area whilst it is compiled, so the compiler can mess with that copy (which will be deleted shortly anyway) and your proper code is unharmed (and diff-able).

FillYourBrain
07-18-2004, 12:38 PM
Is there someway that you could reformat either the original or the modified code to use the same coding convention? Something like running indent on the code before diff'ing?
If I could run the original stuff through the compiler, it would no doubt work this way, but the original doesn't compile in the new compiler and the major formatting changes happen at a later stage in the compile.

Been through the drill. Very annoying.

> The new compiler has a nasty little habit of reformatting code.
What - no "leave_my_code_alone" compiler option flag?

Failing that, use "make" to copy all your proper source code to some temp area whilst it is compiled, so the compiler can mess with that copy (which will be deleted shortly anyway) and your proper code is unharmed (and diff-able).
I wish there were a leave my code alone flag. Believe me I looked for it. The compiler is called Apex, and is a IBM/Rational product. Big piece of turd if you ask me. But it is what the army wanted.

The make idea is brilliant. If I had done that from the beginning. :rolleyes: Oh well.

FillYourBrain
07-18-2004, 12:38 PM
Thanks for the links. I'll check em out.