diff options
| author | Junio C Hamano <junkio@cox.net> | 2007-03-02 00:37:12 -0800 |
|---|---|---|
| committer | Junio C Hamano <junkio@cox.net> | 2007-03-02 00:37:12 -0800 |
| commit | 8ab3e1858676b91bf351537b8afd5599c6640e6f (patch) | |
| tree | 65c62d7da49d1c397ee0ae063803c1cb56eb9ac5 /utf8.c | |
| parent | 8b969a5fb5e5891d9ad4c236fd9487c4673bfa2a (diff) | |
| parent | f8493ec09bcdbd616084dcfa6f5b8ca0bbb68acf (diff) | |
| download | git-8ab3e1858676b91bf351537b8afd5599c6640e6f.tar.gz | |
Merge branch 'js/commit-format'
* js/commit-format:
show_date(): rename the "relative" parameter to "mode"
Actually make print_wrapped_text() useful
pretty-formats: add 'format:<string>'
Diffstat (limited to 'utf8.c')
| -rw-r--r-- | utf8.c | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -235,12 +235,19 @@ static void print_spaces(int count) /* * Wrap the text, if necessary. The variable indent is the indent for the * first line, indent2 is the indent for all other lines. + * If indent is negative, assume that already -indent columns have been + * consumed (and no extra indent is necessary for the first line). */ -void print_wrapped_text(const char *text, int indent, int indent2, int width) +int print_wrapped_text(const char *text, int indent, int indent2, int width) { int w = indent, assume_utf8 = is_utf8(text); const char *bol = text, *space = NULL; + if (indent < 0) { + w = -indent; + space = text; + } + for (;;) { char c = *text; if (!c || isspace(c)) { @@ -251,10 +258,9 @@ void print_wrapped_text(const char *text, int indent, int indent2, int width) else print_spaces(indent); fwrite(start, text - start, 1, stdout); - if (!c) { - putchar('\n'); - return; - } else if (c == '\t') + if (!c) + return w; + else if (c == '\t') w |= 0x07; space = text; w++; @@ -275,6 +281,7 @@ void print_wrapped_text(const char *text, int indent, int indent2, int width) text++; } } + return w; } int is_encoding_utf8(const char *name) |
