--- parser3/src/main/pa_string.C 2001/04/03 15:25:09 1.65 +++ parser3/src/main/pa_string.C 2001/04/05 13:27:14 1.71 @@ -5,13 +5,15 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_string.C,v 1.65 2001/04/03 15:25:09 paf Exp $ + $Id: pa_string.C,v 1.71 2001/04/05 13:27:14 paf Exp $ */ #include "pa_config_includes.h" #include +#include "pcre.h" + #include "pa_pool.h" #include "pa_string.h" #include "pa_hash.h" @@ -22,8 +24,6 @@ #include "pa_table.h" #include "pa_threads.h" -#include "pcre.h" - //#include "pa_sapi.h" // String @@ -199,7 +199,7 @@ int String::cmp(int& partial, const Stri break; if(pos+a_row->item.size > this_offset) { - if(lang!=UL_UNKNOWN && a_row->item.lang!=lang) + if(lang!=UL_UNSPECIFIED && a_row->item.lang!=lang) return -1; // wrong lang -- bail out int size_diff= @@ -279,7 +279,7 @@ int String::cmp(int& partial, const char break; if(pos+a_row->item.size > this_offset) { - if(lang!=UL_UNKNOWN && a_row->item.lang!=lang) + if(lang!=UL_UNSPECIFIED && a_row->item.lang!=lang) return -1; // wrong lang -- bail out int size_diff= @@ -342,7 +342,7 @@ const Origin& String::origin() const { } #endif -String& String::piece(size_t start, size_t finish) const { +String& String::mid(size_t start, size_t finish) const { start=max(0, start); finish=min(size(), finish); if(start==finish) @@ -415,12 +415,12 @@ void String::split(Array& result, int pos_before; // while we have 'delim'... for(; (pos_before=pos(delim, delim_size, pos_after, lang))>=0 && limit; limit--) { - result+=&piece(pos_after, pos_before); + result+=&mid(pos_after, pos_before); pos_after=pos_before+delim_size; } // last piece if(pos_after=0 && limit; limit--) { - result+=&piece(pos_after, pos_before); + result+=&mid(pos_after, pos_before); pos_after=pos_before+delim.size(); } // last piece if(pos_aftercstr():0, option_bits); @@ -506,11 +513,10 @@ bool String::match(const String *aorigin &errptr, &erroffset, tables); - if(!code) { + if(!code) THROW(0, 0, - ®exp.piece(erroffset, regexp.size()), - errptr); - } + ®exp.mid(erroffset, regexp.size()), + "match error - %s", errptr); int info_substrings=pcre_info(code, 0, 0); if(info_substrings<0) { @@ -522,7 +528,7 @@ bool String::match(const String *aorigin } int startoffset=0; - const char *subject=cstr(); + const char *subject=cstr(UL_AS_IS); int length=strlen(subject); int ovecsize; int *ovector=(int *)malloc(sizeof(int)* @@ -549,7 +555,7 @@ bool String::match(const String *aorigin if(exec_substrings==PCRE_ERROR_NOMATCH) { (*pcre_free)(code); - (*row_action)(**table, 0/*last time, no row*/, info); + (*row_action)(**table, 0/*last time, no row*/, 0, 0, info); return option_bits[1]!=0; // global=true+table, not global=false } @@ -562,24 +568,23 @@ bool String::match(const String *aorigin } Array& row=*NEW Array(pool()); - row+=&piece(0, ovector[0]); // .pre-match column value - row+=&piece(ovector[0], ovector[1]); // .match - row+=&piece(ovector[1], size()); // .post-match + row+=&mid(0, ovector[0]); // .pre-match column value + row+=&mid(ovector[0], ovector[1]); // .match + row+=&mid(ovector[1], size()); // .post-match for(int i=1; i