mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-27 00:57:19 +02:00
CLI2: Expand DOM references in single-token values
This commit is contained in:
parent
557a8d357c
commit
e4132f6a02
4 changed files with 25 additions and 1 deletions
10
src/CLI2.cpp
10
src/CLI2.cpp
|
@ -1141,7 +1141,7 @@ void CLI2::findStrayModifications ()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// <name>[.<mod>]:['"][<value>]['"] --> name = value
|
// <name>[.<mod>]:['"][<value>]['"] --> name <op> value
|
||||||
void CLI2::desugarFilterAttributes ()
|
void CLI2::desugarFilterAttributes ()
|
||||||
{
|
{
|
||||||
bool changes = false;
|
bool changes = false;
|
||||||
|
@ -1157,6 +1157,8 @@ void CLI2::desugarFilterAttributes ()
|
||||||
std::string sep = a.attribute ("separator");
|
std::string sep = a.attribute ("separator");
|
||||||
std::string value = a.attribute ("value");
|
std::string value = a.attribute ("value");
|
||||||
|
|
||||||
|
// An unquoted string, while equivalent to an empty string, doesn't cause
|
||||||
|
// an operand shortage in eval.
|
||||||
if (value == "")
|
if (value == "")
|
||||||
value = "''";
|
value = "''";
|
||||||
|
|
||||||
|
@ -1304,8 +1306,14 @@ void CLI2::desugarFilterAttributes ()
|
||||||
reconstructed.push_back (lhs);
|
reconstructed.push_back (lhs);
|
||||||
reconstructed.push_back (op);
|
reconstructed.push_back (op);
|
||||||
|
|
||||||
|
// Do not modify this construct without full understanding.
|
||||||
if (values.size () == 1 || ! evalSupported)
|
if (values.size () == 1 || ! evalSupported)
|
||||||
|
{
|
||||||
|
if (Lexer::isDOM (rhs.attribute ("raw")))
|
||||||
|
rhs._lextype = Lexer::Type::dom;
|
||||||
|
|
||||||
reconstructed.push_back (rhs);
|
reconstructed.push_back (rhs);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
for (auto& v : values)
|
for (auto& v : values)
|
||||||
reconstructed.push_back (v);
|
reconstructed.push_back (v);
|
||||||
|
|
|
@ -1323,6 +1323,20 @@ bool Lexer::isAllDigits (const std::string& text)
|
||||||
return text.find_first_not_of ("0123456789") == std::string::npos;
|
return text.find_first_not_of ("0123456789") == std::string::npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool Lexer::isDOM (const std::string& text)
|
||||||
|
{
|
||||||
|
Lexer lex (text);
|
||||||
|
int count = 0;
|
||||||
|
std::string token;
|
||||||
|
Lexer::Type type;
|
||||||
|
while (lex.token (token, type))
|
||||||
|
++count;
|
||||||
|
|
||||||
|
return count == 1 &&
|
||||||
|
type == Lexer::Type::dom;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Full implementation of a quoted word. Includes:
|
// Full implementation of a quoted word. Includes:
|
||||||
// '\''
|
// '\''
|
||||||
|
|
|
@ -75,6 +75,7 @@ public:
|
||||||
static bool isHardBoundary (int, int);
|
static bool isHardBoundary (int, int);
|
||||||
static bool isPunctuation (int);
|
static bool isPunctuation (int);
|
||||||
static bool isAllDigits (const std::string&);
|
static bool isAllDigits (const std::string&);
|
||||||
|
static bool isDOM (const std::string&);
|
||||||
static void dequote (std::string&, const std::string& quotes = "'\"");
|
static void dequote (std::string&, const std::string& quotes = "'\"");
|
||||||
static bool wasQuoted (const std::string&);
|
static bool wasQuoted (const std::string&);
|
||||||
static bool readWord (const std::string&, const std::string&, std::string::size_type&, std::string&);
|
static bool readWord (const std::string&, const std::string&, std::string::size_type&, std::string&);
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#ifdef PRODUCT_TASKWARRIOR
|
#ifdef PRODUCT_TASKWARRIOR
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Lexer.h>
|
||||||
#include <Nibbler.h>
|
#include <Nibbler.h>
|
||||||
#endif
|
#endif
|
||||||
#include <Date.h>
|
#include <Date.h>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue