зеркало из https://github.com/microsoft/git.git
Merge branch 'rs/column-use-utf8-strnwidth'
Code cleanup. * rs/column-use-utf8-strnwidth: column: use utf8_strnwidth() to strip out ANSI color escapes
This commit is contained in:
Коммит
3def8ae9a4
13
column.c
13
column.c
|
@ -23,18 +23,7 @@ struct column_data {
|
|||
/* return length of 's' in letters, ANSI escapes stripped */
|
||||
static int item_length(const char *s)
|
||||
{
|
||||
int len, i = 0;
|
||||
struct strbuf str = STRBUF_INIT;
|
||||
|
||||
strbuf_addstr(&str, s);
|
||||
while ((s = strstr(str.buf + i, "\033[")) != NULL) {
|
||||
int len = strspn(s + 2, "0123456789;");
|
||||
i = s - str.buf;
|
||||
strbuf_remove(&str, i, len + 3); /* \033[<len><func char> */
|
||||
}
|
||||
len = utf8_strwidth(str.buf);
|
||||
strbuf_release(&str);
|
||||
return len;
|
||||
return utf8_strnwidth(s, -1, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче