|
|
| version 1.381, 2025/05/27 15:10:24 | version 1.385, 2026/11/28 22:13:43 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b table parser class. | Parser: @b table parser class. |
| Copyright (c) 2001-2024 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) |
| Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> | Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> |
| */ | */ |
| Line 417 static void _load(Request& r, MethodPara | Line 417 static void _load(Request& r, MethodPara |
| control_chars.load(*options); | control_chars.load(*options); |
| // loading text | // loading text |
| char *data=file_load_text(r, r.full_disk_path(params.as_file_name(filename_param_index)), true, options); | char *data=file_load_text(r, r.full_disk_path(params.as_file_name(filename_param_index), PA_ALLOW_HTTP), true, options); |
| Skip_lines_action skip_lines_action = (control_chars.separator=='#' || control_chars.encloser=='#') ? skip_empty_lines : skip_empty_and_comment_lines; | Skip_lines_action skip_lines_action = (control_chars.separator=='#' || control_chars.encloser=='#') ? skip_empty_lines : skip_empty_and_comment_lines; |
| Line 1100 struct Table_seq_item : public PA_Alloca | Line 1100 struct Table_seq_item : public PA_Alloca |
| }; | }; |
| #endif | #endif |
| static int sort_cmp_string(const void *a, const void *b) { | static int sort_cmp_string(const void *a, const void *b) { |
| return strcmp( | return Charset::strcmp_utf8( |
| static_cast<const Table_seq_item *>(a)->value.c_str, | static_cast<const Table_seq_item *>(a)->value.c_str, |
| static_cast<const Table_seq_item *>(b)->value.c_str | static_cast<const Table_seq_item *>(b)->value.c_str |
| ); | ); |
| Line 1143 static void _sort(Request& r, MethodPara | Line 1143 static void _sort(Request& r, MethodPara |
| seq[i].value.d=value.as_expr_result().as_double(); | seq[i].value.d=value.as_expr_result().as_double(); |
| } | } |
| // @todo: handle this elsewhere | if(!r.charsets.source().isUTF8() && key_values_are_strings) { // Charset::strcmp_utf8 requires UTF-8 |
| if(r.charsets.source().NAME()=="KOI8-R" && key_values_are_strings) { | |
| for(i=0; i<old_count; i++) | for(i=0; i<old_count; i++) |
| if(*seq[i].value.c_str) | if(*seq[i].value.c_str) |
| seq[i].value.c_str=Charset::transcode(seq[i].value.c_str, r.charsets.source(), pa_UTF8_charset).cstr(); | seq[i].value.c_str=Charset::transcode(seq[i].value.c_str, r.charsets.source(), pa_UTF8_charset).cstr(); |
| Line 1308 static void _append(Request& r, MethodPa | Line 1307 static void _append(Request& r, MethodPa |
| } else { | } else { |
| table+=row_from_string(r, params[0]); | table+=row_from_string(r, params[0]); |
| } | } |
| if(table.count() > pa_array_limit) | |
| throw Exception(PARSER_RUNTIME, 0, "table size (%d) exceeds limit $MAIN:LIMITS.max_array_size (%d)", table.count(), pa_array_limit); | |
| } | } |
| static void _insert(Request& r, MethodParams& params) { | static void _insert(Request& r, MethodParams& params) { |
| Line 1320 static void _insert(Request& r, MethodPa | Line 1322 static void _insert(Request& r, MethodPa |
| } else { | } else { |
| table.insert(table.current(), row_from_string(r, params[0])); | table.insert(table.current(), row_from_string(r, params[0])); |
| } | } |
| if(table.count() > pa_array_limit) | |
| throw Exception(PARSER_RUNTIME, 0, "table size (%d) exceeds limit $MAIN:LIMITS.max_array_size (%d)", table.count(), pa_array_limit); | |
| } | } |
| static void _delete(Request& r, MethodParams&) { | static void _delete(Request& r, MethodParams&) { |