summaryrefslogtreecommitdiff
path: root/src/ivybind.c
diff options
context:
space:
mode:
authorfcolin2009-06-18 14:29:12 +0000
committerfcolin2009-06-18 14:29:12 +0000
commit854c4213d33279e1b30a63f48760a9ffae16d9ed (patch)
tree95ee86b0f2720d1f2c52d2b8fcbc103a069c685c /src/ivybind.c
parentc9de0520e4a6a96cb037eec1086f95b8f297c81f (diff)
downloadivy-c-854c4213d33279e1b30a63f48760a9ffae16d9ed.zip
ivy-c-854c4213d33279e1b30a63f48760a9ffae16d9ed.tar.gz
ivy-c-854c4213d33279e1b30a63f48760a9ffae16d9ed.tar.bz2
ivy-c-854c4213d33279e1b30a63f48760a9ffae16d9ed.tar.xz
correction limite d'argument sur regexp Exec
Diffstat (limited to 'src/ivybind.c')
-rw-r--r--src/ivybind.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/ivybind.c b/src/ivybind.c
index d9bebb2..1886d03 100644
--- a/src/ivybind.c
+++ b/src/ivybind.c
@@ -31,7 +31,6 @@
#ifdef USE_PCRE_REGEX
-#define OVECSIZE 120 /* must be multiple of 3, for regexp return */
#include <pcre.h>
#else /* we don't USE_PCRE_REGEX */
#define MAX_MSG_FIELDS 200
@@ -54,7 +53,8 @@ struct _binding {
pcre *regexp;
pcre_extra *inspect;
int nb_match;
- int ovector[OVECSIZE];
+ int *ovector;
+ int ovectorsize;
#else /* we don't USE_PCRE_REGEX */
regex_t regexp; /* la regexp sous forme machine */
regmatch_t match[MAX_MSG_FIELDS+1]; /* resultat du match */
@@ -74,6 +74,7 @@ IvyBinding IvyBindingCompile( const char * expression, int *erroffset, const ch
/* if ((called %1000) == 0) { */
/* printf ("DBG> IvyBindingCompile called =%d\n", called); */
/* } */
+ int capture_count=0;
IvyBinding bind=0;
#ifdef USE_PCRE_REGEX
pcre *regexp;
@@ -93,6 +94,12 @@ IvyBinding IvyBindingCompile( const char * expression, int *erroffset, const ch
{
printf("Error studying %s, message: %s\n",expression,err_buf);
}
+ pcre_fullinfo( bind->regexp, bind->inspect, PCRE_INFO_CAPTURECOUNT, &capture_count );
+ if ( bind->ovector != NULL )
+ free( bind->ovector );
+ // + 1 pour la capture totale
+ bind->ovectorsize = (capture_count+1) * 3;
+ bind->ovector = malloc( sizeof( int )* bind->ovectorsize);
}
else
{
@@ -134,6 +141,9 @@ void IvyBindingFree( IvyBinding bind )
/* printf ("DBG> IvyBindingFree called =%d\n", called); */
/* } */
#ifdef USE_PCRE_REGEX
+ if ( bind->ovector != NULL )
+ free( bind->ovector );
+
if (bind->inspect!=NULL)
pcre_free(bind->inspect);
pcre_free(bind->regexp);
@@ -157,7 +167,7 @@ int IvyBindingExec( IvyBinding bind, const char * message )
0, /* debut */
0, /* no other regexp option */
bind->ovector,
- OVECSIZE);
+ bind->ovectorsize);
if (nb_match<1) return 0; /* no match */
bind->nb_match = nb_match;
#else /* we don't USE_PCRE_REGEX */