diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-11-27 19:24:36 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-11-27 19:24:36 -0800 |
commit | 2d2b3fd8485eee6dd238b930f2592535730089a4 (patch) | |
tree | 642dc8866db7840ef247164bee3435cf805ee03e /strbuf.c | |
parent | 14de7393f1eca05c99f785cc2f43281da2c46e9e (diff) | |
parent | 7de1950cb28cee7d6b1e9cdaf22f30ddcdc5bd01 (diff) | |
download | git-2d2b3fd8485eee6dd238b930f2592535730089a4.tar.gz git-2d2b3fd8485eee6dd238b930f2592535730089a4.tar.xz |
Merge branch 'rs/strbuf-expand'
* rs/strbuf-expand:
remove the unused files interpolate.c and interpolate.h
daemon: deglobalize variable 'directory'
daemon: inline fill_in_extra_table_entries()
daemon: use strbuf_expand() instead of interpolate()
merge-recursive: use strbuf_expand() instead of interpolate()
add strbuf_expand_dict_cb(), a helper for simple cases
Diffstat (limited to 'strbuf.c')
-rw-r--r-- | strbuf.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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; |