git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Couder <chriscool@tuxfamily.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Johan Herland <johan@herland.net>,
	Josh Triplett <josh@joshtriplett.org>,
	Thomas Rast <tr@thomasrast.ch>,
	Michael Haggerty <mhagger@alum.mit.edu>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Greg Kroah-Hartman <greg@kroah.com>, Jeff King <peff@peff.net>,
	Eric Sunshine <sunshine@sunshineco.com>,
	Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Subject: [PATCH v8 03/12] Move lower case functions into wrapper.c
Date: Wed, 26 Mar 2014 23:15:21 +0100	[thread overview]
Message-ID: <20140326221531.11352.86408.chriscool@tuxfamily.org> (raw)
In-Reply-To: <20140326215858.11352.89243.chriscool@tuxfamily.org>

The lowercase() function from config.c and the xstrdup_tolower()
function from daemon.c can benefit from being moved to the same
place because this way the latter can use the former.

Also let's make them available globally so we can use them from
other places like trailer.c.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 config.c          |  6 ------
 daemon.c          |  8 --------
 git-compat-util.h |  4 ++++
 wrapper.c         | 14 ++++++++++++++
 4 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/config.c b/config.c
index 314d8ee..dde128e 100644
--- a/config.c
+++ b/config.c
@@ -146,12 +146,6 @@ int git_config_include(const char *var, const char *value, void *data)
 	return ret;
 }
 
-static void lowercase(char *p)
-{
-	for (; *p; p++)
-		*p = tolower(*p);
-}
-
 void git_config_push_parameter(const char *text)
 {
 	struct strbuf env = STRBUF_INIT;
diff --git a/daemon.c b/daemon.c
index eba1255..f9c63e9 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/git-compat-util.h b/git-compat-util.h
index 614a5e9..2397706 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -727,4 +727,8 @@ void warn_on_inaccessible(const char *path);
 /* Get the passwd entry for the UID of the current process. */
 struct passwd *xgetpwuid_self(void);
 
+/* Lowercase strings */
+extern void lowercase(char *str);
+extern char *xstrdup_tolower(const char *str);
+
 #endif
diff --git a/wrapper.c b/wrapper.c
index 0cc5636..c46026a 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -455,3 +455,17 @@ struct passwd *xgetpwuid_self(void)
 		    errno ? strerror(errno) : _("no such user"));
 	return pw;
 }
+
+void lowercase(char *p)
+{
+	for (; *p; p++)
+		*p = tolower(*p);
+}
+
+char *xstrdup_tolower(const char *str)
+{
+	char *dup = xstrdup(str);
+	lowercase(dup);
+	return dup;
+}
+
-- 
1.9.0.164.g3aa33cd.dirty

  parent reply	other threads:[~2014-03-26 22:16 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-26 22:15 [PATCH v8 00/12] Add interpret-trailers builtin Christian Couder
2014-03-26 22:15 ` [PATCH v8 01/12] Add data structures and basic functions for commit trailers Christian Couder
2014-03-26 23:06   ` Junio C Hamano
2014-03-27  7:55     ` Christian Couder
2014-03-26 22:15 ` [PATCH v8 02/12] trailer: process trailers from stdin and arguments Christian Couder
2014-03-26 22:15 ` Christian Couder [this message]
2014-03-26 23:07   ` [PATCH v8 03/12] Move lower case functions into wrapper.c Junio C Hamano
2014-03-27  7:47     ` Christian Couder
2014-03-27 16:42       ` Junio C Hamano
2014-03-27 22:16         ` Junio C Hamano
2014-03-27 22:34           ` Jeff King
2014-03-27 22:47             ` Junio C Hamano
2014-03-27 22:56               ` Jeff King
2014-03-28 17:12                 ` Junio C Hamano
2014-03-28 18:50                   ` Jeff King
2014-03-28  7:02             ` Christian Couder
2014-03-26 22:15 ` [PATCH v8 04/12] trailer: read and process config information Christian Couder
2014-03-26 22:15 ` [PATCH v8 05/12] trailer: process command line trailer arguments Christian Couder
2014-03-26 22:15 ` [PATCH v8 06/12] trailer: parse trailers from stdin Christian Couder
2014-03-26 22:15 ` [PATCH v8 07/12] trailer: put all the processing together and print Christian Couder
2014-03-26 22:15 ` [PATCH v8 08/12] trailer: add interpret-trailers command Christian Couder
2014-03-26 22:15 ` [PATCH v8 09/12] trailer: add tests for "git interpret-trailers" Christian Couder
2014-03-26 22:15 ` [PATCH v8 10/12] trailer: execute command from 'trailer.<name>.command' Christian Couder
2014-03-26 22:15 ` [PATCH v8 11/12] trailer: add tests for commands in config file Christian Couder
2014-03-26 22:15 ` [PATCH v8 12/12] Documentation: add documentation for 'git interpret-trailers' Christian Couder
2014-03-26 23:05 ` [PATCH v8 00/12] Add interpret-trailers builtin Junio C Hamano
2014-03-27  7:53   ` Christian Couder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140326221531.11352.86408.chriscool@tuxfamily.org \
    --to=chriscool@tuxfamily.org \
    --cc=dan.carpenter@oracle.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=greg@kroah.com \
    --cc=johan@herland.net \
    --cc=josh@joshtriplett.org \
    --cc=mhagger@alum.mit.edu \
    --cc=peff@peff.net \
    --cc=ramsay@ramsay1.demon.co.uk \
    --cc=sunshine@sunshineco.com \
    --cc=tr@thomasrast.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).