--- parser3/src/main/pa_string.C 2001/09/18 16:05:42 1.103 +++ parser3/src/main/pa_string.C 2001/10/05 16:12:40 1.106 @@ -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.106 2001/10/05 16:12:40 parser Exp $ */ -static const char *RCSId="$Id: pa_string.C,v 1.103 2001/09/18 16:05:42 parser Exp $"; #include "pa_config_includes.h" @@ -654,7 +654,9 @@ break2: return result; } +/// @test restructure string to link pieces of same language together prior to this. String& String::replace(Pool& pool, Dictionary& dict) const { + //_asm int 3; String& result=*new(pool) String(pool); const Chunk *chunk=&head; do { @@ -669,22 +671,17 @@ String& String::replace(Pool& pool, Dict char *dest=new_cstr; while(src_size) { // there is a row where first column starts 'src' - if(Table::Item *item=dict.first_that_starts(src)) { + if(Table::Item *item=dict.first_that_starts(src, src_size)) { // 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--; } }