--- parser3/src/main/pa_string.C 2001/04/05 13:27:14 1.71 +++ parser3/src/main/pa_string.C 2001/04/10 11:24:00 1.76 @@ -5,13 +5,11 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_string.C,v 1.71 2001/04/05 13:27:14 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" @@ -28,7 +26,7 @@ // 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() { @@ -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); }