git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Move color option parsing out of diff.c and into color.[ch]
Date: Fri, 08 Sep 2006 01:49:20 -0700	[thread overview]
Message-ID: <7vk64eivzj.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <20060908080318.GA3771@coredump.intra.peff.net> (Jeff King's message of "Fri, 8 Sep 2006 04:03:18 -0400")

Jeff King <peff@peff.net> writes:

> +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")?

> +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)").

  reply	other threads:[~2006-09-08  8:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <64c62cc942e872b29d7225999e74a07be586674a.1157610743.git.peff@peff.net>
2006-09-07  6:36 ` [PATCH 3/3] git-commit.sh: convert run_status to a C builtin Jeff King
2006-09-07  9:10   ` Jeff King
2006-09-08  0:20   ` Junio C Hamano
2006-09-08  5:42     ` Jeff King
2006-09-08  5:56       ` Junio C Hamano
2006-09-08  7:34         ` Jeff King
2006-09-08  8:03           ` [PATCH] Move color option parsing out of diff.c and into color.[ch] Jeff King
2006-09-08  8:49             ` Junio C Hamano [this message]
2006-09-08  9:12               ` Jeff King
2006-09-08 21:19                 ` Junio C Hamano

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=7vk64eivzj.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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).