From: Kevin Day Date: Thu, 8 Oct 2020 05:05:58 +0000 (-0500) Subject: Bugfix: FSS basic list read newline handling needs improvement. X-Git-Tag: 0.5.1~40 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=bef963c86176db573d8f704a02daee8efa54be15;p=fll Bugfix: FSS basic list read newline handling needs improvement. The last newline is not being preserved in the content read. The *_print_set_* functions end up printing an extra newline. This behavior is inconsistent and invalid. Instead, preserve the newlines, which are valid parts of the content. Then, do not print newlines via *_print_set_*. The empty list needs to have at least one newline when -e/--empty is passed. --- diff --git a/level_1/fl_fss/c/fss_basic_list.c b/level_1/fl_fss/c/fss_basic_list.c index 2573e85..5bf96ae 100644 --- a/level_1/fl_fss/c/fss_basic_list.c +++ b/level_1/fl_fss/c/fss_basic_list.c @@ -287,7 +287,7 @@ extern "C" { if (found_newline) { fl_macro_fss_apply_delimit_placeholders((*buffer), delimits); - found->array[found->used].stop = last_newline - 1; + found->array[found->used].stop = last_newline; range->start = last_newline + 1; found->used++; @@ -355,7 +355,7 @@ extern "C" { if (found_newline) { fl_macro_fss_apply_delimit_placeholders((*buffer), delimits); - found->array[found->used].stop = last_newline - 1; + found->array[found->used].stop = last_newline; range->start = last_newline + 1; found->used++; @@ -379,7 +379,7 @@ extern "C" { if (found_newline) { fl_macro_fss_apply_delimit_placeholders((*buffer), delimits); - found->array[found->used].stop = last_newline - 1; + found->array[found->used].stop = last_newline; range->start = last_newline + 1; found->used++; 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 9f1e812..a021353 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 @@ -400,6 +400,7 @@ extern "C" { if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) { if (!data->contents.array[i].used) { if (include_empty && !line) { + fprintf(f_type_output, "%c", f_string_eol[0]); fss_basic_list_read_print_set_end(*data); } } @@ -458,6 +459,7 @@ extern "C" { } } else if (include_empty) { + fprintf(f_type_output, "%c", f_string_eol[0]); fss_basic_list_read_print_set_end(*data); } @@ -505,6 +507,7 @@ extern "C" { if (!data->contents.array[i].used) { if (include_empty) { if (line_current == line) { + fprintf(f_type_output, "%c", f_string_eol[0]); fss_basic_list_read_print_set_end(*data); break; } @@ -557,6 +560,7 @@ extern "C" { if (!data->contents.array[i].used) { if (include_empty) { + fprintf(f_type_output, "%c", f_string_eol[0]); fss_basic_list_read_print_set_end(*data); } @@ -592,9 +596,6 @@ extern "C" { if (data.parameters[fss_basic_list_read_parameter_pipe].result == f_console_result_found) { fprintf(data.output.stream, "%c", fss_basic_list_read_pipe_content_start); } - else { - fprintf(data.output.stream, "%c", f_fss_eol); - } } #endif // _di_fss_basic_list_read_print_content_end_ @@ -604,9 +605,6 @@ extern "C" { if (data.parameters[fss_basic_list_read_parameter_pipe].result == f_console_result_found) { fprintf(data.output.stream, "%c", fss_basic_list_read_pipe_content_end); } - else { - fprintf(data.output.stream, "%c", f_fss_eol); - } } #endif // _di_fss_basic_list_read_print_set_end_