Merge branch 'jk/daemon-tolower'
authorJunio C Hamano <gitster@pobox.com>
Mon, 16 Jun 2014 17:07:14 +0000 (10:07 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Jun 2014 17:07:15 +0000 (10:07 -0700)
* jk/daemon-tolower:
daemon/config: factor out duplicate xstrdup_tolower

builtin/config.c
daemon.c
strbuf.c
strbuf.h
index 5677c942b6936f3332b1b4ed12541f45c4228dfb..fcd84747015a3d0a1da048612f5ac119a7e161d1 100644 (file)
@@ -395,19 +395,6 @@ static int urlmatch_collect_fn(const char *var, const char *value, void *cb)
        return 0;
 }
 
-static char *dup_downcase(const char *string)
-{
-       char *result;
-       size_t len, i;
-
-       len = strlen(string);
-       result = xmalloc(len + 1);
-       for (i = 0; i < len; i++)
-               result[i] = tolower(string[i]);
-       result[i] = '\0';
-       return result;
-}
-
 static int get_urlmatch(const char *var, const char *url)
 {
        char *section_tail;
@@ -422,7 +409,7 @@ static int get_urlmatch(const char *var, const char *url)
        if (!url_normalize(url, &config.url))
                die("%s", config.url.err);
 
-       config.section = dup_downcase(var);
+       config.section = xstrdup_tolower(var);
        section_tail = strchr(config.section, '.');
        if (section_tail) {
                *section_tail = '\0';
index eba12556848e975cd6f1a55ae25760823e90cdc8..f9c63e96137aff6b5ae2376af3fca789ff03e975 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -475,14 +475,6 @@ static void make_service_overridable(const char *name, int ena)
        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;
-}
-
 static void parse_host_and_port(char *hostport, char **host,
        char **port)
 {
index 4d31567a1a6a67ae9697816d78da442f87ab5803..f5d609a51f346117ea43db91bb54085e7d0e7192 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -563,3 +563,16 @@ int fprintf_ln(FILE *fp, const char *fmt, ...)
                return -1;
        return ret + 1;
 }
+
+char *xstrdup_tolower(const char *string)
+{
+       char *result;
+       size_t len, i;
+
+       len = strlen(string);
+       result = xmalloc(len + 1);
+       for (i = 0; i < len; i++)
+               result[i] = tolower(string[i]);
+       result[i] = '\0';
+       return result;
+}
index 39c14cfa384c5154abd96899a7c02417295f8555..4de7531c434a0e58006f5bb3ebdb947069ba5a9c 100644 (file)
--- a/strbuf.h
+++ b/strbuf.h
@@ -183,4 +183,6 @@ extern int printf_ln(const char *fmt, ...);
 __attribute__((format (printf,2,3)))
 extern int fprintf_ln(FILE *fp, const char *fmt, ...);
 
+char *xstrdup_tolower(const char *);
+
 #endif /* STRBUF_H */