mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Regexes
- Added regex support to substirutions. - Fixed bug that prevented 1.9.4 from shipping with regexes. If the description is "aXXaaXXa", and the substitution is /XX/.../ then the first substitutions changes the length of the string to "a...aaXXa" and therefore invalidates the index for the second match, and makes this change: "a...a...Xa". The fix is to keep a running 'skew' count of the difference in 'from' and 'to' length, to adjust the match indexes. - Moved the helper deltaSubstitutions function into the Task object, which makes more sense. - Cleaned up output composition for CmdAdd. - Eliminated #ifdef FEATURE_REGEX. They are here to stay.
This commit is contained in:
parent
622e9c5e1e
commit
b58438bdd4
11 changed files with 152 additions and 166 deletions
11
src/RX.cpp
11
src/RX.cpp
|
@ -31,8 +31,7 @@
|
|||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
//#define _POSIX_C_SOURCE 1
|
||||
#define MAX_MATCHES 64
|
||||
//#define _POSIX_C_SOURCE 1 // Forgot why this is here. Moving on...
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
RX::RX ()
|
||||
|
@ -126,8 +125,8 @@ bool RX::match (
|
|||
if (!_compiled)
|
||||
compile ();
|
||||
|
||||
regmatch_t rm[MAX_MATCHES];
|
||||
if (regexec (&_regex, in.c_str (), MAX_MATCHES, rm, 0) == 0)
|
||||
regmatch_t rm[RX_MAX_MATCHES];
|
||||
if (regexec (&_regex, in.c_str (), RX_MAX_MATCHES, rm, 0) == 0)
|
||||
{
|
||||
for (unsigned int i = 1; i < 1 + _regex.re_nsub; ++i)
|
||||
matches.push_back (in.substr (rm[i].rm_so, rm[i].rm_eo - rm[i].rm_so));
|
||||
|
@ -147,8 +146,8 @@ bool RX::match (
|
|||
if (!_compiled)
|
||||
compile ();
|
||||
|
||||
regmatch_t rm[MAX_MATCHES];
|
||||
if (regexec (&_regex, in.c_str (), MAX_MATCHES, rm, 0) == 0)
|
||||
regmatch_t rm[RX_MAX_MATCHES];
|
||||
if (regexec (&_regex, in.c_str (), RX_MAX_MATCHES, rm, 0) == 0)
|
||||
{
|
||||
for (unsigned int i = 1; i < 1 + _regex.re_nsub; ++i)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue