Regex: Use AMTL.
This commit is contained in:
parent
08475bb0cc
commit
ee4f6b8a89
@ -10,8 +10,10 @@ elif builder.target_platform == 'mac':
|
|||||||
elif builder.target_platform == 'windows':
|
elif builder.target_platform == 'windows':
|
||||||
binary.compiler.postlink += [binary.Dep('lib_win\\pcre.lib')]
|
binary.compiler.postlink += [binary.Dep('lib_win\\pcre.lib')]
|
||||||
|
|
||||||
binary.compiler.defines += ['PCRE_STATIC']
|
binary.compiler.defines += [
|
||||||
|
'PCRE_STATIC',
|
||||||
|
'HAVE_STDINT_H',
|
||||||
|
]
|
||||||
binary.sources = [
|
binary.sources = [
|
||||||
'sdk/amxxmodule.cpp',
|
'sdk/amxxmodule.cpp',
|
||||||
'module.cpp',
|
'module.cpp',
|
||||||
|
@ -33,23 +33,23 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "pcre.h"
|
#include "pcre.h"
|
||||||
#include "amxxmodule.h"
|
#include "amxxmodule.h"
|
||||||
#include "CVector.h"
|
#include <am-vector.h>
|
||||||
#include "CRegEx.h"
|
#include "CRegEx.h"
|
||||||
|
|
||||||
CVector<RegEx *> PEL;
|
ke::Vector<RegEx *> PEL;
|
||||||
|
|
||||||
int GetPEL()
|
int GetPEL()
|
||||||
{
|
{
|
||||||
for (int i=0; i<(int)PEL.size(); i++)
|
for (int i=0; i<(int)PEL.length(); i++)
|
||||||
{
|
{
|
||||||
if (PEL[i]->isFree())
|
if (PEL[i]->isFree())
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegEx *x = new RegEx();
|
RegEx *x = new RegEx();
|
||||||
PEL.push_back(x);
|
PEL.append(x);
|
||||||
|
|
||||||
return (int)PEL.size() - 1;
|
return (int)PEL.length() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// native Regex:regex_compile(const pattern[], &ret, error[], maxLen, const flags[]="");
|
// native Regex:regex_compile(const pattern[], &ret, error[], maxLen, const flags[]="");
|
||||||
@ -150,7 +150,7 @@ static cell AMX_NATIVE_CALL regex_match_c(AMX *amx, cell *params)
|
|||||||
int id = params[2]-1;
|
int id = params[2]-1;
|
||||||
const char *str = MF_GetAmxString(amx, params[1], 0, &len);
|
const char *str = MF_GetAmxString(amx, params[1], 0, &len);
|
||||||
|
|
||||||
if (id >= (int)PEL.size() || id < 0 || PEL[id]->isFree())
|
if (id >= (int)PEL.length() || id < 0 || PEL[id]->isFree())
|
||||||
{
|
{
|
||||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid regex handle %d", id);
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid regex handle %d", id);
|
||||||
return 0;
|
return 0;
|
||||||
@ -187,7 +187,7 @@ static cell AMX_NATIVE_CALL regex_match_ex(AMX *amx, cell *params)
|
|||||||
{
|
{
|
||||||
int id = params[1] - 1;
|
int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= (int)PEL.size() || id < 0 || PEL[id]->isFree())
|
if (id >= (int)PEL.length() || id < 0 || PEL[id]->isFree())
|
||||||
{
|
{
|
||||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid regex handle %d", id);
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid regex handle %d", id);
|
||||||
return 0;
|
return 0;
|
||||||
@ -226,7 +226,7 @@ static cell AMX_NATIVE_CALL regex_match_ex(AMX *amx, cell *params)
|
|||||||
static cell AMX_NATIVE_CALL regex_substr(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL regex_substr(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
int id = params[1]-1;
|
int id = params[1]-1;
|
||||||
if (id >= (int)PEL.size() || id < 0 || PEL[id]->isFree())
|
if (id >= (int)PEL.length() || id < 0 || PEL[id]->isFree())
|
||||||
{
|
{
|
||||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid regex handle %d", id);
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid regex handle %d", id);
|
||||||
return 0;
|
return 0;
|
||||||
@ -252,7 +252,7 @@ static cell AMX_NATIVE_CALL regex_free(AMX *amx, cell *params)
|
|||||||
int id = *c;
|
int id = *c;
|
||||||
*c = 0;
|
*c = 0;
|
||||||
id -= 1;
|
id -= 1;
|
||||||
if (id >= (int)PEL.size() || id < 0 || PEL[id]->isFree())
|
if (id >= (int)PEL.length() || id < 0 || PEL[id]->isFree())
|
||||||
{
|
{
|
||||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid regex handle %d", id);
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid regex handle %d", id);
|
||||||
return 0;
|
return 0;
|
||||||
@ -282,7 +282,7 @@ void OnAmxxAttach()
|
|||||||
|
|
||||||
void OnAmxxDetach()
|
void OnAmxxDetach()
|
||||||
{
|
{
|
||||||
for (int i = 0; i<(int)PEL.size(); i++)
|
for (int i = 0; i<(int)PEL.length(); i++)
|
||||||
{
|
{
|
||||||
if (PEL[i])
|
if (PEL[i])
|
||||||
{
|
{
|
||||||
|
@ -52,8 +52,8 @@
|
|||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\;..\sdk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\;..\..\..\public\amtl;..\sdk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;REGEX_EXPORTS;PCRE_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;REGEX_EXPORTS;HAVE_STDINT_H;PCRE_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MinimalRebuild>true</MinimalRebuild>
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
@ -75,8 +75,8 @@
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalIncludeDirectories>..\;..\sdk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\;..\..\..\public\amtl;..\sdk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;REGEX_EXPORTS;PCRE_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;REGEX_EXPORTS;HAVE_STDINT_H;PCRE_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||||
<PrecompiledHeader>
|
<PrecompiledHeader>
|
||||||
|
Loading…
Reference in New Issue
Block a user