X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=strbuf.c;h=13be67e4d3e38472adbff019a34e3f5ce9621dd7;hb=9b864e730bda0e028a85387fa568429724582f22;hp=720737d856b694bc5239f0c18af372959c99e744;hpb=f6576f4c0c6fa3b2d979faf28936c09480dedaab;p=thirdparty%2Fgit.git diff --git a/strbuf.c b/strbuf.c index 720737d856..13be67e4d3 100644 --- a/strbuf.c +++ b/strbuf.c @@ -237,6 +237,22 @@ void strbuf_expand(struct strbuf *sb, const char *format, expand_fn_t fn, } } +size_t strbuf_expand_dict_cb(struct strbuf *sb, const char *placeholder, + void *context) +{ + struct strbuf_expand_dict_entry *e = context; + size_t len; + + for (; e->placeholder && (len = strlen(e->placeholder)); e++) { + if (!strncmp(placeholder, e->placeholder, len)) { + if (e->value) + strbuf_addstr(sb, e->value); + return len; + } + } + return 0; +} + size_t strbuf_fread(struct strbuf *sb, size_t size, FILE *f) { size_t res;