summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ebbc088)
raw | patch | inline | side by side (parent: ebbc088)
author | Christian Couder <chriscool@tuxfamily.org> | |
Sun, 29 Mar 2009 09:44:52 +0000 (11:44 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 30 Mar 2009 08:22:53 +0000 (01:22 -0700) |
This new function unwraps the space separated shell quoted elements in
its first argument and places them in the argv array passed as its second
argument.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
its first argument and places them in the argv array passed as its second
argument.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
quote.c | patch | blob | history | |
quote.h | patch | blob | history |
index ea49c7a99fb1fc28f786d53f528addf4dcbf5a02..7a49fcf69671646a0d3ba6de6478cfc6767c31fe 100644 (file)
--- a/quote.c
+++ b/quote.c
return sq_dequote_step(arg, NULL);
}
+int sq_dequote_to_argv(char *arg, const char ***argv, int *nr, int *alloc)
+{
+ char *next = arg;
+
+ if (!*arg)
+ return 0;
+ do {
+ char *dequoted = sq_dequote_step(next, &next);
+ if (!dequoted)
+ return -1;
+ ALLOC_GROW(*argv, *nr + 1, *alloc);
+ (*argv)[(*nr)++] = dequoted;
+ } while (next);
+
+ return 0;
+}
+
/* 1 means: quote as octal
* 0 means: quote as octal if (quote_path_fully)
* -1 means: never quote
index 2315105fa3eae59f6abaf636eec7590c335154b4..66730f2bff3cee42bc7c670e2a6d7da240db1d08 100644 (file)
--- a/quote.h
+++ b/quote.h
* is no more argument to be dequoted, "next" is updated to point to NULL.
*/
extern char *sq_dequote_step(char *arg, char **next);
+extern int sq_dequote_to_argv(char *arg, const char ***argv, int *nr, int *alloc);
extern int unquote_c_style(struct strbuf *, const char *quoted, const char **endp);
extern size_t quote_c_style(const char *name, struct strbuf *, FILE *, int no_dq);