Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
October 23, 2014, 02:09:08 AM

Pages: [1]   Go Down
  Print  
Author Topic: better file comparison tool  (Read 1341 times)
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5893



« on: September 19, 2007, 01:17:28 PM »

I am working on a "branch" of a popular Open Source package, and need a better tool to compare my latest version with their latest release. Right now I'm using "fc" in Windows (or I could use "diff" in Linux). The problem is that the authors of the package have a rule that all MySQL queries must be written on one line (which could be several thousand bytes long) and that keywords must be lowercase. These absurd conventions make for code that's very difficult to read and understand, so as part of my work I have been splitting up the queries into short lines and capitalizing keywords. There are other places where single lines run on for more than a thousand bytes, and sometimes I split up those too.

What I'm looking for is a file compare tool that can 1) ignore differences in capitalization, and 2) treat any sequence of whitespace (blanks, tabs, newlines) as a single blank. I want it to do a file comparison like fc or diff, but ignore the reformatting and capitalization of MySQL queries. I'm hoping that you folks can recommend something existing (and free) so I don't have to reinvent the wheel and write my own file compare tool. I really don't want to preprocess the code to fold everything to uppercase and squeeze out all whitespace, as that makes it hard to map differences back to the original files. A bonus would be the ability to tell it to ignore <br> vs. <br/> and other such minor differences.

Does anyone know of such a super file comparison tool? If one doesn't exist, any thoughts on whether it would it be worthwhile to take the source to "diff" (it's probably out there somewhere the the depths of GNU-land) and modify it? Hopefully it would only be a minor tweak to get diff to run under Windows. Thanks!
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
TranzNDance
Princess of Naboo
Berserker Poster
*****
Offline Offline

Posts: 11619



WWW
« Reply #1 on: September 19, 2007, 04:06:01 PM »

WinMerge can ignore case. I'm not sure what you meant by requirement #2 but WinMerge can ignore differences in whitespace.
Logged

Grr..!! Luff Ya Grr..!! Luff Ya Grr..!! Luff Ya
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5893



« Reply #2 on: September 20, 2007, 07:48:21 AM »

Thanks for the pointer to WinMerge, Tranz. Unfortunately, according to the documentation, it appears that it can't quite do what I want, which is to ignore line splits.

Original code:
Code:
$query="select field1, field2, field3 from " . TABLE_NAME . " where field4 = '" . $value1 . "' and field5 = '" . $value2 . "' order by field2";

My revision:
Code:
$query="
  SELECT field1,
         field2,
         field3
  FROM " . TABLE_NAME .
  " WHERE field4 = '" . $value1 . "' AND
          field5 = '" . $value2 . "'
  ORDER BY field2";

Much easier to read, understand, and update, but comparison tools won't understand it as "the same".
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
Pages: [1]   Go Up
  Print  
 
Jump to: