]> Kevux Git Server - fll/commitdiff
Bugfix: FSS basic list read newline handling needs improvement.
authorKevin Day <thekevinday@gmail.com>
Thu, 8 Oct 2020 05:05:58 +0000 (00:05 -0500)
committerKevin Day <thekevinday@gmail.com>
Thu, 8 Oct 2020 05:05:58 +0000 (00:05 -0500)
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.

level_1/fl_fss/c/fss_basic_list.c
level_3/fss_basic_list_read/c/private-fss_basic_list_read.c

index 2573e859d030b75b0d03acf35d8f8c56785d334f..5bf96ae1051d660c2b594bf01308e742f452294c 100644 (file)
@@ -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++;
 
index 9f1e8125c03206fb413408af8250d4a0c15f8970..a0213535deffe755c0511abbe321931e9408bc7d 100644 (file)
@@ -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_