strbuf: add strbuf_addbuf_percentquote
This is handy for creating strings which will be fed to printf() or strbuf_expand(). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
0a0416a34a
commit
361df5df77
11
strbuf.c
11
strbuf.c
@ -257,6 +257,17 @@ size_t strbuf_expand_dict_cb(struct strbuf *sb, const char *placeholder,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void strbuf_addbuf_percentquote(struct strbuf *dst, const struct strbuf *src)
|
||||
{
|
||||
int i, len = src->len;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (src->buf[i] == '%')
|
||||
strbuf_addch(dst, '%');
|
||||
strbuf_addch(dst, src->buf[i]);
|
||||
}
|
||||
}
|
||||
|
||||
size_t strbuf_fread(struct strbuf *sb, size_t size, FILE *f)
|
||||
{
|
||||
size_t res;
|
||||
|
Reference in New Issue
Block a user