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>
extern char *strlpart(char *txt, int maxlen);
extern char *strrpart(char *txt, int maxlen);
+extern void strbuf_ensure_end(struct strbuf *sb, char c);
+
extern void cgit_add_ref(struct reflist *list, struct refinfo *ref);
extern void cgit_free_reflist_inner(struct reflist *list);
extern int cgit_refs_cb(const char *refname, const unsigned char *sha1,
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;