--- parser3/src/classes/file.C 2024/10/22 02:44:40 1.283 +++ parser3/src/classes/file.C 2024/11/10 20:33:21 1.288 @@ -1,7 +1,7 @@ /** @file Parser: @b file parser class. - 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 */ @@ -27,7 +27,7 @@ #include "pa_vregex.h" #include "pa_version.h" -volatile const char * IDENT_FILE_C="$Id: file.C,v 1.283 2024/10/22 02:44:40 moko Exp $"; +volatile const char * IDENT_FILE_C="$Id: file.C,v 1.288 2024/11/10 20:33:21 moko Exp $"; // defines @@ -57,7 +57,12 @@ public: } }; -Table file_list_table_template(new File_list_table_template_columns); +static Table &file_list_table_template(){ + static Table *singleton=NULL; + if(singleton==NULL) + singleton=new Table(new File_list_table_template_columns); + return *singleton; +} // class @@ -555,7 +560,7 @@ static void _exec_cgi(Request& r, Method if(i.value()){ const String *string=i.value()->get_string(); if(!string) - i.value()->bark("array element is '%s', it does not string value"); + i.value()->bark("array element is '%s', it does not have string value"); append_to_argv(r, argv, string); } } @@ -563,6 +568,15 @@ static void _exec_cgi(Request& r, Method throw Exception(PARSER_RUNTIME, 0, "param must be string or table or array of strings"); } } + + // remove trailing empty arguments for backward compatibility + for(ArrayString::ReverseIterator i(argv); i;){ + if(i.prev()->is_empty()){ // here for correct i.index() + argv.remove(i.index()); + } else { + break; + } + } } // transcode if necessary @@ -728,7 +742,7 @@ static void _list(Request& r, MethodPara const char* absolute_path_cstr=r.full_disk_path(relative_path.as_string()).taint_cstr(String::L_FILE_SPEC); Table::Action_options table_options; - Table& table=*new Table(file_list_table_template, table_options); + Table& table=*new Table(file_list_table_template(), table_options); const int ovector_size=(1/*match*/)*3; int ovector[ovector_size];