commit | d2e20e38141c882e46eaa77f172fc2ae37a19d3b | [log] [tgz] |
---|---|---|
author | John Keeping <john@keeping.me.uk> | Sun Apr 07 14:03:47 2013 +0100 |
committer | Jason A. Donenfeld <Jason@zx2c4.com> | Mon Apr 08 16:10:11 2013 +0200 |
tree | 1a1b7ee0bc3c0d6eb9c82f083866d6cfc56af491 | |
parent | fd00d2f9d6088223f57006949dc6ce7c36316a79 [diff] [blame] |
shared.c: add strbuf_ensure_end This is a small helper so that we can easily ensure that a strbuf ends with the specified character. Signed-off-by: John Keeping <john@keeping.me.uk>
diff --git a/shared.c b/shared.c index 1fa9c99..10be355 100644 --- a/shared.c +++ b/shared.c
@@ -130,6 +130,12 @@ return result; } +void strbuf_ensure_end(struct strbuf *sb, char c) +{ + if (!sb->len || sb->buf[sb->len - 1] != c) + strbuf_addch(sb, c); +} + char *strlpart(char *txt, int maxlen) { char *result;