diff options
Diffstat (limited to 'Ivy/IvyBinding.cxx')
-rw-r--r-- | Ivy/IvyBinding.cxx | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Ivy/IvyBinding.cxx b/Ivy/IvyBinding.cxx index c365b71..0a17d4d 100644 --- a/Ivy/IvyBinding.cxx +++ b/Ivy/IvyBinding.cxx @@ -39,6 +39,7 @@ IvyBinding::IvyBinding() #ifdef USE_PCRE regexp = NULL; inspect = NULL; + ovector = NULL; #else /* we don't USE_PCRE */ regexp = NULL; @@ -52,12 +53,15 @@ IvyBinding::~IvyBinding() pcre_free(inspect); if (regexp!=NULL) pcre_free(regexp); + if ( ovector != NULL ) + delete [] ovector; #else /* we don't USE_PCRE */ delete regexp; #endif /* USE_PCRE */ } bool IvyBinding::Compile( const char * expression, int *erroffset, const char **errmessage ) { + int capture_count = 0; bool compile = false; #ifdef USE_PCRE regexp = pcre_compile(expression, PCRE_CASELESS, &err_buf, &err_offset, NULL); @@ -68,6 +72,12 @@ bool IvyBinding::Compile( const char * expression, int *erroffset, const char * { printf("Error studying %s, message: %s\n",expression,err_buf); } + pcre_fullinfo( regexp, inspect, PCRE_INFO_CAPTURECOUNT, &capture_count ); + if ( ovector != NULL ) + delete [] ovector; + // + 1 pour la capture totale + ovectorsize = (capture_count+1) * 3; + ovector = new int[ovectorsize]; compile = true; } else @@ -106,7 +116,7 @@ int IvyBinding::Exec( const char * message ) 0, /* debut */ 0, /* no other regexp option */ ovector, - OVECSIZE); + ovectorsize); if (nb_match<1) return 0; /* no match */ #else /* we don't USE_PCRE */ if ( !regexp->Match( message ) ) |