diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-10-18 11:40:49 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-10-18 11:40:49 +0900 |
commit | 3def8ae9a4b18f1cb475e0ac3bc6034aaa29741d (patch) | |
tree | fbd87915fa21a35b9f3fea1bad47a486a17fc485 | |
parent | Merge branch 'rs/http-push-simplify' (diff) | |
parent | column: use utf8_strnwidth() to strip out ANSI color escapes (diff) | |
download | tgif-3def8ae9a4b18f1cb475e0ac3bc6034aaa29741d.tar.xz |
Merge branch 'rs/column-use-utf8-strnwidth'
Code cleanup.
* rs/column-use-utf8-strnwidth:
column: use utf8_strnwidth() to strip out ANSI color escapes
-rw-r--r-- | column.c | 13 |
1 files changed, 1 insertions, 12 deletions
@@ -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); } /* |