--- parser3/src/main/pa_string.C 2024/09/11 21:07:36 1.273 +++ parser3/src/main/pa_string.C 2025/05/26 00:52:15 1.283 @@ -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.273 2024/09/11 21:07:36 moko Exp $" IDENT_PA_STRING_H; +volatile const char * IDENT_PA_STRING_C="$Id: pa_string.C,v 1.283 2025/05/26 00:52:15 moko Exp $" IDENT_PA_STRING_H; const String String::Empty; @@ -46,9 +46,10 @@ template inline T pa_ato_any } } - if (base < 2 || base > 16) { /* illegal base */ + if (base < 2 || base > 16) /* illegal base */ throw Exception(PARSER_RUNTIME, 0, "base to must be an integer from 2 to 16"); - } + if (*pos == '-') + throw Exception("number.format", problem_source, problem_source ? "out of range (negative)" : "'%s' is out if range (negative)", str); T cutoff = max / base; int cutoff_digit = (int)(max - cutoff * base); @@ -80,7 +81,7 @@ template inline T pa_ato_any while(char c=*pos++) if(!isspace(c)) - throw Exception("number.format", problem_source, problem_source ? "invalid number (int)" : "'%s' is invalid number (int)", str); + throw Exception("number.format", problem_source, problem_source ? "invalid number (int)" : "'%s' is an invalid number (int)", str); return result; } @@ -115,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); @@ -232,15 +233,29 @@ public: *this+=new String("match"); *this+=new String("postmatch"); for(int i=0; i=start', that's(<) impossible - return 0; // all chars are empty, just return empty string + return String::Body(); // all chars are empty, just return empty string } else - break; + break; CORD_prev(pos); } @@ -315,7 +330,7 @@ String::Body String::Body::trim(String:: if(found){ start+=char_length; if(start==our_length) - return 0; // all chars are empty, just return empty string + return String::Body(); // all chars are empty, just return empty string } else break; } @@ -339,7 +354,7 @@ String::Body String::Body::trim(String:: if(found){ end-=char_length; if(end==0) - return 0; // all chars are empty, just return empty string + return String::Body(); // all chars are empty, just return empty string } else break; } @@ -616,7 +631,7 @@ void String::split(ArrayString& result, if(size_t delim_length=strlen(delim)) { size_t pos_before; // while we have 'delim'... - while((pos_before=pos(delim, pos_after, lang))!=STRING_NOT_FOUND) { + while((pos_before=pos(String::Body(delim), pos_after, lang)) != STRING_NOT_FOUND) { result+=&mid(pos_after, pos_before); pos_after=pos_before+delim_length; } @@ -659,7 +674,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; @@ -699,7 +714,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; @@ -762,7 +777,7 @@ String& String::change_case(Charset& sou } } result.langs=langs; - result.body=new_cstr; + result.body=String::Body(new_cstr); return result; }