diff options
author | George Hazan <ghazan@miranda.im> | 2018-08-13 11:51:22 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-08-13 11:51:29 +0300 |
commit | ef7127e9715147094e39e27edb0143aaecff695b (patch) | |
tree | 095ac791d232df9f682c7432e59b304fbc4d8ead /plugins/Variables/src/parse_regexp.cpp | |
parent | af5b577d924b941d85d87280b1b4df37b848e510 (diff) |
Variables:
- plugin's own hash implementation replaced with the core function;
- unused header dbhelpers.h removed;
- code cleaning
Diffstat (limited to 'plugins/Variables/src/parse_regexp.cpp')
-rw-r--r-- | plugins/Variables/src/parse_regexp.cpp | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/plugins/Variables/src/parse_regexp.cpp b/plugins/Variables/src/parse_regexp.cpp index c6fd4e6737..1c987557a0 100644 --- a/plugins/Variables/src/parse_regexp.cpp +++ b/plugins/Variables/src/parse_regexp.cpp @@ -1,20 +1,20 @@ /*
- Variables Plugin for Miranda-IM (www.miranda-im.org)
- Copyright 2003-2006 P. Boon
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Variables Plugin for Miranda-IM (www.miranda-im.org)
+ Copyright 2003-2006 P. Boon
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "stdafx.h"
@@ -22,7 +22,7 @@ /*
pattern, subject
*/
-static wchar_t *parseRegExpCheck(ARGUMENTSINFO *ai)
+static wchar_t* parseRegExpCheck(ARGUMENTSINFO *ai)
{
const char *err;
int erroffset;
@@ -52,30 +52,29 @@ static wchar_t *parseRegExpCheck(ARGUMENTSINFO *ai) /*
pattern, subject, substring no (== PCRE string no (starting at 0))
*/
-static wchar_t *parseRegExpSubstr(ARGUMENTSINFO *ai)
+static wchar_t* parseRegExpSubstr(ARGUMENTSINFO *ai)
{
- const char *err;
- const wchar_t *substring;
- int erroffset, number;
- int offsets[99];
-
if (ai->argc != 4)
return nullptr;
- number = _wtoi(ai->argv.w[3]);
+ int number = _wtoi(ai->argv.w[3]);
if (number < 0)
return nullptr;
ai->flags = AIF_FALSE;
+ int erroffset;
+ const char *err;
pcre16 *ppat = pcre16_compile(ai->argv.w[1], 0, &err, &erroffset, nullptr);
if (ppat == nullptr)
return nullptr;
+ int offsets[99];
pcre16_extra *extra = pcre16_study(ppat, 0, &err);
int nmat = pcre16_exec(ppat, extra, ai->argv.w[2], (int)mir_wstrlen(ai->argv.w[2]), 0, 0, offsets, 99);
if (nmat >= 0)
ai->flags &= ~AIF_FALSE;
+ const wchar_t *substring;
if (pcre16_get_substring(ai->argv.w[2], offsets, nmat, number, &substring) < 0)
ai->flags |= AIF_FALSE;
else {
@@ -91,4 +90,4 @@ void registerRegExpTokens() {
registerIntToken(REGEXPCHECK, parseRegExpCheck, TRF_FUNCTION, LPGEN("Regular Expressions") "\t(x,y)\t" LPGEN("(ANSI input only) the number of substring matches found in y with pattern x"));
registerIntToken(REGEXPSUBSTR, parseRegExpSubstr, TRF_FUNCTION, LPGEN("Regular Expressions") "\t(x,y,z)\t" LPGEN("(ANSI input only) substring match number z found in subject y with pattern x"));
-}
\ No newline at end of file +}
|