@matheusbsbs / matheus-bagliano / commits / bb96a2c900
Fork 0

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>

René Scharfe committed Feb 19, 2010 at 23:15 UTC bb96a2c9005f925b4e80ece0a7cd6230f7f4b43d
3 files changed +14 -9
builtin-shortlog.c
+14 -3
@@ -301,9 +301,19 @@ parse_done:
301 return 0;
302 }
303
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 +
312 void shortlog_output(struct shortlog *log)
313 {
314 int i, j;
315 + struct strbuf sb = STRBUF_INIT;
316 +
317 if (log->sort_by_number)
318 qsort(log->list.items, log->list.nr, sizeof(struct string_list_item),
319 compare_by_number);
@@ -318,9 +328,9 @@ void shortlog_output(struct shortlog *log)
328 const char *msg = onelines->items[j].string;
329
330 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);
334 }
335 else
336 printf(" %s\n", msg);
@@ -334,6 +344,7 @@ void shortlog_output(struct shortlog *log)
344 log->list.items[i].util = NULL;
345 }
346
347 + strbuf_release(&sb);
348 log->list.strdup_strings = 1;
349 string_list_clear(&log->list, 1);
350 clear_mailmap(&log->mailmap);
utf8.c
-5
@@ -405,11 +405,6 @@ new_line:
405 }
406 }
407
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 -
408 int is_encoding_utf8(const char *name)
409 {
410 if (!name)
utf8.h
-1
@@ -9,7 +9,6 @@ int utf8_strwidth(const char *string);
9 int is_utf8(const char *text);
10 int is_encoding_utf8(const char *name);
11
12 -int print_wrapped_text(const char *text, int indent, int indent2, int len);
12 int strbuf_add_wrapped_text(struct strbuf *buf,
13 const char *text, int indent, int indent2, int width);
14