]> git.ipfire.org Git - thirdparty/git.git/blobdiff - quote.c
Merge branch 'mz/doc-notes-are-not-anchors'
[thirdparty/git.git] / quote.c
diff --git a/quote.c b/quote.c
index 69f4ca45da2040fd64bf060d574a474359d9b98c..8a3a5e39eb12adff643d8bd2d90d1e625203a2ce 100644 (file)
--- a/quote.c
+++ b/quote.c
@@ -116,7 +116,7 @@ void sq_append_quote_argv_pretty(struct strbuf *dst, const char **argv)
        }
 }
 
-static char *sq_dequote_step(char *arg, char **next)
+char *sq_dequote_step(char *arg, char **next)
 {
        char *dst = arg;
        char *src = arg;
@@ -153,11 +153,8 @@ static char *sq_dequote_step(char *arg, char **next)
                        }
                /* Fallthrough */
                default:
-                       if (!next || !isspace(*src))
+                       if (!next)
                                return NULL;
-                       do {
-                               c = *++src;
-                       } while (isspace(c));
                        *dst = 0;
                        *next = src;
                        return arg;
@@ -182,6 +179,14 @@ static int sq_dequote_to_argv_internal(char *arg,
                char *dequoted = sq_dequote_step(next, &next);
                if (!dequoted)
                        return -1;
+               if (next) {
+                       char c;
+                       if (!isspace(*next))
+                               return -1;
+                       do {
+                               c = *++next;
+                       } while (isspace(c));
+               }
                if (argv) {
                        ALLOC_GROW(*argv, *nr + 1, *alloc);
                        (*argv)[(*nr)++] = dequoted;