--- parser3/src/main/pa_string.C 2001/04/03 14:39:03 1.63 +++ parser3/src/main/pa_string.C 2001/04/03 15:25:09 1.65 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_string.C,v 1.63 2001/04/03 14:39:03 paf Exp $ + $Id: pa_string.C,v 1.65 2001/04/03 15:25:09 paf Exp $ */ #include "pa_config_includes.h" @@ -485,11 +485,13 @@ static void regex_options(char *options, } } -/// @test setlocale param to auto.p @test pcre_malloc & pcre_free substs +/// @test setlocale param to auto.p bool String::match(const String *aorigin, const String& regexp, const String *options, - Table **table) const { + Table **table, + Row_action row_action, void *info) const { + static const unsigned char *tables=0; { SYNCHRONIZED(true); if(!tables) { setlocale(LC_CTYPE, "ru"); @@ -524,27 +526,30 @@ bool String::match(const String *aorigin int length=strlen(subject); int ovecsize; int *ovector=(int *)malloc(sizeof(int)* - (ovecsize=(3/*pre/match/post*/+info_substrings)*3)); + (ovecsize=(1/*match*/+info_substrings)*3)); - // create table - Array& columns=*NEW Array(pool()); - columns+=string_pre_match_name; - columns+=string_match_name; - columns+=string_post_match_name; - for(int i=1; i<=info_substrings; i++) { - char *column=(char *)malloc(MAX_NUMBER); - snprintf(column, MAX_NUMBER, "%d", i); - columns+=NEW String(pool(), column); // .i column name + { // create table + Array& columns=*NEW Array(pool()); + columns+=string_pre_match_name; + columns+=string_match_name; + columns+=string_post_match_name; + for(int i=1; i<=info_substrings; i++) { + char *column=(char *)malloc(MAX_NUMBER); + snprintf(column, MAX_NUMBER, "%d", i); + columns+=NEW String(pool(), column); // .i column name + } + *table=NEW Table(pool(), aorigin, &columns); } - *table=NEW Table(pool(), aorigin, &columns); + int exec_option_bits=0; while(true) { int exec_substrings=pcre_exec(code, 0, subject, length, startoffset, - 0/*option_bits[0]*/, ovector, ovecsize); + exec_option_bits, ovector, ovecsize); if(exec_substrings==PCRE_ERROR_NOMATCH) { (*pcre_free)(code); + (*row_action)(**table, 0/*last time, no row*/, info); return option_bits[1]!=0; // global=true+table, not global=false } @@ -557,26 +562,27 @@ bool String::match(const String *aorigin } Array& row=*NEW Array(pool()); - row+=&piece(0, ovector[0]); // pre-match - row+=&piece(ovector[0], ovector[1]); // match - row+=&piece(ovector[1], size()); // post-match + row+=&piece(0, ovector[0]); // .pre-match column value + row+=&piece(ovector[0], ovector[1]); // .match + row+=&piece(ovector[1], size()); // .post-match for(int i=1; i