aboutsummaryrefslogtreecommitdiff
path: root/strbuf.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-11-27 19:24:36 -0800
committerJunio C Hamano <gitster@pobox.com>2008-11-27 19:24:36 -0800
commit2d2b3fd8485eee6dd238b930f2592535730089a4 (patch)
tree642dc8866db7840ef247164bee3435cf805ee03e /strbuf.c
parent14de7393f1eca05c99f785cc2f43281da2c46e9e (diff)
parent7de1950cb28cee7d6b1e9cdaf22f30ddcdc5bd01 (diff)
downloadgit-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.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/strbuf.c b/strbuf.c
index 720737d85..13be67e4d 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;