From d2e20e38141c882e46eaa77f172fc2ae37a19d3b Mon Sep 17 00:00:00 2001 From: John Keeping Date: Sun, 7 Apr 2013 14:03:47 +0100 Subject: 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 --- cgit.h | 2 ++ shared.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/cgit.h b/cgit.h index 7619cbb..3e9d55b 100644 --- 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 index 1fa9c99..10be355 100644 --- 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; -- cgit 1.4.1 /diff/bin/gdns?id=2d84c11421144e500d9c579c23c98c8a272a706a&follow=1'>diff
Commit message (Expand)Author
2014-06-30Add CSS Color pluginJune McEnroe
2014-06-30Add Eunuch pluginJune McEnroe
2014-06-30Switch to Hybrid colorschemeJune McEnroe
2014-06-30Plugin cleanupJune McEnroe
2014-06-30Add speeddatingJune McEnroe
2014-06-29Add nrformats settingJune McEnroe
2014-06-28Add multiple cursorsJune McEnroe
2014-06-28Add indent guidesJune McEnroe
2014-06-10Add delimitMateJune McEnroe
2014-05-28Use ~ for home directory in gitconfigJune McEnroe
2014-05-28Add .DS_store to global gitignoreJune McEnroe
2014-05-15Add OS X specific shell configurationsJune McEnroe
2014-04-19Heavily comment .vimrcJune McEnroe
2014-04-19Autocorrect git commandsJune McEnroe
2014-04-19Fix gitprompt for git 1.9.1June McEnroe