summaryrefslogtreecommitdiff
path: root/strbuf.c
diff options
context:
space:
mode:
authorBrian Gesiak <modocache@gmail.com>2014-04-30 17:58:06 +0900
committerJunio C Hamano <gitster@pobox.com>2014-05-06 15:33:39 -0700
commit3bb55e8aa86f054c081c372b227f723e3aad14c7 (patch)
tree767922f4f740f8f611947626354d48f4f60c7cde /strbuf.c
parentd8779e1e2536bdd024254af14d2c046bba2bbb01 (diff)
downloadgit-3bb55e8aa86f054c081c372b227f723e3aad14c7.tar.gz
strbuf: use _rtrim and _ltrim in strbuf_trim
strbuf_trim() strips whitespace from the end, then the beginning of a strbuf. Those operations are duplicated in strbuf_rtrim() and strbuf_ltrim(). Replace strbuf_trim() implementation with calls to strbuf_rtrim(), then strbuf_ltrim(). Signed-off-by: Brian Gesiak <modocache@gmail.com> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/strbuf.c b/strbuf.c
index ee96dcfb81..4d31567a1a 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -78,15 +78,8 @@ void strbuf_grow(struct strbuf *sb, size_t extra)
void strbuf_trim(struct strbuf *sb)
{
- char *b = sb->buf;
- while (sb->len > 0 && isspace((unsigned char)sb->buf[sb->len - 1]))
- sb->len--;
- while (sb->len > 0 && isspace(*b)) {
- b++;
- sb->len--;
- }
- memmove(sb->buf, b, sb->len);
- sb->buf[sb->len] = '\0';
+ strbuf_rtrim(sb);
+ strbuf_ltrim(sb);
}
void strbuf_rtrim(struct strbuf *sb)
{