Skip to content

Commit 68ad5e1

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

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

utf8.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,6 @@ int is_utf8(const char *text)
280280
return 1;
281281
}
282282

283-
static inline void strbuf_write(struct strbuf *sb, const char *buf, int len)
284-
{
285-
if (sb)
286-
strbuf_insert(sb, sb->len, buf, len);
287-
else
288-
fwrite(buf, len, 1, stdout);
289-
}
290-
291283
static void strbuf_addchars(struct strbuf *sb, int c, size_t n)
292284
{
293285
strbuf_grow(sb, n);
@@ -305,7 +297,7 @@ static void strbuf_add_indented_text(struct strbuf *buf, const char *text,
305297
if (*eol == '\n')
306298
eol++;
307299
strbuf_addchars(buf, ' ', indent);
308-
strbuf_write(buf, text, eol - text);
300+
strbuf_add(buf, text, eol - text);
309301
text = eol;
310302
indent = indent2;
311303
}
@@ -364,7 +356,7 @@ int strbuf_add_wrapped_text(struct strbuf *buf,
364356
start = space;
365357
else
366358
strbuf_addchars(buf, ' ', indent);
367-
strbuf_write(buf, start, text - start);
359+
strbuf_add(buf, start, text - start);
368360
if (!c)
369361
return w;
370362
space = text;
@@ -373,20 +365,20 @@ int strbuf_add_wrapped_text(struct strbuf *buf,
373365
else if (c == '\n') {
374366
space++;
375367
if (*space == '\n') {
376-
strbuf_write(buf, "\n", 1);
368+
strbuf_addch(buf, '\n');
377369
goto new_line;
378370
}
379371
else if (!isalnum(*space))
380372
goto new_line;
381373
else
382-
strbuf_write(buf, " ", 1);
374+
strbuf_addch(buf, ' ');
383375
}
384376
w++;
385377
text++;
386378
}
387379
else {
388380
new_line:
389-
strbuf_write(buf, "\n", 1);
381+
strbuf_addch(buf, '\n');
390382
text = bol = space + isspace(*space);
391383
space = NULL;
392384
w = indent = indent2;

0 commit comments

Comments
 (0)