--- parser3/src/main/pa_string.C 2003/03/24 11:05:28 1.172.2.21.2.19 +++ parser3/src/main/pa_string.C 2003/03/24 16:08:35 1.172.2.21.2.26 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_STRING_C="$Date: 2003/03/24 11:05:28 $"; +static const char* IDENT_STRING_C="$Date: 2003/03/24 16:08:35 $"; #include "pcre.h" @@ -49,7 +49,10 @@ void String::ArrayFragment::append_posit const element_type& fragment=i.next(); fragment_end=fragment_begin+fragment.length; - if(fragment_beginfragment_end) // not reached fragments which may include 'substr'? continue; // found first fragment including piece of 'substr' @@ -73,14 +76,15 @@ void String::ArrayFragment::append_posit break; } } -/* -void String::ArrayFragment::mid(ArrayFragment& result, size_t substr_begin, size_t substr_end) { -} -*/ // StringSimple methods +static int CORD_batched_iter_fn_generic_hash_code(char c, void * client_data) { + uint& result=*static_cast(client_data); + generic_hash_code(result, c); + return 0; +} static int CORD_batched_iter_fn_generic_hash_code(const char* s, void * client_data) { uint& result=*static_cast(client_data); generic_hash_code(result, s); @@ -88,7 +92,9 @@ static int CORD_batched_iter_fn_generic_ }; uint StringBody::hash_code() const { uint result=0; - CORD_iter5(body, 0, 0, CORD_batched_iter_fn_generic_hash_code, &result); + CORD_iter5(body, 0, + CORD_batched_iter_fn_generic_hash_code, + CORD_batched_iter_fn_generic_hash_code, &result); return result; } @@ -137,7 +143,7 @@ String& String::mid(size_t substr_begin, size_t String::pos(const StringBody substr, size_t this_offset, Language lang) const { // first: letters themselves - size_t substr_begin=body.pos(this_offset, substr); + size_t substr_begin=body.pos(substr, this_offset); if(substr_begin==CORD_NOT_FOUND) return STRING_NOT_FOUND; @@ -165,11 +171,11 @@ size_t String::pos(const StringBody subs "searching for '%s' starting from %ud problem: found begin in one fragment, but end in another", substr.cstr(), this_offset); - if(fragment.lang==lang) + if(fragment.lang<=lang) return substr_begin; else { // bad lang... /// WARNING: this possibly skips assert (*), but it's fast - substr_begin=body.pos(fragment_end/*...search AFTER for more*/, substr); + substr_begin=body.pos(substr, fragment_end/*...search AFTER for more*/); if(substr_begin==CORD_NOT_FOUND) return STRING_NOT_FOUND; @@ -189,7 +195,7 @@ size_t String::pos(const String& substr, void String::split(ArrayString& result, size_t& pos_after, const char* delim, - Language lang, int limit) { + Language lang, int limit) const { size_t self_length=length(); if(size_t delim_length=strlen(delim)) { int pos_before; @@ -231,7 +237,7 @@ void String::split(ArrayString& result, } } -static void regex_options(const String& options, int *result, bool& need_pre_post_match){ +static void regex_options(const String* options, int *result, bool& need_pre_post_match){ struct Regex_option { const char* keyL; const char* keyU; @@ -250,10 +256,10 @@ static void regex_options(const String& result[0]=PCRE_EXTRA | PCRE_DOTALL | PCRE_DOLLAR_ENDONLY; result[1]=0; - if(!options.is_empty()) + if(options && !options->is_empty()) for(Regex_option *o=regex_option; o->keyL; o++) - if(options.pos(o->keyL)>=0 - || (o->keyU && options.pos(o->keyU)>=0)) { + if(options->pos(o->keyL)>=0 + || (o->keyU && options->pos(o->keyU)>=0)) { if(o->flag) *o->flag=true; else { // result @@ -265,7 +271,7 @@ static void regex_options(const String& Table* String::match(Charset& source_charset, const String& regexp, - const String& options, + const String* options, Row_action row_action, void *info, bool& just_matched) const { if(regexp.is_empty()) @@ -303,7 +309,7 @@ Table* String::match(Charset& source_cha int ovector[oveclength]; // create table - Table* table=new Table(string_match_table_template); + Table& table=*new Table(string_match_table_template); int exec_option_bits=0; int prestart=0; @@ -318,7 +324,7 @@ Table* String::match(Charset& source_cha pcre_free(code); row_action(table, 0/*last time, no raw*/, 0, 0, poststart, postfinish, info); if(global || subpatterns) - return table; // global or with subpatterns=true+result + return &table; // global or with subpatterns=true+result else { just_matched=false; return 0; // not global=no result } @@ -355,7 +361,7 @@ Table* String::match(Charset& source_cha if(!global || prestart==poststart) { // not global | going to hang pcre_free(code); row_action(table, 0/*last time, no row*/, 0, 0, poststart, postfinish, info); - return table; + return &table; } prestart=poststart; @@ -366,7 +372,7 @@ Table* String::match(Charset& source_cha } } -String& String::change_case(Charset& source_charset, Change_case_kind kind) { +String& String::change_case(Charset& source_charset, Change_case_kind kind) const { String& result=*new String(); const unsigned char *tables=source_charset.pcre_tables;