Re: [PATCH 1/1] general style: replaces memcmp() with starts_with()
- From
Jeff King <peff@peff.net>
- Date
- Mar 18, 2014, 02:41 UTC
- Message-ID
- <20140318024134.GA644@sigill.intra.peff.net>
- In-Reply-To
- <xmqqd2hka0h7.fsf@gitster.dls.corp.google.com>
On Mon, Mar 17, 2014 at 04:07:00PM -0700, Junio C Hamano wrote:
Show 6 quoted lines
> >> > - if (!memcmp(used_atom[at], "color:", 6)) > >> > + if (starts_with(used_atom[at], "color:")) > >> > need_color_reset_at_eol = !!strcmp(used_atom[at], color_reset); > [...] > What if used_atom[at] is not related to color at all? We do not > want to touch the variable.
Thanks, that is what I was missing. It is not "did we find a reset" but "toggle on for a non-reset color, toggle off for a reset".
It could be written with skip_prefix as:
if (skip_prefix(used_atom[at], "color:", &c))
need_color_reset_at_eol = !!strcmp(c, "reset");but I do not think it is particularly important to do so. Sorry for the noise.
-Peff