Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-06-16 21:07:14 +0400
committerJunio C Hamano <gitster@pobox.com>2014-06-16 21:07:15 +0400
commitb4516df9b88989a175f88aa514a187831631f9f8 (patch)
tree6c699d6b39248593193b1cd9ad5d0430ab4a64ee
parent09e13ad5b0f0689418a723289dca7b3c72d538c4 (diff)
parent88d5a6f6cd1b63e1637027322cdfdbeefe38c3ed (diff)
Merge branch 'jk/daemon-tolower'
* jk/daemon-tolower: daemon/config: factor out duplicate xstrdup_tolower
-rw-r--r--builtin/config.c15
-rw-r--r--daemon.c8
-rw-r--r--strbuf.c13
-rw-r--r--strbuf.h2
4 files changed, 16 insertions, 22 deletions
diff --git a/builtin/config.c b/builtin/config.c
index 5677c942b6..fcd8474701 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -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';
diff --git a/daemon.c b/daemon.c
index eba1255684..f9c63e9613 100644
--- 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)
{
diff --git a/strbuf.c b/strbuf.c
index 4d31567a1a..f5d609a51f 100644
--- 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;
+}
diff --git a/strbuf.h b/strbuf.h
index 39c14cfa38..4de7531c43 100644
--- 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 */