--- parser3/src/main/pa_string.C 2001/09/06 14:55:06 1.102 +++ parser3/src/main/pa_string.C 2001/10/05 14:48:58 1.105 @@ -2,10 +2,10 @@ Parser: string class. @see untasize_t.C. Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) + + $Id: pa_string.C,v 1.105 2001/10/05 14:48:58 parser Exp $ */ -static const char *RCSId="$Id: pa_string.C,v 1.102 2001/09/06 14:55:06 parser Exp $"; #include "pa_config_includes.h" @@ -655,6 +655,7 @@ break2: } String& String::replace(Pool& pool, Dictionary& dict) const { + String& result=*new(pool) String(pool); const Chunk *chunk=&head; do { @@ -673,18 +674,13 @@ String& String::replace(Pool& pool, Dict // get a=>b values const String& a=*static_cast(item)->get_string(0); const String& b=*static_cast(item)->get_string(1); - // skip 'a' in 'src' - src+=a.size(); - // write 'b' to 'dest' - b.store_to(dest); - // skip 'b' in 'dest' - dest+=b.size(); - // reduce work size - src_size-=a.size(); + // skip 'a' in 'src' && reduce work size + src+=a.size(); src_size-=a.size(); + // write 'b' to 'dest' && skip 'b' in 'dest' + b.store_to(dest); dest+=b.size(); } else { - *dest++=*src++; - // reduce work size - src_size--; + // write a char to b && reduce work size + *dest++=*src++; src_size--; } } @@ -712,7 +708,7 @@ double String::as_double() const { else result=(double)strtod(cstr, &error_pos); - if(error_pos==cstr/*empty*/ || *error_pos/*not eos*/) + if(*error_pos/*not EOS*/) THROW(0, 0, this, "invalid number (double)"); @@ -732,7 +728,7 @@ int String::as_int() const { else result=(int)strtol(cstr, &error_pos, 0); - if(error_pos==cstr/*empty*/ || *error_pos/*not eos*/) + if(*error_pos/*not EOS*/) THROW(0, 0, this, "invalid number (int)");