|
@@ -22,16 +22,16 @@ boolean ini_expreg(expreg* er, char* str, char* regex) {
|
|
|
memset(er->str, 0, length + 1);
|
|
|
strncpy(er->str, str, length);
|
|
|
//Setup structure
|
|
|
- er->pos = er->str;
|
|
|
+ er->pos = 0;
|
|
|
er->nmatch = er->regex.re_nsub;
|
|
|
er->pmatch = malloc(sizeof (regmatch_t) * er->nmatch);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
char* get_match_expreg(expreg* er, int* deb, int* fin) {
|
|
|
- if (regexec(&er->regex, er->pos, er->nmatch, er->pmatch, 0) != 0) {
|
|
|
+ if (regexec(&er->regex, er->str + er->pos, er->nmatch, er->pmatch, 0) != 0) {
|
|
|
if(deb != NULL){
|
|
|
- *deb = -1;
|
|
|
+ *deb = -1;
|
|
|
}
|
|
|
if(fin != NULL){
|
|
|
*fin = -1;
|
|
@@ -44,7 +44,7 @@ char* get_match_expreg(expreg* er, int* deb, int* fin) {
|
|
|
int length = end - start;
|
|
|
//Indique les positions
|
|
|
if(deb != NULL){
|
|
|
- *deb = start;
|
|
|
+ *deb = er->pos + start;
|
|
|
}
|
|
|
if(fin != NULL){
|
|
|
*fin = end;
|
|
@@ -53,7 +53,7 @@ char* get_match_expreg(expreg* er, int* deb, int* fin) {
|
|
|
char* str;
|
|
|
str = malloc(sizeof(char) * (length + 1));
|
|
|
memset(str, 0, length + 1);
|
|
|
- strncpy(str, &er->pos[start], length);
|
|
|
+ strncpy(str, &er->str[er->pos + start], length);
|
|
|
//On avance dans la chaine
|
|
|
er->pos += end;
|
|
|
return str;
|