зеркало из https://github.com/microsoft/git.git
utf8.c: remove print_wrapped_text()
strbuf_add_wrapped_text() is called only from print_wrapped_text() without a strbuf (in which case it writes its results to stdout). At its only callsite, supply a strbuf, call strbuf_add_wrapped_text() directly and remove the wrapper function. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
8a3c63e01d
Коммит
bb96a2c900
|
@ -301,9 +301,19 @@ parse_done:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void add_wrapped_shortlog_msg(struct strbuf *sb, const char *s,
|
||||||
|
const struct shortlog *log)
|
||||||
|
{
|
||||||
|
int col = strbuf_add_wrapped_text(sb, s, log->in1, log->in2, log->wrap);
|
||||||
|
if (col != log->wrap)
|
||||||
|
strbuf_addch(sb, '\n');
|
||||||
|
}
|
||||||
|
|
||||||
void shortlog_output(struct shortlog *log)
|
void shortlog_output(struct shortlog *log)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
struct strbuf sb = STRBUF_INIT;
|
||||||
|
|
||||||
if (log->sort_by_number)
|
if (log->sort_by_number)
|
||||||
qsort(log->list.items, log->list.nr, sizeof(struct string_list_item),
|
qsort(log->list.items, log->list.nr, sizeof(struct string_list_item),
|
||||||
compare_by_number);
|
compare_by_number);
|
||||||
|
@ -318,9 +328,9 @@ void shortlog_output(struct shortlog *log)
|
||||||
const char *msg = onelines->items[j].string;
|
const char *msg = onelines->items[j].string;
|
||||||
|
|
||||||
if (log->wrap_lines) {
|
if (log->wrap_lines) {
|
||||||
int col = print_wrapped_text(msg, log->in1, log->in2, log->wrap);
|
strbuf_reset(&sb);
|
||||||
if (col != log->wrap)
|
add_wrapped_shortlog_msg(&sb, msg, log);
|
||||||
putchar('\n');
|
fwrite(sb.buf, sb.len, 1, stdout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf(" %s\n", msg);
|
printf(" %s\n", msg);
|
||||||
|
@ -334,6 +344,7 @@ void shortlog_output(struct shortlog *log)
|
||||||
log->list.items[i].util = NULL;
|
log->list.items[i].util = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strbuf_release(&sb);
|
||||||
log->list.strdup_strings = 1;
|
log->list.strdup_strings = 1;
|
||||||
string_list_clear(&log->list, 1);
|
string_list_clear(&log->list, 1);
|
||||||
clear_mailmap(&log->mailmap);
|
clear_mailmap(&log->mailmap);
|
||||||
|
|
5
utf8.c
5
utf8.c
|
@ -405,11 +405,6 @@ new_line:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int print_wrapped_text(const char *text, int indent, int indent2, int width)
|
|
||||||
{
|
|
||||||
return strbuf_add_wrapped_text(NULL, text, indent, indent2, width);
|
|
||||||
}
|
|
||||||
|
|
||||||
int is_encoding_utf8(const char *name)
|
int is_encoding_utf8(const char *name)
|
||||||
{
|
{
|
||||||
if (!name)
|
if (!name)
|
||||||
|
|
1
utf8.h
1
utf8.h
|
@ -9,7 +9,6 @@ int utf8_strwidth(const char *string);
|
||||||
int is_utf8(const char *text);
|
int is_utf8(const char *text);
|
||||||
int is_encoding_utf8(const char *name);
|
int is_encoding_utf8(const char *name);
|
||||||
|
|
||||||
int print_wrapped_text(const char *text, int indent, int indent2, int len);
|
|
||||||
int strbuf_add_wrapped_text(struct strbuf *buf,
|
int strbuf_add_wrapped_text(struct strbuf *buf,
|
||||||
const char *text, int indent, int indent2, int width);
|
const char *text, int indent, int indent2, int width);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче