--- parser3/src/main/pa_string.C 2002/04/19 11:59:44 1.156 +++ parser3/src/main/pa_string.C 2002/06/10 13:50:03 1.159 @@ -4,7 +4,7 @@ Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) - $Id: pa_string.C,v 1.156 2002/04/19 11:59:44 paf Exp $ + $Id: pa_string.C,v 1.159 2002/06/10 13:50:03 paf Exp $ */ #include "pcre.h" @@ -474,7 +474,7 @@ static void regex_options(const String * } /// @todo make replacement Table stacked -bool String::match(const char *acstr, +bool String::match( const String *aorigin, const String& regexp, const String *options, @@ -512,13 +512,13 @@ bool String::match(const char *acstr, info_substrings); } - const char *subject=acstr?acstr:cstr(); + const char *subject=cstr(); int length=strlen(subject); const int ovecsize=(1/*match*/+MAX_STRING_MATCH_TABLE_COLUMNS)*3; int ovector[ovecsize]; // create table - *table=NEW Table(pool(), 0, string_match_table_columns); + *table=NEW Table(pool(), *string_match_table_template); int exec_option_bits=0; int prestart=0; @@ -648,31 +648,6 @@ String& String::replace(Pool& pool, Dict return result; } -/// @test real! -bool String::is_join_chains_profitable() const { - // mimimum actually sizeof(String), - // but one must also consider CPU time optimize would eat - const int minimum_economy=sizeof(String)*2; - - size_t wasted=0; - STRING_FOREACH_ROW( - uchar joined_lang=row->item.lang; - STRING_PREPARED_FOREACH_ROW(*this, - if(row->item.lang==joined_lang) { - wasted+=sizeof(String::Chunk::rows_type); - if(wasted>minimum_economy) - return true; - } else - break; // before non-ours - ); - - // pointers are after joined piece - // & one step back, see STRING_FOREACH_ROW - --row; ++countdown; - ); - return false; -} - String& String::join_chains(Pool& pool, char** acstr) const { char *lcstr=cstr(); const char *current=lcstr; @@ -729,10 +704,11 @@ double String::as_double() const { else result=(double)strtod(cstr, &error_pos); - if(*error_pos/*not EOS*/) - throw Exception("number.format", - this, - "invalid number (double)"); + while(char c=*error_pos++) + if(!isspace(c)) + throw Exception("number.format", + this, + "invalid number (double)"); return result; } @@ -757,10 +733,11 @@ int String::as_int() const { else result=(int)strtol(cstr, &error_pos, 0); - if(*error_pos/*not EOS*/) - throw Exception("number.format", - this, - "invalid number (int)"); + while(char c=*error_pos++) + if(!isspace(c)) + throw Exception("number.format", + this, + "invalid number (int)"); return result; }