From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Git Mailing List <git@vger.kernel.org>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: [PATCH 3/4] utf8.c: remove strbuf_write()
Date: Fri, 19 Feb 2010 23:16:45 +0100 [thread overview]
Message-ID: <4B7F0DCD.6040006@lsrfire.ath.cx> (raw)
In-Reply-To: <4B7F0D08.6040608@lsrfire.ath.cx>
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>
---
utf8.c | 18 +++++-------------
1 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/utf8.c b/utf8.c
index 5146d30..87437b0 100644
--- a/utf8.c
+++ b/utf8.c
@@ -280,14 +280,6 @@ int is_utf8(const char *text)
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)
{
strbuf_grow(sb, n);
@@ -305,7 +297,7 @@ static void strbuf_add_indented_text(struct strbuf *buf, const char *text,
if (*eol == '\n')
eol++;
strbuf_addchars(buf, ' ', indent);
- strbuf_write(buf, text, eol - text);
+ strbuf_add(buf, text, eol - text);
text = eol;
indent = indent2;
}
@@ -364,7 +356,7 @@ int strbuf_add_wrapped_text(struct strbuf *buf,
start = space;
else
strbuf_addchars(buf, ' ', indent);
- strbuf_write(buf, start, text - start);
+ strbuf_add(buf, start, text - start);
if (!c)
return w;
space = text;
@@ -373,20 +365,20 @@ int strbuf_add_wrapped_text(struct strbuf *buf,
else if (c == '\n') {
space++;
if (*space == '\n') {
- strbuf_write(buf, "\n", 1);
+ strbuf_addch(buf, '\n');
goto new_line;
}
else if (!isalnum(*space))
goto new_line;
else
- strbuf_write(buf, " ", 1);
+ strbuf_addch(buf, ' ');
}
w++;
text++;
}
else {
new_line:
- strbuf_write(buf, "\n", 1);
+ strbuf_addch(buf, '\n');
text = bol = space + isspace(*space);
space = NULL;
w = indent = indent2;
--
1.7.0
next prev parent reply other threads:[~2010-02-19 22:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-19 22:13 [PATCH 0/4] utf8.c: strbuf'ify strbuf_add_wrapped_text() René Scharfe
2010-02-19 22:15 ` [PATCH 1/4] utf8.c: remove print_wrapped_text() René Scharfe
2010-02-19 22:15 ` [PATCH 2/4] utf8.c: remove print_spaces() René Scharfe
2010-02-19 22:16 ` René Scharfe [this message]
2010-02-19 22:20 ` [PATCH 4/4] utf8.c: speculatively assume utf-8 in strbuf_add_wrapped_text() René Scharfe
2010-02-20 9:14 ` Johannes Schindelin
2010-02-20 19:22 ` Junio C Hamano
2010-02-20 9:03 ` [PATCH 0/4] utf8.c: strbuf'ify strbuf_add_wrapped_text() Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B7F0DCD.6040006@lsrfire.ath.cx \
--to=rene.scharfe@lsrfire.ath.cx \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).