--- parser3/src/main/pa_string.C 2024/10/27 17:50:59 1.276 +++ parser3/src/main/pa_string.C 2024/11/13 00:09:52 1.281 @@ -1,7 +1,7 @@ /** @file Parser: string class. @see untalength_t.C. - Copyright (c) 2001-2023 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2024 Art. Lebedev Studio (http://www.artlebedev.com) Authors: Konstantin Morshnev , Alexandr Petrosian */ @@ -12,7 +12,7 @@ #include "pa_charset.h" #include "pa_vregex.h" -volatile const char * IDENT_PA_STRING_C="$Id: pa_string.C,v 1.276 2024/10/27 17:50:59 moko Exp $" IDENT_PA_STRING_H; +volatile const char * IDENT_PA_STRING_C="$Id: pa_string.C,v 1.281 2024/11/13 00:09:52 moko Exp $" IDENT_PA_STRING_H; const String String::Empty; @@ -238,7 +238,12 @@ public: } }; -Table string_match_table_template(new String_match_table_template_columns); +static Table &string_match_table_template(){ + static Table *singleton=NULL; + if(!singleton) + singleton=new Table(new String_match_table_template_columns); + return *singleton; +} // String::Body methods @@ -261,7 +266,7 @@ String::Body String::Body::trim(String:: size_t start=0; size_t end=our_length; if(!chars) - chars=" \t\n"; // white space + chars=" \t\r\n"; // white space if(fast){ // from left... @@ -273,7 +278,7 @@ String::Body String::Body::trim(String:: if(++start==our_length) return 0; // all chars are empty, just return empty string } else - break; + break; CORD_next(pos); } @@ -288,7 +293,7 @@ String::Body String::Body::trim(String:: if(--end==0) // optimization: NO need to check for 'end>=start', that's(<) impossible return 0; // all chars are empty, just return empty string } else - break; + break; CORD_prev(pos); } @@ -660,7 +665,7 @@ Table* String::match(VRegex* vregex, Row int ovector[ovector_size]; Table::Action_options table_options; - Table& table=*new Table(string_match_table_template, table_options); + Table& table=*new Table(string_match_table_template(), table_options); int prestart=0; int poststart=0;