From a34e91f61c2287ba8f7500b2f586de2ba2331f4f Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 8 Jan 2022 18:17:18 -0600 Subject: [PATCH] Cleanup: Coding style updates and miscellaneous fixes. Use fewer macros. Update documentation in regards to return codes and related functions (much more work is needed here than is currently done). Reduce nesting where obviously possible. Fix typos and mistakes in words for documentation, comments, and prints. Use "(pipe)" for designating the pipe input source. Correctly identify last file when getting file name string. Fix naming mistakes in programs where the "_read" is missing. Add appropriate newlines to get code more up to date with latest practices. Update comments to start with upper case letter where noticed. Fix ordering of functions where they were noticed to be out of order. --- level_2/fll_fss/c/fss_basic.c | 10 +- level_2/fll_fss/c/fss_basic.h | 9 +- level_2/fll_fss/c/fss_basic_list.c | 25 +-- level_2/fll_fss/c/fss_basic_list.h | 8 +- level_2/fll_fss/c/fss_embedded_list.h | 4 +- level_2/fll_fss/c/fss_extended.c | 12 +- level_2/fll_fss/c/fss_extended.h | 7 +- level_2/fll_fss/c/fss_extended_list.c | 4 +- level_2/fll_fss/c/fss_extended_list.h | 7 +- .../fss_basic_list_read/c/fss_basic_list_read.c | 125 ++++++++------- .../fss_basic_list_read/c/fss_basic_list_read.h | 94 ++++++------ .../c/private-fss_basic_list_read.c | 108 +++++++------ .../c/private-fss_basic_list_read.h | 38 ++--- .../fss_basic_list_write/c/fss_basic_list_write.c | 19 ++- .../c/private-fss_basic_list_write.c | 28 ++-- level_3/fss_basic_read/c/fss_basic_read.c | 13 +- level_3/fss_basic_read/c/private-common.h | 22 +-- level_3/fss_basic_read/c/private-fss_basic_read.c | 97 ++++++------ level_3/fss_basic_write/c/fss_basic_write.c | 18 ++- .../fss_basic_write/c/private-fss_basic_write.c | 29 ++-- .../c/fss_embedded_list_read.c | 9 ++ .../c/private-fss_embedded_list_read.c | 23 ++- .../c/fss_embedded_list_write.c | 20 ++- .../c/private-fss_embedded_list_write.c | 28 ++-- .../c/fss_extended_list_read.c | 13 +- level_3/fss_extended_list_read/c/private-common.h | 22 +-- .../c/private-fss_extended_list_read.c | 170 +++++++++++---------- .../c/private-fss_extended_list_read.h | 38 ++--- .../c/fss_extended_list_write.c | 18 ++- .../c/private-fss_extended_list_write.c | 30 ++-- level_3/fss_extended_read/c/fss_extended_read.c | 9 +- level_3/fss_extended_read/c/private-common.h | 22 +-- .../c/private-fss_extended_read.c | 135 ++++++++-------- .../c/private-fss_extended_read.h | 2 +- level_3/fss_extended_write/c/fss_extended_write.c | 17 ++- .../c/private-fss_extended_write.c | 20 ++- level_3/iki_write/c/iki_write.c | 4 +- 37 files changed, 724 insertions(+), 533 deletions(-) diff --git a/level_2/fll_fss/c/fss_basic.c b/level_2/fll_fss/c/fss_basic.c index 33abe75..4c631ad 100644 --- a/level_2/fll_fss/c/fss_basic.c +++ b/level_2/fll_fss/c/fss_basic.c @@ -23,14 +23,14 @@ extern "C" { do { if (objects->used == objects->size) { - macro_f_fss_objects_t_increase(status2, F_fss_default_allocation_step_small_d, (*objects)) + status2 = f_string_ranges_increase(F_fss_default_allocation_step_small_d, objects); if (F_status_is_error(status2)) return status2; - macro_f_fss_contents_t_increase(status2, F_fss_default_allocation_step_small_d, (*contents)) + status2 = f_string_rangess_increase(F_fss_default_allocation_step_small_d, contents); if (F_status_is_error(status2)) return status2; if (objects_quoted) { - macro_f_fss_quotes_t_increase(status2, F_fss_default_allocation_step_small_d, (*objects_quoted)) + status2 = f_type_uint8s_increase(F_fss_default_allocation_step_small_d, objects_quoted); if (F_status_is_error(status2)) return status2; } } @@ -51,7 +51,7 @@ extern "C" { ++objects_quoted->used; } - macro_f_fss_content_t_increase(status2, F_fss_default_allocation_step_small_d, contents->array[contents->used]) + status2 = f_string_ranges_increase(F_fss_default_allocation_step_small_d, &contents->array[contents->used]); if (F_status_is_error(status2)) return status2; ++contents->used; @@ -86,7 +86,7 @@ extern "C" { else if (status == F_fss_found_object_content_not) { found_data = F_true; - macro_f_fss_content_t_increase(status2, F_fss_default_allocation_step_small_d, contents->array[contents->used]) + status2 = f_string_ranges_increase(F_fss_default_allocation_step_small_d, &contents->array[contents->used]); if (F_status_is_error(status2)) return status2; break; diff --git a/level_2/fll_fss/c/fss_basic.h b/level_2/fll_fss/c/fss_basic.h index 2d9ab56..6402922 100644 --- a/level_2/fll_fss/c/fss_basic.h +++ b/level_2/fll_fss/c/fss_basic.h @@ -75,6 +75,9 @@ extern "C" { * * Errors (with error bit) from: fl_fss_basic_content_read(). * Errors (with error bit) from: fl_fss_basic_object_read(). + * + * @see fl_fss_basic_content_read() + * @see fl_fss_basic_object_read() */ #ifndef _di_fll_fss_basic_read_ extern f_status_t fll_fss_basic_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_quotes_t *objects_quoted, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits); @@ -115,9 +118,13 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * + * Errors (with error bit) from: f_string_dynamic_increase(). * Errors (with error bit) from: fl_fss_basic_content_write(). * Errors (with error bit) from: fl_fss_basic_object_write(). - * Errors (with error bit) from: f_string_dynamic_increase_by(). + * + * @see f_string_dynamic_increase() + * @see fl_fss_basic_content_write() + * @see fl_fss_basic_object_write() */ #ifndef _di_fll_fss_basic_write_string_ extern f_status_t fll_fss_basic_write_string(const f_string_static_t object, const f_string_static_t content, const f_fss_quote_t quote, f_state_t state, f_string_dynamic_t *destination); diff --git a/level_2/fll_fss/c/fss_basic_list.c b/level_2/fll_fss/c/fss_basic_list.c index 85f251f..5bcfffd 100644 --- a/level_2/fll_fss/c/fss_basic_list.c +++ b/level_2/fll_fss/c/fss_basic_list.c @@ -36,7 +36,7 @@ extern "C" { if (status == F_fss_found_object || status == F_fss_found_object_content_not) { ++objects->used; - macro_f_fss_content_t_increase(status2, F_fss_default_allocation_step_small_d, contents->array[contents->used]) + status2 = f_string_ranges_increase(F_fss_default_allocation_step_small_d, &contents->array[contents->used]); if (F_status_is_error(status2)) return status2; ++contents->used; @@ -51,13 +51,12 @@ extern "C" { return F_none_stop; } - else { - if (range->start >= buffer.used) { - return F_data_not_eos; - } - return F_data_not_stop; + if (range->start >= buffer.used) { + return F_data_not_eos; } + + return F_data_not_stop; } if (status == F_fss_found_object) { @@ -68,10 +67,11 @@ extern "C" { break; } - else if (status == F_fss_found_object_content_not) { + + if (status == F_fss_found_object_content_not) { found_data = F_true; - macro_f_fss_content_t_increase(status2, F_fss_default_allocation_step_small_d, contents->array[contents->used]) + status2 = f_string_ranges_increase(F_fss_default_allocation_step_small_d, &contents->array[contents->used]); if (F_status_is_error(status2)) return status2; break; @@ -85,7 +85,8 @@ extern "C" { return status; } - else if (status == F_data_not_eos || status == F_data_not_stop) { + + if (status == F_data_not_eos || status == F_data_not_stop) { // If at least some valid object was found, then return F_none equivalents. if (objects->used > initial_used) { @@ -100,10 +101,12 @@ extern "C" { return status; } - else if (status != F_fss_found_object && status != F_fss_found_content && status != F_fss_found_content_not && status != F_fss_found_object_content_not) { + + if (status != F_fss_found_object && status != F_fss_found_content && status != F_fss_found_content_not && status != F_fss_found_object_content_not) { return status; } - else if (range->start >= range->stop || range->start >= buffer.used) { + + if (range->start >= range->stop || range->start >= buffer.used) { // When content is found, the range->start is incremented, if content is found at range->stop, then range->start will be > range.stop. if (status == F_fss_found_object || status == F_fss_found_content || status == F_fss_found_content_not || status == F_fss_found_object_content_not) { diff --git a/level_2/fll_fss/c/fss_basic_list.h b/level_2/fll_fss/c/fss_basic_list.h index 3c1f6b7..b23eb70 100644 --- a/level_2/fll_fss/c/fss_basic_list.h +++ b/level_2/fll_fss/c/fss_basic_list.h @@ -62,7 +62,6 @@ extern "C" { * F_none on success. * F_none_eos on success after reaching the end of the buffer. * F_none_stop on success after reaching stopping point. - * F_data_not_eol if there is no data to write and EOL was reached (@todo review related code and detemine what this is doing). * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * F_data_not_stop no data to write due start location being greater than stop location. * @@ -75,6 +74,9 @@ extern "C" { * * Errors (with error bit) from: fl_fss_basic_list_content_read(). * Errors (with error bit) from: fl_fss_basic_list_object_read(). + * + * @see fl_fss_basic_list_content_read() + * @see fl_fss_basic_list_object_read() */ #ifndef _di_fll_fss_basic_list_read_ extern f_status_t fll_fss_basic_list_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments); @@ -117,7 +119,9 @@ extern "C" { * * Errors (with error bit) from: fl_fss_basic_list_content_write(). * Errors (with error bit) from: fl_fss_basic_list_object_write(). - * Errors (with error bit) from: f_string_dynamic_increase_by(). + * + * @see fl_fss_basic_list_content_write() + * @see fl_fss_basic_list_object_write() */ #ifndef _di_fll_fss_basic_list_write_string_ extern f_status_t fll_fss_basic_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, f_state_t state, f_string_dynamic_t *destination); diff --git a/level_2/fll_fss/c/fss_embedded_list.h b/level_2/fll_fss/c/fss_embedded_list.h index f78c8b7..d8e6772 100644 --- a/level_2/fll_fss/c/fss_embedded_list.h +++ b/level_2/fll_fss/c/fss_embedded_list.h @@ -126,7 +126,9 @@ extern "C" { * * Errors (with error bit) from: fl_fss_embedded_list_content_write(). * Errors (with error bit) from: fl_fss_embedded_list_object_write(). - * Errors (with error bit) from: f_string_dynamic_increase_by(). + * + * @see fl_fss_embedded_list_content_write() + * @see fl_fss_embedded_list_object_write() */ #ifndef _di_fll_fss_embedded_list_write_string_ extern f_status_t fll_fss_embedded_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_state_t state, f_string_dynamic_t *destination); diff --git a/level_2/fll_fss/c/fss_extended.c b/level_2/fll_fss/c/fss_extended.c index 4db9787..394e5af 100644 --- a/level_2/fll_fss/c/fss_extended.c +++ b/level_2/fll_fss/c/fss_extended.c @@ -24,14 +24,14 @@ extern "C" { do { if (objects->used == objects->size) { - macro_f_fss_objects_t_increase(status2, F_fss_default_allocation_step_small_d, (*objects)); + status2 = f_string_ranges_increase(F_fss_default_allocation_step_small_d, objects); if (F_status_is_error(status2)) return status2; - macro_f_fss_contents_t_increase(status2, F_fss_default_allocation_step_small_d, (*contents)); + status2 = f_string_rangess_increase(F_fss_default_allocation_step_small_d, contents); if (F_status_is_error(status2)) return status2; if (objects_quoted) { - macro_f_fss_quotes_t_increase(status2, F_fss_default_allocation_step_small_d, (*objects_quoted)); + status2 = f_type_uint8s_increase(F_fss_default_allocation_step_small_d, objects_quoted); if (F_status_is_error(status2)) return status2; } @@ -57,13 +57,13 @@ extern "C" { ++objects_quoted->used; } - macro_f_fss_content_t_increase(status2, F_fss_default_allocation_step_small_d, contents->array[contents->used]) + status2 = f_string_ranges_increase(F_fss_default_allocation_step_small_d, &contents->array[contents->used]); if (F_status_is_error(status2)) return status2; ++contents->used; if (contents_quoted) { - macro_f_fss_quotes_t_increase(status2, F_fss_default_allocation_step_small_d, contents_quoted->array[contents_quoted->used]) + status2 = f_type_uint8s_increase(F_fss_default_allocation_step_small_d, &contents_quoted->array[contents_quoted->used]); if (F_status_is_error(status2)) return status2; ++contents_quoted->used; @@ -91,7 +91,7 @@ extern "C" { found_data = F_true; if (contents_quoted) { - macro_f_fss_quotes_t_increase(status2, F_fss_default_allocation_step_small_d, contents_quoted->array[contents_quoted->used]) + status2 = f_type_uint8s_increase(F_fss_default_allocation_step_small_d, &contents_quoted->array[contents_quoted->used]); if (F_status_is_error(status2)) return status2; quoted_content = &contents_quoted->array[contents_quoted->used]; diff --git a/level_2/fll_fss/c/fss_extended.h b/level_2/fll_fss/c/fss_extended.h index d34a397..817c4d8 100644 --- a/level_2/fll_fss/c/fss_extended.h +++ b/level_2/fll_fss/c/fss_extended.h @@ -77,6 +77,9 @@ extern "C" { * * Errors (with error bit) from: fl_fss_extended_content_read(). * Errors (with error bit) from: fl_fss_extended_object_read(). + * + * @see fl_fss_extended_content_read() + * @see fl_fss_extended_object_read() */ #ifndef _di_fll_fss_extended_read_ extern f_status_t fll_fss_extended_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_quotes_t *objects_quoted, f_fss_quotess_t *contents_quoted, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits); @@ -119,7 +122,9 @@ extern "C" { * * Errors (with error bit) from: fl_fss_extended_content_write(). * Errors (with error bit) from: fl_fss_extended_object_write(). - * Errors (with error bit) from: f_string_dynamic_increase_by(). + * + * @see fl_fss_extended_content_write() + * @see fl_fss_extended_object_write() */ #ifndef _di_fll_fss_extended_write_string_ extern f_status_t fll_fss_extended_write_string(const f_string_static_t object, const f_string_statics_t contents, const f_fss_quote_t quote, f_state_t state, f_string_dynamic_t *destination); diff --git a/level_2/fll_fss/c/fss_extended_list.c b/level_2/fll_fss/c/fss_extended_list.c index ca2c770..8e778e9 100644 --- a/level_2/fll_fss/c/fss_extended_list.c +++ b/level_2/fll_fss/c/fss_extended_list.c @@ -36,7 +36,7 @@ extern "C" { if (status == F_fss_found_object || status == F_fss_found_object_content_not) { ++objects->used; - macro_f_fss_content_t_increase(status2, F_fss_default_allocation_step_small_d, contents->array[contents->used]) + status2 = f_string_ranges_increase(F_fss_default_allocation_step_small_d, &contents->array[contents->used]); if (F_status_is_error(status2)) return status2; ++contents->used; @@ -71,7 +71,7 @@ extern "C" { else if (status == F_fss_found_object_content_not) { found_data = F_true; - macro_f_fss_content_t_increase(status2, F_fss_default_allocation_step_small_d, contents->array[contents->used]) + status2 = f_string_ranges_increase(F_fss_default_allocation_step_small_d, &contents->array[contents->used]); if (F_status_is_error(status2)) return status2; break; diff --git a/level_2/fll_fss/c/fss_extended_list.h b/level_2/fll_fss/c/fss_extended_list.h index d2af4a4..6d6b5c7 100644 --- a/level_2/fll_fss/c/fss_extended_list.h +++ b/level_2/fll_fss/c/fss_extended_list.h @@ -83,6 +83,9 @@ extern "C" { * * Errors (with error bit) from: fl_fss_extended_list_content_read(). * Errors (with error bit) from: fl_fss_extended_list_object_read(). + * + * @see fl_fss_extended_list_content_read() + * @see fl_fss_extended_list_object_read() */ #ifndef _di_fll_fss_extended_list_read_ extern f_status_t fll_fss_extended_list_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments); @@ -130,7 +133,9 @@ extern "C" { * * Errors (with error bit) from: fl_fss_extended_list_content_write(). * Errors (with error bit) from: fl_fss_extended_list_object_write(). - * Errors (with error bit) from: f_string_dynamic_increase_by(). + * + * @see fl_fss_extended_list_content_write() + * @see fl_fss_extended_list_object_write() */ #ifndef _di_fll_fss_extended_list_write_string_ extern f_status_t fll_fss_extended_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_state_t state, f_string_dynamic_t *destination); diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.c b/level_3/fss_basic_list_read/c/fss_basic_list_read.c index b4c8f92..7744de6 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.c @@ -25,20 +25,20 @@ extern "C" { f_print_character(f_string_eol_s[0], file.stream); - fll_program_print_help_option(file, context, fss_basic_list_short_at_s, fss_basic_list_long_at_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object at this numeric index."); - fll_program_print_help_option(file, context, fss_basic_list_short_content_s, fss_basic_list_long_content_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the Content (default)."); - fll_program_print_help_option(file, context, fss_basic_list_short_columns_s, fss_basic_list_long_columns_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the total number of columns."); - fll_program_print_help_option(file, context, fss_basic_list_short_delimit_s, fss_basic_list_long_delimit_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Designate how to handle applying delimits."); - fll_program_print_help_option(file, context, fss_basic_list_short_depth_s, fss_basic_list_long_depth_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object at this numeric depth."); - fll_program_print_help_option(file, context, fss_basic_list_short_empty_s, fss_basic_list_long_empty_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Include empty Content when processing."); - fll_program_print_help_option(file, context, fss_basic_list_short_line_s, fss_basic_list_long_line_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print only the Content at the given line."); - fll_program_print_help_option(file, context, fss_basic_list_short_name_s, fss_basic_list_long_name_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object with this name."); - fll_program_print_help_option(file, context, fss_basic_list_short_object_s, fss_basic_list_long_object_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the Object."); - fll_program_print_help_option(file, context, fss_basic_list_short_pipe_s, fss_basic_list_long_pipe_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print using the special pipe format."); - fll_program_print_help_option(file, context, fss_basic_list_short_raw_s, fss_basic_list_long_raw_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print with the original quotes and escapes."); - fll_program_print_help_option(file, context, fss_basic_list_short_select_s, fss_basic_list_long_select_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select sub-Content at this index."); - fll_program_print_help_option(file, context, fss_basic_list_short_total_s, fss_basic_list_long_total_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the total number of lines."); - fll_program_print_help_option(file, context, fss_basic_list_short_trim_s, fss_basic_list_long_trim_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Trim Object names on select or print."); + fll_program_print_help_option(file, context, fss_basic_list_read_short_at_s, fss_basic_list_read_long_at_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object at this numeric index."); + fll_program_print_help_option(file, context, fss_basic_list_read_short_content_s, fss_basic_list_read_long_content_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the Content (default)."); + fll_program_print_help_option(file, context, fss_basic_list_read_short_columns_s, fss_basic_list_read_long_columns_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the total number of columns."); + fll_program_print_help_option(file, context, fss_basic_list_read_short_delimit_s, fss_basic_list_read_long_delimit_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Designate how to handle applying delimits."); + fll_program_print_help_option(file, context, fss_basic_list_read_short_depth_s, fss_basic_list_read_long_depth_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object at this numeric depth."); + fll_program_print_help_option(file, context, fss_basic_list_read_short_empty_s, fss_basic_list_read_long_empty_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Include empty Content when processing."); + fll_program_print_help_option(file, context, fss_basic_list_read_short_line_s, fss_basic_list_read_long_line_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print only the Content at the given line."); + fll_program_print_help_option(file, context, fss_basic_list_read_short_name_s, fss_basic_list_read_long_name_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object with this name."); + fll_program_print_help_option(file, context, fss_basic_list_read_short_object_s, fss_basic_list_read_long_object_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the Object."); + fll_program_print_help_option(file, context, fss_basic_list_read_short_pipe_s, fss_basic_list_read_long_pipe_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print using the special pipe format."); + fll_program_print_help_option(file, context, fss_basic_list_read_short_raw_s, fss_basic_list_read_long_raw_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print with the original quotes and escapes."); + fll_program_print_help_option(file, context, fss_basic_list_read_short_select_s, fss_basic_list_read_long_select_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select sub-Content at this index."); + fll_program_print_help_option(file, context, fss_basic_list_read_short_total_s, fss_basic_list_read_long_total_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the total number of lines."); + fll_program_print_help_option(file, context, fss_basic_list_read_short_trim_s, fss_basic_list_read_long_trim_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Trim Object names on select or print."); fll_program_print_help_usage(file, context, fss_basic_list_program_name_s, "filename(s)"); @@ -49,47 +49,47 @@ extern "C" { fl_print_format(" All numeric positions (indexes) start at 0 instead of 1.%c", file.stream, f_string_eol_s[0]); fl_print_format(" For example, a file of 17 lines would range from 0 to 16.%c%c", file.stream, f_string_eol_s[0], f_string_eol_s[0]); - fl_print_format(" When using the %[%s%s%] option, an order of operations is enforced on the parameters.%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_depth_s, context.set.notable, f_string_eol_s[0]); + fl_print_format(" When using the %[%s%s%] option, an order of operations is enforced on the parameters.%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_depth_s, context.set.notable, f_string_eol_s[0]); fl_print_format(" When this order of operations is in effect, parameters to the right of a depth parameter are influenced by that depth parameter:%c", file.stream, f_string_eol_s[0]); - fl_print_format(" %[%s%s%]: An Object index at the specified depth.%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_at_s, context.set.notable, f_string_eol_s[0]); - fl_print_format(" %[%s%s%]: A new depth within the specified depth, indexed from the root.%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_depth_s, context.set.notable, f_string_eol_s[0]); - fl_print_format(" %[%s%s%]: An Object name at the specified depth.%c%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_name_s, context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); + fl_print_format(" %[%s%s%]: An Object index at the specified depth.%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_at_s, context.set.notable, f_string_eol_s[0]); + fl_print_format(" %[%s%s%]: A new depth within the specified depth, indexed from the root.%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_depth_s, context.set.notable, f_string_eol_s[0]); + fl_print_format(" %[%s%s%]: An Object name at the specified depth.%c%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_name_s, context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); - fl_print_format(" The parameter %[%s%s%] must be in numeric order, but values in between may be skipped.%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_depth_s, context.set.notable, f_string_eol_s[0]); + fl_print_format(" The parameter %[%s%s%] must be in numeric order, but values in between may be skipped.%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_depth_s, context.set.notable, f_string_eol_s[0]); fl_print_format(" ('-d 0 -a 1 -d 2 -a 2' would specify index 1 at depth 0, any index at depth 1, and index 2 at depth 2.)%c", file.stream, f_string_eol_s[0]); fl_print_format(" ('-d 2 -a 1 -d 0 -a 2' would be invalid because depth 2 is before depth 1.)%c%c", file.stream, f_string_eol_s[0], f_string_eol_s[0]); - fl_print_format(" The parameter %[%s%s%] selects a Content column.%c%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_select_s, context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); + fl_print_format(" The parameter %[%s%s%] selects a Content column.%c%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_select_s, context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); - fl_print_format(" Specify both %[%s%s%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_object_s, context.set.notable); - fl_print_format(" and the %[%s%s%] parameters to get the total objects.%c%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_total_s, context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); + fl_print_format(" Specify both %[%s%s%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_object_s, context.set.notable); + fl_print_format(" and the %[%s%s%] parameters to get the total objects.%c%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_total_s, context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); - fl_print_format(" When both %[%s%s%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_at_s, context.set.notable); - fl_print_format(" and %[%s%s%] parameters are specified (at the same depth),", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_name_s, context.set.notable); - fl_print_format(" the %[%s%s%] parameter value will be treated as a position relative to the specified", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_at_s, context.set.notable); - fl_print_format(" %[%s%s%] parameter value.%c%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_name_s, context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); + fl_print_format(" When both %[%s%s%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_at_s, context.set.notable); + fl_print_format(" and %[%s%s%] parameters are specified (at the same depth),", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_name_s, context.set.notable); + fl_print_format(" the %[%s%s%] parameter value will be treated as a position relative to the specified", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_at_s, context.set.notable); + fl_print_format(" %[%s%s%] parameter value.%c%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_name_s, context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); - fl_print_format(" This program may support parameters, such as %[%s%s%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_depth_s, context.set.notable); - fl_print_format(" or %[%s%s%], even if not supported by the standard.%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_select_s, context.set.notable, f_string_eol_s[0]); + fl_print_format(" This program may support parameters, such as %[%s%s%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_depth_s, context.set.notable); + fl_print_format(" or %[%s%s%], even if not supported by the standard.%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_select_s, context.set.notable, f_string_eol_s[0]); fl_print_format(" This is done to help ensure consistency for scripting.%c%c", file.stream, f_string_eol_s[0], f_string_eol_s[0]); - fl_print_format(" For parameters like %[%s%s%],", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_depth_s, context.set.notable); + fl_print_format(" For parameters like %[%s%s%],", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_depth_s, context.set.notable); fl_print_format(" if the standard doesn't support nested Content, then only a depth of 0 would be valid.%c", file.stream, f_string_eol_s[0]); - fl_print_format(" For parameters like %[%s%s%],", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_select_s, context.set.notable); + fl_print_format(" For parameters like %[%s%s%],", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_select_s, context.set.notable); fl_print_format(" if the standard doesn't support multiple Content groups, then only a select of 0 would be valid.%c%c", file.stream, f_string_eol_s[0], f_string_eol_s[0]); - fl_print_format(" The parameter %[%s%s%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_trim_s, context.set.notable); + fl_print_format(" The parameter %[%s%s%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_trim_s, context.set.notable); fl_print_format(" will remove leading and trailing whitespaces when selecting objects or when printing objects.%c%c", file.stream, f_string_eol_s[0], f_string_eol_s[0]); - fl_print_format(" When specifying both the %[%s%s%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_object_s, context.set.notable); - fl_print_format(" parameter and the %[%s%s%] parameter, the entire Object and Content are printed, including the formatting.%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_content_s, context.set.notable, f_string_eol_s[0]); + fl_print_format(" When specifying both the %[%s%s%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_object_s, context.set.notable); + fl_print_format(" parameter and the %[%s%s%] parameter, the entire Object and Content are printed, including the formatting.%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_content_s, context.set.notable, f_string_eol_s[0]); fl_print_format(" Both the Object and Content printed are already escaped.%c", file.stream, f_string_eol_s[0]); fl_print_format(" Both the Object and Content are separated by an EOL.%c%c", file.stream, f_string_eol_s[0], f_string_eol_s[0]); - fl_print_format(" The parameter %[%s%s%] accepts the following:%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_delimit_s, context.set.notable, f_string_eol_s[0]); + fl_print_format(" The parameter %[%s%s%] accepts the following:%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_delimit_s, context.set.notable, f_string_eol_s[0]); fl_print_format(" - %[%s%]: Do not apply delimits.%c", file.stream, context.set.notable, fss_basic_list_read_delimit_mode_name_none_s, context.set.notable, f_string_eol_s[0]); fl_print_format(" - %[%s%]: (default) Apply all delimits.%c", file.stream, context.set.notable, fss_basic_list_read_delimit_mode_name_all_s, context.set.notable, f_string_eol_s[0]); fl_print_format(" - %[%s%]: Apply delimits for Objects.%c", file.stream, context.set.notable, fss_basic_list_read_delimit_mode_name_object_s, context.set.notable, f_string_eol_s[0]); @@ -97,15 +97,15 @@ extern "C" { fl_print_format(" - A number, 0 or greater, followed by a %[%s%]: (such as '1+') apply delimits for Content at the specified depth and any greater depth (numerically).%c", file.stream, context.set.notable, fss_basic_list_read_delimit_mode_name_greater_s, context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); fl_print_format(" - A number, 0 or lesser, followed by a %[%s%]: (such as '1-') apply delimits for Content at the specified depth and any lesser depth (numerically).%c%c", file.stream, context.set.notable, fss_basic_list_read_delimit_mode_name_lesser_s, context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); - fl_print_format(" The %[%s%s%] parameter may be specified multiple times to customize the delimit behavior.%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_delimit_s, context.set.notable, f_string_eol_s[0]); + fl_print_format(" The %[%s%s%] parameter may be specified multiple times to customize the delimit behavior.%c", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_delimit_s, context.set.notable, f_string_eol_s[0]); - fl_print_format(" The %[%s%s%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_delimit_s, context.set.notable); + fl_print_format(" The %[%s%s%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_delimit_s, context.set.notable); fl_print_format(" values %[%s%]", file.stream, context.set.notable, fss_basic_list_read_delimit_mode_name_none_s, context.set.notable); fl_print_format(" and %[%s%],", file.stream, context.set.notable, fss_basic_list_read_delimit_mode_name_all_s, context.set.notable); fl_print_format(" overrule all other delimit values.%c%c", file.stream, f_string_eol_s[0], f_string_eol_s[0]); - fl_print_format(" The parameters %[%s%s%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_columns_s, context.set.notable); - fl_print_format(" and %[%s%s%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_long_select_s, context.set.notable); + fl_print_format(" The parameters %[%s%s%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_columns_s, context.set.notable); + fl_print_format(" and %[%s%s%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_select_s, context.set.notable); fl_print_format(" refer to a Content column.%c", file.stream, f_string_eol_s[0]); fl_print_format(" The word \"column\" is being loosely defined to refer to a specific Content.%c", file.stream, f_string_eol_s[0]); fl_print_format(" This is not to be confused with a depth.%c%c", file.stream, f_string_eol_s[0], f_string_eol_s[0]); @@ -200,6 +200,7 @@ extern "C" { fss_basic_list_read_print_help(main->output.to, main->context); fss_basic_list_read_main_delete(main); + return status; } @@ -207,6 +208,7 @@ extern "C" { fll_program_print_version(main->output.to, fss_basic_list_program_version_s); fss_basic_list_read_main_delete(main); + return status; } @@ -217,6 +219,9 @@ extern "C" { data.files.array = files_array; data.files.used = 1; data.files.size = main->remaining.used + 1; + data.files.array[0].name = "(pipe)"; + data.files.array[0].range.start = 1; + data.files.array[0].range.stop = 0; if (main->remaining.used || main->process_pipe) { { @@ -230,12 +235,12 @@ extern "C" { }; const f_string_t parameter_name[] = { - fss_basic_list_long_at_s, - fss_basic_list_long_depth_s, - fss_basic_list_long_line_s, - fss_basic_list_long_select_s, - fss_basic_list_long_name_s, - fss_basic_list_long_delimit_s, + fss_basic_list_read_long_at_s, + fss_basic_list_read_long_depth_s, + fss_basic_list_read_long_line_s, + fss_basic_list_read_long_select_s, + fss_basic_list_read_long_name_s, + fss_basic_list_read_long_delimit_s, }; const f_string_t message_positive_number = "positive number"; @@ -263,6 +268,7 @@ extern "C" { funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); + break; } } // for @@ -278,11 +284,11 @@ extern "C" { }; const f_string_t parameter_name[] = { - fss_basic_list_long_depth_s, - fss_basic_list_long_line_s, - fss_basic_list_long_pipe_s, - fss_basic_list_long_select_s, - fss_basic_list_long_total_s, + fss_basic_list_read_long_depth_s, + fss_basic_list_read_long_line_s, + fss_basic_list_read_long_pipe_s, + fss_basic_list_read_long_select_s, + fss_basic_list_read_long_total_s, }; const uint8_t parameter_match[] = { @@ -299,7 +305,7 @@ extern "C" { flockfile(main->error.to.stream); fl_print_format("%c%[%sCannot specify the '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_long_columns_s, main->error.notable); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_columns_s, main->error.notable); fl_print_format("%[' parameter with the '%]", main->error.to.stream, main->error.context, main->error.context); fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, parameter_name[i], main->error.notable); fl_print_format("%[' parameter.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); @@ -307,6 +313,7 @@ extern "C" { funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); + break; } } // for @@ -317,9 +324,9 @@ extern "C" { flockfile(main->error.to.stream); fl_print_format("%c%[%sCannot specify the '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_long_pipe_s, main->error.notable); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_pipe_s, main->error.notable); fl_print_format("%[' parameter with the '%]", main->error.to.stream, main->error.context, main->error.context); - fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_long_total_s, main->error.notable); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_total_s, main->error.notable); fl_print_format("%[' parameter.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); funlockfile(main->error.to.stream); @@ -330,9 +337,9 @@ extern "C" { flockfile(main->error.to.stream); fl_print_format("%c%[%sCannot specify the '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_long_pipe_s, main->error.notable); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_pipe_s, main->error.notable); fl_print_format("%[' parameter with the '%]", main->error.to.stream, main->error.context, main->error.context); - fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_long_line_s, main->error.notable); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_line_s, main->error.notable); fl_print_format("%[' parameter.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); funlockfile(main->error.to.stream); @@ -354,6 +361,7 @@ extern "C" { if (!((++signal_check) % fss_basic_list_read_signal_check_d)) { if (fss_basic_list_read_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } @@ -367,12 +375,13 @@ extern "C" { flockfile(main->error.to.stream); fl_print_format("%c%[%sThe value for the parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_long_delimit_s, main->error.notable); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_delimit_s, main->error.notable); fl_print_format("%[' must not be empty.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); + break; } else if (fl_string_compare(arguments->argv[location], fss_basic_list_read_delimit_mode_name_none_s, length, fss_basic_list_read_delimit_mode_name_none_s_length) == F_equal_to) { @@ -455,7 +464,7 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments->argv[location], range, &data.delimit_depth); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_list_long_delimit_s, arguments->argv[location]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_list_read_long_delimit_s, arguments->argv[location]); break; } @@ -500,7 +509,7 @@ extern "C" { flockfile(main->error.to.stream); fl_print_format("%c%[%sThe '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_long_select_s, main->error.notable); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_select_s, main->error.notable); fl_print_format("%[' parameter requires a positive number.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); funlockfile(main->error.to.stream); @@ -522,7 +531,6 @@ extern "C" { file.id = F_type_descriptor_input_d; file.stream = F_type_input_d; - data.files.array[0].name = 0; data.files.array[0].range.start = 0; status = f_file_stream_read(file, &data.buffer); @@ -556,6 +564,7 @@ extern "C" { if (!((++signal_check) % fss_basic_list_read_signal_check_d)) { if (fss_basic_list_read_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.h b/level_3/fss_basic_list_read/c/fss_basic_list_read.h index a77c2eb..9ddb27a 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.h +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.h @@ -75,39 +75,39 @@ extern "C" { #ifndef _di_fss_basic_list_read_defines_ #define fss_basic_list_read_signal_check_d 10000 - #define fss_basic_list_pipe_content_end_s '\f' - #define fss_basic_list_pipe_content_ignore_s '\v' - #define fss_basic_list_pipe_content_start_s '\b' - - #define fss_basic_list_short_at_s "a" - #define fss_basic_list_short_content_s "c" - #define fss_basic_list_short_columns_s "C" - #define fss_basic_list_short_delimit_s "D" - #define fss_basic_list_short_depth_s "d" - #define fss_basic_list_short_empty_s "e" - #define fss_basic_list_short_line_s "l" - #define fss_basic_list_short_name_s "n" - #define fss_basic_list_short_object_s "o" - #define fss_basic_list_short_pipe_s "p" - #define fss_basic_list_short_raw_s "R" - #define fss_basic_list_short_select_s "s" - #define fss_basic_list_short_total_s "t" - #define fss_basic_list_short_trim_s "T" - - #define fss_basic_list_long_at_s "at" - #define fss_basic_list_long_content_s "content" - #define fss_basic_list_long_columns_s "columns" - #define fss_basic_list_long_delimit_s "delimit" - #define fss_basic_list_long_depth_s "depth" - #define fss_basic_list_long_empty_s "empty" - #define fss_basic_list_long_line_s "line" - #define fss_basic_list_long_name_s "name" - #define fss_basic_list_long_object_s "object" - #define fss_basic_list_long_pipe_s "pipe" - #define fss_basic_list_long_raw_s "raw" - #define fss_basic_list_long_select_s "select" - #define fss_basic_list_long_total_s "total" - #define fss_basic_list_long_trim_s "trim" + #define fss_basic_list_read_pipe_content_end_s '\f' + #define fss_basic_list_read_pipe_content_ignore_s '\v' + #define fss_basic_list_read_pipe_content_start_s '\b' + + #define fss_basic_list_read_short_at_s "a" + #define fss_basic_list_read_short_content_s "c" + #define fss_basic_list_read_short_columns_s "C" + #define fss_basic_list_read_short_delimit_s "D" + #define fss_basic_list_read_short_depth_s "d" + #define fss_basic_list_read_short_empty_s "e" + #define fss_basic_list_read_short_line_s "l" + #define fss_basic_list_read_short_name_s "n" + #define fss_basic_list_read_short_object_s "o" + #define fss_basic_list_read_short_pipe_s "p" + #define fss_basic_list_read_short_raw_s "R" + #define fss_basic_list_read_short_select_s "s" + #define fss_basic_list_read_short_total_s "t" + #define fss_basic_list_read_short_trim_s "T" + + #define fss_basic_list_read_long_at_s "at" + #define fss_basic_list_read_long_content_s "content" + #define fss_basic_list_read_long_columns_s "columns" + #define fss_basic_list_read_long_delimit_s "delimit" + #define fss_basic_list_read_long_depth_s "depth" + #define fss_basic_list_read_long_empty_s "empty" + #define fss_basic_list_read_long_line_s "line" + #define fss_basic_list_read_long_name_s "name" + #define fss_basic_list_read_long_object_s "object" + #define fss_basic_list_read_long_pipe_s "pipe" + #define fss_basic_list_read_long_raw_s "raw" + #define fss_basic_list_read_long_select_s "select" + #define fss_basic_list_read_long_total_s "total" + #define fss_basic_list_read_long_trim_s "trim" enum { fss_basic_list_read_parameter_help_e, @@ -147,20 +147,20 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, 0, 0, f_console_type_inverse_e), \ f_console_parameter_t_initialize(f_console_standard_short_debug_s, f_console_standard_long_debug_s, 0, 0, f_console_type_inverse_e), \ f_console_parameter_t_initialize(f_console_standard_short_version_s, f_console_standard_long_version_s, 0, 0, f_console_type_inverse_e), \ - f_console_parameter_t_initialize(fss_basic_list_short_at_s, fss_basic_list_long_at_s, 0, 1, f_console_type_normal_e), \ - f_console_parameter_t_initialize(fss_basic_list_short_content_s, fss_basic_list_long_content_s, 0, 0, f_console_type_normal_e), \ - f_console_parameter_t_initialize(fss_basic_list_short_columns_s, fss_basic_list_long_columns_s, 0, 0, f_console_type_normal_e), \ - f_console_parameter_t_initialize(fss_basic_list_short_delimit_s, fss_basic_list_long_delimit_s, 0, 1, f_console_type_normal_e), \ - f_console_parameter_t_initialize(fss_basic_list_short_depth_s, fss_basic_list_long_depth_s, 0, 1, f_console_type_normal_e), \ - f_console_parameter_t_initialize(fss_basic_list_short_empty_s, fss_basic_list_long_empty_s, 0, 0, f_console_type_normal_e), \ - f_console_parameter_t_initialize(fss_basic_list_short_line_s, fss_basic_list_long_line_s, 0, 1, f_console_type_normal_e), \ - f_console_parameter_t_initialize(fss_basic_list_short_name_s, fss_basic_list_long_name_s, 0, 1, f_console_type_normal_e), \ - f_console_parameter_t_initialize(fss_basic_list_short_object_s, fss_basic_list_long_object_s, 0, 0, f_console_type_normal_e), \ - f_console_parameter_t_initialize(fss_basic_list_short_pipe_s, fss_basic_list_long_pipe_s, 0, 0, f_console_type_normal_e), \ - f_console_parameter_t_initialize(fss_basic_list_short_raw_s, fss_basic_list_long_raw_s, 0, 0, f_console_type_normal_e), \ - f_console_parameter_t_initialize(fss_basic_list_short_select_s, fss_basic_list_long_select_s, 0, 1, f_console_type_normal_e), \ - f_console_parameter_t_initialize(fss_basic_list_short_total_s, fss_basic_list_long_total_s, 0, 0, f_console_type_normal_e), \ - f_console_parameter_t_initialize(fss_basic_list_short_trim_s, fss_basic_list_long_trim_s, 0, 0, f_console_type_normal_e), \ + f_console_parameter_t_initialize(fss_basic_list_read_short_at_s, fss_basic_list_read_long_at_s, 0, 1, f_console_type_normal_e), \ + f_console_parameter_t_initialize(fss_basic_list_read_short_content_s, fss_basic_list_read_long_content_s, 0, 0, f_console_type_normal_e), \ + f_console_parameter_t_initialize(fss_basic_list_read_short_columns_s, fss_basic_list_read_long_columns_s, 0, 0, f_console_type_normal_e), \ + f_console_parameter_t_initialize(fss_basic_list_read_short_delimit_s, fss_basic_list_read_long_delimit_s, 0, 1, f_console_type_normal_e), \ + f_console_parameter_t_initialize(fss_basic_list_read_short_depth_s, fss_basic_list_read_long_depth_s, 0, 1, f_console_type_normal_e), \ + f_console_parameter_t_initialize(fss_basic_list_read_short_empty_s, fss_basic_list_read_long_empty_s, 0, 0, f_console_type_normal_e), \ + f_console_parameter_t_initialize(fss_basic_list_read_short_line_s, fss_basic_list_read_long_line_s, 0, 1, f_console_type_normal_e), \ + f_console_parameter_t_initialize(fss_basic_list_read_short_name_s, fss_basic_list_read_long_name_s, 0, 1, f_console_type_normal_e), \ + f_console_parameter_t_initialize(fss_basic_list_read_short_object_s, fss_basic_list_read_long_object_s, 0, 0, f_console_type_normal_e), \ + f_console_parameter_t_initialize(fss_basic_list_read_short_pipe_s, fss_basic_list_read_long_pipe_s, 0, 0, f_console_type_normal_e), \ + f_console_parameter_t_initialize(fss_basic_list_read_short_raw_s, fss_basic_list_read_long_raw_s, 0, 0, f_console_type_normal_e), \ + f_console_parameter_t_initialize(fss_basic_list_read_short_select_s, fss_basic_list_read_long_select_s, 0, 1, f_console_type_normal_e), \ + f_console_parameter_t_initialize(fss_basic_list_read_short_total_s, fss_basic_list_read_long_total_s, 0, 0, f_console_type_normal_e), \ + f_console_parameter_t_initialize(fss_basic_list_read_short_trim_s, fss_basic_list_read_long_trim_s, 0, 0, f_console_type_normal_e), \ } #define fss_basic_list_total_parameters_d 23 diff --git a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c index c80f5a5..371a8e6 100644 --- a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c @@ -112,7 +112,7 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments->argv[position_depth], range, &data->depths.array[i].depth); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_list_long_depth_s, arguments->argv[position_depth]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_list_read_long_depth_s, arguments->argv[position_depth]); return status; } @@ -136,7 +136,7 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments->argv[data->depths.array[i].index_at], range, &data->depths.array[i].value_at); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_list_long_at_s, arguments->argv[data->depths.array[i].index_at]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_list_read_long_at_s, arguments->argv[data->depths.array[i].index_at]); return status; } @@ -191,7 +191,7 @@ extern "C" { fl_print_format("%c%[%sThe value '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%ul%]", main->error.to.stream, main->error.notable, data->depths.array[i].depth, main->error.notable); fl_print_format("%[' may only be specified once for the parameter '%]", main->error.to.stream, main->error.context, main->error.context); - fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_long_depth_s, main->error.notable); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_depth_s, main->error.notable); fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); funlockfile(main->error.to.stream); @@ -204,7 +204,7 @@ extern "C" { flockfile(main->error.to.stream); fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_long_depth_s, main->error.notable); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_depth_s, main->error.notable); fl_print_format("%[' may not have the value '%]", main->error.to.stream, main->error.context, main->error.context); fl_print_format("%[%ul%]", main->error.to.stream, main->error.notable, data->depths.array[i].depth, main->error.notable); fl_print_format("%[' before the value '%]", main->error.to.stream, main->error.context, main->error.context); @@ -233,6 +233,11 @@ extern "C" { } } // for + // When stopped after the end of the buffer, the last file in the list is the correct file. + if (at > files.array[files.used - 1].range.stop) { + return files.array[files.used - 1].name; + } + return ""; } #endif // _di_fss_basic_list_read_file_identify_ @@ -251,11 +256,12 @@ extern "C" { if (F_status_is_error(status)) { const f_string_t file_name = fss_basic_list_read_file_identify(input.start, data->files); - fll_error_file_print(main->error, F_status_set_fine(status), "fll_fss_basic_list_read", F_true, file_name ? file_name : "-", "process", fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "fll_fss_basic_list_read", F_true, file_name, "process", fll_error_file_type_file_e); return status; } - else if (status == F_data_not_stop || status == F_data_not_eos) { + + if (status == F_data_not_stop || status == F_data_not_eos) { if (data->option & fss_basic_list_read_data_option_total_d) { flockfile(main->output.to.stream); @@ -355,7 +361,7 @@ extern "C" { void fss_basic_list_read_print_content_ignore(fss_basic_list_read_main_t * const main) { if (main->parameters[fss_basic_list_read_parameter_pipe_e].result == f_console_result_found_e) { - f_print_character(fss_basic_list_pipe_content_ignore_s, main->output.to.stream); + f_print_character(fss_basic_list_read_pipe_content_ignore_s, main->output.to.stream); } } #endif // _di_fss_basic_list_read_print_content_ignore_ @@ -364,7 +370,7 @@ extern "C" { void fss_basic_list_read_print_object_end(fss_basic_list_read_main_t * const main) { if (main->parameters[fss_basic_list_read_parameter_pipe_e].result == f_console_result_found_e) { - f_print_character(fss_basic_list_pipe_content_start_s, main->output.to.stream); + f_print_character(fss_basic_list_read_pipe_content_start_s, main->output.to.stream); } else { if (main->parameters[fss_basic_list_read_parameter_content_e].result == f_console_result_found_e) { @@ -382,13 +388,14 @@ extern "C" { void fss_basic_list_read_print_set_end(fss_basic_list_read_main_t * const main) { if (main->parameters[fss_basic_list_read_parameter_pipe_e].result == f_console_result_found_e) { - f_print_character(fss_basic_list_pipe_content_end_s, main->output.to.stream); + f_print_character(fss_basic_list_read_pipe_content_end_s, main->output.to.stream); } } #endif // _di_fss_basic_list_read_print_set_end_ #ifndef _di_fss_basic_list_read_print_one_ void fss_basic_list_read_print_one(fss_basic_list_read_main_t * const main) { + f_print_character(f_string_ascii_1_s[0], main->output.to.stream); f_print_character(f_string_eol_s[0], main->output.to.stream); } @@ -396,6 +403,7 @@ extern "C" { #ifndef _di_fss_basic_list_read_print_zero_ void fss_basic_list_read_print_zero(fss_basic_list_read_main_t * const main) { + f_print_character(f_string_ascii_0_s[0], main->output.to.stream); f_print_character(f_string_eol_s[0], main->output.to.stream); } @@ -557,45 +565,6 @@ extern "C" { } #endif // _di_fss_basic_list_read_process_at_ -#ifndef _di_fss_basic_list_read_process_columns_ - f_status_t fss_basic_list_read_process_columns(fss_basic_list_read_main_t * const main, fss_basic_list_read_data_t *data, bool names[]) { - - if (!(data->option & fss_basic_list_read_data_option_content_d)) { - flockfile(main->output.to.stream); - - fss_basic_list_read_print_zero(main); - - funlockfile(main->output.to.stream); - - return F_none; - } - - f_array_length_t max = 0; - uint16_t signal_check = 0; - - for (f_array_length_t at = 0; at < data->contents.used; ++at) { - - if (!names[at]) continue; - - if (!((++signal_check) % fss_basic_list_read_signal_check_d)) { - if (fss_basic_list_read_signal_received(main)) { - return F_status_set_error(F_interrupt); - } - - signal_check = 0; - } - - if (data->contents.array[at].used > max) { - max = data->contents.array[at].used; - } - } // for - - fll_print_format("%ul%c", main->output.to.stream, max, f_string_eol_s[0]); - - return F_none; - } -#endif // _di_fss_basic_list_read_process_columns_ - #ifndef _di_fss_basic_list_read_process_at_line_ f_status_t fss_basic_list_read_process_at_line(fss_basic_list_read_main_t * const main, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, fss_basic_list_read_data_t *data, f_array_length_t *line) { @@ -700,6 +669,45 @@ extern "C" { } #endif // _di_fss_basic_list_read_process_at_line_ +#ifndef _di_fss_basic_list_read_process_columns_ + f_status_t fss_basic_list_read_process_columns(fss_basic_list_read_main_t * const main, fss_basic_list_read_data_t *data, bool names[]) { + + if (!(data->option & fss_basic_list_read_data_option_content_d)) { + flockfile(main->output.to.stream); + + fss_basic_list_read_print_zero(main); + + funlockfile(main->output.to.stream); + + return F_none; + } + + f_array_length_t max = 0; + uint16_t signal_check = 0; + + for (f_array_length_t at = 0; at < data->contents.used; ++at) { + + if (!names[at]) continue; + + if (!((++signal_check) % fss_basic_list_read_signal_check_d)) { + if (fss_basic_list_read_signal_received(main)) { + return F_status_set_error(F_interrupt); + } + + signal_check = 0; + } + + if (data->contents.array[at].used > max) { + max = data->contents.array[at].used; + } + } // for + + fll_print_format("%ul%c", main->output.to.stream, max, f_string_eol_s[0]); + + return F_none; + } +#endif // _di_fss_basic_list_read_process_columns_ + #ifndef _di_fss_basic_list_read_process_line_ f_status_t fss_basic_list_read_process_line(fss_basic_list_read_main_t * const main, fss_basic_list_read_data_t *data, bool names[]) { @@ -786,7 +794,7 @@ extern "C" { if (main->parameters[fss_basic_list_read_parameter_line_e].result == f_console_result_additional_e) { data->option |= fss_basic_list_read_data_option_line_d; - status = fss_basic_list_read_load_number(main, fss_basic_list_read_parameter_line_e, fss_basic_list_long_line_s, arguments, &data->line); + status = fss_basic_list_read_load_number(main, fss_basic_list_read_parameter_line_e, fss_basic_list_read_long_line_s, arguments, &data->line); if (F_status_is_error(status)) return status; } @@ -805,7 +813,7 @@ extern "C" { if (main->parameters[fss_basic_list_read_parameter_select_e].result == f_console_result_additional_e) { data->option |= fss_basic_list_read_data_option_select_d; - status = fss_basic_list_read_load_number(main, fss_basic_list_read_parameter_select_e, fss_basic_list_long_select_s, arguments, &data->select); + status = fss_basic_list_read_load_number(main, fss_basic_list_read_parameter_select_e, fss_basic_list_read_long_select_s, arguments, &data->select); if (F_status_is_error(status)) return status; } diff --git a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.h b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.h index 47a7d96..c9dcba6 100644 --- a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.h +++ b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.h @@ -240,7 +240,7 @@ extern "C" { #endif // _di_fss_basic_list_read_print_zero_ /** - * Perform the basic read processing on the buffer. + * Perform the basic list read processing on the buffer. * * This will print an error message on error. * @@ -285,24 +285,6 @@ extern "C" { #endif // _di_fss_basic_list_read_process_at_ /** - * Process based on columns parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_basic_list_read_process_columns_ - extern f_status_t fss_basic_list_read_process_columns(fss_basic_list_read_main_t * const main, fss_basic_list_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_process_columns_ - -/** * Process based on at parameter for some line. * * @param main @@ -326,6 +308,24 @@ extern "C" { #endif // _di_fss_basic_list_read_process_at_line_ /** + * Process based on columns parameter. + * + * @param main + * The main program data. + * @param data + * The program data. + * @param names + * An array of booleans representing whether or not some Object name is to be used. + * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) + * + * @return + * F_none on success. + */ +#ifndef _di_fss_basic_list_read_process_columns_ + extern f_status_t fss_basic_list_read_process_columns(fss_basic_list_read_main_t * const main, fss_basic_list_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; +#endif // _di_fss_basic_list_read_process_columns_ + +/** * Process based on line parameter. * * @param main diff --git a/level_3/fss_basic_list_write/c/fss_basic_list_write.c b/level_3/fss_basic_list_write/c/fss_basic_list_write.c index 429d37c..5767f46 100644 --- a/level_3/fss_basic_list_write/c/fss_basic_list_write.c +++ b/level_3/fss_basic_list_write/c/fss_basic_list_write.c @@ -25,7 +25,7 @@ extern "C" { f_print_character(f_string_eol_s[0], file.stream); - fll_program_print_help_option(file, context, fss_basic_list_write_short_file_s, fss_basic_list_write_long_file_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a file to send file to."); + fll_program_print_help_option(file, context, fss_basic_list_write_short_file_s, fss_basic_list_write_long_file_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a file to send data to."); fll_program_print_help_option(file, context, fss_basic_list_write_short_content_s, fss_basic_list_write_long_content_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "The Content to file."); fll_program_print_help_option(file, context, fss_basic_list_write_short_double_s, fss_basic_list_write_long_double_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Use double quotes (default)."); fll_program_print_help_option(file, context, fss_basic_list_write_short_ignore_s, fss_basic_list_write_long_ignore_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Ignore a given range within a Content."); @@ -92,6 +92,7 @@ extern "C" { if (F_status_is_error(status)) { fss_basic_list_write_main_delete(main); + return F_status_set_error(status); } } @@ -106,6 +107,7 @@ extern "C" { if (F_status_is_error(status)) { fss_basic_list_write_main_delete(main); + return status; } @@ -138,6 +140,7 @@ extern "C" { fss_basic_list_write_print_help(main->output.to, main->context); fss_basic_list_write_main_delete(main); + return status; } @@ -145,6 +148,7 @@ extern "C" { fll_program_print_version(main->output.to, fss_basic_list_write_program_version_s); fss_basic_list_write_main_delete(main); + return status; } @@ -251,6 +255,7 @@ extern "C" { } status = F_status_set_error(F_parameter); + break; } } // for @@ -343,6 +348,7 @@ extern "C" { } status = F_status_set_error(F_parameter); + break; } } // for @@ -440,6 +446,7 @@ extern "C" { if (fss_basic_list_write_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } @@ -456,6 +463,7 @@ extern "C" { if (fss_basic_list_write_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } @@ -473,6 +481,7 @@ extern "C" { if (fss_basic_list_write_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } @@ -501,14 +510,14 @@ extern "C" { } else if (main->error.verbosity != f_console_verbosity_quiet_e && main->parameters[fss_basic_list_write_parameter_file_e].result == f_console_result_none_e) { - // ensure there is always a newline at the end, unless in quiet mode. - fll_print_character(f_string_eol_s[0], main->error.to.stream); + // Ensure there is always a newline at the end, unless in quiet mode. + fll_print_character(f_string_eol_s[0], main->output.to.stream); } } macro_f_string_dynamic_t_delete_simple(escaped); - // object and content, though being a "dynamic" type, is being used statically, so clear them up to avoid invalid free(). + // Object and content, though being a "dynamic" type, is being used statically, so clear them up to avoid invalid free(). object.string = 0; object.used = 0; object.size = 0; @@ -524,7 +533,7 @@ extern "C" { } } - // ensure a newline is always put at the end of the program execution, unless in quiet mode. + // Ensure a newline is always put at the end of the program execution, unless in quiet mode. if (main->error.verbosity != f_console_verbosity_quiet_e) { if (F_status_is_error(status)) { fll_print_character(f_string_eol_s[0], main->error.to.stream); diff --git a/level_3/fss_basic_list_write/c/private-fss_basic_list_write.c b/level_3/fss_basic_list_write/c/private-fss_basic_list_write.c index f381382..2139530 100644 --- a/level_3/fss_basic_list_write/c/private-fss_basic_list_write.c +++ b/level_3/fss_basic_list_write/c/private-fss_basic_list_write.c @@ -175,6 +175,7 @@ extern "C" { fll_error_print(main->error, F_status_set_fine(status_pipe), "f_file_read_block", F_true); status_pipe = F_status_set_error(F_pipe); + break; } @@ -197,6 +198,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true); + break; } } @@ -206,17 +208,20 @@ extern "C" { if (block.string[range.start] == fss_basic_list_write_pipe_content_start_s) { state = 0x2; ++range.start; + break; } if (block.string[range.start] == fss_basic_list_write_pipe_content_end_s) { state = 0x3; ++range.start; + break; } if (block.string[range.start] == fss_basic_list_write_pipe_content_ignore_s) { - // this is not used by objects. + + // This is not used by objects. continue; } @@ -225,10 +230,10 @@ extern "C" { if (F_status_is_error(status)) break; - // if the start of content was not found, then fetch the next block. + // If the start of content was not found, then fetch the next block. if (state == 0x1) continue; - // if the end of the current block is reached, fetch the next block. + // If the end of the current block is reached, fetch the next block. if (range.start > range.stop) continue; } @@ -241,13 +246,11 @@ extern "C" { } if (total) { - if (content.used + total > content.size) { - status = f_string_dynamic_increase_by(total, &content); + status = f_string_dynamic_increase_by(total, &content); - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true); - break; - } + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true); + break; } for (; range.start <= range.stop; ++range.start) { @@ -258,17 +261,20 @@ extern "C" { } status = F_status_set_error(F_supported_not); + break; } if (block.string[range.start] == fss_basic_list_write_pipe_content_end_s) { state = 0x3; ++range.start; + break; } if (block.string[range.start] == fss_basic_list_write_pipe_content_ignore_s) { - // this is not used by this program. + + // This is not used by this program. continue; } @@ -290,7 +296,7 @@ extern "C" { } } // for - // if the pipe ended before finishing, then attempt to wrap up. + // If the pipe ended before finishing, then attempt to wrap up. if (F_status_is_error_not(status) && status_pipe == F_none_eof && state) { status = fss_basic_list_write_process(main, output, quote, &object, &content, buffer); } diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c index 077a751..8d06542 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -200,6 +200,7 @@ extern "C" { fss_basic_read_print_help(main->output.to, main->context); fss_basic_read_main_delete(main); + return status; } @@ -207,6 +208,7 @@ extern "C" { fll_program_print_version(main->output.to, fss_basic_read_program_version_s); fss_basic_read_main_delete(main); + return status; } @@ -217,6 +219,9 @@ extern "C" { data.files.array = files_array; data.files.used = 1; data.files.size = main->remaining.used + 1; + data.files.array[0].name = "(pipe)"; + data.files.array[0].range.start = 1; + data.files.array[0].range.stop = 0; if (main->remaining.used || main->process_pipe) { { @@ -263,6 +268,7 @@ extern "C" { funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); + break; } } // for @@ -307,6 +313,7 @@ extern "C" { funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); + break; } } // for @@ -352,6 +359,7 @@ extern "C" { if (fss_basic_read_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } @@ -368,6 +376,7 @@ extern "C" { funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); + break; } else if (fl_string_compare(arguments->argv[location], fss_basic_read_delimit_mode_name_none_s, length, fss_basic_read_delimit_mode_name_none_s_length) == F_equal_to) { @@ -517,7 +526,6 @@ extern "C" { file.id = F_type_descriptor_input_d; file.stream = F_type_input_d; - data.files.array[0].name = 0; data.files.array[0].range.start = 0; status = f_file_stream_read(file, &data.buffer); @@ -589,7 +597,8 @@ extern "C" { break; } - else if (data.buffer.used > data.files.array[data.files.used].range.start) { + + if (data.buffer.used > data.files.array[data.files.used].range.start) { data.files.array[data.files.used].name = arguments->argv[main->remaining.array[i]]; data.files.array[data.files.used++].range.stop = data.buffer.used - 1; diff --git a/level_3/fss_basic_read/c/private-common.h b/level_3/fss_basic_read/c/private-common.h index 0bcd710..3ce37ce 100644 --- a/level_3/fss_basic_read/c/private-common.h +++ b/level_3/fss_basic_read/c/private-common.h @@ -153,17 +153,17 @@ extern "C" { * delimits: The positions within the buffer representing character delimits. */ #ifndef _di_fss_basic_read_data_t_ - #define fss_basic_read_data_option_at 0x1 - #define fss_basic_read_data_option_columns 0x2 - #define fss_basic_read_data_option_content 0x4 - #define fss_basic_read_data_option_empty 0x8 - #define fss_basic_read_data_option_line 0x10 - #define fss_basic_read_data_option_name 0x20 - #define fss_basic_read_data_option_object 0x40 - #define fss_basic_read_data_option_raw 0x80 - #define fss_basic_read_data_option_select 0x100 - #define fss_basic_read_data_option_total 0x200 - #define fss_basic_read_data_option_trim 0x400 + #define fss_basic_read_data_option_at_d 0x1 + #define fss_basic_read_data_option_columns_d 0x2 + #define fss_basic_read_data_option_content_d 0x4 + #define fss_basic_read_data_option_empty_d 0x8 + #define fss_basic_read_data_option_line_d 0x10 + #define fss_basic_read_data_option_name_d 0x20 + #define fss_basic_read_data_option_object_d 0x40 + #define fss_basic_read_data_option_raw_d 0x80 + #define fss_basic_read_data_option_select_d 0x100 + #define fss_basic_read_data_option_total_d 0x200 + #define fss_basic_read_data_option_trim_d 0x400 typedef struct { uint16_t option; diff --git a/level_3/fss_basic_read/c/private-fss_basic_read.c b/level_3/fss_basic_read/c/private-fss_basic_read.c index 911b232..130d099 100644 --- a/level_3/fss_basic_read/c/private-fss_basic_read.c +++ b/level_3/fss_basic_read/c/private-fss_basic_read.c @@ -167,7 +167,8 @@ extern "C" { return F_status_set_error(F_parameter); } - else if (data->depths.array[i].depth > data->depths.array[j].depth) { + + if (data->depths.array[i].depth > data->depths.array[j].depth) { if (main->error.verbosity != f_console_verbosity_quiet_e) { flockfile(main->error.to.stream); @@ -201,6 +202,11 @@ extern "C" { } } // for + // When stopped after the end of the buffer, the last file in the list is the correct file. + if (at > files.array[files.used - 1].range.stop) { + return files.array[files.used - 1].name; + } + return ""; } #endif // _di_fss_basic_read_file_identify_ @@ -219,12 +225,13 @@ extern "C" { if (F_status_is_error(status)) { const f_string_t file_name = fss_basic_read_file_identify(input.start, data->files); - fll_error_file_print(main->error, F_status_set_fine(status), "fll_fss_basic_read", F_true, file_name ? file_name : "-", "process", fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "fll_fss_basic_read", F_true, file_name, "process", fll_error_file_type_file_e); return status; } - else if (status == F_data_not_stop || status == F_data_not_eos) { - if (data->option & fss_basic_read_data_option_total) { + + if (status == F_data_not_stop || status == F_data_not_eos) { + if (data->option & fss_basic_read_data_option_total_d) { fss_basic_read_print_zero(main); return F_none; @@ -266,12 +273,12 @@ extern "C" { return; } - if ((data->option & fss_basic_read_data_option_object) || (data->option & fss_basic_read_data_option_content) && (data->contents.array[at].used || (data->option & fss_basic_read_data_option_empty))) { + if ((data->option & fss_basic_read_data_option_object_d) || (data->option & fss_basic_read_data_option_content_d) && (data->contents.array[at].used || (data->option & fss_basic_read_data_option_empty_d))) { flockfile(main->output.to.stream); - if (data->option & fss_basic_read_data_option_object) { - if (data->option & fss_basic_read_data_option_trim) { - if (data->option & fss_basic_read_data_option_raw) { + if (data->option & fss_basic_read_data_option_object_d) { + if (data->option & fss_basic_read_data_option_trim_d) { + if (data->option & fss_basic_read_data_option_raw_d) { if (data->quotes.array[at]) { f_print_character_safely(data->quotes.array[at] == f_fss_quote_type_single_e ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.to.stream); } @@ -287,7 +294,7 @@ extern "C" { } } else { - if (data->option & fss_basic_read_data_option_raw) { + if (data->option & fss_basic_read_data_option_raw_d) { if (data->quotes.array[at]) { f_print_character_safely(data->quotes.array[at] == f_fss_quote_type_single_e ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.to.stream); } @@ -303,13 +310,13 @@ extern "C" { } } - if (data->option & fss_basic_read_data_option_content) { + if (data->option & fss_basic_read_data_option_content_d) { fss_basic_read_print_object_end(main); } } - if ((data->option & fss_basic_read_data_option_content) && data->contents.array[at].used) { - if (data->option & fss_basic_read_data_option_raw) { + if ((data->option & fss_basic_read_data_option_content_d) && data->contents.array[at].used) { + if (data->option & fss_basic_read_data_option_raw_d) { f_print_dynamic_partial(data->buffer, data->contents.array[at].array[0], main->output.to.stream); } else { @@ -338,6 +345,7 @@ extern "C" { #ifndef _di_fss_basic_read_print_one_ void fss_basic_read_print_one(fss_basic_read_main_t * const main) { + f_print_character(f_string_ascii_1_s[0], main->output.to.stream); f_print_character(f_string_eol_s[0], main->output.to.stream); } @@ -357,6 +365,7 @@ extern "C" { #ifndef _di_fss_basic_read_print_zero_ void fss_basic_read_print_zero(fss_basic_read_main_t * const main) { + f_print_character(f_string_ascii_0_s[0], main->output.to.stream); f_print_character(f_string_eol_s[0], main->output.to.stream); } @@ -369,7 +378,7 @@ extern "C" { if (F_status_is_error(status)) return status; // This standard does not support multiple content groups. - if ((data->option & fss_basic_read_data_option_select) && data->select) { + if ((data->option & fss_basic_read_data_option_select_d) && data->select) { if (main->parameters[fss_basic_read_parameter_total_e].result == f_console_result_found_e) { flockfile(main->output.to.stream); @@ -393,15 +402,15 @@ extern "C" { return fss_basic_read_process_at(main, data, names); } - if (data->option & fss_basic_read_data_option_columns) { + if (data->option & fss_basic_read_data_option_columns_d) { return fss_basic_read_process_columns(main, data, names); } - if (data->option & fss_basic_read_data_option_total) { + if (data->option & fss_basic_read_data_option_total_d) { return fss_basic_read_process_total(main, data, names); } - if (data->option & fss_basic_read_data_option_line) { + if (data->option & fss_basic_read_data_option_line_d) { return fss_basic_read_process_line(main, data, names); } @@ -423,7 +432,7 @@ extern "C" { f_status_t fss_basic_read_process_at(fss_basic_read_main_t * const main, fss_basic_read_data_t *data, bool names[]) { if (data->depths.array[0].value_at >= data->objects.used) { - if (data->option & (fss_basic_read_data_option_columns | fss_basic_read_data_option_total)) { + if (data->option & (fss_basic_read_data_option_columns_d | fss_basic_read_data_option_total_d)) { flockfile(main->output.to.stream); fss_basic_read_print_zero(main); @@ -435,9 +444,9 @@ extern "C" { } // This standard only has one line per Content; therefore, any line value greater than 0 equates to no line to print. - if (data->option & fss_basic_read_data_option_line) { + if (data->option & fss_basic_read_data_option_line_d) { if (data->line) { - if (data->option & fss_basic_read_data_option_total) { + if (data->option & fss_basic_read_data_option_total_d) { flockfile(main->output.to.stream); fss_basic_read_print_zero(main); @@ -463,12 +472,12 @@ extern "C" { } if (at == data->depths.array[0].value_at) { - if (data->option & fss_basic_read_data_option_line) { + if (data->option & fss_basic_read_data_option_line_d) { // This standard only supports one line per Object so when using "--at", the only valid line is line 0. if (data->line) break; - if (data->option & fss_basic_read_data_option_total) { + if (data->option & fss_basic_read_data_option_total_d) { flockfile(main->output.to.stream); fss_basic_read_print_one(main); @@ -479,10 +488,10 @@ extern "C" { fss_basic_read_print_at(main, i, *delimits, except_none, data); } } - else if (data->option & fss_basic_read_data_option_columns) { + else if (data->option & fss_basic_read_data_option_columns_d) { fll_print_format("%ul%c", main->output.to.stream, data->contents.array[i].used, f_string_eol_s[0]); } - else if (data->option & fss_basic_read_data_option_total) { + else if (data->option & fss_basic_read_data_option_total_d) { flockfile(main->output.to.stream); if (data->contents.array[i].used) { @@ -504,7 +513,7 @@ extern "C" { ++at; } // for - if (data->option & fss_basic_read_data_option_total) { + if (data->option & fss_basic_read_data_option_total_d) { flockfile(main->output.to.stream); fss_basic_read_print_zero(main); @@ -519,7 +528,7 @@ extern "C" { #ifndef _di_fss_basic_read_process_columns_ f_status_t fss_basic_read_process_columns(fss_basic_read_main_t * const main, fss_basic_read_data_t *data, bool names[]) { - if (!(data->option & fss_basic_read_data_option_content)) { + if (!(data->option & fss_basic_read_data_option_content_d)) { flockfile(main->output.to.stream); fss_basic_read_print_zero(main); @@ -566,9 +575,9 @@ extern "C" { return F_status_set_error(F_interrupt); } - if (!(data->option & fss_basic_read_data_option_object) && (data->option & fss_basic_read_data_option_content)) { + if (!(data->option & fss_basic_read_data_option_object_d) && (data->option & fss_basic_read_data_option_content_d)) { if (!data->contents.array[i].used) { - if (data->option & fss_basic_read_data_option_empty) { + if (data->option & fss_basic_read_data_option_empty_d) { if (line == data->line) { flockfile(main->output.to.stream); @@ -609,7 +618,7 @@ extern "C" { memset(names, F_false, sizeof(bool) * data->objects.used); - if (data->option & fss_basic_read_data_option_trim) { + if (data->option & fss_basic_read_data_option_trim_d) { for (i = 0; i < data->objects.used; ++i) { if (fl_string_dynamic_partial_compare_except_trim_dynamic(data->depths.array[0].value_name, data->buffer, data->objects.array[i], except_none, data->delimits) == F_equal_to) { @@ -640,58 +649,58 @@ extern "C" { f_status_t status = F_none; if (main->parameters[fss_basic_read_parameter_at_e].result == f_console_result_additional_e) { - data->option |= fss_basic_read_data_option_at; + data->option |= fss_basic_read_data_option_at_d; } if (main->parameters[fss_basic_read_parameter_columns_e].result == f_console_result_found_e) { - data->option |= fss_basic_read_data_option_columns; + data->option |= fss_basic_read_data_option_columns_d; } if (main->parameters[fss_basic_read_parameter_content_e].result == f_console_result_found_e) { - data->option |= fss_basic_read_data_option_content; + data->option |= fss_basic_read_data_option_content_d; } if (main->parameters[fss_basic_read_parameter_empty_e].result == f_console_result_found_e) { - data->option |= fss_basic_read_data_option_empty; + data->option |= fss_basic_read_data_option_empty_d; } if (main->parameters[fss_basic_read_parameter_line_e].result == f_console_result_additional_e) { - data->option |= fss_basic_read_data_option_line; + data->option |= fss_basic_read_data_option_line_d; status = fss_basic_read_load_number(main, fss_basic_read_parameter_line_e, fss_basic_read_long_line_s, arguments, &data->line); if (F_status_is_error(status)) return status; } if (main->parameters[fss_basic_read_parameter_name_e].result == f_console_result_additional_e) { - data->option |= fss_basic_read_data_option_name; + data->option |= fss_basic_read_data_option_name_d; } if (main->parameters[fss_basic_read_parameter_object_e].result == f_console_result_found_e) { - data->option |= fss_basic_read_data_option_object; + data->option |= fss_basic_read_data_option_object_d; } if (main->parameters[fss_basic_read_parameter_raw_e].result == f_console_result_found_e) { - data->option |= fss_basic_read_data_option_raw; + data->option |= fss_basic_read_data_option_raw_d; } if (main->parameters[fss_basic_read_parameter_select_e].result == f_console_result_additional_e) { - data->option |= fss_basic_read_data_option_select; + data->option |= fss_basic_read_data_option_select_d; status = fss_basic_read_load_number(main, fss_basic_read_parameter_select_e, fss_basic_read_long_select_s, arguments, &data->select); if (F_status_is_error(status)) return status; } if (main->parameters[fss_basic_read_parameter_total_e].result == f_console_result_found_e) { - data->option |= fss_basic_read_data_option_total; + data->option |= fss_basic_read_data_option_total_d; } if (main->parameters[fss_basic_read_parameter_trim_e].result == f_console_result_found_e) { - data->option |= fss_basic_read_data_option_trim; + data->option |= fss_basic_read_data_option_trim_d; } // Default to content if neither Object nor Content is explicitly requested. - if (!(data->option & (fss_basic_read_data_option_content | fss_basic_read_data_option_object))) { - data->option |= fss_basic_read_data_option_content; + if (!(data->option & (fss_basic_read_data_option_content_d | fss_basic_read_data_option_object_d))) { + data->option |= fss_basic_read_data_option_content_d; } return F_none; @@ -711,8 +720,8 @@ extern "C" { return F_status_set_error(F_interrupt); } - if (!(data->option & fss_basic_read_data_option_object) && data->option & fss_basic_read_data_option_content) { - if (!(data->contents.array[i].used || (data->option & fss_basic_read_data_option_empty))) { + if (!(data->option & fss_basic_read_data_option_object_d) && data->option & fss_basic_read_data_option_content_d) { + if (!(data->contents.array[i].used || (data->option & fss_basic_read_data_option_empty_d))) { continue; } } @@ -722,7 +731,7 @@ extern "C" { flockfile(main->output.to.stream); - if (data->option & fss_basic_read_data_option_line) { + if (data->option & fss_basic_read_data_option_line_d) { if (data->line < total) { fss_basic_read_print_one(main); } diff --git a/level_3/fss_basic_write/c/fss_basic_write.c b/level_3/fss_basic_write/c/fss_basic_write.c index 2e027a6..14140ce 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.c +++ b/level_3/fss_basic_write/c/fss_basic_write.c @@ -25,7 +25,7 @@ extern "C" { f_print_character(f_string_eol_s[0], file.stream); - fll_program_print_help_option(file, context, fss_basic_write_short_file_s, fss_basic_write_long_file_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a file to send file to."); + fll_program_print_help_option(file, context, fss_basic_write_short_file_s, fss_basic_write_long_file_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a file to send data to."); fll_program_print_help_option(file, context, fss_basic_write_short_content_s, fss_basic_write_long_content_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "The Content to file."); fll_program_print_help_option(file, context, fss_basic_write_short_double_s, fss_basic_write_long_double_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Use double quotes (default)."); fll_program_print_help_option(file, context, fss_basic_write_short_ignore_s, fss_basic_write_long_ignore_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Ignore a given range within a Content."); @@ -92,6 +92,7 @@ extern "C" { if (F_status_is_error(status)) { fss_basic_write_main_delete(main); + return F_status_set_error(status); } } @@ -106,6 +107,7 @@ extern "C" { if (F_status_is_error(status)) { fss_basic_write_main_delete(main); + return status; } @@ -138,6 +140,7 @@ extern "C" { fss_basic_write_print_help(main->output.to, main->context); fss_basic_write_main_delete(main); + return status; } @@ -145,6 +148,7 @@ extern "C" { fll_program_print_version(main->output.to, fss_basic_write_program_version_s); fss_basic_write_main_delete(main); + return status; } @@ -249,6 +253,7 @@ extern "C" { } status = F_status_set_error(F_parameter); + break; } } // for @@ -339,6 +344,7 @@ extern "C" { } status = F_status_set_error(F_parameter); + break; } } // for @@ -437,6 +443,7 @@ extern "C" { if (fss_basic_write_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } @@ -455,6 +462,7 @@ extern "C" { if (fss_basic_write_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } @@ -500,14 +508,14 @@ extern "C" { } else if (main->error.verbosity != f_console_verbosity_quiet_e && main->parameters[fss_basic_write_parameter_file_e].result == f_console_result_none_e) { - // ensure there is always a newline at the end, unless in quiet mode. - fll_print_character(f_string_eol_s[0], main->error.to.stream); + // Ensure there is always a newline at the end, unless in quiet mode. + fll_print_character(f_string_eol_s[0], main->output.to.stream); } } macro_f_string_dynamic_t_delete_simple(escaped); - // object and content, though being a "dynamic" type, is being used statically, so clear them up to avoid invalid free(). + // Object and content, though being a "dynamic" type, is being used statically, so clear them up to avoid invalid free(). object.string = 0; object.used = 0; object.size = 0; @@ -523,7 +531,7 @@ extern "C" { } } - // ensure a newline is always put at the end of the program execution, unless in quiet mode. + // Ensure a newline is always put at the end of the program execution, unless in quiet mode. if (main->error.verbosity != f_console_verbosity_quiet_e) { if (F_status_is_error(status)) { fll_print_character(f_string_eol_s[0], main->error.to.stream); diff --git a/level_3/fss_basic_write/c/private-fss_basic_write.c b/level_3/fss_basic_write/c/private-fss_basic_write.c index 37c2062..5e03365 100644 --- a/level_3/fss_basic_write/c/private-fss_basic_write.c +++ b/level_3/fss_basic_write/c/private-fss_basic_write.c @@ -186,6 +186,7 @@ extern "C" { fll_error_print(main->error, F_status_set_fine(status_pipe), "f_file_read_block", F_true); status_pipe = F_status_set_error(F_pipe); + break; } @@ -208,6 +209,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true); + break; } } @@ -217,17 +219,20 @@ extern "C" { if (block.string[range.start] == fss_basic_write_pipe_content_start_s) { state = 0x2; ++range.start; + break; } if (block.string[range.start] == fss_basic_write_pipe_content_end_s) { state = 0x3; ++range.start; + break; } if (block.string[range.start] == fss_basic_write_pipe_content_ignore_s) { - // this is not used by objects. + + // This is not used by objects. continue; } @@ -236,10 +241,10 @@ extern "C" { if (F_status_is_error(status)) break; - // if the start of content was not found, then fetch the next block. + // If the start of content was not found, then fetch the next block. if (state == 0x1) continue; - // if the end of the current block is reached, fetch the next block. + // If the end of the current block is reached, fetch the next block. if (range.start > range.stop) continue; } @@ -252,13 +257,12 @@ extern "C" { } if (total) { - if (content.used + total > content.size) { - status = f_string_dynamic_increase_by(total, &content); + status = f_string_dynamic_increase_by(total, &content); - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true); - break; - } + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true); + + break; } for (; range.start <= range.stop; ++range.start) { @@ -269,17 +273,20 @@ extern "C" { } status = F_status_set_error(F_supported_not); + break; } if (block.string[range.start] == fss_basic_write_pipe_content_end_s) { state = 0x3; ++range.start; + break; } if (block.string[range.start] == fss_basic_write_pipe_content_ignore_s) { - // this is not used by this program. + + // This is not used by this program. continue; } @@ -308,7 +315,7 @@ extern "C" { } } // for - // if the pipe ended before finishing, then attempt to wrap up. + // If the pipe ended before finishing, then attempt to wrap up. if (F_status_is_error_not(status) && status_pipe == F_none_eof && state) { status = fss_basic_write_process(main, output, quote, &object, &content, buffer); } diff --git a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c index 1b05c31..4443cfa 100644 --- a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c +++ b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c @@ -119,6 +119,7 @@ extern "C" { #ifndef _di_fss_embedded_list_read_main_ f_status_t fss_embedded_list_read_main(fss_embedded_list_read_main_t * const main, const f_console_arguments_t *arguments) { + f_status_t status = F_none; { @@ -166,6 +167,7 @@ extern "C" { if (F_status_is_error(status)) { fss_embedded_list_read_main_delete(main); + return status; } @@ -198,6 +200,7 @@ extern "C" { fss_embedded_list_read_print_help(main->output.to, main->context); fss_embedded_list_read_main_delete(main); + return F_none; } @@ -205,6 +208,7 @@ extern "C" { fll_program_print_version(main->output.to, fss_embedded_list_read_program_version_s); fss_embedded_list_read_main_delete(main); + return F_none; } @@ -449,6 +453,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_file_print(main->error, F_status_set_fine(status), "f_file_open", F_true, arguments->argv[main->remaining.array[i]], "open", fll_error_file_type_file_e); + break; } @@ -458,6 +463,7 @@ extern "C" { fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, arguments->argv[main->remaining.array[i]], "read", fll_error_file_type_file_e); f_file_stream_close(F_true, &file); + break; } @@ -468,6 +474,7 @@ extern "C" { } f_file_stream_close(F_true, &file); + continue; } } @@ -478,6 +485,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_file_print(main->error, F_status_set_fine(status), "f_file_read_until", F_true, arguments->argv[main->remaining.array[i]], "read", fll_error_file_type_file_e); + break; } @@ -485,6 +493,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_file_print(main->error, F_status_set_fine(status), "fss_embedded_list_read_main_process_file", F_true, arguments->argv[main->remaining.array[i]], "read", fll_error_file_type_file_e); + break; } diff --git a/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.c b/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.c index 84145fd..d7cb423 100644 --- a/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.c +++ b/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.c @@ -19,7 +19,7 @@ extern "C" { f_array_length_t i = 0; f_array_length_t j = 0; - // determine the linear order in which all of the three parameter values are to be applied. + // Determine the linear order in which all of the three parameter values are to be applied. if (values_total) { memset(values_order, 0, values_total); @@ -46,6 +46,7 @@ extern "C" { values_order[k] = main->parameters[fss_embedded_list_read_parameter_at_e].values.array[j]; values_type[k] = fss_embedded_list_read_parameter_at_e; i++; + break; } } // for @@ -78,6 +79,7 @@ extern "C" { values_order[k] = main->parameters[fss_embedded_list_read_parameter_name_e].values.array[j]; values_type[k] = fss_embedded_list_read_parameter_name_e; i++; + break; } } // for @@ -273,8 +275,9 @@ extern "C" { f_array_length_t i = 0; f_array_length_t j = 0; - // comments are not to be part of the file, so remove them. + // Comments are not to be part of the file, so remove them. for (; i < comments->used; ++i) { + for (j = comments->array[i].start; j <= comments->array[i].stop; ++j) { main->buffer.string[j] = F_fss_delimit_placeholder_s; } // for @@ -351,7 +354,7 @@ extern "C" { bool skip[items->used]; - // setup defaults to be not skipped unless any given parent is skipped. + // Setup defaults to be not skipped unless any given parent is skipped. memset(skip, F_false, sizeof(skip) * items->used); if (parents.used) { @@ -439,7 +442,7 @@ extern "C" { } } - // if the current depth is not the final depth, then recurse into the next depth. + // If the current depth is not the final depth, then recurse into the next depth. if (depths_index + 1 < depths.used) { bool skip_next[main->nest.depth[depths.array[depths_index + 1].depth - 1].used]; @@ -490,7 +493,7 @@ extern "C" { return fss_embedded_list_read_main_process_for_depth(main, arguments, filename, depths, depths_index + 1, line, parents_next, objects_delimits, contents_delimits); } - // process objects. + // Process objects. f_array_length_t i = 0; f_array_length_t j = 0; @@ -539,7 +542,7 @@ extern "C" { return F_none; } - // process contents. + // Process contents. bool include_empty = 0; if (main->parameters[fss_embedded_list_read_parameter_empty_e].result == f_console_result_found_e) { @@ -593,6 +596,7 @@ extern "C" { if (include_empty) { if (line_current == line) { fss_embedded_list_read_print_set_end(main); + break; } @@ -612,6 +616,7 @@ extern "C" { if (line_current == line) { ++j; + break; } } @@ -627,6 +632,7 @@ extern "C" { if (main->buffer.string[j] == f_string_eol_s[0]) { f_print_character(f_string_eol_s[0], main->output.to.stream); + break; } @@ -727,6 +733,7 @@ extern "C" { if (main->delimit_mode == fss_embedded_list_read_delimit_mode_none_e) { objects_delimits->used = 0; contents_delimits->used = 0; + return; } @@ -734,6 +741,7 @@ extern "C" { if (main->delimit_depth >= main->nest.used) { objects_delimits->used = 0; contents_delimits->used = 0; + return; } } @@ -752,7 +760,7 @@ extern "C" { if (main->delimit_mode == fss_embedded_list_read_delimit_mode_depth_e) { - // only depth 0 objects are stored in objects_delimits. + // Only depth 0 objects are stored in objects_delimits. if (main->delimit_depth) { fss_embedded_list_read_process_delimits_objects(main, main->delimit_depth, original_contents_delimits, original_contents_used, contents_delimits); } @@ -763,7 +771,6 @@ extern "C" { fss_embedded_list_read_process_delimits_contents(main, main->delimit_depth, original_contents_delimits, original_contents_used, contents_delimits); } else { - if (main->delimit_mode == fss_embedded_list_read_delimit_mode_depth_lesser_e) { // only depth 0 objects are stored in objects_delimits. diff --git a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c index ab80cd8..a78dd9a 100644 --- a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c +++ b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c @@ -25,7 +25,7 @@ extern "C" { f_print_character(f_string_eol_s[0], file.stream); - fll_program_print_help_option(file, context, fss_embedded_list_write_short_file_s, fss_embedded_list_write_long_file_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a file to send file to."); + fll_program_print_help_option(file, context, fss_embedded_list_write_short_file_s, fss_embedded_list_write_long_file_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a file to send data to."); fll_program_print_help_option(file, context, fss_embedded_list_write_short_content_s, fss_embedded_list_write_long_content_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "The Content to file."); fll_program_print_help_option(file, context, fss_embedded_list_write_short_double_s, fss_embedded_list_write_long_double_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Use double quotes (default)."); fll_program_print_help_option(file, context, fss_embedded_list_write_short_ignore_s, fss_embedded_list_write_long_ignore_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Ignore a given range within a Content."); @@ -61,6 +61,7 @@ extern "C" { #ifndef _di_fss_embedded_list_write_main_ f_status_t fss_embedded_list_write_main(fss_embedded_list_write_main_t * const main, const f_console_arguments_t *arguments) { + f_status_t status = F_none; { @@ -94,6 +95,7 @@ extern "C" { if (F_status_is_error(status)) { fss_embedded_list_write_main_delete(main); + return F_status_set_error(status); } } @@ -108,6 +110,7 @@ extern "C" { if (F_status_is_error(status)) { fss_embedded_list_write_main_delete(main); + return status; } @@ -140,6 +143,7 @@ extern "C" { fss_embedded_list_write_print_help(main->output.to, main->context); fss_embedded_list_write_main_delete(main); + return status; } @@ -147,6 +151,7 @@ extern "C" { fll_program_print_version(main->output.to, fss_embedded_list_write_program_version_s); fss_embedded_list_write_main_delete(main); + return status; } @@ -251,6 +256,7 @@ extern "C" { } status = F_status_set_error(F_parameter); + break; } } // for @@ -343,6 +349,7 @@ extern "C" { } status = F_status_set_error(F_parameter); + break; } } // for @@ -443,6 +450,7 @@ extern "C" { if (fss_embedded_list_write_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } @@ -459,6 +467,7 @@ extern "C" { if (fss_embedded_list_write_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } @@ -479,6 +488,7 @@ extern "C" { if (fss_embedded_list_write_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } @@ -510,15 +520,15 @@ extern "C" { } else if (main->error.verbosity != f_console_verbosity_quiet_e && main->parameters[fss_embedded_list_write_parameter_file_e].result == f_console_result_none_e) { - // ensure there is always a newline at the end, unless in quiet mode. - fll_print_character(f_string_eol_s[0], main->error.to.stream); + // Ensure there is always a newline at the end, unless in quiet mode. + fll_print_character(f_string_eol_s[0], main->output.to.stream); } } macro_f_string_dynamic_t_delete_simple(escaped); macro_f_string_ranges_t_delete_simple(ignore); - // object and content, though being a "dynamic" type, is being used statically, so clear them up to avoid invalid free(). + // Object and content, though being a "dynamic" type, is being used statically, so clear them up to avoid invalid free(). object.string = 0; object.used = 0; object.size = 0; @@ -534,7 +544,7 @@ extern "C" { } } - // ensure a newline is always put at the end of the program execution, unless in quiet mode. + // Ensure a newline is always put at the end of the program execution, unless in quiet mode. if (main->error.verbosity != f_console_verbosity_quiet_e) { if (F_status_is_error(status)) { fll_print_character(f_string_eol_s[0], main->error.to.stream); diff --git a/level_3/fss_embedded_list_write/c/private-fss_embedded_list_write.c b/level_3/fss_embedded_list_write/c/private-fss_embedded_list_write.c index 222b83e..65dd847 100644 --- a/level_3/fss_embedded_list_write/c/private-fss_embedded_list_write.c +++ b/level_3/fss_embedded_list_write/c/private-fss_embedded_list_write.c @@ -130,6 +130,7 @@ extern "C" { fll_print_dynamic(*buffer, output.stream); buffer->used = 0; + return status; } #endif // _di_fss_embedded_list_write_process_ @@ -179,6 +180,7 @@ extern "C" { fll_error_print(main->error, F_status_set_fine(status_pipe), "f_file_read_block", F_true); status_pipe = F_status_set_error(F_pipe); + break; } @@ -204,6 +206,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true); + break; } } @@ -213,12 +216,14 @@ extern "C" { if (block.string[range.start] == fss_embedded_list_write_pipe_content_start_s) { state = 0x2; ++range.start; + break; } if (block.string[range.start] == fss_embedded_list_write_pipe_content_end_s) { state = 0x3; ++range.start; + break; } @@ -232,10 +237,10 @@ extern "C" { if (F_status_is_error(status)) break; - // if the start of content was not found, then fetch the next block. + // If the start of content was not found, then fetch the next block. if (state == 0x1) continue; - // if the end of the current block is reached, fetch the next block. + // If the end of the current block is reached, fetch the next block. if (range.start > range.stop) continue; } @@ -248,13 +253,12 @@ extern "C" { } if (total) { - if (content.used + total > content.size) { - status = f_string_dynamic_increase_by(total, &content); + status = f_string_dynamic_increase_by(total, &content); - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true); - break; - } + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true); + + break; } for (; range.start <= range.stop; ++range.start) { @@ -265,12 +269,14 @@ extern "C" { } status = F_status_set_error(F_supported_not); + break; } if (block.string[range.start] == fss_embedded_list_write_pipe_content_end_s) { state = 0x3; ++range.start; + break; } @@ -287,6 +293,7 @@ extern "C" { fll_error_print(main->error, F_string_too_large, "fss_embedded_list_write_process_pipe", F_true); status = F_status_set_error(F_string_too_large); + break; } @@ -298,6 +305,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main->error, F_string_too_large, "fss_embedded_list_write_process_pipe", F_true); + break; } } @@ -331,7 +339,7 @@ extern "C" { } } // for - // if the pipe ended before finishing, then attempt to wrap up. + // If the pipe ended before finishing, then attempt to wrap up. if (F_status_is_error_not(status) && status_pipe == F_none_eof && state) { status = fss_embedded_list_write_process(main, output, quote, &object, &content, ignore, buffer); } @@ -339,6 +347,7 @@ extern "C" { macro_f_string_dynamic_t_delete_simple(block); macro_f_string_dynamic_t_delete_simple(object); macro_f_string_dynamic_t_delete_simple(content); + return status; } #endif // _di_fss_embedded_list_write_process_pipe_ @@ -373,6 +382,7 @@ extern "C" { if (ignore->size + F_fss_default_allocation_step_d > F_array_length_t_size_d) { if (ignore->size + 1 > F_array_length_t_size_d) { fll_error_print(main->error, F_string_too_large, "fss_embedded_list_write_process_parameter_ignore", F_true); + return F_status_set_error(F_string_too_large); } diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.c b/level_3/fss_extended_list_read/c/fss_extended_list_read.c index 9752d08..77e0e8b 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.c @@ -152,6 +152,7 @@ extern "C" { if (F_status_is_error(status)) { fss_extended_list_read_main_delete(main); + return F_status_set_error(status); } } @@ -166,6 +167,7 @@ extern "C" { if (F_status_is_error(status)) { fss_extended_list_read_main_delete(main); + return status; } @@ -198,6 +200,7 @@ extern "C" { fss_extended_list_read_print_help(main->output.to, main->context); fss_extended_list_read_main_delete(main); + return status; } @@ -205,6 +208,7 @@ extern "C" { fll_program_print_version(main->output.to, fss_extended_list_read_program_version_s); fss_extended_list_read_main_delete(main); + return status; } @@ -215,6 +219,9 @@ extern "C" { data.files.array = files_array; data.files.used = 1; data.files.size = main->remaining.used + 1; + data.files.array[0].name = "(pipe)"; + data.files.array[0].range.start = 1; + data.files.array[0].range.stop = 0; if (main->remaining.used || main->process_pipe) { { @@ -261,6 +268,7 @@ extern "C" { funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); + break; } } // for @@ -305,6 +313,7 @@ extern "C" { funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); + break; } } // for @@ -350,6 +359,7 @@ extern "C" { if (fss_extended_list_read_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } @@ -366,6 +376,7 @@ extern "C" { funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); + break; } else if (fl_string_compare(arguments->argv[location], fss_extended_list_read_delimit_mode_name_none_s, length, fss_extended_list_read_delimit_mode_name_none_s_length) == F_equal_to) { @@ -515,7 +526,6 @@ extern "C" { file.id = F_type_descriptor_input_d; file.stream = F_type_input_d; - data.files.array[0].name = 0; data.files.array[0].range.start = 0; status = f_file_stream_read(file, &data.buffer); @@ -547,6 +557,7 @@ extern "C" { if (fss_extended_list_read_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } diff --git a/level_3/fss_extended_list_read/c/private-common.h b/level_3/fss_extended_list_read/c/private-common.h index 8d4bc8c..3a5752b 100644 --- a/level_3/fss_extended_list_read/c/private-common.h +++ b/level_3/fss_extended_list_read/c/private-common.h @@ -155,17 +155,17 @@ extern "C" { * delimits_content: The positions within the buffer representing Content character delimits. */ #ifndef _di_fss_extended_list_read_data_t_ - #define fss_extended_list_read_data_option_at 0x1 - #define fss_extended_list_read_data_option_columns 0x2 - #define fss_extended_list_read_data_option_content 0x4 - #define fss_extended_list_read_data_option_empty 0x8 - #define fss_extended_list_read_data_option_line 0x10 - #define fss_extended_list_read_data_option_name 0x20 - #define fss_extended_list_read_data_option_object 0x40 - #define fss_extended_list_read_data_option_raw 0x80 - #define fss_extended_list_read_data_option_select 0x100 - #define fss_extended_list_read_data_option_total 0x200 - #define fss_extended_list_read_data_option_trim 0x400 + #define fss_extended_list_read_data_option_at_d 0x1 + #define fss_extended_list_read_data_option_columns_d 0x2 + #define fss_extended_list_read_data_option_content_d 0x4 + #define fss_extended_list_read_data_option_empty_d 0x8 + #define fss_extended_list_read_data_option_line_d 0x10 + #define fss_extended_list_read_data_option_name_d 0x20 + #define fss_extended_list_read_data_option_object_d 0x40 + #define fss_extended_list_read_data_option_raw_d 0x80 + #define fss_extended_list_read_data_option_select_d 0x100 + #define fss_extended_list_read_data_option_total_d 0x200 + #define fss_extended_list_read_data_option_trim_d 0x400 typedef struct { uint16_t option; diff --git a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c index 32bc4e0..4512045 100644 --- a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c @@ -224,6 +224,11 @@ extern "C" { } } // for + // When stopped after the end of the buffer, the last file in the list is the correct file. + if (at > files.array[files.used - 1].range.stop) { + return files.array[files.used - 1].name; + } + return ""; } #endif // _di_fss_extended_list_read_file_identify_ @@ -242,12 +247,13 @@ extern "C" { if (F_status_is_error(status)) { const f_string_t file_name = fss_extended_list_read_file_identify(input.start, data->files); - fll_error_file_print(main->error, F_status_set_fine(status), "fll_fss_extended_list_read", F_true, file_name ? file_name : "-", "process", fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "fll_fss_extended_list_read", F_true, file_name, "process", fll_error_file_type_file_e); return status; } - else if (status == F_data_not_stop || status == F_data_not_eos) { - if (data->option & fss_extended_list_read_data_option_total) { + + if (status == F_data_not_stop || status == F_data_not_eos) { + if (data->option & fss_extended_list_read_data_option_total_d) { fss_extended_list_read_print_zero(main); return F_none; @@ -289,11 +295,11 @@ extern "C" { return; } - if ((data->option & fss_extended_list_read_data_option_object) || ((data->option & fss_extended_list_read_data_option_content) && (data->contents.array[at].used && data->contents.array[at].array[0].start <= data->contents.array[at].array[0].stop || (data->option & fss_extended_list_read_data_option_empty)))) { + if ((data->option & fss_extended_list_read_data_option_object_d) || ((data->option & fss_extended_list_read_data_option_content_d) && (data->contents.array[at].used && data->contents.array[at].array[0].start <= data->contents.array[at].array[0].stop || (data->option & fss_extended_list_read_data_option_empty_d)))) { flockfile(main->output.to.stream); - if (data->option & fss_extended_list_read_data_option_object) { - if (data->option & fss_extended_list_read_data_option_trim) { + if (data->option & fss_extended_list_read_data_option_object_d) { + if (data->option & fss_extended_list_read_data_option_trim_d) { fl_print_trim_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.to.stream); } else { @@ -303,7 +309,7 @@ extern "C" { fss_extended_list_read_print_object_end(main, data); } - if (data->option & fss_extended_list_read_data_option_content) { + if (data->option & fss_extended_list_read_data_option_content_d) { if (data->contents.array[at].used && data->contents.array[at].array[0].start <= data->contents.array[at].array[0].stop) { if (data->contents.array[at].used && data->contents.array[at].array[0].start <= data->contents.array[at].array[0].stop) { fss_extended_list_read_print_content_ignore(main); @@ -329,7 +335,7 @@ extern "C" { return; } - if (data->option & fss_extended_list_read_data_option_trim) { + if (data->option & fss_extended_list_read_data_option_trim_d) { fl_print_trim_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.to.stream); } else { @@ -356,7 +362,7 @@ extern "C" { f_print_character(fss_extended_list_read_pipe_content_start, main->output.to.stream); } else { - if ((data->option & fss_extended_list_read_data_option_object) && (data->option & fss_extended_list_read_data_option_content)) { + if ((data->option & fss_extended_list_read_data_option_object_d) && (data->option & fss_extended_list_read_data_option_content_d)) { f_print_character(f_fss_extended_list_open_s[0], main->output.to.stream); f_print_character(f_fss_extended_list_open_end_s[0], main->output.to.stream); } @@ -371,12 +377,12 @@ extern "C" { f_print_character(fss_extended_list_read_pipe_content_end, main->output.to.stream); } else { - if (data->option & fss_extended_list_read_data_option_object) { - if (data->option & fss_extended_list_read_data_option_content) { + if (data->option & fss_extended_list_read_data_option_object_d) { + if (data->option & fss_extended_list_read_data_option_content_d) { f_print_character(f_fss_extended_list_close_s[0], main->output.to.stream); f_print_character(f_fss_extended_list_close_end_s[0], main->output.to.stream); } - else if (!(data->option & fss_extended_list_read_data_option_content)) { + else if (!(data->option & fss_extended_list_read_data_option_content_d)) { f_print_character(f_fss_eol_s[0], main->output.to.stream); } } @@ -386,6 +392,7 @@ extern "C" { #ifndef _di_fss_extended_list_read_print_one_ void fss_extended_list_read_print_one(fss_extended_list_read_main_t * const main) { + f_print_character(f_string_ascii_1_s[0], main->output.to.stream); f_print_character(f_string_eol_s[0], main->output.to.stream); } @@ -393,6 +400,7 @@ extern "C" { #ifndef _di_fss_extended_list_read_print_zero_ void fss_extended_list_read_print_zero(fss_extended_list_read_main_t * const main) { + f_print_character(f_string_ascii_0_s[0], main->output.to.stream); f_print_character(f_string_eol_s[0], main->output.to.stream); } @@ -405,7 +413,7 @@ extern "C" { if (F_status_is_error(status)) return status; // This standard does not support multiple content groups. - if ((data->option & fss_extended_list_read_data_option_select) && data->select) { + if ((data->option & fss_extended_list_read_data_option_select_d) && data->select) { if (main->parameters[fss_extended_list_read_parameter_total_e].result == f_console_result_found_e) { fss_extended_list_read_print_zero(main); } @@ -425,15 +433,15 @@ extern "C" { return fss_extended_list_read_process_at(main, data, names); } - if (data->option & fss_extended_list_read_data_option_columns) { + if (data->option & fss_extended_list_read_data_option_columns_d) { return fss_extended_list_read_process_columns(main, data, names); } - if (data->option & fss_extended_list_read_data_option_total) { + if (data->option & fss_extended_list_read_data_option_total_d) { return fss_extended_list_read_process_total(main, data, names); } - if (data->option & fss_extended_list_read_data_option_line) { + if (data->option & fss_extended_list_read_data_option_line_d) { return fss_extended_list_read_process_line(main, data, names); } @@ -441,7 +449,7 @@ extern "C" { f_array_lengths_t *delimits_object = fss_extended_list_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; f_array_lengths_t *delimits_content = fss_extended_list_read_delimit_content_is(0, data) ? &data->delimits_content : &except_none; - if (data->option & fss_extended_list_read_data_option_raw) { + if (data->option & fss_extended_list_read_data_option_raw_d) { delimits_object = &except_none; delimits_content = &except_none; } @@ -461,7 +469,7 @@ extern "C" { f_status_t fss_extended_list_read_process_at(fss_extended_list_read_main_t * const main, fss_extended_list_read_data_t *data, bool names[]) { if (data->depths.array[0].value_at >= data->objects.used) { - if (data->option & (fss_extended_list_read_data_option_columns | fss_extended_list_read_data_option_total)) { + if (data->option & (fss_extended_list_read_data_option_columns_d | fss_extended_list_read_data_option_total_d)) { flockfile(main->output.to.stream); fss_extended_list_read_print_zero(main); @@ -476,7 +484,7 @@ extern "C" { f_array_lengths_t *delimits_object = fss_extended_list_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; f_array_lengths_t *delimits_content = fss_extended_list_read_delimit_content_is(0, data) ? &data->delimits_content : &except_none; - if (data->option & fss_extended_list_read_data_option_raw) { + if (data->option & fss_extended_list_read_data_option_raw_d) { delimits_object = &except_none; delimits_content = &except_none; } @@ -489,17 +497,17 @@ extern "C" { if (!names[i]) continue; if (at == data->depths.array[0].value_at) { - if (data->option & fss_extended_list_read_data_option_line) { + if (data->option & fss_extended_list_read_data_option_line_d) { f_array_length_t line = 0; status = fss_extended_list_read_process_at_line(main, i, *delimits_object, *delimits_content, data, &line); if (status == F_success) return F_none; } - else if (data->option & fss_extended_list_read_data_option_columns) { + else if (data->option & fss_extended_list_read_data_option_columns_d) { fll_print_format("%ul%c", main->output.to.stream, data->contents.array[i].used, f_string_eol_s[0]); } - else if (data->option & fss_extended_list_read_data_option_total) { - if ((data->option & fss_extended_list_read_data_option_object) && !(data->option & fss_extended_list_read_data_option_content)) { + else if (data->option & fss_extended_list_read_data_option_total_d) { + if ((data->option & fss_extended_list_read_data_option_object_d) && !(data->option & fss_extended_list_read_data_option_content_d)) { flockfile(main->output.to.stream); if (data->contents.array[i].used) { @@ -519,12 +527,12 @@ extern "C" { for (; j < data->contents.array[i].used; ++j) { if (data->contents.array[i].array[0].start > data->contents.array[i].array[0].stop) { - if (data->option & fss_extended_list_read_data_option_object) { + if (data->option & fss_extended_list_read_data_option_object_d) { total += 2; } } else { - if (data->option & fss_extended_list_read_data_option_object) { + if (data->option & fss_extended_list_read_data_option_object_d) { total += 2; } @@ -564,7 +572,7 @@ extern "C" { ++at; } // for - if (data->option & fss_extended_list_read_data_option_total) { + if (data->option & fss_extended_list_read_data_option_total_d) { flockfile(main->output.to.stream); fss_extended_list_read_print_zero(main); @@ -576,45 +584,15 @@ extern "C" { } #endif // _di_fss_extended_list_read_process_at_ -#ifndef _di_fss_extended_list_read_process_columns_ - f_status_t fss_extended_list_read_process_columns(fss_extended_list_read_main_t * const main, fss_extended_list_read_data_t *data, bool names[]) { - - if (!(data->option & fss_extended_list_read_data_option_content)) { - flockfile(main->output.to.stream); - - fss_extended_list_read_print_zero(main); - - funlockfile(main->output.to.stream); - - return F_none; - } - - f_array_length_t max = 0; - - for (f_array_length_t at = 0; at < data->contents.used; ++at) { - - if (!names[at]) continue; - - if (data->contents.array[at].used > max) { - max = data->contents.array[at].used; - } - } // for - - fll_print_format("%ul%c", main->output.to.stream, max, f_string_eol_s[0]); - - return F_none; - } -#endif // _di_fss_extended_list_read_process_columns_ - #ifndef _di_fss_extended_list_read_process_at_line_ f_status_t fss_extended_list_read_process_at_line(fss_extended_list_read_main_t * const main, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, fss_extended_list_read_data_t *data, f_array_length_t *line) { - if (data->option & fss_extended_list_read_data_option_object) { + if (data->option & fss_extended_list_read_data_option_object_d) { if (*line == data->line) { flockfile(main->output.to.stream); - if (data->option & fss_extended_list_read_data_option_total) { + if (data->option & fss_extended_list_read_data_option_total_d) { fss_extended_list_read_print_one(main); } else { @@ -630,7 +608,7 @@ extern "C" { } // There is only a single Content column for this standard. - if (data->option & fss_extended_list_read_data_option_content) { + if (data->option & fss_extended_list_read_data_option_content_d) { if (!data->contents.array[at].used) { return F_none; } @@ -654,7 +632,7 @@ extern "C" { flockfile(main->output.to.stream); - if (data->option & fss_extended_list_read_data_option_total) { + if (data->option & fss_extended_list_read_data_option_total_d) { fss_extended_list_read_print_one(main); } else { @@ -681,7 +659,7 @@ extern "C" { if (*line == data->line) { flockfile(main->output.to.stream); - if (data->option & fss_extended_list_read_data_option_total) { + if (data->option & fss_extended_list_read_data_option_total_d) { fss_extended_list_read_print_one(main); } else { @@ -702,6 +680,36 @@ extern "C" { } #endif // _di_fss_extended_list_read_process_at_line_ +#ifndef _di_fss_extended_list_read_process_columns_ + f_status_t fss_extended_list_read_process_columns(fss_extended_list_read_main_t * const main, fss_extended_list_read_data_t *data, bool names[]) { + + if (!(data->option & fss_extended_list_read_data_option_content_d)) { + flockfile(main->output.to.stream); + + fss_extended_list_read_print_zero(main); + + funlockfile(main->output.to.stream); + + return F_none; + } + + f_array_length_t max = 0; + + for (f_array_length_t at = 0; at < data->contents.used; ++at) { + + if (!names[at]) continue; + + if (data->contents.array[at].used > max) { + max = data->contents.array[at].used; + } + } // for + + fll_print_format("%ul%c", main->output.to.stream, max, f_string_eol_s[0]); + + return F_none; + } +#endif // _di_fss_extended_list_read_process_columns_ + #ifndef _di_fss_extended_list_read_process_line_ f_status_t fss_extended_list_read_process_line(fss_extended_list_read_main_t * const main, fss_extended_list_read_data_t *data, bool names[]) { @@ -709,7 +717,7 @@ extern "C" { f_array_lengths_t *delimits_object = fss_extended_list_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; f_array_lengths_t *delimits_content = fss_extended_list_read_delimit_content_is(0, data) ? &data->delimits_content : &except_none; - if (data->option & fss_extended_list_read_data_option_raw) { + if (data->option & fss_extended_list_read_data_option_raw_d) { delimits_object = &except_none; delimits_content = &except_none; } @@ -761,58 +769,58 @@ extern "C" { f_status_t status = F_none; if (main->parameters[fss_extended_list_read_parameter_at_e].result == f_console_result_additional_e) { - data->option |= fss_extended_list_read_data_option_at; + data->option |= fss_extended_list_read_data_option_at_d; } if (main->parameters[fss_extended_list_read_parameter_columns_e].result == f_console_result_found_e) { - data->option |= fss_extended_list_read_data_option_columns; + data->option |= fss_extended_list_read_data_option_columns_d; } if (main->parameters[fss_extended_list_read_parameter_content_e].result == f_console_result_found_e) { - data->option |= fss_extended_list_read_data_option_content; + data->option |= fss_extended_list_read_data_option_content_d; } if (main->parameters[fss_extended_list_read_parameter_empty_e].result == f_console_result_found_e) { - data->option |= fss_extended_list_read_data_option_empty; + data->option |= fss_extended_list_read_data_option_empty_d; } if (main->parameters[fss_extended_list_read_parameter_line_e].result == f_console_result_additional_e) { - data->option |= fss_extended_list_read_data_option_line; + data->option |= fss_extended_list_read_data_option_line_d; status = fss_extended_list_read_load_number(main, fss_extended_list_read_parameter_line_e, fss_extended_list_read_long_line_s, arguments, &data->line); if (F_status_is_error(status)) return status; } if (main->parameters[fss_extended_list_read_parameter_name_e].result == f_console_result_additional_e) { - data->option |= fss_extended_list_read_data_option_name; + data->option |= fss_extended_list_read_data_option_name_d; } if (main->parameters[fss_extended_list_read_parameter_object_e].result == f_console_result_found_e) { - data->option |= fss_extended_list_read_data_option_object; + data->option |= fss_extended_list_read_data_option_object_d; } if (main->parameters[fss_extended_list_read_parameter_raw_e].result == f_console_result_found_e) { - data->option |= fss_extended_list_read_data_option_raw; + data->option |= fss_extended_list_read_data_option_raw_d; } if (main->parameters[fss_extended_list_read_parameter_select_e].result == f_console_result_additional_e) { - data->option |= fss_extended_list_read_data_option_select; + data->option |= fss_extended_list_read_data_option_select_d; status = fss_extended_list_read_load_number(main, fss_extended_list_read_parameter_select_e, fss_extended_list_read_long_select_s, arguments, &data->select); if (F_status_is_error(status)) return status; } if (main->parameters[fss_extended_list_read_parameter_total_e].result == f_console_result_found_e) { - data->option |= fss_extended_list_read_data_option_total; + data->option |= fss_extended_list_read_data_option_total_d; } if (main->parameters[fss_extended_list_read_parameter_trim_e].result == f_console_result_found_e) { - data->option |= fss_extended_list_read_data_option_trim; + data->option |= fss_extended_list_read_data_option_trim_d; } // Default to content if neither Object nor Content is explicitly requested. - if (!(data->option & (fss_extended_list_read_data_option_content | fss_extended_list_read_data_option_object))) { - data->option |= fss_extended_list_read_data_option_content; + if (!(data->option & (fss_extended_list_read_data_option_content_d | fss_extended_list_read_data_option_object_d))) { + data->option |= fss_extended_list_read_data_option_content_d; } return F_none; @@ -830,17 +838,17 @@ extern "C" { if (!names[at]) continue; - if (data->option & fss_extended_list_read_data_option_object) { + if (data->option & fss_extended_list_read_data_option_object_d) { ++total; // Include the closing brace in the total count. - if (data->option & fss_extended_list_read_data_option_content) { + if (data->option & fss_extended_list_read_data_option_content_d) { ++total; } } // There is only a single Content column for this standard. - if (data->option & fss_extended_list_read_data_option_content) { + if (data->option & fss_extended_list_read_data_option_content_d) { if (!data->contents.array[at].used) continue; @@ -848,9 +856,7 @@ extern "C" { range.stop = data->contents.array[at].array[0].stop; // This content has no data, do not even check "include empty" because it cannot be counted as a line. - if (range.start > range.stop) { - continue; - } + if (range.start > range.stop) continue; for (i = range.start; i <= range.stop; ++i) { @@ -872,7 +878,7 @@ extern "C" { flockfile(main->output.to.stream); - if (data->option & fss_extended_list_read_data_option_line) { + if (data->option & fss_extended_list_read_data_option_line_d) { if (data->line < total) { fss_extended_list_read_print_one(main); } diff --git a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.h b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.h index 097b406..76dadf9 100644 --- a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.h +++ b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.h @@ -242,7 +242,7 @@ extern "C" { #endif // _di_fss_extended_list_read_print_zero_ /** - * Perform the basic read processing on the buffer. + * Perform the extended list read processing on the buffer. * * This will print an error message on error. * @@ -287,24 +287,6 @@ extern "C" { #endif // _di_fss_extended_list_read_process_at_ /** - * Process based on columns parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_extended_list_read_process_columns_ - extern f_status_t fss_extended_list_read_process_columns(fss_extended_list_read_main_t * const main, fss_extended_list_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_process_columns_ - -/** * Process based on at parameter for some line. * * @param main @@ -328,6 +310,24 @@ extern "C" { #endif // _di_fss_extended_list_read_process_at_line_ /** + * Process based on columns parameter. + * + * @param main + * The main program data. + * @param data + * The program data. + * @param names + * An array of booleans representing whether or not some Object name is to be used. + * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) + * + * @return + * F_none on success. + */ +#ifndef _di_fss_extended_list_read_process_columns_ + extern f_status_t fss_extended_list_read_process_columns(fss_extended_list_read_main_t * const main, fss_extended_list_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; +#endif // _di_fss_extended_list_read_process_columns_ + +/** * Process based on line parameter. * * @param main diff --git a/level_3/fss_extended_list_write/c/fss_extended_list_write.c b/level_3/fss_extended_list_write/c/fss_extended_list_write.c index 3323f54..0a14e91 100644 --- a/level_3/fss_extended_list_write/c/fss_extended_list_write.c +++ b/level_3/fss_extended_list_write/c/fss_extended_list_write.c @@ -25,7 +25,7 @@ extern "C" { f_print_character(f_string_eol_s[0], file.stream); - fll_program_print_help_option(file, context, fss_extended_list_write_short_file_s, fss_extended_list_write_long_file_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a file to send file to."); + fll_program_print_help_option(file, context, fss_extended_list_write_short_file_s, fss_extended_list_write_long_file_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a file to send data to."); fll_program_print_help_option(file, context, fss_extended_list_write_short_content_s, fss_extended_list_write_long_content_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "The Content to file."); fll_program_print_help_option(file, context, fss_extended_list_write_short_double_s, fss_extended_list_write_long_double_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Use double quotes (default)."); fll_program_print_help_option(file, context, fss_extended_list_write_short_ignore_s, fss_extended_list_write_long_ignore_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Ignore a given range within a Content."); @@ -95,6 +95,7 @@ extern "C" { if (F_status_is_error(status)) { fss_extended_list_write_main_delete(main); + return F_status_set_error(status); } } @@ -109,6 +110,7 @@ extern "C" { if (F_status_is_error(status)) { fss_extended_list_write_main_delete(main); + return status; } @@ -141,6 +143,7 @@ extern "C" { fss_extended_list_write_print_help(main->output.to, main->context); fss_extended_list_write_main_delete(main); + return status; } @@ -148,6 +151,7 @@ extern "C" { fll_program_print_version(main->output.to, fss_extended_list_write_program_version_s); fss_extended_list_write_main_delete(main); + return status; } @@ -344,6 +348,7 @@ extern "C" { } status = F_status_set_error(F_parameter); + break; } } // for @@ -444,6 +449,7 @@ extern "C" { if (fss_extended_list_write_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } @@ -460,6 +466,7 @@ extern "C" { if (fss_extended_list_write_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } @@ -480,6 +487,7 @@ extern "C" { if (fss_extended_list_write_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } @@ -511,15 +519,15 @@ extern "C" { } else if (main->error.verbosity != f_console_verbosity_quiet_e && main->parameters[fss_extended_list_write_parameter_file_e].result == f_console_result_none_e) { - // ensure there is always a newline at the end, unless in quiet mode. - fll_print_character(f_string_eol_s[0], main->error.to.stream); + // Ensure there is always a newline at the end, unless in quiet mode. + fll_print_character(f_string_eol_s[0], main->output.to.stream); } } macro_f_string_dynamic_t_delete_simple(escaped); macro_f_string_ranges_t_delete_simple(ignore); - // object and content, though being a "dynamic" type, is being used statically, so clear them up to avoid invalid free(). + // Object and content, though being a "dynamic" type, is being used statically, so clear them up to avoid invalid free(). object.string = 0; object.used = 0; object.size = 0; @@ -535,7 +543,7 @@ extern "C" { } } - // ensure a newline is always put at the end of the program execution, unless in quiet mode. + // Ensure a newline is always put at the end of the program execution, unless in quiet mode. if (main->error.verbosity != f_console_verbosity_quiet_e) { if (F_status_is_error(status)) { fll_print_character(f_string_eol_s[0], main->error.to.stream); diff --git a/level_3/fss_extended_list_write/c/private-fss_extended_list_write.c b/level_3/fss_extended_list_write/c/private-fss_extended_list_write.c index c894026..0cc6d75 100644 --- a/level_3/fss_extended_list_write/c/private-fss_extended_list_write.c +++ b/level_3/fss_extended_list_write/c/private-fss_extended_list_write.c @@ -130,6 +130,7 @@ extern "C" { fll_print_dynamic(*buffer, output.stream); buffer->used = 0; + return status; } #endif // _di_fss_extended_list_write_process_ @@ -175,6 +176,7 @@ extern "C" { fll_error_print(main->error, F_status_set_fine(status_pipe), "f_file_read_block", F_true); status_pipe = F_status_set_error(F_pipe); + break; } @@ -200,6 +202,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true); + break; } } @@ -209,17 +212,20 @@ extern "C" { if (block.string[range.start] == fss_extended_list_write_pipe_content_start_s) { state = 0x2; ++range.start; + break; } if (block.string[range.start] == fss_extended_list_write_pipe_content_end_s) { state = 0x3; ++range.start; + break; } if (block.string[range.start] == fss_extended_list_write_pipe_content_ignore_s) { - // this is not used by objects. + + // This is not used by objects. continue; } @@ -228,10 +234,10 @@ extern "C" { if (F_status_is_error(status)) break; - // if the start of content was not found, then fetch the next block. + // If the start of content was not found, then fetch the next block. if (state == 0x1) continue; - // if the end of the current block is reached, fetch the next block. + // If the end of the current block is reached, fetch the next block. if (range.start > range.stop) continue; } @@ -244,13 +250,12 @@ extern "C" { } if (total) { - if (content.used + total > content.size) { - status = f_string_dynamic_increase_by(total, &content); + status = f_string_dynamic_increase_by(total, &content); - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true); - break; - } + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true); + + break; } for (; range.start <= range.stop; ++range.start) { @@ -261,12 +266,14 @@ extern "C" { } status = F_status_set_error(F_supported_not); + break; } if (block.string[range.start] == fss_extended_list_write_pipe_content_end_s) { state = 0x3; range.start++; + break; } @@ -283,6 +290,7 @@ extern "C" { fll_error_print(main->error, F_string_too_large, "fss_extended_list_write_process_pipe", F_true); status = F_status_set_error(F_string_too_large); + break; } @@ -294,6 +302,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main->error, F_string_too_large, "fss_extended_list_write_process_pipe", F_true); + break; } } @@ -327,7 +336,7 @@ extern "C" { } } // for - // if the pipe ended before finishing, then attempt to wrap up. + // If the pipe ended before finishing, then attempt to wrap up. if (F_status_is_error_not(status) && status_pipe == F_none_eof && state) { status = fss_extended_list_write_process(main, output, quote, &object, &content, ignore, buffer); } @@ -335,6 +344,7 @@ extern "C" { macro_f_string_dynamic_t_delete_simple(block); macro_f_string_dynamic_t_delete_simple(object); macro_f_string_dynamic_t_delete_simple(content); + return status; } #endif // _di_fss_extended_list_write_process_pipe_ diff --git a/level_3/fss_extended_read/c/fss_extended_read.c b/level_3/fss_extended_read/c/fss_extended_read.c index 5961a15..4352951 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -219,6 +219,9 @@ extern "C" { data.files.array = files_array; data.files.used = 1; data.files.size = main->remaining.used + 1; + data.files.array[0].name = "(pipe)"; + data.files.array[0].range.start = 1; + data.files.array[0].range.stop = 0; if (main->remaining.used || main->process_pipe) { { @@ -375,6 +378,7 @@ extern "C" { funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); + break; } else if (fl_string_compare(arguments->argv[location], fss_extended_read_delimit_mode_name_none, length, fss_extended_read_delimit_mode_name_none_length) == F_equal_to) { @@ -458,6 +462,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_read_long_delimit_s, arguments->argv[location]); + break; } @@ -523,7 +528,6 @@ extern "C" { file.id = F_type_descriptor_input_d; file.stream = F_type_input_d; - data.files.array[0].name = 0; data.files.array[0].range.start = 0; status = f_file_stream_read(file, &data.buffer); @@ -600,7 +604,8 @@ extern "C" { break; } - else if (data.buffer.used > data.files.array[data.files.used].range.start) { + + if (data.buffer.used > data.files.array[data.files.used].range.start) { data.files.array[data.files.used].name = arguments->argv[main->remaining.array[i]]; data.files.array[data.files.used++].range.stop = data.buffer.used - 1; diff --git a/level_3/fss_extended_read/c/private-common.h b/level_3/fss_extended_read/c/private-common.h index 5f4f15b..d88cd00 100644 --- a/level_3/fss_extended_read/c/private-common.h +++ b/level_3/fss_extended_read/c/private-common.h @@ -154,17 +154,17 @@ extern "C" { * delimits_content: The positions within the buffer representing Content character delimits. */ #ifndef _di_fss_extended_read_data_t_ - #define fss_extended_read_data_option_at 0x1 - #define fss_extended_read_data_option_columns 0x2 - #define fss_extended_read_data_option_content 0x4 - #define fss_extended_read_data_option_empty 0x8 - #define fss_extended_read_data_option_line 0x10 - #define fss_extended_read_data_option_name 0x20 - #define fss_extended_read_data_option_object 0x40 - #define fss_extended_read_data_option_raw 0x80 - #define fss_extended_read_data_option_select 0x100 - #define fss_extended_read_data_option_total 0x200 - #define fss_extended_read_data_option_trim 0x400 + #define fss_extended_read_data_option_at_d 0x1 + #define fss_extended_read_data_option_columns_d 0x2 + #define fss_extended_read_data_option_content_d 0x4 + #define fss_extended_read_data_option_empty_d 0x8 + #define fss_extended_read_data_option_line_d 0x10 + #define fss_extended_read_data_option_name_d 0x20 + #define fss_extended_read_data_option_object_d 0x40 + #define fss_extended_read_data_option_raw_d 0x80 + #define fss_extended_read_data_option_select_d 0x100 + #define fss_extended_read_data_option_total_d 0x200 + #define fss_extended_read_data_option_trim_d 0x400 typedef struct { uint16_t option; diff --git a/level_3/fss_extended_read/c/private-fss_extended_read.c b/level_3/fss_extended_read/c/private-fss_extended_read.c index 363bfaf..e4cf681 100644 --- a/level_3/fss_extended_read/c/private-fss_extended_read.c +++ b/level_3/fss_extended_read/c/private-fss_extended_read.c @@ -237,6 +237,11 @@ extern "C" { } } // for + // When stopped after the end of the buffer, the last file in the list is the correct file. + if (at > files.array[files.used - 1].range.stop) { + return files.array[files.used - 1].name; + } + return ""; } #endif // _di_fss_extended_read_file_identify_ @@ -257,12 +262,13 @@ extern "C" { if (F_status_is_error(status)) { const f_string_t file_name = fss_extended_read_file_identify(input.start, data->files); - fll_error_file_print(main->error, F_status_set_fine(status), "fll_fss_extended_read", F_true, file_name ? file_name : "-", "process", fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "fll_fss_extended_read", F_true, file_name, "process", fll_error_file_type_file_e); return status; } - else if (status == F_data_not_stop || status == F_data_not_eos) { - if (data->option & fss_extended_read_data_option_total) { + + if (status == F_data_not_stop || status == F_data_not_eos) { + if (data->option & fss_extended_read_data_option_total_d) { fss_extended_read_print_zero(main); return F_none; @@ -306,50 +312,50 @@ extern "C" { flockfile(main->output.to.stream); - if ((data->option & fss_extended_read_data_option_object) || (data->option & fss_extended_read_data_option_content) && (data->contents.array[at].used || (data->option & fss_extended_read_data_option_empty))) { - if (data->option & fss_extended_read_data_option_object) { - if (data->option & fss_extended_read_data_option_trim) { - if ((data->option & fss_extended_read_data_option_raw) && data->quotes_object.array[at]) { + if ((data->option & fss_extended_read_data_option_object_d) || (data->option & fss_extended_read_data_option_content_d) && (data->contents.array[at].used || (data->option & fss_extended_read_data_option_empty_d))) { + if (data->option & fss_extended_read_data_option_object_d) { + if (data->option & fss_extended_read_data_option_trim_d) { + if ((data->option & fss_extended_read_data_option_raw_d) && data->quotes_object.array[at]) { f_print_character_safely(data->quotes_object.array[at] == f_fss_quote_type_single_e ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.to.stream); } fl_print_trim_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.to.stream); - if ((data->option & fss_extended_read_data_option_raw) && data->quotes_object.array[at]) { + if ((data->option & fss_extended_read_data_option_raw_d) && data->quotes_object.array[at]) { f_print_character_safely(data->quotes_object.array[at] == f_fss_quote_type_single_e ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.to.stream); } } else { - if ((data->option & fss_extended_read_data_option_raw) && data->quotes_object.array[at]) { + if ((data->option & fss_extended_read_data_option_raw_d) && data->quotes_object.array[at]) { f_print_character_safely(data->quotes_object.array[at] == f_fss_quote_type_single_e ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.to.stream); } f_print_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.to.stream); - if ((data->option & fss_extended_read_data_option_raw) && data->quotes_object.array[at]) { + if ((data->option & fss_extended_read_data_option_raw_d) && data->quotes_object.array[at]) { f_print_character_safely(data->quotes_object.array[at] == f_fss_quote_type_single_e ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.to.stream); } } - if (data->option & fss_extended_read_data_option_content) { + if (data->option & fss_extended_read_data_option_content_d) { fss_extended_read_print_object_end(main); } } bool content_printed = F_false; - if ((data->option & fss_extended_read_data_option_content) && data->contents.array[at].used) { - if (data->option & fss_extended_read_data_option_select) { + if ((data->option & fss_extended_read_data_option_content_d) && data->contents.array[at].used) { + if (data->option & fss_extended_read_data_option_select_d) { if (data->select < data->contents.array[at].used) { content_printed = F_true; - if ((data->option & fss_extended_read_data_option_raw) && data->quotes_content.array[at].array[data->select]) { + if ((data->option & fss_extended_read_data_option_raw_d) && data->quotes_content.array[at].array[data->select]) { f_print_character_safely(data->quotes_content.array[at].array[data->select] == f_fss_quote_type_single_e ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.to.stream); } f_print_except_dynamic_partial(data->buffer, data->contents.array[at].array[data->select], delimits_content, main->output.to.stream); - if ((data->option & fss_extended_read_data_option_raw) && data->quotes_content.array[at].array[data->select]) { + if ((data->option & fss_extended_read_data_option_raw_d) && data->quotes_content.array[at].array[data->select]) { f_print_character_safely(data->quotes_content.array[at].array[data->select] == f_fss_quote_type_single_e ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.to.stream); } } @@ -363,13 +369,13 @@ extern "C" { content_printed = F_true; - if ((data->option & fss_extended_read_data_option_raw) && data->quotes_content.array[at].array[i]) { + if ((data->option & fss_extended_read_data_option_raw_d) && data->quotes_content.array[at].array[i]) { f_print_character_safely(data->quotes_content.array[at].array[i] == f_fss_quote_type_single_e ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.to.stream); } f_print_except_dynamic_partial(data->buffer, data->contents.array[at].array[i], delimits_content, main->output.to.stream); - if ((data->option & fss_extended_read_data_option_raw) && data->quotes_content.array[at].array[i]) { + if ((data->option & fss_extended_read_data_option_raw_d) && data->quotes_content.array[at].array[i]) { f_print_character_safely(data->quotes_content.array[at].array[i] == f_fss_quote_type_single_e ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.to.stream); } @@ -380,7 +386,7 @@ extern "C" { } } - if ((data->option & fss_extended_read_data_option_object) || (data->option & fss_extended_read_data_option_content) && (content_printed || (data->option & fss_extended_read_data_option_empty))) { + if ((data->option & fss_extended_read_data_option_object_d) || (data->option & fss_extended_read_data_option_content_d) && (content_printed || (data->option & fss_extended_read_data_option_empty_d))) { fss_extended_read_print_set_end(main); } @@ -392,8 +398,8 @@ extern "C" { #ifndef _di_fss_extended_read_print_at_total_ f_status_t fss_extended_read_print_at_total(fss_extended_read_main_t * const main, const f_array_length_t at, fss_extended_read_data_t *data) { - if (data->option & fss_extended_read_data_option_select) { - if (data->option & fss_extended_read_data_option_object) { + if (data->option & fss_extended_read_data_option_select_d) { + if (data->option & fss_extended_read_data_option_object_d) { flockfile(main->output.to.stream); fss_extended_read_print_one(main); @@ -404,7 +410,7 @@ extern "C" { } if (data->select < data->contents.array[at].used) { - if (data->contents.array[at].array[data->select].start <= data->contents.array[at].array[data->select].stop || (data->option & fss_extended_read_data_option_empty)) { + if (data->contents.array[at].array[data->select].start <= data->contents.array[at].array[data->select].stop || (data->option & fss_extended_read_data_option_empty_d)) { flockfile(main->output.to.stream); fss_extended_read_print_one(main); @@ -415,7 +421,7 @@ extern "C" { } } } - else if ((data->option & fss_extended_read_data_option_object) || (data->option & fss_extended_read_data_option_empty)) { + else if ((data->option & fss_extended_read_data_option_object_d) || (data->option & fss_extended_read_data_option_empty_d)) { flockfile(main->output.to.stream); fss_extended_read_print_one(main); @@ -489,6 +495,7 @@ extern "C" { #ifndef _di_fss_extended_read_print_zero_ void fss_extended_read_print_zero(fss_extended_read_main_t * const main) { + f_print_character(f_string_ascii_0_s[0], main->output.to.stream); f_print_character(f_string_eol_s[0], main->output.to.stream); } @@ -512,23 +519,23 @@ extern "C" { return fss_extended_read_process_at(main, data, names); } - if (data->option & fss_extended_read_data_option_columns) { + if (data->option & fss_extended_read_data_option_columns_d) { return fss_extended_read_process_columns(main, data, names); } - if (data->option & fss_extended_read_data_option_total) { + if (data->option & fss_extended_read_data_option_total_d) { return fss_extended_read_process_total(main, data, names); } - if (data->option & fss_extended_read_data_option_line) { + if (data->option & fss_extended_read_data_option_line_d) { return fss_extended_read_process_line(main, data, names); } f_array_lengths_t except_none = f_array_lengths_t_initialize; f_array_lengths_t *delimits_object = fss_extended_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; - f_array_lengths_t *delimits_content = fss_extended_read_delimit_content_is((data->option & fss_extended_read_data_option_select) ? data->select : 0, data) ? &data->delimits_content : &except_none; + f_array_lengths_t *delimits_content = fss_extended_read_delimit_content_is((data->option & fss_extended_read_data_option_select_d) ? data->select : 0, data) ? &data->delimits_content : &except_none; - if (data->option & fss_extended_read_data_option_raw) { + if (data->option & fss_extended_read_data_option_raw_d) { delimits_object = &except_none; delimits_content = &except_none; } @@ -548,7 +555,7 @@ extern "C" { f_status_t fss_extended_read_process_at(fss_extended_read_main_t * const main, fss_extended_read_data_t *data, bool names[]) { if (data->depths.array[0].value_at >= data->objects.used) { - if (data->option & (fss_extended_read_data_option_columns | fss_extended_read_data_option_total)) { + if (data->option & (fss_extended_read_data_option_columns_d | fss_extended_read_data_option_total_d)) { flockfile(main->output.to.stream); fss_extended_read_print_zero(main); @@ -560,9 +567,9 @@ extern "C" { } // This standard only has one line per Content; therefore, any line value greater than 0 equates to no line to print. - if (data->option & fss_extended_read_data_option_line) { + if (data->option & fss_extended_read_data_option_line_d) { if (data->line) { - if (data->option & fss_extended_read_data_option_total) { + if (data->option & fss_extended_read_data_option_total_d) { flockfile(main->output.to.stream); fss_extended_read_print_zero(main); @@ -576,9 +583,9 @@ extern "C" { f_array_lengths_t except_none = f_array_lengths_t_initialize; f_array_lengths_t *delimits_object = fss_extended_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; - f_array_lengths_t *delimits_content = fss_extended_read_delimit_content_is((data->option & fss_extended_read_data_option_select) ? data->select : 0, data) ? &data->delimits_content : &except_none; + f_array_lengths_t *delimits_content = fss_extended_read_delimit_content_is((data->option & fss_extended_read_data_option_select_d) ? data->select : 0, data) ? &data->delimits_content : &except_none; - if (data->option & fss_extended_read_data_option_raw) { + if (data->option & fss_extended_read_data_option_raw_d) { delimits_object = &except_none; delimits_content = &except_none; } @@ -590,44 +597,44 @@ extern "C" { if (!names[i]) continue; if (at == data->depths.array[0].value_at) { - if (data->option & fss_extended_read_data_option_line) { + if (data->option & fss_extended_read_data_option_line_d) { // This standard only supports one line per Object so when using "--at", the only valid line is line 0. if (data->line) break; - if (data->option & fss_extended_read_data_option_total) { + if (data->option & fss_extended_read_data_option_total_d) { if (fss_extended_read_print_at_total(main, i, data) == F_none) { break; } } else { - if ((data->option & fss_extended_read_data_option_raw) && data->quotes_object.array[at]) { + if ((data->option & fss_extended_read_data_option_raw_d) && data->quotes_object.array[at]) { f_print_character_safely(data->quotes_object.array[at] == f_fss_quote_type_single_e ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.to.stream); } fss_extended_read_print_at(main, i, *delimits_object, *delimits_content, data); - if ((data->option & fss_extended_read_data_option_raw) && data->quotes_object.array[at]) { + if ((data->option & fss_extended_read_data_option_raw_d) && data->quotes_object.array[at]) { f_print_character_safely(data->quotes_object.array[at] == f_fss_quote_type_single_e ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.to.stream); } } } - else if (data->option & fss_extended_read_data_option_columns) { + else if (data->option & fss_extended_read_data_option_columns_d) { fll_print_format("%ul%c", main->output.to.stream, data->contents.array[i].used, f_string_eol_s[0]); } - else if (data->option & fss_extended_read_data_option_total) { + else if (data->option & fss_extended_read_data_option_total_d) { if (fss_extended_read_print_at_total(main, i, data) == F_none) { break; } } else { - if ((data->option & fss_extended_read_data_option_raw) && data->quotes_content.array[at].array[i]) { + if ((data->option & fss_extended_read_data_option_raw_d) && data->quotes_content.array[at].array[i]) { f_print_character_safely(data->quotes_content.array[at].array[i] == f_fss_quote_type_single_e ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.to.stream); } fss_extended_read_print_at(main, i, *delimits_object, *delimits_content, data); - if ((data->option & fss_extended_read_data_option_raw) && data->quotes_content.array[at].array[i]) { + if ((data->option & fss_extended_read_data_option_raw_d) && data->quotes_content.array[at].array[i]) { f_print_character_safely(data->quotes_content.array[at].array[i] == f_fss_quote_type_single_e ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.to.stream); } } @@ -638,7 +645,7 @@ extern "C" { ++at; } // for - if (data->option & fss_extended_read_data_option_total) { + if (data->option & fss_extended_read_data_option_total_d) { flockfile(main->output.to.stream); fss_extended_read_print_zero(main); @@ -653,7 +660,7 @@ extern "C" { #ifndef _di_fss_extended_read_process_columns_ f_status_t fss_extended_read_process_columns(fss_extended_read_main_t * const main, fss_extended_read_data_t *data, bool names[]) { - if (!(data->option & fss_extended_read_data_option_content)) { + if (!(data->option & fss_extended_read_data_option_content_d)) { flockfile(main->output.to.stream); fss_extended_read_print_zero(main); @@ -685,9 +692,9 @@ extern "C" { f_array_lengths_t except_none = f_array_lengths_t_initialize; f_array_lengths_t *delimits_object = fss_extended_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; - f_array_lengths_t *delimits_content = fss_extended_read_delimit_content_is((data->option & fss_extended_read_data_option_select) ? data->select : 0, data) ? &data->delimits_content : &except_none; + f_array_lengths_t *delimits_content = fss_extended_read_delimit_content_is((data->option & fss_extended_read_data_option_select_d) ? data->select : 0, data) ? &data->delimits_content : &except_none; - if (data->option & fss_extended_read_data_option_raw) { + if (data->option & fss_extended_read_data_option_raw_d) { delimits_object = &except_none; delimits_content = &except_none; } @@ -698,9 +705,9 @@ extern "C" { if (!names[i]) continue; - if (!(data->option & fss_extended_read_data_option_object) && (data->option & fss_extended_read_data_option_content)) { + if (!(data->option & fss_extended_read_data_option_object_d) && (data->option & fss_extended_read_data_option_content_d)) { if (!data->contents.array[i].used) { - if (data->option & fss_extended_read_data_option_empty) { + if (data->option & fss_extended_read_data_option_empty_d) { if (line == data->line) { flockfile(main->output.to.stream); @@ -741,7 +748,7 @@ extern "C" { memset(names, F_false, sizeof(bool) * data->objects.used); - if (data->option & fss_extended_read_data_option_trim) { + if (data->option & fss_extended_read_data_option_trim_d) { for (i = 0; i < data->objects.used; ++i) { if (fl_string_dynamic_partial_compare_except_trim_dynamic(data->depths.array[0].value_name, data->buffer, data->objects.array[i], except_none, data->delimits_object) == F_equal_to) { @@ -772,58 +779,58 @@ extern "C" { f_status_t status = F_none; if (main->parameters[fss_extended_read_parameter_at_e].result == f_console_result_additional_e) { - data->option |= fss_extended_read_data_option_at; + data->option |= fss_extended_read_data_option_at_d; } if (main->parameters[fss_extended_read_parameter_columns_e].result == f_console_result_found_e) { - data->option |= fss_extended_read_data_option_columns; + data->option |= fss_extended_read_data_option_columns_d; } if (main->parameters[fss_extended_read_parameter_content_e].result == f_console_result_found_e) { - data->option |= fss_extended_read_data_option_content; + data->option |= fss_extended_read_data_option_content_d; } if (main->parameters[fss_extended_read_parameter_empty_e].result == f_console_result_found_e) { - data->option |= fss_extended_read_data_option_empty; + data->option |= fss_extended_read_data_option_empty_d; } if (main->parameters[fss_extended_read_parameter_line_e].result == f_console_result_additional_e) { - data->option |= fss_extended_read_data_option_line; + data->option |= fss_extended_read_data_option_line_d; status = fss_extended_read_load_number(main, fss_extended_read_parameter_line_e, fss_extended_read_long_line_s, arguments, &data->line); if (F_status_is_error(status)) return status; } if (main->parameters[fss_extended_read_parameter_name_e].result == f_console_result_additional_e) { - data->option |= fss_extended_read_data_option_name; + data->option |= fss_extended_read_data_option_name_d; } if (main->parameters[fss_extended_read_parameter_object_e].result == f_console_result_found_e) { - data->option |= fss_extended_read_data_option_object; + data->option |= fss_extended_read_data_option_object_d; } if (main->parameters[fss_extended_read_parameter_raw_e].result == f_console_result_found_e) { - data->option |= fss_extended_read_data_option_raw; + data->option |= fss_extended_read_data_option_raw_d; } if (main->parameters[fss_extended_read_parameter_select_e].result == f_console_result_additional_e) { - data->option |= fss_extended_read_data_option_select; + data->option |= fss_extended_read_data_option_select_d; status = fss_extended_read_load_number(main, fss_extended_read_parameter_select_e, fss_extended_read_long_select_s, arguments, &data->select); if (F_status_is_error(status)) return status; } if (main->parameters[fss_extended_read_parameter_total_e].result == f_console_result_found_e) { - data->option |= fss_extended_read_data_option_total; + data->option |= fss_extended_read_data_option_total_d; } if (main->parameters[fss_extended_read_parameter_trim_e].result == f_console_result_found_e) { - data->option |= fss_extended_read_data_option_trim; + data->option |= fss_extended_read_data_option_trim_d; } // Default to content if neither Object nor Content is explicitly requested. - if (!(data->option & (fss_extended_read_data_option_content | fss_extended_read_data_option_object))) { - data->option |= fss_extended_read_data_option_content; + if (!(data->option & (fss_extended_read_data_option_content_d | fss_extended_read_data_option_object_d))) { + data->option |= fss_extended_read_data_option_content_d; } return F_none; @@ -836,7 +843,7 @@ extern "C" { f_array_length_t total = 0; // This standard only has one Content per line, however it has multiple Contents within that line. - if ((data->option & fss_extended_read_data_option_object) || (data->option & fss_extended_read_data_option_content) && (data->option & fss_extended_read_data_option_empty)) { + if ((data->option & fss_extended_read_data_option_object_d) || (data->option & fss_extended_read_data_option_content_d) && (data->option & fss_extended_read_data_option_empty_d)) { for (f_array_length_t i = 0; i < data->objects.used; ++i) { if (!names[i]) continue; @@ -853,14 +860,14 @@ extern "C" { if (!names[i]) continue; if (!data->contents.array[i].used) continue; - if ((data->option & fss_extended_read_data_option_select) && data->contents.array[i].used <= data->select) { + if ((data->option & fss_extended_read_data_option_select_d) && data->contents.array[i].used <= data->select) { continue; } for (j = 0; j < data->contents.array[i].used; ++j) { if (data->contents.array[i].array[j].start <= data->contents.array[i].array[j].stop) { - if (data->option & fss_extended_read_data_option_select) { + if (data->option & fss_extended_read_data_option_select_d) { if (j == data->select) { ++total; @@ -879,7 +886,7 @@ extern "C" { flockfile(main->output.to.stream); - if (data->option & fss_extended_read_data_option_line) { + if (data->option & fss_extended_read_data_option_line_d) { if (data->line < total) { fss_extended_read_print_one(main); } diff --git a/level_3/fss_extended_read/c/private-fss_extended_read.h b/level_3/fss_extended_read/c/private-fss_extended_read.h index cd18a79..e38f12a 100644 --- a/level_3/fss_extended_read/c/private-fss_extended_read.h +++ b/level_3/fss_extended_read/c/private-fss_extended_read.h @@ -238,7 +238,7 @@ extern "C" { #endif // _di_fss_extended_read_print_zero_ /** - * Perform the basic read processing on the buffer. + * Perform the extended read processing on the buffer. * * This will print an error message on error. * diff --git a/level_3/fss_extended_write/c/fss_extended_write.c b/level_3/fss_extended_write/c/fss_extended_write.c index 85b3e2d..92df616 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.c +++ b/level_3/fss_extended_write/c/fss_extended_write.c @@ -25,7 +25,7 @@ extern "C" { f_print_character(f_string_eol_s[0], file.stream); - fll_program_print_help_option(file, context, fss_extended_write_short_file_s, fss_extended_write_long_file_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a file to send file to."); + fll_program_print_help_option(file, context, fss_extended_write_short_file_s, fss_extended_write_long_file_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a file to send data to."); fll_program_print_help_option(file, context, fss_extended_write_short_content_s, fss_extended_write_long_content_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "The Content to file."); fll_program_print_help_option(file, context, fss_extended_write_short_double_s, fss_extended_write_long_double_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Use double quotes (default)."); fll_program_print_help_option(file, context, fss_extended_write_short_ignore_s, fss_extended_write_long_ignore_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Ignore a given range within a Content."); @@ -106,6 +106,7 @@ extern "C" { if (F_status_is_error(status)) { fss_extended_write_main_delete(main); + return status; } @@ -138,6 +139,7 @@ extern "C" { fss_extended_write_print_help(main->output.to, main->context); fss_extended_write_main_delete(main); + return status; } @@ -145,6 +147,7 @@ extern "C" { fll_program_print_version(main->output.to, fss_extended_write_program_version_s); fss_extended_write_main_delete(main); + return status; } @@ -353,6 +356,7 @@ extern "C" { } status = F_status_set_error(F_parameter); + break; } } // for @@ -453,6 +457,7 @@ extern "C" { if (!((++signal_check) % fss_extended_write_signal_check_d)) { if (fss_extended_write_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } @@ -546,6 +551,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamics_increase_by", F_true); + break; } @@ -557,6 +563,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_string_append", F_true); + break; } @@ -582,19 +589,19 @@ extern "C" { } else if (main->error.verbosity != f_console_verbosity_quiet_e && main->parameters[fss_extended_write_parameter_file_e].result == f_console_result_none_e) { - // ensure there is always a newline at the end, unless in quiet mode. - fll_print_character(f_string_eol_s[0], main->error.to.stream); + // Ensure there is always a newline at the end, unless in quiet mode. + fll_print_character(f_string_eol_s[0], main->output.to.stream); } } macro_f_string_dynamic_t_delete_simple(escaped); - // object, though being a "dynamic" type, is being used statically, so clear them up to avoid invalid free(). + // Object, though being a "dynamic" type, is being used statically, so clear them up to avoid invalid free(). object.string = 0; object.used = 0; object.size = 0; - // reset contents used, it is dynamically allocated so leave everything else alone. + // Reset contents used, it is dynamically allocated so leave everything else alone. contents.used = 0; } diff --git a/level_3/fss_extended_write/c/private-fss_extended_write.c b/level_3/fss_extended_write/c/private-fss_extended_write.c index 0996677..c3a9e4c 100644 --- a/level_3/fss_extended_write/c/private-fss_extended_write.c +++ b/level_3/fss_extended_write/c/private-fss_extended_write.c @@ -146,6 +146,7 @@ extern "C" { fll_print_dynamic(*buffer, output.stream); buffer->used = 0; + return status; } #endif // _di_fss_extended_write_process_ @@ -232,17 +233,20 @@ extern "C" { if (block.string[range.start] == fss_extended_write_pipe_content_start_s) { state = 0x2; ++range.start; + break; } if (block.string[range.start] == fss_extended_write_pipe_content_end_s) { state = 0x4; ++range.start; + break; } if (block.string[range.start] == fss_extended_write_pipe_content_ignore_s) { - // this is not used by objects. + + // This is not used by objects. continue; } @@ -251,10 +255,10 @@ extern "C" { if (F_status_is_error(status)) break; - // if the start of content was not found, then fetch the next block. + // If the start of content was not found, then fetch the next block. if (state == 0x1) continue; - // if the end of the current block is reached, fetch the next block. + // If the end of the current block is reached, fetch the next block. if (range.start > range.stop) continue; } @@ -289,23 +293,26 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamics_increase_by", F_true); + break; } } ++contents.used; + continue; } if (block.string[range.start] == fss_extended_write_pipe_content_end_s) { state = 0x4; ++range.start; + break; } if (block.string[range.start] == fss_extended_write_pipe_content_ignore_s) { - // this is not used by this program. + // This is not used by this program. continue; } @@ -313,6 +320,7 @@ extern "C" { fss_extended_write_error_parameter_unsupported_eol_print(main); status = F_status_set_error(F_supported_not); + break; } @@ -321,6 +329,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true); + break; } } @@ -343,7 +352,7 @@ extern "C" { } } // for - // if the pipe ended before finishing, then attempt to wrap up. + // If the pipe ended before finishing, then attempt to wrap up. if (F_status_is_error_not(status) && status_pipe == F_none_eof && state) { status = fss_extended_write_process(main, output, quote, &object, &contents, buffer); } @@ -351,6 +360,7 @@ extern "C" { macro_f_string_dynamic_t_delete_simple(block); macro_f_string_dynamic_t_delete_simple(object); macro_f_string_dynamics_t_delete_simple(contents); + return status; } #endif // _di_fss_extended_write_process_pipe_ diff --git a/level_3/iki_write/c/iki_write.c b/level_3/iki_write/c/iki_write.c index 31f4cc6..a3711b1 100644 --- a/level_3/iki_write/c/iki_write.c +++ b/level_3/iki_write/c/iki_write.c @@ -25,7 +25,7 @@ extern "C" { f_print_character(f_string_eol_s[0], file.stream); - fll_program_print_help_option(file, context, iki_write_short_file_s, iki_write_long_file_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a file to send file to."); + fll_program_print_help_option(file, context, iki_write_short_file_s, iki_write_long_file_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a file to send data to."); fll_program_print_help_option(file, context, iki_write_short_content_s, iki_write_long_content_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "The content to file."); fll_program_print_help_option(file, context, iki_write_short_double_s, iki_write_long_double_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Use double quotes (default)."); fll_program_print_help_option(file, context, iki_write_short_object_s, iki_write_long_object_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " The object to file."); @@ -445,7 +445,7 @@ extern "C" { fll_print_character(f_string_eol_s[0], file.stream); } // for - // ensure there is always a newline at the end, unless in quiet mode. + // Ensure there is always a newline at the end, unless in quiet mode. if (F_status_is_error_not(status) && main->error.verbosity != f_console_verbosity_quiet_e && main->parameters[iki_write_parameter_file_e].result == f_console_result_none_e) { fll_print_character(f_string_eol_s[0], file.stream); } -- 1.8.3.1