diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2014-08-02 18:20:45 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2014-08-02 18:20:45 +0000 |
commit | c335029d1e6a301eecc0d9dbcfacb70ba7d8c975 (patch) | |
tree | 9766ea62b92224afbb54fce07beebc810673c6b0 /plugins/Spamotron | |
parent | c8853873429be6ee3f7b4ba68d061309bbd201dc (diff) |
use pcre16
git-svn-id: http://svn.miranda-ng.org/main/trunk@10033 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Spamotron')
-rw-r--r-- | plugins/Spamotron/Spamotron_10.vcxproj | 14 | ||||
-rw-r--r-- | plugins/Spamotron/Spamotron_10.vcxproj.filters | 6 | ||||
-rw-r--r-- | plugins/Spamotron/Spamotron_12.vcxproj | 12 | ||||
-rw-r--r-- | plugins/Spamotron/Spamotron_12.vcxproj.filters | 6 | ||||
-rw-r--r-- | plugins/Spamotron/src/common.h | 2 | ||||
-rw-r--r-- | plugins/Spamotron/src/pcre/pcre.h | 186 | ||||
-rw-r--r-- | plugins/Spamotron/src/pcre/pcre.lib | bin | 61592 -> 0 bytes | |||
-rw-r--r-- | plugins/Spamotron/src/pcre/pcre64.lib | bin | 87682 -> 0 bytes | |||
-rw-r--r-- | plugins/Spamotron/src/utils.cpp | 98 |
9 files changed, 60 insertions, 264 deletions
diff --git a/plugins/Spamotron/Spamotron_10.vcxproj b/plugins/Spamotron/Spamotron_10.vcxproj index 96cd0f1aa2..cb58c921ea 100644 --- a/plugins/Spamotron/Spamotron_10.vcxproj +++ b/plugins/Spamotron/Spamotron_10.vcxproj @@ -85,9 +85,7 @@ <Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
- <AdditionalDependencies>src\pcre\pcre.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <AdditionalOptions>/NODEFAULTLIB:LIBCMT %(AdditionalOptions)</AdditionalOptions>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<SubSystem>Windows</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
@@ -109,9 +107,7 @@ <Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
- <AdditionalDependencies>src\pcre\pcre64.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <AdditionalOptions>/NODEFAULTLIB:LIBCMT %(AdditionalOptions)</AdditionalOptions>
<SubSystem>Windows</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
</Link>
@@ -138,9 +134,7 @@ <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
- <AdditionalDependencies>src\pcre\pcre.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <AdditionalOptions>/NODEFAULTLIB:LIBCMT %(AdditionalOptions)</AdditionalOptions>
<SubSystem>Windows</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
</Link>
@@ -167,9 +161,7 @@ <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
- <AdditionalDependencies>src\pcre\pcre64.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <AdditionalOptions>/NODEFAULTLIB:LIBCMT %(AdditionalOptions)</AdditionalOptions>
<SubSystem>Windows</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
</Link>
@@ -192,7 +184,6 @@ <ClCompile Include="src\utils.cpp" />
</ItemGroup>
<ItemGroup>
- <ClInclude Include="src\pcre\pcre.h" />
<ClInclude Include="src\sqlite3\sqlite3.h" />
<ClInclude Include="src\common.h" />
<ClInclude Include="src\resource.h" />
@@ -202,6 +193,11 @@ <ResourceCompile Include="res\spamotron.rc" />
<ResourceCompile Include="res\Version.rc" />
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Pcre16\pcre16_12.vcxproj">
+ <Project>{6124e997-426e-4a0b-9617-d6d577d5e7d7}</Project>
+ </ProjectReference>
+ </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
diff --git a/plugins/Spamotron/Spamotron_10.vcxproj.filters b/plugins/Spamotron/Spamotron_10.vcxproj.filters index 0758212e31..00bebfea61 100644 --- a/plugins/Spamotron/Spamotron_10.vcxproj.filters +++ b/plugins/Spamotron/Spamotron_10.vcxproj.filters @@ -15,9 +15,6 @@ <Filter Include="Header Files\sqlite3">
<UniqueIdentifier>{c2cd5aa5-923e-4b82-aa84-48bbdd5a2d47}</UniqueIdentifier>
</Filter>
- <Filter Include="Header Files\pcre">
- <UniqueIdentifier>{5c4a0315-c2e2-4685-97e1-4131819b7dbc}</UniqueIdentifier>
- </Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
@@ -56,9 +53,6 @@ <ClInclude Include="src\sqlite3\sqlite3.h">
<Filter>Header Files\sqlite3</Filter>
</ClInclude>
- <ClInclude Include="src\pcre\pcre.h">
- <Filter>Header Files\pcre</Filter>
- </ClInclude>
<ClInclude Include="src\Version.h">
<Filter>Header Files</Filter>
</ClInclude>
diff --git a/plugins/Spamotron/Spamotron_12.vcxproj b/plugins/Spamotron/Spamotron_12.vcxproj index 8332ce9353..abace9b2bb 100644 --- a/plugins/Spamotron/Spamotron_12.vcxproj +++ b/plugins/Spamotron/Spamotron_12.vcxproj @@ -89,9 +89,7 @@ <Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ProfileDir)..\..\bin12\lib</AdditionalLibraryDirectories>
- <AdditionalDependencies>src\pcre\pcre.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <AdditionalOptions>/NODEFAULTLIB:LIBCMT %(AdditionalOptions)</AdditionalOptions>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<SubSystem>Windows</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
@@ -113,9 +111,7 @@ <Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ProfileDir)..\..\bin12\lib</AdditionalLibraryDirectories>
- <AdditionalDependencies>src\pcre\pcre64.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <AdditionalOptions>/NODEFAULTLIB:LIBCMT %(AdditionalOptions)</AdditionalOptions>
<SubSystem>Windows</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
</Link>
@@ -142,7 +138,6 @@ <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(ProfileDir)..\..\bin12\lib</AdditionalLibraryDirectories>
- <AdditionalDependencies>src\pcre\pcre.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
<AdditionalOptions>/NODEFAULTLIB:LIBCMT %(AdditionalOptions)</AdditionalOptions>
<SubSystem>Windows</SubSystem>
@@ -171,7 +166,6 @@ <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(ProfileDir)..\..\bin12\lib</AdditionalLibraryDirectories>
- <AdditionalDependencies>src\pcre\pcre64.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
<AdditionalOptions>/NODEFAULTLIB:LIBCMT %(AdditionalOptions)</AdditionalOptions>
<SubSystem>Windows</SubSystem>
@@ -196,7 +190,6 @@ <ClCompile Include="src\utils.cpp" />
</ItemGroup>
<ItemGroup>
- <ClInclude Include="src\pcre\pcre.h" />
<ClInclude Include="src\sqlite3\sqlite3.h" />
<ClInclude Include="src\common.h" />
<ClInclude Include="src\resource.h" />
@@ -206,6 +199,11 @@ <ResourceCompile Include="res\spamotron.rc" />
<ResourceCompile Include="res\Version.rc" />
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Pcre16\pcre16_12.vcxproj">
+ <Project>{6124e997-426e-4a0b-9617-d6d577d5e7d7}</Project>
+ </ProjectReference>
+ </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
diff --git a/plugins/Spamotron/Spamotron_12.vcxproj.filters b/plugins/Spamotron/Spamotron_12.vcxproj.filters index 0758212e31..00bebfea61 100644 --- a/plugins/Spamotron/Spamotron_12.vcxproj.filters +++ b/plugins/Spamotron/Spamotron_12.vcxproj.filters @@ -15,9 +15,6 @@ <Filter Include="Header Files\sqlite3">
<UniqueIdentifier>{c2cd5aa5-923e-4b82-aa84-48bbdd5a2d47}</UniqueIdentifier>
</Filter>
- <Filter Include="Header Files\pcre">
- <UniqueIdentifier>{5c4a0315-c2e2-4685-97e1-4131819b7dbc}</UniqueIdentifier>
- </Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
@@ -56,9 +53,6 @@ <ClInclude Include="src\sqlite3\sqlite3.h">
<Filter>Header Files\sqlite3</Filter>
</ClInclude>
- <ClInclude Include="src\pcre\pcre.h">
- <Filter>Header Files\pcre</Filter>
- </ClInclude>
<ClInclude Include="src\Version.h">
<Filter>Header Files</Filter>
</ClInclude>
diff --git a/plugins/Spamotron/src/common.h b/plugins/Spamotron/src/common.h index 1de7db832c..e078fdb2d4 100644 --- a/plugins/Spamotron/src/common.h +++ b/plugins/Spamotron/src/common.h @@ -19,7 +19,7 @@ #include "m_folders.h"
-#include "pcre/pcre.h"
+#include "..\pcre16\src\pcre.h"
#include "resource.h"
#include "version.h"
diff --git a/plugins/Spamotron/src/pcre/pcre.h b/plugins/Spamotron/src/pcre/pcre.h deleted file mode 100644 index 5aed08e722..0000000000 --- a/plugins/Spamotron/src/pcre/pcre.h +++ /dev/null @@ -1,186 +0,0 @@ -/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* Copyright (c) 1997-2003 University of Cambridge */
-
-#ifndef _PCRE_H
-#define _PCRE_H
-
-/* The file pcre.h is build by "configure". Do not edit it; instead
-make changes to pcre.in. */
-
-#define PCRE_MAJOR 4
-#define PCRE_MINOR 4
-#define PCRE_DATE 21-August-2003
-
-/* Win32 uses DLL by default */
-
-#ifdef _WIN32
-# ifdef PCRE_DEFINITION
-# ifdef DLL_EXPORT
-# define PCRE_DATA_SCOPE __declspec(dllexport)
-# endif
-# else
-# ifndef PCRE_STATIC
-# define PCRE_DATA_SCOPE extern __declspec(dllimport)
-# endif
-# endif
-#endif
-#ifndef PCRE_DATA_SCOPE
-# define PCRE_DATA_SCOPE extern
-#endif
-
-/* Have to include stdlib.h in order to ensure that size_t is defined;
-it is needed here for malloc. */
-
-#include <stdlib.h>
-
-/* Allow for C++ users */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Options */
-
-#define PCRE_CASELESS 0x0001
-#define PCRE_MULTILINE 0x0002
-#define PCRE_DOTALL 0x0004
-#define PCRE_EXTENDED 0x0008
-#define PCRE_ANCHORED 0x0010
-#define PCRE_DOLLAR_ENDONLY 0x0020
-#define PCRE_EXTRA 0x0040
-#define PCRE_NOTBOL 0x0080
-#define PCRE_NOTEOL 0x0100
-#define PCRE_UNGREEDY 0x0200
-#define PCRE_NOTEMPTY 0x0400
-#define PCRE_UTF8 0x0800
-#define PCRE_NO_AUTO_CAPTURE 0x1000
-#define PCRE_NO_UTF8_CHECK 0x2000
-
-/* Exec-time and get/set-time error codes */
-
-#define PCRE_ERROR_NOMATCH (-1)
-#define PCRE_ERROR_NULL (-2)
-#define PCRE_ERROR_BADOPTION (-3)
-#define PCRE_ERROR_BADMAGIC (-4)
-#define PCRE_ERROR_UNKNOWN_NODE (-5)
-#define PCRE_ERROR_NOMEMORY (-6)
-#define PCRE_ERROR_NOSUBSTRING (-7)
-#define PCRE_ERROR_MATCHLIMIT (-8)
-#define PCRE_ERROR_CALLOUT (-9) /* Never used by PCRE itself */
-#define PCRE_ERROR_BADUTF8 (-10)
-
-/* Request types for pcre_fullinfo() */
-
-#define PCRE_INFO_OPTIONS 0
-#define PCRE_INFO_SIZE 1
-#define PCRE_INFO_CAPTURECOUNT 2
-#define PCRE_INFO_BACKREFMAX 3
-#define PCRE_INFO_FIRSTBYTE 4
-#define PCRE_INFO_FIRSTCHAR 4 /* For backwards compatibility */
-#define PCRE_INFO_FIRSTTABLE 5
-#define PCRE_INFO_LASTLITERAL 6
-#define PCRE_INFO_NAMEENTRYSIZE 7
-#define PCRE_INFO_NAMECOUNT 8
-#define PCRE_INFO_NAMETABLE 9
-#define PCRE_INFO_STUDYSIZE 10
-
-/* Request types for pcre_config() */
-
-#define PCRE_CONFIG_UTF8 0
-#define PCRE_CONFIG_NEWLINE 1
-#define PCRE_CONFIG_LINK_SIZE 2
-#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD 3
-#define PCRE_CONFIG_MATCH_LIMIT 4
-
-/* Bit flags for the pcre_extra structure */
-
-#define PCRE_EXTRA_STUDY_DATA 0x0001
-#define PCRE_EXTRA_MATCH_LIMIT 0x0002
-#define PCRE_EXTRA_CALLOUT_DATA 0x0004
-
-/* Types */
-
-struct real_pcre; /* declaration; the definition is private */
-typedef struct real_pcre pcre;
-
-/* The structure for passing additional data to pcre_exec(). This is defined in
-such as way as to be extensible. */
-
-typedef struct pcre_extra {
- unsigned long int flags; /* Bits for which fields are set */
- void *study_data; /* Opaque data from pcre_study() */
- unsigned long int match_limit; /* Maximum number of calls to match() */
- void *callout_data; /* Data passed back in callouts */
-} pcre_extra;
-
-/* The structure for passing out data via the pcre_callout_function. We use a
-structure so that new fields can be added on the end in future versions,
-without changing the API of the function, thereby allowing old clients to work
-without modification. */
-
-typedef struct pcre_callout_block {
- int version; /* Identifies version of block */
- /* ------------------------ Version 0 ------------------------------- */
- int callout_number; /* Number compiled into pattern */
- int *offset_vector; /* The offset vector */
- const char *subject; /* The subject being matched */
- int subject_length; /* The length of the subject */
- int start_match; /* Offset to start of this match attempt */
- int current_position; /* Where we currently are */
- int capture_top; /* Max current capture */
- int capture_last; /* Most recently closed capture */
- void *callout_data; /* Data passed in with the call */
- /* ------------------------------------------------------------------ */
-} pcre_callout_block;
-
-/* Indirection for store get and free functions. These can be set to
-alternative malloc/free functions if required. There is also an optional
-callout function that is triggered by the (?) regex item. Some magic is
-required for Win32 DLL; it is null on other OS. For Virtual Pascal, these
-have to be different again. */
-
-#ifndef VPCOMPAT
-PCRE_DATA_SCOPE void *(*pcre_malloc)(size_t);
-PCRE_DATA_SCOPE void (*pcre_free)(void *);
-PCRE_DATA_SCOPE int (*pcre_callout)(pcre_callout_block *);
-#else /* VPCOMPAT */
-extern void *pcre_malloc(size_t);
-extern void pcre_free(void *);
-extern int pcre_callout(pcre_callout_block *);
-#endif /* VPCOMPAT */
-
-/* Exported PCRE functions */
-
-extern pcre *pcre_compile(const char *, int, const char **,
- int *, const unsigned char *);
-extern int pcre_config(int, void *);
-extern int pcre_copy_named_substring(const pcre *, const char *,
- int *, int, const char *, char *, int);
-extern int pcre_copy_substring(const char *, int *, int, int,
- char *, int);
-extern int pcre_exec(const pcre *, const pcre_extra *,
- const char *, int, int, int, int *, int);
-extern void pcre_free_substring(const char *);
-extern void pcre_free_substring_list(const char **);
-extern int pcre_fullinfo(const pcre *, const pcre_extra *, int,
- void *);
-extern int pcre_get_named_substring(const pcre *, const char *,
- int *, int, const char *, const char **);
-extern int pcre_get_stringnumber(const pcre *, const char *);
-extern int pcre_get_substring(const char *, int *, int, int,
- const char **);
-extern int pcre_get_substring_list(const char *, int *, int,
- const char ***);
-extern int pcre_info(const pcre *, int *, int *);
-extern const unsigned char *pcre_maketables(void);
-extern pcre_extra *pcre_study(const pcre *, int, const char **);
-extern const char *pcre_version(void);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* End of pcre.h */
diff --git a/plugins/Spamotron/src/pcre/pcre.lib b/plugins/Spamotron/src/pcre/pcre.lib Binary files differdeleted file mode 100644 index 8320452ab9..0000000000 --- a/plugins/Spamotron/src/pcre/pcre.lib +++ /dev/null diff --git a/plugins/Spamotron/src/pcre/pcre64.lib b/plugins/Spamotron/src/pcre/pcre64.lib Binary files differdeleted file mode 100644 index a2432056ed..0000000000 --- a/plugins/Spamotron/src/pcre/pcre64.lib +++ /dev/null diff --git a/plugins/Spamotron/src/utils.cpp b/plugins/Spamotron/src/utils.cpp index 5c561aa750..ef78a9f29d 100644 --- a/plugins/Spamotron/src/utils.cpp +++ b/plugins/Spamotron/src/utils.cpp @@ -26,24 +26,24 @@ TCHAR *_tcstoupper(TCHAR *dst) BOOL _isregex(TCHAR* strSearch)
{
BOOL ret = FALSE;
- pcre *re;
+ pcre16 *re;
const char *error;
int erroroffs, rc;
- char *regex;
- char regex_parse[] = "/(.*)/([igsm]*)";
+ TCHAR *regex;
+ TCHAR regex_parse[] = _T("/(.*)/([igsm]*)");
int ovector[9];
- re = pcre_compile(regex_parse, 0, &error, &erroroffs, NULL);
+ re = pcre16_compile(regex_parse, 0, &error, &erroroffs, NULL);
if (!re)
return FALSE;
- regex = mir_u2a(strSearch);
- rc = pcre_exec(re, NULL, regex, (int)strlen(regex), 0, 0, ovector, 9);
+ regex = mir_tstrdup(strSearch);
+ rc = pcre16_exec(re, NULL, regex, (int)lstrlen(regex), 0, 0, ovector, 9);
if (rc == 3)
ret = TRUE;
if (re)
- pcre_free(re);
+ pcre16_free(re);
if (regex)
mir_free(regex);
@@ -53,21 +53,21 @@ BOOL _isregex(TCHAR* strSearch) BOOL _isvalidregex(TCHAR* strSearch)
{
BOOL ret;
- pcre *re;
+ pcre16 *re;
const char *error;
int erroroffs, rc;
- char *regex, *regexp, *mod;
+ TCHAR *regex, *regexp, *mod;
int opts = 0;
- char regex_parse[] = "/(.*)/([igsm]*)";
+ TCHAR regex_parse[] = _T("/(.*)/([igsm]*)");
int ovector[9];
- re = pcre_compile(regex_parse, 0, &error, &erroroffs, NULL);
+ re = pcre16_compile(regex_parse, 0, &error, &erroroffs, NULL);
if (!re)
return FALSE;
- regex = mir_u2a(strSearch);
- rc = pcre_exec(re, NULL, regex, (int)strlen(regex), 0, 0, ovector, 9);
- pcre_free(re);
+ regex = mir_tstrdup(strSearch);
+ rc = pcre16_exec(re, NULL, regex, (int)lstrlen(regex), 0, 0, ovector, 9);
+ pcre16_free(re);
if (rc == 3) {
regexp = regex + ovector[2];
@@ -75,19 +75,19 @@ BOOL _isvalidregex(TCHAR* strSearch) mod = regex + ovector[4];
mod[ovector[5]-ovector[4]] = 0;
- if (strstr(mod, "i"))
+ if (_tcsstr(mod, _T("i")))
opts |= PCRE_CASELESS;
- if (strstr(mod, "m"))
+ if (_tcsstr(mod, _T("m")))
opts |= PCRE_MULTILINE;
- if (strstr(mod, "s"))
+ if (_tcsstr(mod, _T("s")))
opts |= PCRE_DOTALL;
- re = pcre_compile(regexp, opts, &error, &erroroffs, NULL);
+ re = pcre16_compile(regexp, opts, &error, &erroroffs, NULL);
ret = (re) ? TRUE : FALSE;
}
if (re)
- pcre_free(re);
+ pcre16_free(re);
if (regex)
mir_free(regex);
@@ -97,20 +97,20 @@ BOOL _isvalidregex(TCHAR* strSearch) BOOL _regmatch(TCHAR* str, TCHAR* strSearch)
{
BOOL ret;
- pcre *re;
+ pcre16 *re;
const char *error;
int erroroffs, rc;
- char *regex, *regexp, *data, *mod;
+ TCHAR *regex, *regexp, *data, *mod;
int opts = 0;
- char regex_parse[] = "^/(.*)/([igsm]*)";
+ TCHAR regex_parse[] = _T("^/(.*)/([igsm]*)");
int ovector[9];
- re = pcre_compile(regex_parse, 0, &error, &erroroffs, NULL);
+ re = pcre16_compile(regex_parse, 0, &error, &erroroffs, NULL);
if (!re)
return FALSE; // [TODO] and log some error
- regex = mir_u2a(strSearch);
- rc = pcre_exec(re, NULL, regex, (int)strlen(regex), 0, 0, ovector, 9);
+ regex = mir_tstrdup(strSearch);
+ rc = pcre16_exec(re, NULL, regex, (int)lstrlen(regex), 0, 0, ovector, 9);
if (rc != 3) {
mir_free(regex);
return FALSE; // [TODO] and log some error (better check for valid regex on options save)
@@ -120,25 +120,25 @@ BOOL _regmatch(TCHAR* str, TCHAR* strSearch) regexp[ovector[3]-ovector[2]] = 0;
mod = regex + ovector[4];
mod[ovector[5]-ovector[4]] = 0;
- pcre_free(re);
+ pcre16_free(re);
- data = mir_u2a(str);
+ data = mir_tstrdup(str);
- if (strstr(mod, "i"))
+ if (_tcsstr(mod, _T("i")))
opts |= PCRE_CASELESS;
- if (strstr(mod, "m"))
+ if (_tcsstr(mod, _T("m")))
opts |= PCRE_MULTILINE;
- if (strstr(mod, "s"))
+ if (_tcsstr(mod, _T("s")))
opts |= PCRE_DOTALL;
- re = pcre_compile(regexp, opts, &error, &erroroffs, NULL);
+ re = pcre16_compile(regexp, opts, &error, &erroroffs, NULL);
if (!re) {
mir_free(regex);
mir_free(data);
return FALSE;
}
- rc = pcre_exec(re, NULL, data, (int)strlen(data), 0, 0, NULL, 0);
+ rc = pcre16_exec(re, NULL, data, (int)lstrlen(data), 0, 0, NULL, 0);
if (rc < 0) {
ret = FALSE;
} else {
@@ -146,7 +146,7 @@ BOOL _regmatch(TCHAR* str, TCHAR* strSearch) }
if (re)
- pcre_free(re);
+ pcre16_free(re);
if (regex)
mir_free(regex);
if (data)
@@ -158,31 +158,31 @@ BOOL _regmatch(TCHAR* str, TCHAR* strSearch) int get_response_id(const TCHAR* strvar)
{
int ret;
- pcre *re;
+ pcre16 *re;
const char *error;
int erroroffs, rc;
- char *_str, *_strvar;
+ TCHAR *_str, *_strvar;
int opts = 0;
- char regex[] = "^%response([#-_]([0-9]+))?%$";
+ TCHAR regex[] = _T("^%response([#-_]([0-9]+))?%$");
int ovector[9];
- re = pcre_compile(regex, 0, &error, &erroroffs, NULL);
+ re = pcre16_compile(regex, 0, &error, &erroroffs, NULL);
if (!re)
return FALSE; // [TODO] and log some error
- _strvar = mir_u2a(strvar);
- rc = pcre_exec(re, NULL, _strvar, (int)strlen(_strvar), 0, 0, ovector, 9);
+ _strvar = mir_tstrdup(strvar);
+ rc = pcre16_exec(re, NULL, _strvar, (int)lstrlen(_strvar), 0, 0, ovector, 9);
if (rc < 0) {
ret = -1;
} else if (rc == 3) {
_str = _strvar + ovector[4];
_str[ovector[5]-ovector[4]] = 0;
- ret = atoi(_str);
+ ret = _ttoi(_str);
} else
ret = 0;
if (re)
- pcre_free(re);
+ pcre16_free(re);
if (_strvar)
mir_free(_strvar);
@@ -365,17 +365,17 @@ TCHAR* ReplaceVarsNum(TCHAR *dst, unsigned int len, int num) {
TCHAR response[2048];
int ret, i = 1;
- pcre *re;
+ pcre16 *re;
const char *error;
int erroroffs, rc;
- char *_str, *tmp;
+ TCHAR *_str, *tmp;
TCHAR **r;
TCHAR *ttmp, *dstcopy;
int opts = 0;
- char regex[] = "%response([#-_]([0-9]+))?%";
+ TCHAR regex[] = _T("%response([#-_]([0-9]+))?%");
int ovector[9];
- re = pcre_compile(regex, 0, &error, &erroroffs, NULL);
+ re = pcre16_compile(regex, 0, &error, &erroroffs, NULL);
if (!re)
return FALSE; // [TODO] and log some error
@@ -393,11 +393,11 @@ TCHAR* ReplaceVarsNum(TCHAR *dst, unsigned int len, int num) }
do {
- _str = mir_u2a(dst);
+ _str = mir_tstrdup(dst);
dstcopy = (TCHAR*)malloc((_tcslen(dst)+1)*sizeof(TCHAR));
_tcscpy(dstcopy, dst);
- rc = pcre_exec(re, NULL, _str, (int)strlen(_str), 0, 0, ovector, 9);
+ rc = pcre16_exec(re, NULL, _str, (int)lstrlen(_str), 0, 0, ovector, 9);
if (rc < 0) {
ret = -1;
} else if (rc == 3) {
@@ -405,7 +405,7 @@ TCHAR* ReplaceVarsNum(TCHAR *dst, unsigned int len, int num) ttmp[ovector[1]-ovector[0]] = 0;
tmp = _str + ovector[4];
tmp[ovector[5]-ovector[4]] = 0;
- ret = atoi(tmp);
+ ret = _ttoi(tmp);
} else {
ttmp = dstcopy + ovector[0];
ttmp[ovector[1]-ovector[0]] = 0;
@@ -428,7 +428,7 @@ TCHAR* ReplaceVarsNum(TCHAR *dst, unsigned int len, int num) } while (rc >= 0);
if (re)
- pcre_free(re);
+ pcre16_free(re);
return dst;
}
|