summaryrefslogtreecommitdiff
path: root/builtin-rerere.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-02-20 09:53:29 (GMT)
committerJunio C Hamano <junkio@cox.net>2007-02-21 06:03:15 (GMT)
commitcc44c7655fe2dd0cfb46e841156634fe622df397 (patch)
tree6829fa96174f857c90e8baf966a2a8c7b924514a /builtin-rerere.c
parentcff0302c14522ba7b34265ee39f23e6321a4777d (diff)
downloadgit-cc44c7655fe2dd0cfb46e841156634fe622df397.zip
git-cc44c7655fe2dd0cfb46e841156634fe622df397.tar.gz
git-cc44c7655fe2dd0cfb46e841156634fe622df397.tar.bz2
Mechanical conversion to use prefixcmp()
This mechanically converts strncmp() to use prefixcmp(), but only when the parameters match specific patterns, so that they can be verified easily. Leftover from this will be fixed in a separate step, including idiotic conversions like if (!strncmp("foo", arg, 3)) => if (!(-prefixcmp(arg, "foo"))) 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 Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-rerere.c')
-rw-r--r--builtin-rerere.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/builtin-rerere.c b/builtin-rerere.c
index 318d959..978105b 100644
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
@@ -105,11 +105,11 @@ static int handle_file(const char *path,
SHA1_Init(&ctx);
while (fgets(buf, sizeof(buf), f)) {
- if (!strncmp("<<<<<<< ", buf, 8))
+ if (!(-prefixcmp(buf, "<<<<<<< ")))
hunk = 1;
- else if (!strncmp("=======", buf, 7))
+ else if (!(-prefixcmp(buf, "=======")))
hunk = 2;
- else if (!strncmp(">>>>>>> ", buf, 8)) {
+ else if (!(-prefixcmp(buf, ">>>>>>> "))) {
hunk_no++;
hunk = 0;
if (memcmp(one->ptr, two->ptr, one->nr < two->nr ?