mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Variant
- The ::operator_match (and by extension operator_nomatch) now obey the rc.regex setting.
This commit is contained in:
parent
9e0ea1cb4a
commit
dcc5dbf16a
3 changed files with 45 additions and 13 deletions
|
@ -126,6 +126,7 @@ int Context::initialize (int argc, const char** argv)
|
||||||
Lexer::dateFormat = config.get ("dateformat");
|
Lexer::dateFormat = config.get ("dateformat");
|
||||||
Variant::dateFormat = config.get ("dateformat");
|
Variant::dateFormat = config.get ("dateformat");
|
||||||
Variant::searchCaseSensitive = config.getBoolean ("search.case.sensitive");
|
Variant::searchCaseSensitive = config.getBoolean ("search.case.sensitive");
|
||||||
|
Variant::searchUsingRegex = config.getBoolean ("regex");
|
||||||
|
|
||||||
parser.initialize (argc, argv); // task arg0 arg1 ...
|
parser.initialize (argc, argv); // task arg0 arg1 ...
|
||||||
|
|
||||||
|
@ -148,6 +149,14 @@ int Context::initialize (int argc, const char** argv)
|
||||||
|
|
||||||
// Create missing config file and data directory, if necessary.
|
// Create missing config file and data directory, if necessary.
|
||||||
parser.applyOverrides ();
|
parser.applyOverrides ();
|
||||||
|
|
||||||
|
// These may have changed.
|
||||||
|
// TODO Uh oh.
|
||||||
|
Lexer::dateFormat = config.get ("dateformat");
|
||||||
|
Variant::dateFormat = config.get ("dateformat");
|
||||||
|
Variant::searchCaseSensitive = config.getBoolean ("search.case.sensitive");
|
||||||
|
Variant::searchUsingRegex = config.getBoolean ("regex");
|
||||||
|
|
||||||
createDefaultConfig ();
|
createDefaultConfig ();
|
||||||
|
|
||||||
// Initialize the color rules, if necessary.
|
// Initialize the color rules, if necessary.
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
|
|
||||||
std::string Variant::dateFormat = "";
|
std::string Variant::dateFormat = "";
|
||||||
bool Variant::searchCaseSensitive = true;
|
bool Variant::searchCaseSensitive = true;
|
||||||
|
bool Variant::searchUsingRegex = true;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Variant::Variant ()
|
Variant::Variant ()
|
||||||
|
@ -913,21 +914,42 @@ bool Variant::operator_match (const Variant& other, const Task& task) const
|
||||||
left.cast (type_string);
|
left.cast (type_string);
|
||||||
right.cast (type_string);
|
right.cast (type_string);
|
||||||
|
|
||||||
RX r (right._string, searchCaseSensitive);
|
if (searchUsingRegex)
|
||||||
if (r.match (left._string))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// If the above did not match, and the left source is "description", then
|
|
||||||
// in the annotations.
|
|
||||||
if (left.source () == "description")
|
|
||||||
{
|
{
|
||||||
std::map <std::string, std::string> annotations;
|
RX r (right._string, searchCaseSensitive);
|
||||||
task.getAnnotations (annotations);
|
if (r.match (left._string))
|
||||||
|
return true;
|
||||||
|
|
||||||
std::map <std::string, std::string>::iterator a;
|
// If the above did not match, and the left source is "description", then
|
||||||
for (a = annotations.begin (); a != annotations.end (); ++a)
|
// in the annotations.
|
||||||
if (r.match (a->second))
|
if (left.source () == "description")
|
||||||
return true;
|
{
|
||||||
|
std::map <std::string, std::string> annotations;
|
||||||
|
task.getAnnotations (annotations);
|
||||||
|
|
||||||
|
std::map <std::string, std::string>::iterator a;
|
||||||
|
for (a = annotations.begin (); a != annotations.end (); ++a)
|
||||||
|
if (r.match (a->second))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (find (left._string, right._string, searchCaseSensitive) != std::string::npos)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// If the above did not match, and the left source is "description", then
|
||||||
|
// in the annotations.
|
||||||
|
if (left.source () == "description")
|
||||||
|
{
|
||||||
|
std::map <std::string, std::string> annotations;
|
||||||
|
task.getAnnotations (annotations);
|
||||||
|
|
||||||
|
std::map <std::string, std::string>::iterator a;
|
||||||
|
for (a = annotations.begin (); a != annotations.end (); ++a)
|
||||||
|
if (find (a->second, right._string, searchCaseSensitive) != std::string::npos)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -36,6 +36,7 @@ class Variant
|
||||||
public:
|
public:
|
||||||
static std::string dateFormat;
|
static std::string dateFormat;
|
||||||
static bool searchCaseSensitive;
|
static bool searchCaseSensitive;
|
||||||
|
static bool searchUsingRegex;
|
||||||
|
|
||||||
enum type {type_unknown, type_boolean, type_integer, type_real, type_string,
|
enum type {type_unknown, type_boolean, type_integer, type_real, type_string,
|
||||||
type_date, type_duration};
|
type_date, type_duration};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue