--- parser3/src/main/pa_string.C 2003/09/29 11:15:40 1.182 +++ parser3/src/main/pa_string.C 2003/10/03 09:40:57 1.184 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_STRING_C="$Date: 2003/09/29 11:15:40 $"; +static const char* IDENT_STRING_C="$Date: 2003/10/03 09:40:57 $"; #include "pcre.h" @@ -167,11 +167,18 @@ String& String::mid(size_t substr_begin, } size_t String::pos(const String::Body substr, size_t this_offset, Language lang) const { - size_t substr_begin=body.pos(substr, this_offset); - if(substr_begin==CORD_NOT_FOUND || !langs.check_lang(lang, substr_begin, substr.length())) - return STRING_NOT_FOUND; + size_t substr_length=substr.length(); + while(true) { + size_t substr_begin=body.pos(substr, this_offset); + + if(substr_begin==CORD_NOT_FOUND) + return STRING_NOT_FOUND; + + if(langs.check_lang(lang, substr_begin, substr_length)) + return substr_begin; - return substr_begin; + this_offset=substr_begin+substr_length; + } } size_t String::pos(const String& substr, @@ -422,7 +429,7 @@ const String& String::replace(const Dict const char* current=old_cstr; while(*current) { - if(Table::element_type row=dict.first_that_begins(current)) { + if(Dictionary::Subst subst=dict.first_that_begins(current)) { // prematch if(size_t prematch_length=current-prematch_begin) { result.langs.append(result.body, langs, prematch_begin-old_cstr, prematch_length); @@ -430,15 +437,11 @@ const String& String::replace(const Dict } // match - - const String* a=row->get(0); // skip 'a' in 'current'; move prematch_begin - current+=a->length(); prematch_begin=current; + current+=subst.from_length; prematch_begin=current; - if(row->count()>1) { // are there any b? - const String* b=row->get(1); + if(const String* b=subst.to) // are there any b? result<<*b; - } } else // simply advance current++; }