mirror of
https://git.zx2c4.com/cgit
synced 2025-07-28 22:54:30 +02:00
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>
This commit is contained in:
parent
fd00d2f9d6
commit
d2e20e3814
2 changed files with 8 additions and 0 deletions
6
shared.c
6
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue