--- parser3/src/classes/string.C 2020/11/10 22:42:25 1.246 +++ parser3/src/classes/string.C 2020/12/17 20:01:03 1.249 @@ -1,7 +1,7 @@ /** @file Parser: @b string parser class. - Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ @@ -21,7 +21,7 @@ #include "pa_vregex.h" #include "pa_charsets.h" -volatile const char * IDENT_STRING_C="$Id: string.C,v 1.246 2020/11/10 22:42:25 moko Exp $"; +volatile const char * IDENT_STRING_C="$Id: string.C,v 1.249 2020/12/17 20:01:03 moko Exp $"; // class @@ -205,8 +205,7 @@ static void _pos(Request& r, MethodParam r.write(*new VInt((int)string.pos(r.charsets.source(), substr.as_string(), offset))); } -static void split_list(MethodParams& params, int paramIndex, const String& string, ArrayString& result) { - Value& delim_value=params.as_no_junction(paramIndex, "delimiter must not be code"); +static void split_list(Value& delim_value, const String& string, ArrayString& result) { string.split(result, 0, delim_value.as_string()); } @@ -286,7 +285,7 @@ static void split_with_options(Request& size_t params_count=params.count(); ArrayString pieces; - split_list(params, 0, string, pieces); + split_list(params.as_no_junction(0, "delimiter must not be code"), string, pieces); if(!bits) { const String* options=0; @@ -553,9 +552,11 @@ static void _replace(Request& r, MethodP if(params.count()==1) { // ^string.replace[table] - Table* table=params.as_table(0, "param"); - Dictionary dict(*table); - r.write(src.replace(dict)); + if(Table* table=params.as_table(0, "param")){ + Dictionary dict(*table); + r.write(src.replace(dict)); + } else + r.write(src); } else { // ^string.replace[from-string;to-string] Dictionary dict(params.as_string(0, "from must be string"), params.as_string(1, "to must be string"));