From bab8b091f69679c373e4f8ccfa794cd52419db8f Mon Sep 17 00:00:00 2001 From: fcolin Date: Wed, 10 Dec 2008 11:57:07 +0000 Subject: mise en conformite avec Regexp.cxx et Regexp.h pour compilation sans USE_PCRE --- Ivy/Ivy.vcproj | 42 +++++++++++++++++++----------------------- Ivy/IvyBinding.cxx | 46 +++++++++++++++++----------------------------- Ivy/IvyBinding.h | 9 ++++----- Ivy/IvyLib/IvyLib.vdproj | 10 +++++----- Ivy/Regexp.cxx | 2 +- 5 files changed, 46 insertions(+), 63 deletions(-) diff --git a/Ivy/Ivy.vcproj b/Ivy/Ivy.vcproj index f9e983a..2da9ffb 100644 --- a/Ivy/Ivy.vcproj +++ b/Ivy/Ivy.vcproj @@ -1,13 +1,14 @@ @@ -53,7 +54,7 @@ Name="VCCLCompilerTool" AdditionalOptions="" Optimization="0" - AdditionalIncludeDirectories=""..\..\..\pcre-6.4"" + AdditionalIncludeDirectories="$(PcreDir)" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;IVY_EXPORTS;NO_IVY_DEBUG" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -63,7 +64,6 @@ BrowseInformation="1" WarningLevel="3" SuppressStartupBanner="true" - Detect64BitPortabilityProblems="true" DebugInformationFormat="4" /> - @@ -145,7 +145,7 @@ Name="VCCLCompilerTool" AdditionalOptions="" Optimization="0" - AdditionalIncludeDirectories=""..\..\..\pcre-6.4"" + AdditionalIncludeDirectories="$(PcreDir)" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;IVY_EXPORTS;NO_IVY_DEBUG" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -155,7 +155,6 @@ BrowseInformation="1" WarningLevel="3" SuppressStartupBanner="true" - Detect64BitPortabilityProblems="true" DebugInformationFormat="3" /> - @@ -208,7 +206,7 @@ OutputDirectory="$(SolutionDir)$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)" ConfigurationType="2" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;.\PcreDir.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" CharacterSet="0" @@ -237,7 +235,7 @@ Name="VCCLCompilerTool" AdditionalOptions="" InlineFunctionExpansion="1" - AdditionalIncludeDirectories=""..\..\..\pcre-6.4"" + AdditionalIncludeDirectories="$(PcreDir)" PreprocessorDefinitions="WIN32;_WINDOWS;_USRDLL;IVY_EXPORTS" StringPooling="true" RuntimeLibrary="2" @@ -264,6 +262,8 @@ LinkIncremental="1" SuppressStartupBanner="true" AdditionalLibraryDirectories="" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" /> - @@ -296,7 +293,7 @@ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="2" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;.\PcreDir.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" CharacterSet="0" @@ -325,7 +322,7 @@ Name="VCCLCompilerTool" AdditionalOptions="" InlineFunctionExpansion="1" - AdditionalIncludeDirectories=""..\..\..\pcre-6.4"" + AdditionalIncludeDirectories="$(PcreDir)" PreprocessorDefinitions="WIN32;_WINDOWS;_USRDLL;IVY_EXPORTS" StringPooling="true" RuntimeLibrary="2" @@ -353,6 +350,8 @@ LinkIncremental="1" SuppressStartupBanner="true" AdditionalLibraryDirectories="" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="17" /> - diff --git a/Ivy/IvyBinding.cxx b/Ivy/IvyBinding.cxx index 9013cad..c365b71 100644 --- a/Ivy/IvyBinding.cxx +++ b/Ivy/IvyBinding.cxx @@ -24,7 +24,7 @@ static int err_offset; #ifdef USE_PCRE static const char *err_buf; #else /* we don't USE_PCRE */ - static char err_buf[4096]; +static ivy::string err_buf; #endif /* USE_PCRE */ /* classes de messages emis par l'application utilise pour le filtrage */ @@ -35,13 +35,15 @@ static IvyBinding token_extract; IvyBinding::IvyBinding() { + nb_match = 0; #ifdef USE_PCRE regexp = NULL; inspect = NULL; + #else /* we don't USE_PCRE */ - free( regexp ); + regexp = NULL; #endif /* USE_PCRE */ - nb_match = 0; + } IvyBinding::~IvyBinding() { @@ -51,7 +53,7 @@ IvyBinding::~IvyBinding() if (regexp!=NULL) pcre_free(regexp); #else /* we don't USE_PCRE */ - free( regexp ); + delete regexp; #endif /* USE_PCRE */ } bool IvyBinding::Compile( const char * expression, int *erroffset, const char **errmessage ) @@ -75,18 +77,16 @@ bool IvyBinding::Compile( const char * expression, int *erroffset, const char * printf("Error compiling '%s', %s\n", expression, err_buf); } #else /* we don't USE_PCRE */ - regex_t regexp; - int reg; - reg = regcomp(®exp, expression, REGCOMP_OPT|REG_EXTENDED); - if ( reg == 0 ) + regexp = new Regexp( expression, false ); + if ( regexp->CompiledOK() ) { - this->next = NULL; + compile = true; } else { - regerror (reg, ®exp, err_buf, sizeof(err_buf) ); + err_buf = regexp->GetErrorString(); *erroffset = err_offset; - *errmessage = err_buf; + *errmessage = err_buf.c_str(); printf("Error compiling '%s', %s\n", expression, err_buf); } #endif /* USE_PCRE */ @@ -109,15 +109,9 @@ int IvyBinding::Exec( const char * message ) OVECSIZE); if (nb_match<1) return 0; /* no match */ #else /* we don't USE_PCRE */ - memset( match, -1, sizeof(match )); /* work around bug !!!*/ - nb_match = regexec (®exp, message, MAX_MSG_FIELDS, match, 0) - if (nb_match == REG_NOMATCH) + if ( !regexp->Match( message ) ) return 0; - for ( index = 1; index < MAX_MSG_FIELDS; index++ ) - { - if ( match[i].rm_so != -1 ) - nb_match++; - } + nb_match = regexp->SubStrings()+1; // +1 first arg is wall string #endif /* USE_PCRE */ return nb_match; } @@ -130,16 +124,10 @@ void IvyBinding::Match( const char *message, int argnum, int *arglen, const char *arg = message + ovector[2*argnum]; #else /* we don't USE_PCRE */ - regmatch_t* p; - - p = &match[argnum+1]; - if ( p->rm_so != -1 ) { - *arglen = p->rm_eo - p->rm_so; - *arg = message + p->rm_so; - } else { // ARG VIDE - *arglen = 0; - *arg = NULL; - } + + *arglen = regexp->SubLength(argnum); + *arg = message + regexp->SubStart(argnum); + #endif /* USE_PCRE */ } diff --git a/Ivy/IvyBinding.h b/Ivy/IvyBinding.h index 44a87ee..58f6d42 100644 --- a/Ivy/IvyBinding.h +++ b/Ivy/IvyBinding.h @@ -24,7 +24,7 @@ #include #else /* we don't USE_PCRE */ #define MAX_MSG_FIELDS 200 -#include "Regex.h" +#include "Regexp.h" #endif /* USE_PCRE */ class IvyBinding @@ -48,11 +48,10 @@ private: #ifdef USE_PCRE pcre *regexp; pcre_extra *inspect; - int nb_match; int ovector[OVECSIZE]; #else /* we don't USE_PCRE */ - regex_t regexp; /* la regexp sous forme machine */ - regmatch_t match[MAX_MSG_FIELDS+1]; /* resultat du match */ + Regexp *regexp; /* la regexp sous forme machine */ + //regmatch_t match[MAX_MSG_FIELDS+1]; /* resultat du match */ #endif /* USE_PCRE */ - + int nb_match; }; \ No newline at end of file diff --git a/Ivy/IvyLib/IvyLib.vdproj b/Ivy/IvyLib/IvyLib.vdproj index e8a78e1..e08321f 100644 --- a/Ivy/IvyLib/IvyLib.vdproj +++ b/Ivy/IvyLib/IvyLib.vdproj @@ -15,14 +15,14 @@ { "Entry" { - "MsmKey" = "8:_66D910CBB02B47569794CF954A72E057" + "MsmKey" = "8:_800E481F824E4563B3647395936B79A9" "OwnerKey" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_DE30DB02DD7494AFFBB32B50F67B491E" - "OwnerKey" = "8:_66D910CBB02B47569794CF954A72E057" + "OwnerKey" = "8:_800E481F824E4563B3647395936B79A9" "MsmSig" = "8:_UNDEFINED" } "Entry" @@ -118,7 +118,7 @@ "SharedLegacy" = "11:FALSE" "PackageAs" = "3:1" "Register" = "3:1" - "Exclude" = "11:TRUE" + "Exclude" = "11:FALSE" "IsDependency" = "11:TRUE" "IsolateTo" = "8:" } @@ -167,7 +167,7 @@ } "ProjectOutput" { - "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_66D910CBB02B47569794CF954A72E057" + "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_800E481F824E4563B3647395936B79A9" { "SourcePath" = "8:..\\..\\release\\Ivy.dll" "TargetName" = "8:" @@ -189,7 +189,7 @@ "ProjectOutputGroupRegister" = "3:1" "OutputConfiguration" = "8:" "OutputGroupCanonicalName" = "8:Built" - "OutputProjectGuid" = "8:{9BD87B7A-517E-4900-B3EA-A358885CD876}" + "OutputProjectGuid" = "8:{9818D652-CC05-463E-880D-AFCA2C7BFABE}" "ShowKeyOutput" = "11:FALSE" "ExcludeFilters" { diff --git a/Ivy/Regexp.cxx b/Ivy/Regexp.cxx index 4dc1823..f04da7b 100644 --- a/Ivy/Regexp.cxx +++ b/Ivy/Regexp.cxx @@ -68,7 +68,7 @@ // regular-expression syntax might require a total rethink. #include "IvyStdAfx.h" -#include "regexp.h" +#include "Regexp.h" // The first byte of the regexp internal "program" is actually this magic // number; the start node begins in the second byte. -- cgit v1.1