From d4a398fb13ccca1d1a3db735b7e0bf466f991788 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sat, 25 Jun 2022 15:20:40 +0200 Subject: [PATCH] [DISKPART] Support quoted command options in script files --- base/system/diskpart/interpreter.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/base/system/diskpart/interpreter.c b/base/system/diskpart/interpreter.c index 7ba17480605..bc18f9f2402 100644 --- a/base/system/diskpart/interpreter.c +++ b/base/system/diskpart/interpreter.c @@ -185,21 +185,26 @@ InterpretScript(LPWSTR input_line) LPWSTR args_vector[MAX_ARGS_COUNT]; INT args_count = 0; BOOL bWhiteSpace = TRUE; + BOOL bQuote = FALSE; LPWSTR ptr; memset(args_vector, 0, sizeof(args_vector)); + bQuote = FALSE; ptr = input_line; while (*ptr != 0) { - if (iswspace(*ptr) || *ptr == L'\n') + if (*ptr == L'"') + bQuote = !bQuote; + + if ((iswspace(*ptr) && (bQuote == FALSE))|| *ptr == L'\n') { *ptr = 0; bWhiteSpace = TRUE; } else { - if ((bWhiteSpace != FALSE) && (args_count < MAX_ARGS_COUNT)) + if ((bWhiteSpace != FALSE) && (bQuote == FALSE) && (args_count < MAX_ARGS_COUNT)) { args_vector[args_count] = ptr; args_count++;