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

Re: [PATCH] Move color option parsing out of diff.c and into color.[ch]

From
Junio C Hamano <junkio@cox.net>
Date
Sep 8, 2006, 08:49 UTC
Message-ID
<7vk64eivzj.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060908080318.GA3771@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 14 quoted lines
> +static int color_vprintf(const char *color, const char *fmt,
> +		va_list args, const char *trail)
> +{
> +	int r = 0;
> +
> +	if (*color)
> +		r += printf("%s", color);
> +	r += vprintf(fmt, args);
> +	if (trail)
> +		r += printf("%s", trail);
> +	if (*color)
> +		r += printf("%s", COLOR_RESET);
> +	return r;
> +}
Hmm,... don't you mean RESET first and then trail (which is often "\n")?
Show 9 quoted lines
> +int color_printf(const char *color, const char *fmt, ...)
> +{
> +	va_list args;
> +	int r;
> +	va_start(args, fmt);
> +	r = color_vprintf(color, fmt, args, 0);
> +	va_end(args);
> +	return r;
> +}

Please spell NULL not 0 (please do not argue that writing a NULL pointer as integral constant 0 is perfectly valid C -- we all know that. This is not the language-lawyers correctness issue, but ../linux-2.6/Documentation/CodingStyle thing). Using pointer as boolean seems to be Ok style (e.g. "if (trail)" does not have to be written "if (trail == NULL)").

Previous: Jeff KingNext: Jeff King
Message 8 of 10 in “git-commit.sh: convert run_status to a C builtin”
  1. 3/3 git-commit.sh: convert run_status to a C builtinJeff King, Sep 7, 2006
  2. Jeff KingSep 7, 2006
  3. Junio C HamanoSep 8, 2006
  4. Jeff KingSep 8, 2006
  5. Junio C HamanoSep 8, 2006
  6. Jeff KingSep 8, 2006
  7. Move color option parsing out of diff.c and into color.[ch]Jeff King, Sep 8, 2006
  8. Junio C HamanoSep 8, 2006
  9. Jeff KingSep 8, 2006
  10. Junio C HamanoSep 8, 2006

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.