diff options
author | Jeff King <peff@peff.net> | 2012-04-18 23:10:05 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-04-19 01:16:38 +0200 |
commit | d15bbe1379a12e2d9a5f18f7dc96b38afafc6c5d (patch) | |
tree | 140d766d32778ef23540fde9607032a5bf2206e4 /argv-array.c | |
parent | argv-array: refactor empty_argv initialization (diff) | |
download | git-d15bbe1379a12e2d9a5f18f7dc96b38afafc6c5d.tar.xz git-d15bbe1379a12e2d9a5f18f7dc96b38afafc6c5d.zip |
argv-array: add a new "pushl" method
It can be convenient to push many strings in a single line
(e.g., if you are initializing an array with defaults). This
patch provides a convenience wrapper to allow this.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'argv-array.c')
-rw-r--r-- | argv-array.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/argv-array.c b/argv-array.c index 110a61b93a..0b5f8898a1 100644 --- a/argv-array.c +++ b/argv-array.c @@ -38,6 +38,17 @@ void argv_array_pushf(struct argv_array *array, const char *fmt, ...) argv_array_push_nodup(array, strbuf_detach(&v, NULL)); } +void argv_array_pushl(struct argv_array *array, ...) +{ + va_list ap; + const char *arg; + + va_start(ap, array); + while((arg = va_arg(ap, const char *))) + argv_array_push(array, arg); + va_end(ap); +} + void argv_array_clear(struct argv_array *array) { if (array->argv != empty_argv) { |