Here's an example if in the ./new/file1 doesnt exist keyword like #ifdef __FOO__ paired with #endif which exist in ./old/file1, then apply that to the file1 in ./merged/file1. Or like #include<XXX> in ./old/file1 that also must be applied
and so on.
Another example, there's 1 file contains ridiculous amount of hexa bytecodes which differ here and there
between the ./new/file1 and ./old/file1.
The rules for this is don't apply any bytecode changes ,IOW, keep it that way.
And then one other rule is if in the new/file1 contain new function prototypes which old/file1 don't, keep it that way.
I hope you guys now what I mean.
There are more rules actually, not that many, some are just base on obvious keyword, some are more base on pattern
and then one special case is must input keyword in the middle.
Example:
Now, imagine the above example exist hundreds time,sparsely. But I think ,maybe, I know the pattern of the BULL appearances in old/file1 cause there are same remark/comment in file1 for each section which is very useful I guess to make this automatic. Maybe wrong though. This latter example is tedious if you do it manually. But Thank God this only happen in one file.one line in ./new/file1: abcdefghjiklm 0x1356 one line in ./old/file1: abcdefghijklm BULL((0x1150) one line in new copy of ./merged/file1 must be: abcdefghijklm BULL(0x1356)
Anyway, I think that's all for my explanation. Hope the monks get this clear. This task is challenging enough for me that now I ran out of idea. If perl can't do it, I dont know any tool can do it...well,except human brain.
My current half-idea is , put the rules of keyword/pattern as an array or maybe hash.
and then what ?
Also my previous idea was generate unified diff patch file.
And then edit the patch file, output to 2nd customized patch file. Apply the 2nd patch file.
In short,I have had trouble editing diff file not to mention 'Patch' complain regarding my edited patch file.
And other problem is if in 1 chunk from diff file contains part that need to be applied and need not applied.
BTW,currently my tools are activeperl, Text::Diff pm, and gnuwin32 patch.
I hope 'patch' is the only external util to minimize dependency/app requirement.
So, do you guys have any applicable idea? Or is this attempt-to-automatize thing impossible to be done by machine ? Thanks very much in advance
In reply to Applying diff partially using perl by mhd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |