diff options
author | John Keeping | 2013-04-07 14:03:47 +0100 |
---|---|---|
committer | Jason A. Donenfeld | 2013-04-08 16:10:11 +0200 |
commit | d2e20e38141c882e46eaa77f172fc2ae37a19d3b (patch) | |
tree | 1a1b7ee0bc3c0d6eb9c82f083866d6cfc56af491 /shared.c | |
parent | fd00d2f9d6088223f57006949dc6ce7c36316a79 (diff) | |
download | cgit-d2e20e38141c882e46eaa77f172fc2ae37a19d3b.tar.gz cgit-d2e20e38141c882e46eaa77f172fc2ae37a19d3b.tar.bz2 cgit-d2e20e38141c882e46eaa77f172fc2ae37a19d3b.zip |
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>
Diffstat (limited to 'shared.c')
-rw-r--r-- | shared.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -130,6 +130,12 @@ char *ensure_end(const char *str, char c) | |||
130 | return result; | 130 | return result; |
131 | } | 131 | } |
132 | 132 | ||
133 | void strbuf_ensure_end(struct strbuf *sb, char c) | ||
134 | { | ||
135 | if (!sb->len || sb->buf[sb->len - 1] != c) | ||
136 | strbuf_addch(sb, c); | ||
137 | } | ||
138 | |||
133 | char *strlpart(char *txt, int maxlen) | 139 | char *strlpart(char *txt, int maxlen) |
134 | { | 140 | { |
135 | char *result; | 141 | char *result; |