neocgit

a more 'modern' version of cgit
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/neocgit

commit d2e20e38141c882e46eaa77f172fc2ae37a19d3b
parent fd00d2f9d6088223f57006949dc6ce7c36316a79
Author: John Keeping <john@keeping.me.uk>
Date:   Sun,  7 Apr 2013 14:03:47 +0100

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:
Mcgit.h | 2++
Mshared.c | 6++++++
2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/cgit.h b/cgit.h @@ -304,6 +304,8 @@ extern char *ensure_end(const char *str, char c); 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, diff --git a/shared.c b/shared.c @@ -130,6 +130,12 @@ char *ensure_end(const char *str, char c) 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;