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

Re: [PATCH] sideband: color lines with keyword only

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Dec 3, 2018, 23:34 UTC
Message-ID
<20181203233439.GB157301@google.com>
In-Reply-To
<20181203232353.GA157301@google.com>
Jonathan Nieder wrote:
> Stefan Beller wrote:
Show 13 quoted lines
>>  		/*
>>  		 * Match case insensitively, so we colorize output from existing
>> @@ -95,7 +95,8 @@ static void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n)
>>  		 * messages. We only highlight the word precisely, so
>>  		 * "successful" stays uncolored.
>>  		 */
>> -		if (!strncasecmp(p->keyword, src, len) && !isalnum(src[len])) {
>> +		if (!strncasecmp(p->keyword, src, len) &&
>> +		    (len == n || !isalnum(src[len]))) {
>
> Our custom isalnum treats '\0' as not alphanumeric (sane_ctype[0] ==
> GIT_CNTRL) so this part of the patch is unnecessary.  That said, it's
> good for clarity and defensive programming.
Correction: I am being silly here.  src[len] can be '\0', '\n', or
'\r' --- it's not always '\0'.  And the contract of this function is
that src[len] could be anything.  Thanks for having handled it
correctly. :)
Jonathan
Previous: Jonathan NiederNext: Stefan Beller
Message 3 of 7 in “sideband: color lines with keyword only”
  1. sideband: color lines with keyword onlyStefan Beller, Dec 3, 2018
  2. Jonathan NiederDec 3, 2018
  3. Jonathan NiederDec 3, 2018
  4. Stefan BellerDec 3, 2018
  5. Jonathan NiederDec 3, 2018
  6. Junio C HamanoDec 4, 2018
  7. Han-Wen NienhuysDec 10, 2018

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.