PragmaTwice commented on code in PR #2873:
URL: https://github.com/apache/kvrocks/pull/2873#discussion_r2036581454
##########
src/common/string_util.cc:
##########
@@ -276,6 +276,71 @@ std::pair<std::string, std::string>
SplitGlob(std::string_view glob) {
return {prefix, ""};
}
+StatusOr<std::vector<std::string>> SplitArguments(std::string_view in) {
+ std::vector<std::string> arguments;
+ std::string current_string;
+
+ enum { NORMAL, QUOTED, SINGLE_QUOTED, ESCAPE } state = NORMAL;
+
+ bool is_quoted = false;
+ for (const char c : in) {
+ switch (state) {
+ case NORMAL:
+ if (std::isspace(c)) {
+ if (!current_string.empty()) {
+ arguments.emplace_back(std::move(current_string));
+ current_string.clear();
+ }
+ // skip spaces
+ } else if (c == '"' || c == '\'') {
+ state = c == '"' ? QUOTED : SINGLE_QUOTED;
+ is_quoted = c == '"';
Review Comment:
Ahh I got it. Maybe we can use `state_before_escape` to store the previous
before ESCAPE and revert to it after ESCAPE.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]