--- parser3/src/main/pa_string.C 2009/06/23 10:05:16 1.229 +++ parser3/src/main/pa_string.C 2009/07/14 11:15:29 1.232 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_STRING_C="$Date: 2009/06/23 10:05:16 $"; +static const char * const IDENT_STRING_C="$Date: 2009/07/14 11:15:29 $"; #include "pa_string.h" #include "pa_exception.h" @@ -226,7 +226,8 @@ String::Body String::Body::trim(String:: while(src_begin127 && *src_begin<0xC0)/* searching first UTF-8 byte */) + // searching first UTF-8 byte: http://tools.ietf.org/html/rfc3629#section-3 + while(++src_begin<=src_end && (*src_begin>127 && *src_begin<0xC0)) char_length++; bool found=false; @@ -249,7 +250,8 @@ String::Body String::Body::trim(String:: if(kind!=TRIM_START) { while(src_begin127 && *src_end<0xC0)/* searching first UTF-8 byte */) + // searching first UTF-8 byte: http://tools.ietf.org/html/rfc3629#section-3 + while(src_begin<=--src_end && (*src_end>127 && *src_end<0xC0)) char_length++; bool found=false; @@ -407,12 +409,12 @@ String& String::mid(Charset& charset, si return result; if(charset.isUTF8()){ - const XMLByte* srcPtr=(const XMLByte*)cstrm(); - const XMLByte* srcEnd=srcPtr+body.length(); + const XMLByte* src_begin=(const XMLByte*)cstrm(); + const XMLByte* src_end=src_begin+body.length(); // convert 'from' and 'substr_length' from 'characters' to 'bytes' - from=getUTF8BytePos(srcPtr, srcEnd, from); - substr_length=getUTF8BytePos(srcPtr+from, srcEnd, substr_length); + from=getUTF8BytePos(src_begin, src_end, from); + substr_length=getUTF8BytePos(src_begin+from, src_end, substr_length); if(!substr_length) return result; } @@ -541,7 +543,7 @@ Table* String::match(VRegex* vregex, int prefinish=ovector[0]; poststart=ovector[1]; - ArrayString* row=new ArrayString; + ArrayString* row=new ArrayString(3); if(need_pre_post_match) { *row+=&mid(0, prefinish); // .prematch column value *row+=&mid(prefinish, poststart); // .match @@ -554,7 +556,7 @@ Table* String::match(VRegex* vregex, for(int i=1; i=0 && ovector[i*2+1]>0)?&mid(ovector[i*2+0], ovector[i*2+1]):new String; // .i column value } matches_count++;