Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How to know if two files (.c,.h,.cpp) are different content-wise ignoring the comments?

by elef (Friar)
on Feb 13, 2011 at 08:45 UTC ( #887834=note: print w/ replies, xml ) Need Help??


in reply to How to know if two files (.c,.h,.cpp) are different content-wise ignoring the comments?

Another idea would be to run both files through B::Deparse.
That would standardise whitespace, get rid of comments and standardise code structures, too. Perhaps overkill, but it's probably the only way to tell if two files are compiled identically.

Edit: I just saw you mention .cpp, i.e. this is not about perl code, so B::Deparse won't work. The problem I can see with just stripping comments and comparing the files is that even if you strip empty lines, they may have different whitespace within lines that's not relevant to the code but would be picked up by tools like diff.


Comment on Re: How to know if two files (.c,.h,.cpp) are different content-wise ignoring the comments?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://887834]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2014-07-31 05:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (245 votes), past polls