--- parser3/src/main/pa_string.C 2001/04/04 10:50:36 1.69 +++ parser3/src/main/pa_string.C 2001/04/10 11:24:00 1.76 @@ -5,12 +5,12 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_string.C,v 1.69 2001/04/04 10:50:36 paf Exp $ + $Id: pa_string.C,v 1.76 2001/04/10 11:24:00 paf Exp $ */ #include "pa_config_includes.h" -#include +#include "pcre.h" #include "pa_pool.h" #include "pa_string.h" @@ -22,13 +22,11 @@ #include "pa_table.h" #include "pa_threads.h" -#include "pcre.h" - //#include "pa_sapi.h" // String -String::String(Pool& apool, const char *src, bool tasize_ted) : +String::String(Pool& apool, const char *src, size_t src_size, bool tainted) : Pooled(apool) { last_chunk=&head; head.count=CR_PREALLOCATED_COUNT; @@ -38,10 +36,10 @@ String::String(Pool& apool, const char * fused_rows=fsize=0; if(src) - if(tasize_ted) - APPEND_TAINTED(src, 0, 0, 0); + if(tainted) + APPEND_TAINTED(src, src_size, 0, 0); else - APPEND_CONST(src); + APPEND_CLEAN(src, src_size, 0, 0); } void String::expand() { @@ -199,7 +197,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 +277,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= @@ -491,7 +489,6 @@ static void regex_options(char *options, @verbatim pre-match/match/post-match/1/2/3/... @endverbatim - @test setlocale param to auto.p */ bool String::match(const String *aorigin, const String& regexp, @@ -499,32 +496,30 @@ bool String::match(const String *aorigin Table **table, Row_action row_action, void *info) const { - static const unsigned char *tables=0; { SYNCHRONIZED(true); - if(!tables) { - setlocale(LC_CTYPE, "ru"); - tables=pcre_maketables(); - } - } + if(!regexp.size()) + THROW(0, 0, + aorigin, + "regexp is empty"); const char *pattern=regexp.cstr(UL_AS_IS); const char *errptr; int erroffset; int option_bits[2]; regex_options(options?options->cstr():0, option_bits); pcre *code=pcre_compile(pattern, option_bits[0], &errptr, &erroffset, - tables); + pcre_tables); if(!code) THROW(0, 0, ®exp.mid(erroffset, regexp.size()), - "match error - %s", errptr); + "regular expression syntax error - %s", errptr); int info_substrings=pcre_info(code, 0, 0); if(info_substrings<0) { (*pcre_free)(code); THROW(0, 0, - aorigin, - "pcre_info error #%d", - info_substrings); + aorigin, + "pcre_info error (%d)", + info_substrings); } int startoffset=0; @@ -563,7 +558,7 @@ bool String::match(const String *aorigin (*pcre_free)(code); THROW(0, 0, aorigin, - "pcre_exec error #%d", + "regular expression execute error (%d)", exec_substrings); }