Fix up the ParameterParser a bit more
This commit is contained in:
+29
-11
@@ -64,7 +64,10 @@ namespace uWS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (op[0] != ';') {
|
if (op[0] != ';') {
|
||||||
return {key, getToken()};
|
auto value = getToken();
|
||||||
|
/* Strip ; or if at end, nothing */
|
||||||
|
getToken();
|
||||||
|
return {key, value};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {key, ""};
|
return {key, ""};
|
||||||
@@ -91,18 +94,33 @@ namespace uWS {
|
|||||||
remainingLine.remove_prefix(1);
|
remainingLine.remove_prefix(1);
|
||||||
return op;
|
return op;
|
||||||
} else {
|
} else {
|
||||||
/* This part is not entirely correct */
|
/* Are we at a quoted string? */
|
||||||
|
if (remainingLine[0] == '\"') {
|
||||||
/* Read the whole alpha word */
|
/* Remove first quote and start counting */
|
||||||
std::string_view token = remainingLine;
|
|
||||||
|
|
||||||
int tokenLength = 0;
|
|
||||||
while (remainingLine.length() && remainingLine[0] != ';' && remainingLine[0] != '=' && !isspace(remainingLine[0])) {
|
|
||||||
remainingLine.remove_prefix(1);
|
remainingLine.remove_prefix(1);
|
||||||
tokenLength++;
|
auto quote = remainingLine;
|
||||||
}
|
int quoteLength = 0;
|
||||||
|
|
||||||
return token.substr(0, tokenLength);
|
/* Read anything until other double quote appears */
|
||||||
|
while (remainingLine.length() && remainingLine[0] != '\"') {
|
||||||
|
remainingLine.remove_prefix(1);
|
||||||
|
quoteLength++;
|
||||||
|
}
|
||||||
|
|
||||||
|
remainingLine.remove_prefix(1);
|
||||||
|
return quote.substr(0, quoteLength);
|
||||||
|
} else {
|
||||||
|
/* Read anything until ; = space or end */
|
||||||
|
std::string_view token = remainingLine;
|
||||||
|
|
||||||
|
int tokenLength = 0;
|
||||||
|
while (remainingLine.length() && remainingLine[0] != ';' && remainingLine[0] != '=' && !isspace(remainingLine[0])) {
|
||||||
|
remainingLine.remove_prefix(1);
|
||||||
|
tokenLength++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return token.substr(0, tokenLength);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user