summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a583971)
raw | patch | inline | side by side (parent: a583971)
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Fri, 26 Dec 2008 10:12:15 +0000 (11:12 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 27 Dec 2008 03:09:56 +0000 (19:09 -0800) |
Add xstrdup_tolower(), a helper to get a lower case copy of a
string, and use it in two cases.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
string, and use it in two cases.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
daemon.c | patch | blob | history |
diff --git a/daemon.c b/daemon.c
index 4468fb9d3513a7071f904717e89e09887f6dbde1..60bf6c743c559676f0c9e0ff8dc6d9a5dfede195 100644 (file)
--- a/daemon.c
+++ b/daemon.c
die("No such service %s", name);
}
+static char *xstrdup_tolower(const char *str)
+{
+ char *p, *dup = xstrdup(str);
+ for (p = dup; *p; p++)
+ *p = tolower(*p);
+ return dup;
+}
+
/*
* Separate the "extra args" information as supplied by the client connection.
*/
char *val;
int vallen;
char *end = extra_args + buflen;
- char *hp;
while (extra_args < end && *extra_args) {
saw_extended_args = 1;
tcp_port = xstrdup(port);
}
free(hostname);
- hostname = xstrdup(host);
+ hostname = xstrdup_tolower(host);
}
/* On to the next one */
}
}
- /*
- * Replace literal host with lowercase-ized hostname.
- */
- hp = hostname;
- if (!hp)
- return;
- for ( ; *hp; hp++)
- *hp = tolower(*hp);
-
/*
* Locate canonical hostname and its IP address.
*/
+ if (hostname) {
#ifndef NO_IPV6
- {
struct addrinfo hints;
struct addrinfo *ai, *ai0;
int gai;
}
freeaddrinfo(ai0);
}
- }
#else
- {
struct hostent *hent;
struct sockaddr_in sa;
char **ap;
canon_hostname = xstrdup(hent->h_name);
free(ip_address);
ip_address = xstrdup(addrbuf);
- }
#endif
+ }
}
char *arg = argv[i];
if (!prefixcmp(arg, "--listen=")) {
- char *p = arg + 9;
- char *ph = listen_addr = xmalloc(strlen(arg + 9) + 1);
- while (*p)
- *ph++ = tolower(*p++);
- *ph = 0;
- continue;
+ listen_addr = xstrdup_tolower(arg + 9);
+ continue;
}
if (!prefixcmp(arg, "--port=")) {
char *end;