summaryrefslogtreecommitdiff
path: root/strbuf.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2010-01-13 12:36:42 -0500
committerJunio C Hamano <gitster@pobox.com>2010-01-14 09:25:15 -0800
commit361df5df77255321b2ca409d892b4c24b7b0441d (patch)
treef4896a9a959d1a026cccb01aa6568c4522e8278c /strbuf.c
parent0a0416a34a7ef5c64f4e0226371e4cab8c1ba982 (diff)
downloadgit-361df5df77255321b2ca409d892b4c24b7b0441d.tar.gz
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>
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/strbuf.c b/strbuf.c
index 6cbc1fcfd8..af9130e52d 100644
--- a/strbuf.c
+++ b/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;