Merge branch 'jk/sq-dequote-cleanup'
Code simplification. * jk/sq-dequote-cleanup: quote: simplify internals of dequoting quote: drop sq_dequote_to_argv() quote.h: bump strvec forward declaration to the topmain
commit
a77a640250
21
quote.c
21
quote.c
|
|
@ -171,9 +171,7 @@ char *sq_dequote(char *arg)
|
|||
return sq_dequote_step(arg, NULL);
|
||||
}
|
||||
|
||||
static int sq_dequote_to_argv_internal(char *arg,
|
||||
const char ***argv, int *nr, int *alloc,
|
||||
struct strvec *array)
|
||||
int sq_dequote_to_strvec(char *arg, struct strvec *array)
|
||||
{
|
||||
char *next = arg;
|
||||
|
||||
|
|
@ -191,27 +189,12 @@ static int sq_dequote_to_argv_internal(char *arg,
|
|||
c = *++next;
|
||||
} while (isspace(c));
|
||||
}
|
||||
if (argv) {
|
||||
ALLOC_GROW(*argv, *nr + 1, *alloc);
|
||||
(*argv)[(*nr)++] = dequoted;
|
||||
}
|
||||
if (array)
|
||||
strvec_push(array, dequoted);
|
||||
strvec_push(array, dequoted);
|
||||
} while (next);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sq_dequote_to_argv(char *arg, const char ***argv, int *nr, int *alloc)
|
||||
{
|
||||
return sq_dequote_to_argv_internal(arg, argv, nr, alloc, NULL);
|
||||
}
|
||||
|
||||
int sq_dequote_to_strvec(char *arg, struct strvec *array)
|
||||
{
|
||||
return sq_dequote_to_argv_internal(arg, NULL, NULL, NULL, array);
|
||||
}
|
||||
|
||||
/* 1 means: quote as octal
|
||||
* 0 means: quote as octal if (quote_path_fully)
|
||||
* -1 means: never quote
|
||||
|
|
|
|||
14
quote.h
14
quote.h
|
|
@ -2,6 +2,7 @@
|
|||
#define QUOTE_H
|
||||
|
||||
struct strbuf;
|
||||
struct strvec;
|
||||
|
||||
extern int quote_path_fully;
|
||||
|
||||
|
|
@ -67,17 +68,10 @@ char *sq_dequote_step(char *src, char **next);
|
|||
|
||||
/*
|
||||
* Same as the above, but can be used to unwrap many arguments in the
|
||||
* same string separated by space. Like sq_quote, it works in place,
|
||||
* modifying arg and appending pointers into it to argv.
|
||||
* same string separated by space. The strvec will duplicate and take
|
||||
* ownership of the strings, but note that "arg" is still modified in-place
|
||||
* during parsing.
|
||||
*/
|
||||
int sq_dequote_to_argv(char *arg, const char ***argv, int *nr, int *alloc);
|
||||
|
||||
/*
|
||||
* Same as above, but store the unquoted strings in a strvec. We will
|
||||
* still modify arg in place, but unlike sq_dequote_to_argv, the strvec
|
||||
* will duplicate and take ownership of the strings.
|
||||
*/
|
||||
struct strvec;
|
||||
int sq_dequote_to_strvec(char *arg, struct strvec *);
|
||||
|
||||
int unquote_c_style(struct strbuf *, const char *quoted, const char **endp);
|
||||
|
|
|
|||
Loading…
Reference in New Issue