utf8.c: remove strbuf_write()
The patch before the previous one made sure that all callers of strbuf_add_wrapped_text() supply a strbuf. Replace all calls of strbuf_write() with regular strbuf functions and remove it. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
3c0ff44a1e
commit
68ad5e1e9c
18
utf8.c
18
utf8.c
@ -280,14 +280,6 @@ int is_utf8(const char *text)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void strbuf_write(struct strbuf *sb, const char *buf, int len)
|
|
||||||
{
|
|
||||||
if (sb)
|
|
||||||
strbuf_insert(sb, sb->len, buf, len);
|
|
||||||
else
|
|
||||||
fwrite(buf, len, 1, stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void strbuf_addchars(struct strbuf *sb, int c, size_t n)
|
static void strbuf_addchars(struct strbuf *sb, int c, size_t n)
|
||||||
{
|
{
|
||||||
strbuf_grow(sb, n);
|
strbuf_grow(sb, n);
|
||||||
@ -305,7 +297,7 @@ static void strbuf_add_indented_text(struct strbuf *buf, const char *text,
|
|||||||
if (*eol == '\n')
|
if (*eol == '\n')
|
||||||
eol++;
|
eol++;
|
||||||
strbuf_addchars(buf, ' ', indent);
|
strbuf_addchars(buf, ' ', indent);
|
||||||
strbuf_write(buf, text, eol - text);
|
strbuf_add(buf, text, eol - text);
|
||||||
text = eol;
|
text = eol;
|
||||||
indent = indent2;
|
indent = indent2;
|
||||||
}
|
}
|
||||||
@ -364,7 +356,7 @@ int strbuf_add_wrapped_text(struct strbuf *buf,
|
|||||||
start = space;
|
start = space;
|
||||||
else
|
else
|
||||||
strbuf_addchars(buf, ' ', indent);
|
strbuf_addchars(buf, ' ', indent);
|
||||||
strbuf_write(buf, start, text - start);
|
strbuf_add(buf, start, text - start);
|
||||||
if (!c)
|
if (!c)
|
||||||
return w;
|
return w;
|
||||||
space = text;
|
space = text;
|
||||||
@ -373,20 +365,20 @@ int strbuf_add_wrapped_text(struct strbuf *buf,
|
|||||||
else if (c == '\n') {
|
else if (c == '\n') {
|
||||||
space++;
|
space++;
|
||||||
if (*space == '\n') {
|
if (*space == '\n') {
|
||||||
strbuf_write(buf, "\n", 1);
|
strbuf_addch(buf, '\n');
|
||||||
goto new_line;
|
goto new_line;
|
||||||
}
|
}
|
||||||
else if (!isalnum(*space))
|
else if (!isalnum(*space))
|
||||||
goto new_line;
|
goto new_line;
|
||||||
else
|
else
|
||||||
strbuf_write(buf, " ", 1);
|
strbuf_addch(buf, ' ');
|
||||||
}
|
}
|
||||||
w++;
|
w++;
|
||||||
text++;
|
text++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
new_line:
|
new_line:
|
||||||
strbuf_write(buf, "\n", 1);
|
strbuf_addch(buf, '\n');
|
||||||
text = bol = space + isspace(*space);
|
text = bol = space + isspace(*space);
|
||||||
space = NULL;
|
space = NULL;
|
||||||
w = indent = indent2;
|
w = indent = indent2;
|
||||||
|
Loading…
Reference in New Issue
Block a user