diff options
author | Junio C Hamano <junkio@cox.net> | 2007-02-20 01:53:29 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-02-20 22:03:15 -0800 |
commit | cc44c7655fe2dd0cfb46e841156634fe622df397 (patch) | |
tree | 6829fa96174f857c90e8baf966a2a8c7b924514a /daemon.c | |
parent | cff0302c14522ba7b34265ee39f23e6321a4777d (diff) | |
download | git-cc44c7655fe2dd0cfb46e841156634fe622df397.tar.gz git-cc44c7655fe2dd0cfb46e841156634fe622df397.tar.xz |
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 'daemon.c')
-rw-r--r-- | daemon.c | 32 |
1 files changed, 16 insertions, 16 deletions
@@ -286,7 +286,7 @@ static int service_enabled; static int git_daemon_config(const char *var, const char *value) { - if (!strncmp(var, "daemon.", 7) && + if (!prefixcmp(var, "daemon.") && !strcmp(var + 7, service_looking_at->config_name)) { service_enabled = git_config_bool(var, value); return 0; @@ -562,7 +562,7 @@ static int execute(struct sockaddr *addr) for (i = 0; i < ARRAY_SIZE(daemon_service); i++) { struct daemon_service *s = &(daemon_service[i]); int namelen = strlen(s->name); - if (!strncmp("git-", line, 4) && + if (!(-prefixcmp(line, "git-")) && !strncmp(s->name, line + 4, namelen) && line[namelen + 4] == ' ') { /* @@ -1011,7 +1011,7 @@ int main(int argc, char **argv) for (i = 1; i < argc; i++) { char *arg = argv[i]; - if (!strncmp(arg, "--listen=", 9)) { + if (!prefixcmp(arg, "--listen=")) { char *p = arg + 9; char *ph = listen_addr = xmalloc(strlen(arg + 9) + 1); while (*p) @@ -1019,7 +1019,7 @@ int main(int argc, char **argv) *ph = 0; continue; } - if (!strncmp(arg, "--port=", 7)) { + if (!prefixcmp(arg, "--port=")) { char *end; unsigned long n; n = strtoul(arg+7, &end, 0); @@ -1045,11 +1045,11 @@ int main(int argc, char **argv) export_all_trees = 1; continue; } - if (!strncmp(arg, "--timeout=", 10)) { + if (!prefixcmp(arg, "--timeout=")) { timeout = atoi(arg+10); continue; } - if (!strncmp(arg, "--init-timeout=", 15)) { + if (!prefixcmp(arg, "--init-timeout=")) { init_timeout = atoi(arg+15); continue; } @@ -1057,11 +1057,11 @@ int main(int argc, char **argv) strict_paths = 1; continue; } - if (!strncmp(arg, "--base-path=", 12)) { + if (!prefixcmp(arg, "--base-path=")) { base_path = arg+12; continue; } - if (!strncmp(arg, "--interpolated-path=", 20)) { + if (!prefixcmp(arg, "--interpolated-path=")) { interpolated_path = arg+20; continue; } @@ -1073,11 +1073,11 @@ int main(int argc, char **argv) user_path = ""; continue; } - if (!strncmp(arg, "--user-path=", 12)) { + if (!prefixcmp(arg, "--user-path=")) { user_path = arg + 12; continue; } - if (!strncmp(arg, "--pid-file=", 11)) { + if (!prefixcmp(arg, "--pid-file=")) { pid_file = arg + 11; continue; } @@ -1086,27 +1086,27 @@ int main(int argc, char **argv) log_syslog = 1; continue; } - if (!strncmp(arg, "--user=", 7)) { + if (!prefixcmp(arg, "--user=")) { user_name = arg + 7; continue; } - if (!strncmp(arg, "--group=", 8)) { + if (!prefixcmp(arg, "--group=")) { group_name = arg + 8; continue; } - if (!strncmp(arg, "--enable=", 9)) { + if (!prefixcmp(arg, "--enable=")) { enable_service(arg + 9, 1); continue; } - if (!strncmp(arg, "--disable=", 10)) { + if (!prefixcmp(arg, "--disable=")) { enable_service(arg + 10, 0); continue; } - if (!strncmp(arg, "--allow-override=", 17)) { + if (!prefixcmp(arg, "--allow-override=")) { make_service_overridable(arg + 17, 1); continue; } - if (!strncmp(arg, "--forbid-override=", 18)) { + if (!prefixcmp(arg, "--forbid-override=")) { make_service_overridable(arg + 18, 0); continue; } |