Thread: "diff" for reformatted code

  1. #1
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297

    "diff" for reformatted code

    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?
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    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?
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  3. #3
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681

  4. #4
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    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/Soft...8580/Meld.html

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > 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).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    Quote Originally Posted by SilentStrike
    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.
    Quote Originally Posted by Salem
    > 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. Oh well.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  7. #7
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    Thanks for the links. I'll check em out.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 10:20 AM
  4. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM