--- parser3/src/main/pa_string.C 2024/09/24 00:18:54 1.274 +++ parser3/src/main/pa_string.C 2024/11/10 20:46:08 1.280 @@ -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.274 2024/09/24 00:18:54 moko Exp $" IDENT_PA_STRING_H; +volatile const char * IDENT_PA_STRING_C="$Id: pa_string.C,v 1.280 2024/11/10 20:46:08 moko Exp $" IDENT_PA_STRING_H; const String String::Empty; @@ -116,11 +116,11 @@ int pa_atoi(const char* str, int base, c negative=true; str++; if(!*str || isspace(*str)) - throw Exception("number.format", problem_source, problem_source ? "invalid number (int)" : "'%s' is invalid number (int)", str_copy); + throw Exception("number.format", problem_source, problem_source ? "invalid number (int)" : "'%s' is an invalid number (int)", str_copy); } else if(str[0]=='+') { str++; if(!*str || isspace(*str)) - throw Exception("number.format", problem_source, problem_source ? "invalid number (int)" : "'%s' is invalid number (int)", str_copy); + throw Exception("number.format", problem_source, problem_source ? "invalid number (int)" : "'%s' is an invalid number (int)", str_copy); } unsigned int result=pa_atoui(str, base, problem_source); @@ -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 @@ -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; @@ -700,7 +705,7 @@ Table* String::match(VRegex* vregex, Row matches_count++; row_action(table, row, prestart - !action_was_executed, prefinish, poststart, postfinish, info); - if(!global || poststart>=subject_length) // last step, avoid prestart++ after last char + if(!global || (size_t)poststart>=subject_length) // last step, avoid prestart++ after last char break; prestart=poststart;