Skip to content

Commit 2387aa3

Browse files
committed
Added selectors to GetTriggerInfo, GetAliasInfo to show number of match attempts
1 parent a3943a0 commit 2387aa3

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

regexp.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ int count;
8181
prog->iTimeTaken += finish.QuadPart - start.QuadPart;
8282
}
8383

84+
prog->m_iMatchAttempts++; // how many times did we try to match?
85+
8486
if (count == PCRE_ERROR_NOMATCH)
8587
return false; // no match - don't save matching string etc.
8688

regexp.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class t_regexp
3535
m_extra = NULL;
3636
iTimeTaken = 0;
3737
m_iCount = 0;
38+
m_iMatchAttempts = 0;
3839
m_iExecutionError = 0;
3940
}; // constructor
4041
~t_regexp () {
@@ -46,8 +47,9 @@ class t_regexp
4647

4748
// pairs of offsets from match
4849
vector<int> m_vOffsets;
49-
// count of matches
50+
// count of matching wildcards
5051
int m_iCount;
52+
long m_iMatchAttempts;
5153
// the string we match on (to extract wildcards from)
5254
string m_sTarget;
5355
// the program itself

scripting/methods.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,6 +2280,11 @@ CAlias * alias_item;
22802280
}
22812281
break;
22822282

2283+
case 31:
2284+
if (alias_item->regexp)
2285+
SetUpVariantLong (vaResult, alias_item->regexp->m_iMatchAttempts);
2286+
break;
2287+
22832288
case 101: SetUpVariantString (vaResult, alias_item->wildcards [1].c_str ()); break;
22842289
case 102: SetUpVariantString (vaResult, alias_item->wildcards [2].c_str ()); break;
22852290
case 103: SetUpVariantString (vaResult, alias_item->wildcards [3].c_str ()); break;
@@ -2395,6 +2400,11 @@ CTrigger * trigger_item;
23952400
}
23962401
break;
23972402

2403+
case 38:
2404+
if (trigger_item->regexp)
2405+
SetUpVariantLong (vaResult, trigger_item->regexp->m_iMatchAttempts);
2406+
break;
2407+
23982408
#ifdef PANE
23992409
case 38: SetUpVariantString (vaResult, trigger_item->strPane); break;
24002410
#endif // PANE

0 commit comments

Comments
 (0)