Skip to content

Commit bb96a2c

Browse files
René Scharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8a3c63e commit bb96a2c

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

builtin-shortlog.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,19 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
301301
return 0;
302302
}
303303

304+
static void add_wrapped_shortlog_msg(struct strbuf *sb, const char *s,
305+
const struct shortlog *log)
306+
{
307+
int col = strbuf_add_wrapped_text(sb, s, log->in1, log->in2, log->wrap);
308+
if (col != log->wrap)
309+
strbuf_addch(sb, '\n');
310+
}
311+
304312
void shortlog_output(struct shortlog *log)
305313
{
306314
int i, j;
315+
struct strbuf sb = STRBUF_INIT;
316+
307317
if (log->sort_by_number)
308318
qsort(log->list.items, log->list.nr, sizeof(struct string_list_item),
309319
compare_by_number);
@@ -318,9 +328,9 @@ void shortlog_output(struct shortlog *log)
318328
const char *msg = onelines->items[j].string;
319329

320330
if (log->wrap_lines) {
321-
int col = print_wrapped_text(msg, log->in1, log->in2, log->wrap);
322-
if (col != log->wrap)
323-
putchar('\n');
331+
strbuf_reset(&sb);
332+
add_wrapped_shortlog_msg(&sb, msg, log);
333+
fwrite(sb.buf, sb.len, 1, stdout);
324334
}
325335
else
326336
printf(" %s\n", msg);
@@ -334,6 +344,7 @@ void shortlog_output(struct shortlog *log)
334344
log->list.items[i].util = NULL;
335345
}
336346

347+
strbuf_release(&sb);
337348
log->list.strdup_strings = 1;
338349
string_list_clear(&log->list, 1);
339350
clear_mailmap(&log->mailmap);

utf8.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -405,11 +405,6 @@ int strbuf_add_wrapped_text(struct strbuf *buf,
405405
}
406406
}
407407

408-
int print_wrapped_text(const char *text, int indent, int indent2, int width)
409-
{
410-
return strbuf_add_wrapped_text(NULL, text, indent, indent2, width);
411-
}
412-
413408
int is_encoding_utf8(const char *name)
414409
{
415410
if (!name)

utf8.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ int utf8_strwidth(const char *string);
99
int is_utf8(const char *text);
1010
int is_encoding_utf8(const char *name);
1111

12-
int print_wrapped_text(const char *text, int indent, int indent2, int len);
1312
int strbuf_add_wrapped_text(struct strbuf *buf,
1413
const char *text, int indent, int indent2, int width);
1514

0 commit comments

Comments
 (0)