Index: source/Interpreter/Args.cpp =================================================================== --- source/Interpreter/Args.cpp +++ source/Interpreter/Args.cpp @@ -196,7 +196,6 @@ // argument "Hello world!") we remember the first quote character // we encounter and use that for the quote character. char first_quote_char = '\0'; - char quote_char = '\0'; bool arg_complete = false; do @@ -226,10 +225,10 @@ break; default: - // Only consider this two-character sequence an escape sequence if we're unquoted and + // Only consider this two-character sequence an escape sequence if // the character after the backslash is a whitelisted escapable character. Otherwise // leave the character sequence untouched. - if (quote_char == '\0' && (nullptr != strchr(k_escapable_characters, arg_end[1]))) + if (nullptr != strchr(k_escapable_characters, arg_end[1])) { arg.append (arg_piece_start, arg_end - arg_piece_start); arg.append (arg_end + 1, 1); @@ -244,33 +243,6 @@ case '"': case '\'': case '`': - // Quote characters - if (quote_char) - { - // We found a quote character while inside a quoted - // character argument. If it matches our current quote - // character, this ends the effect of the quotes. If it - // doesn't we ignore it. - if (quote_char == arg_end[0]) - { - arg.append (arg_piece_start, arg_end - arg_piece_start); - // Clear the quote character and let parsing - // continue (we need to watch for things like: - // "Hello ""World" - // "Hello "World - // "Hello "'World' - // All of which will result in a single argument "Hello World" - quote_char = '\0'; // Note that we are no longer inside quotes - arg_pos = arg_end + 1; // Skip the quote character - arg_piece_start = arg_pos; // Note we are starting from later in the string - } - else - { - // different quote, skip it and keep going - arg_pos = arg_end + 1; - } - } - else { // We found the start of a quote scope. // Make sure there isn't a string that precedes @@ -281,7 +253,7 @@ arg.append (arg_piece_start, arg_end - arg_piece_start); // Enter into a quote scope - quote_char = arg_end[0]; + char quote_char = arg_end[0]; if (first_quote_char == '\0') first_quote_char = quote_char; @@ -292,13 +264,6 @@ // Skip till the next quote character const char *end_quote = ::strchr (arg_piece_start, quote_char); - while (end_quote && end_quote[-1] == '\\') - { - // Don't skip the quote character if it is - // preceded by a '\' character - end_quote = ::strchr (end_quote + 1, quote_char); - } - if (end_quote) { if (end_quote > arg_piece_start) @@ -316,7 +281,6 @@ arg_pos = end_quote + 1; arg_piece_start = arg_pos; } - quote_char = '\0'; } else { @@ -330,21 +294,11 @@ case ' ': case '\t': - if (quote_char) - { - // We are currently processing a quoted character and found - // a space character, skip any spaces and keep trying to find - // the end of the argument. - arg_pos = ::strspn (arg_end, k_space_separators) + arg_end; - } - else - { - // We are not inside any quotes, we just found a space after an - // argument - if (arg_end > arg_piece_start) - arg.append (arg_piece_start, arg_end - arg_piece_start); - arg_complete = true; - } + // We are not inside any quotes, we just found a space after an + // argument + if (arg_end > arg_piece_start) + arg.append (arg_piece_start, arg_end - arg_piece_start); + arg_complete = true; break; } } while (!arg_complete);