mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-23 05:27:47 +02:00
CLI2: Quoted Lexer::Type::pair args are maximal
This commit is contained in:
parent
1836ac29e2
commit
a7982e434a
1 changed files with 11 additions and 1 deletions
12
src/CLI2.cpp
12
src/CLI2.cpp
|
@ -354,11 +354,16 @@ void CLI2::lexArguments ()
|
||||||
bool terminated = false;
|
bool terminated = false;
|
||||||
for (unsigned int i = 1; i < _original_args.size (); ++i)
|
for (unsigned int i = 1; i < _original_args.size (); ++i)
|
||||||
{
|
{
|
||||||
|
bool quoted = Lexer::wasQuoted (_original_args[i]);
|
||||||
|
|
||||||
std::string lexeme;
|
std::string lexeme;
|
||||||
Lexer::Type type;
|
Lexer::Type type;
|
||||||
Lexer lex (_original_args[i]);
|
Lexer lex (_original_args[i]);
|
||||||
if (lex.token (lexeme, type) &&
|
if (lex.token (lexeme, type) &&
|
||||||
lex.isEOS ())
|
(lex.isEOS () || // Token goes to EOS
|
||||||
|
(quoted && type == Lexer::Type::pair) // Quoted pairs automatically go to EOS
|
||||||
|
)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (type == Lexer::Type::separator)
|
if (type == Lexer::Type::separator)
|
||||||
terminated = true;
|
terminated = true;
|
||||||
|
@ -368,12 +373,17 @@ void CLI2::lexArguments ()
|
||||||
A2 a (lexeme, type);
|
A2 a (lexeme, type);
|
||||||
if (terminated)
|
if (terminated)
|
||||||
a.tag ("TERMINATED");
|
a.tag ("TERMINATED");
|
||||||
|
if (quoted)
|
||||||
|
a.tag ("QUOTED");
|
||||||
|
|
||||||
_args.push_back (a);
|
_args.push_back (a);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
A2 unknown (_original_args[i], Lexer::Type::word);
|
A2 unknown (_original_args[i], Lexer::Type::word);
|
||||||
|
if (lex.wasQuoted (_original_args[i]))
|
||||||
|
unknown.tag ("QUOTED");
|
||||||
|
|
||||||
_args.push_back (unknown);
|
_args.push_back (unknown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue