git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v8 03/12] Move lower case functions into wrapper.c

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 26, 2014, 23:07 UTC
Message-ID
<xmqqppl8ftjd.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20140326221531.11352.86408.chriscool@tuxfamily.org>
Christian Couder <chriscool@tuxfamily.org> writes:
Show 22 quoted lines
> 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;
> +}
> +

As a pure code-movement step, this may be OK, but I am not sure if both of them want to be public functions in this shape.

Perhaps
char *downcase_copy(const char *str)
{
	char *copy = xmalloc(strlen(str) + 1);
        int i;
        for (i = 0; str[i]; i++)
        	copy[i] = tolower(str[i]);
	copy[i] = '\0';
        return copy;
}

may avoid having to copy things twice. Do you need the other function exposed?

Previous: Christian CouderNext: Christian Couder
Message 7 of 27 in “Add interpret-trailers builtin”
  1. 00/12 Add interpret-trailers builtinChristian Couder, Mar 26, 2014
  2. 01/12 Add data structures and basic functions for commit trailersChristian Couder, Mar 26, 2014
  3. Junio C HamanoMar 26, 2014
  4. Christian CouderMar 27, 2014
  5. 02/12 trailer: process trailers from stdin and argumentsChristian Couder, Mar 26, 2014
  6. 03/12 Move lower case functions into wrapper.cChristian Couder, Mar 26, 2014
  7. Junio C HamanoMar 26, 2014
  8. Christian CouderMar 27, 2014
  9. Junio C HamanoMar 27, 2014
  10. Junio C HamanoMar 27, 2014
  11. Jeff KingMar 27, 2014
  12. Junio C HamanoMar 27, 2014
  13. Jeff KingMar 27, 2014
  14. Junio C HamanoMar 28, 2014
  15. Jeff KingMar 28, 2014
  16. Christian CouderMar 28, 2014
  17. 04/12 trailer: read and process config informationChristian Couder, Mar 26, 2014
  18. 05/12 trailer: process command line trailer argumentsChristian Couder, Mar 26, 2014
  19. 06/12 trailer: parse trailers from stdinChristian Couder, Mar 26, 2014
  20. 07/12 trailer: put all the processing together and printChristian Couder, Mar 26, 2014
  21. 08/12 trailer: add interpret-trailers commandChristian Couder, Mar 26, 2014
  22. 09/12 trailer: add tests for "git interpret-trailers"Christian Couder, Mar 26, 2014
  23. 10/12 trailer: execute command from 'trailer.<name>.command'Christian Couder, Mar 26, 2014
  24. 11/12 trailer: add tests for commands in config fileChristian Couder, Mar 26, 2014
  25. 12/12 Documentation: add documentation for 'git interpret-trailers'Christian Couder, Mar 26, 2014
  26. Junio C HamanoMar 26, 2014
  27. Christian CouderMar 27, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.