Searching a code segment from a file

137 Views Asked by At

I am trying to achieve searching for bug fixes available on certain code repository. All I have is individual fix's code . I need to come up with an executable which can parse the entire file and can establish whether the fix is available or not based on comparison of fix's code in entire file the fix is intended. I need some suggestions algorithm to implement this pattern matching exercise which would be conditional in nature.

1

There are 1 best solutions below

2
On

Given the fix, I assume you can characterize it as a delta: the programmer made this change in that place/text in a file. (If you don't have that, you can get it from diff-like tools applied to the before-and-after files (see my Bio for a smart one).

Then you want to hunt for that text. You can do this with a regular expression probably fairly well, at least if the change is significant in size.

You're likely to have to show the matches to the user to vet them, since the search/match process is heuristic.