--- parser3/src/classes/string.C 2024/09/07 15:01:38 1.252 +++ parser3/src/classes/string.C 2024/10/02 22:54:02 1.256 @@ -21,7 +21,7 @@ #include "pa_vregex.h" #include "pa_charsets.h" -volatile const char * IDENT_STRING_C="$Id: string.C,v 1.252 2024/09/07 15:01:38 moko Exp $"; +volatile const char * IDENT_STRING_C="$Id: string.C,v 1.256 2024/10/02 22:54:02 moko Exp $"; // class @@ -147,7 +147,7 @@ static void _bool(Request& r, MethodPara // for some time due to stupid {} in original design const String& fmt=r.process_to_string(fmt_maybe_code); - const char* buf=format(r.get_self().as_double(), fmt.trim().cstrm()); + const char* buf=format_double(r.get_self().as_double(), fmt.trim().cstrm()); r.write(String(buf)); } @@ -221,8 +221,7 @@ static void split_action(Table& , ArrayS } static void split_list(Value& delim_value, const String& string, ArrayString& result) { - if(Value* value=delim_value.as(VREGEX_TYPE)){ - VRegex *vregex=static_cast(value); + if(VRegex *vregex=dynamic_cast(&delim_value)){ vregex->study(); int matches_count=0; @@ -278,8 +277,7 @@ static Table& split_vertical(ArrayString table+=row; } } else { // left - ArrayString::Iterator i(pieces); - while(i.has_next()) { + for(ArrayString::Iterator i(pieces); i; ) { Table::element_type row(new ArrayString); *row+=i.next(); table+=row; @@ -296,7 +294,7 @@ static Table& split_horizontal(ArrayStri for(int i=pieces.count(); --i>=0; ) *row+=pieces[i]; } else { // left - for(ArrayString::Iterator i(pieces); i.has_next(); ) + for(ArrayString::Iterator i(pieces); i; ) *row+=i.next(); } table+=row; @@ -387,13 +385,12 @@ static void _match(Request& r, MethodPar Value& regexp=params.as_no_junction(0, "regexp must not be code"); Value* options=(params_count>1)?¶ms.as_no_junction(1, OPTIONS_MUST_NOT_BE_CODE):0; - VRegex* vregex; + VRegex* vregex=dynamic_cast(®exp); VRegexCleaner vrcleaner; - if(Value* value=regexp.as(VREGEX_TYPE)){ + if(vregex){ if(options && options->is_defined()) - throw Exception(PARSER_RUNTIME, 0, "you can not specify regex-object and options together"); - vregex=static_cast(value); + throw Exception(PARSER_RUNTIME, 0, "you cannot specify regex-object and options together"); } else { vregex=new VRegex(r.charsets.source(), ®exp.as_string(), (options) ? (&options->as_string()) : 0); vregex->study(); @@ -489,7 +486,7 @@ public: bool add_row(SQL_Error& /*error*/) { /* ignore */ return false; } bool add_row_cell(SQL_Error& error, const char* str, size_t) { if(got_cell) { - error=SQL_Error("result must not contain more then one row"); + error=SQL_Error("result must contain no more than one row"); return true; } try {