Im trying to achive string parsing between 2 files, about 70 to 80 percent of the files are exactly the same but theres thoes little diffrences between them, i was searching them by hand in a hex editor and that got old pretty fast considering i couldnt pay attention to the minor details between boath files. Now i came up with an idea to use a microsoft word document to show the diffrences between files, for instance, if one file has a diffrence it will highlite boath diffrences in red, i know how to achive that in the word file format, but i cant seem to get off the ground with the file handling, Note: i have searched the fourms for an hour or two before posting, seems every one i viewed told the person to search the fourms, any sugestions and/or links will be greatly appreciated.
Posted on 2003-09-27 06:38:30 by EvanderCrovax
Posted on 2003-09-27 08:46:55 by lingo12
That doesnt help me.
Posted on 2003-09-27 09:27:22 by EvanderCrovax
http://sourceforge.net/projects/winmerge/

another diff tool, but with sources.....



ok, what you need do (in my point of view) is:

have a structure, that hold:

the characters of the line
a mark (that first is 0), then will be unchanged, inserted, deleted
the direction of the next structure next line



read the two files, and do two list, initializing mark to 0.

compare the two list, then comes the thing, where the text is inserted or deleted...

ok, is the same in principle, for example:

----- deleted lines
first file


hola
mundo
mundo
.

second file


hola
mundo
. <--------diference

---inserted lines
first file


hola
mundo
mundo
.

second file


hola
mundo
mundo
como estas <---------- diference
.



See that both cases will start in the third line ( where the next is diferent), but how to diferentiate if is inserted text or deleted?, maybe puting a mark and checking for inserted text (search the line of the first file that contain the .) if is finded, you need mark this section like inserted (in the second list), and in the other case, search for the line (in the second file), and do the same operation, and in the case, mark like deleted.

first file


hola
mundo
mundo
.
adios

second file


pero
que
paso
en
esta parte
.
adios

The first line 'hola' is not in the second list, then search for it to the end, is not finded, then mark that line like deleted, but this like you see, will need check each line, you can try instead of triying this like lines, try manipulating like blocks, for example, fhe first line 'hola, is not in the second list, then see the next line of first list 'mundo', is to not in second list, the same with the next, but with the line '.' you have at the end of second list, then you can mark the first three lines of the first file like deleted, and the first 5 lines of the second list like inserted (two birds with one shoot).


I am playing with the ideas, maybe another way can be have a list of the first file and second, and have a like a binary tree for the comparitions, then the left side, is the lines deleted, and the right are the inserted, if at the end, the binary tree is nill, then you have not modifications....., this can be easy, in the way of delete the left or right side of comparations.

That are my first shoots ;)... i dont think are good, but let me try later....

nice day.
Posted on 2003-09-27 15:22:57 by rea
what i need seems simple enough, ive got 14 sets of 4 charictors (hex values) what i need to do first is selectively space this from within the file, Count 4 charictors Insert a space charictor and repeat that 14 times, then insert the text \par.. (enter for microsoft word) at the end of the string now i need to do that for boath files. once one line has been inserted, i need to throw throw a line in from the other file (count 4 insert space 14 times then insert \par..)and insert an extra \par.. to seperate the lines, while thats happening (and this is where i get confused) i need to compair each of them to eachother and if they are diffrent insert \cf1 (red color) before boath charictors and \ after each charictor i dont have any idea how i would achive compairing them togeather because during manipulation only one string is loaded, probably what i will have to do is manipulate all of the strings from boath files, and then begin to compair the 2
Posted on 2003-09-28 04:39:22 by EvanderCrovax
okay i have a better question here, Can i load up boath files at once and parse one, store it somewhere, parse another, store it somewhere then compair each of them aganst eachother virtualy, if so how would i achive that?
Posted on 2003-09-28 08:14:32 by EvanderCrovax