summaryrefslogtreecommitdiff
path: root/http-push.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 /http-push.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 'http-push.c')
-rw-r--r--http-push.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/http-push.c b/http-push.c
index b128c01..eb77c9a 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1060,7 +1060,7 @@ static int fetch_indices(void)
case 'P':
i++;
if (i + 52 < buffer.posn &&
- !strncmp(data + i, " pack-", 6) &&
+ !prefixcmp(data + i, " pack-") &&
!strncmp(data + i + 46, ".pack\n", 6)) {
get_sha1_hex(data + i + 6, sha1);
setup_index(sha1);
@@ -1206,11 +1206,11 @@ static void handle_new_lock_ctx(struct xml_ctx *ctx, int tag_closed)
lock->owner = xmalloc(strlen(ctx->cdata) + 1);
strcpy(lock->owner, ctx->cdata);
} else if (!strcmp(ctx->name, DAV_ACTIVELOCK_TIMEOUT)) {
- if (!strncmp(ctx->cdata, "Second-", 7))
+ if (!prefixcmp(ctx->cdata, "Second-"))
lock->timeout =
strtol(ctx->cdata + 7, NULL, 10);
} else if (!strcmp(ctx->name, DAV_ACTIVELOCK_TOKEN)) {
- if (!strncmp(ctx->cdata, "opaquelocktoken:", 16)) {
+ if (!prefixcmp(ctx->cdata, "opaquelocktoken:")) {
lock->token = xmalloc(strlen(ctx->cdata) - 15);
strcpy(lock->token, ctx->cdata + 16);
}
@@ -2168,7 +2168,7 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)
return;
/* If it's a symref, set the refname; otherwise try for a sha1 */
- if (!strncmp((char *)buffer.buffer, "ref: ", 5)) {
+ if (!prefixcmp((char *)buffer.buffer, "ref: ")) {
*symref = xmalloc(buffer.posn - 5);
strlcpy(*symref, (char *)buffer.buffer + 5, buffer.posn - 5);
} else {