Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Function to compare two scripts?

From: greggirwin:mindspring at: 22-Aug-2003 8:35

Hi Sunanda, Sac> Very clever code, but a couple of problems: Sac> First, it gets confused by completely different strings, Guess I need to revisit that. :) Thanks. Sac> ...or case differences: If you compare strings, by byte, case will matter because each item in the series is char that it's comparing. I figured mine wouldn't work out of the box for you, since there's no UI and the output format was designed so you could just DO it to apply diff patches. You should be able to build a front end for it though. Check out Volker's stuff (if he's published it); that may work for you. Sac> I've taken a look at your code, but I can't see any obvious way Sac> to morph it into something that reports differences by lines. All you have to do is give it blocks of lines to compare. It compares two series element by element, it doesn't parse strings into lines for you automatically. version-1: parse/all { rebol [ name: "fred" title: "test script" ] print "test" haltt} "^/" version-2: parse/all { REBOL [ name: "fred" title: "test script" history: [21-aug-2003 "Fixed exit problem"] halt} "^/"
>> diff/create version-2 version-1
== [ change/part at result 5 [{ history: [21-aug-2003 "Fixed exit problem"]}] 1 append clear at result 7 ["halt"]] So, it's still not human-friendly output or, even better, a side-by-side display, but not entirely useless in some cases. -- Gregg