git-2.22.0/sideband.c
/*
 * Optionally highlight one keyword in remote output if it appears at the start
 * of the line. This should be called for a single line only, which is
 * passed as the first N characters of the SRC array.
 *
 * NEEDSWORK: use "size_t n" instead for clarity.
 */
Optionally highlight one keyword in remote output if it appears at the start
of the line. This should be called for a single line only, which is
passed as the first N characters of the SRC array.

use "size_t n" instead for clarity.
Optionally highlight one keyword in remote output if it appears at the start of the line . This should be called for a single line only which is passed as the first N characters of the SRC array . use " size_t n " instead for clarity .
static void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n)
{
	int i;
	if (!want_color_stderr(use_sideband_colors())) {
		strbuf_add(dest, src, n);
		return;
	}
	while (0 < n && isspace(*src)) {
		strbuf_addch(dest, *src);
		src++;
		n--;
	}
	for (i = 0; i < ARRAY_SIZE(keywords); i++) {
		struct keyword_entry *p = keywords + i;
		int len = strlen(p->keyword);
		if (n < len)
			continue;
		if (!strncasecmp(p->keyword, src, len) &&
		    (len == n || !isalnum(src[len]))) {
			strbuf_addstr(dest, p->color);
			strbuf_add(dest, src, len);
			strbuf_addstr(dest, GIT_COLOR_RESET);
			n -= len;
			src += len;
			break;
		}
	}
	strbuf_add(dest, src, n);
}
static void maybe_colorize_sideband ( struct strbuf * dest , const char * src , int n ) { int i ; if ( ! want_color_stderr ( use_sideband_colors ( ) ) ) { strbuf_add ( dest , src , n ) ; return ; } while ( 0 < n && isspace ( * src ) ) { strbuf_addch ( dest , * src ) ; src ++ ; n -- ; } for ( i = 0 ; i < ARRAY_SIZE ( keywords ) ; i ++ ) { struct keyword_entry * p = keywords + i ; int len = strlen ( p -> keyword ) ; if ( n < len ) continue ; if ( ! strncasecmp ( p -> keyword , src , len ) && ( len == n || ! isalnum ( src [ len ] ) ) ) { strbuf_addstr ( dest , p -> color ) ; strbuf_add ( dest , src , len ) ; strbuf_addstr ( dest , GIT_COLOR_RESET ) ; n -= len ; src += len ; break ; } } strbuf_add ( dest , src , n ) ; }
Optionally highlight one keyword in remote output if it appears at the start
 of the line.
Optionally highlight one keyword in remote output if it appears at the start of the line .
/*
		 * Match case insensitively, so we colorize output from existing
		 * servers regardless of the case that they use for their
		 * messages. We only highlight the word precisely, so
		 * "successful" stays uncolored.
		 */