quote: simplify internals of dequoting
Our sq_dequote_to_argv_internal() helper was wrapped by the to_argv() and to_strvec() forms. Now that we have only the latter, we can stop wrapping it and drop the argv-only bits. Note that in theory sq_dequote_to_strvec() could take a const input string, which would be friendlier to its callers. We couldn't do that with the to_argv() form because it reused the input string to hold the output elements. But since we're built on sq_dequote_step(), which munges the input, we'd have to rework the parser. Since no callers care about it currently, we'll leave that for another day. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
May 18, 2026 at 21:20 UTC
b56ab270aab71168ab7d0731f0a3853dac7aa62f
1 file changed
+2
-14
quote.c
+2
-14
@@ -171,9 +171,7 @@ char *sq_dequote(char *arg)
171
return sq_dequote_step(arg, NULL);
172
}
173
174
-static int sq_dequote_to_argv_internal(char *arg,
175
- const char ***argv, int *nr, int *alloc,
176
- struct strvec *array)
174
+int sq_dequote_to_strvec(char *arg, struct strvec *array)
175
{
176
char *next = arg;
177
@@ -191,22 +189,12 @@ static int sq_dequote_to_argv_internal(char *arg,
189
c = *++next;
190
} while (isspace(c));
191
}
194
- if (argv) {
195
- ALLOC_GROW(*argv, *nr + 1, *alloc);
196
- (*argv)[(*nr)++] = dequoted;
197
- }
198
- if (array)
199
- strvec_push(array, dequoted);
192
+ strvec_push(array, dequoted);
193
} while (next);
194
195
return 0;
196
}
197
205
-int sq_dequote_to_strvec(char *arg, struct strvec *array)
206
-{
207
- return sq_dequote_to_argv_internal(arg, NULL, NULL, NULL, array);
208
-}
209
-
198
/* 1 means: quote as octal
199
* 0 means: quote as octal if (quote_path_fully)
200
* -1 means: never quote