Junio C Hamano <junkio@xxxxxxx> writes: > This mechanically converts strncmp() to use prefixcmp(), > ... > * This was done by using this script in px.perl > > #!/usr/bin/perl -i.bak -p > if (/strncmp\(([^,]+), "([^\\"]*)", (\d+)\)/ && (length($2) == $3)) { > s|strncmp\(([^,]+), "([^\\"]*)", (\d+)\)|prefixcmp($1, "$2")|; > } > if (/strncmp\("([^\\"]*)", ([^,]+), (\d+)\)/ && (length($1) == $3)) { > s|strncmp\("([^\\"]*)", ([^,]+), (\d+)\)|(-prefixcmp($2, "$1"))|; > } > > and running: > > $ git grep -l strncmp -- '*.c' | xargs perl px.perl Two useless comments to add. (1) Yes, I have seen the "Oh, I lost my data doing this silly thing" thread that mentioned the risk of using xargs ;-). In general, piping output from git commands that give list of paths (e.g. "grep", "ls-files", "diff --name-only" and "ls-tree -r --name-only") to xargs should be a much safer practice, and people should get into the habit of doing so, instead of using "find | xargs". (2) This multi-step "mechanical conversion followed by manual fixup" is a trick I picked up from Linus. The replacement regexp quoted above are designed to be stricter than necessary to catch only the safe conversion target, while accepting false negatives. Doing the conversion this way, I do not have to worry too much about auditing 1800 lines of diff in [PATCH 2/4], as long as I make sure the above regexp is strict enough (although I did look at all 1800 lines of diff before committing this). Manual conversions in later steps do need to be looked at much more carefully than the result of this step, of course. - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html