]> Kevux Git Server - fll/commitdiff
Bugfix: FSS Embedded List Read is not applying delimits when printing in line mode.
authorKevin Day <Kevin@kevux.org>
Sun, 1 Sep 2024 02:34:04 +0000 (21:34 -0500)
committerKevin Day <Kevin@kevux.org>
Sun, 1 Sep 2024 02:34:04 +0000 (21:34 -0500)
Make sure delimits are properly applied.

The `--line` mode is printing the line character by character.
Add a loop to check if the given character is to be printed or not based on the delimits array.

level_3/fss_embedded_list_read/c/private-read.c

index bdd5a2c9303f77c9403d1bbc76561e64d6c84c51..c6300a5b2cd6a97a3e0ad11e109c72373aa3211a 100644 (file)
@@ -557,6 +557,7 @@ extern "C" {
 
       if (data->main->parameters.array[fss_embedded_list_read_parameter_line_e].result == f_console_result_additional_e) {
         f_array_length_t line_current = 0;
+        f_array_length_t delimit = 0;
         uint8_t newline_missing = F_true;
 
         flockfile(data->main->output.to.stream);
@@ -610,6 +611,16 @@ extern "C" {
                       break;
                     }
 
+                    if (delimit < contents_delimits->used) {
+                      while (contents_delimits->array[delimit] < j) ++delimit;
+
+                      if (delimit < contents_delimits->used && j == contents_delimits->array[delimit]) {
+                        ++delimit;
+
+                        continue;
+                      }
+                    }
+
                     f_print_character(data->buffer.string[j], data->main->output.to.stream);
                   } // for
                 }
@@ -802,8 +813,7 @@ extern "C" {
   void fss_embedded_list_read_process_delimits(fss_embedded_list_read_data_t * const data, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits) {
 
     if (!data->nest.used) return;
-
-    if ((!objects_delimits->used && !contents_delimits->used) || data->delimit_mode == fss_embedded_list_read_delimit_mode_all_e) return;
+    if (!objects_delimits->used && !contents_delimits->used || data->delimit_mode == fss_embedded_list_read_delimit_mode_all_e) return;
 
     if (data->delimit_mode == fss_embedded_list_read_delimit_mode_depth_lesser_e && data->nest.used < data->delimit_depth) return;
     if (data->delimit_mode == fss_embedded_list_read_delimit_mode_depth_greater_e && data->delimit_depth == 0) return;
@@ -843,7 +853,7 @@ extern "C" {
         fss_embedded_list_read_process_delimits_objects(data, data->delimit_depth, original_contents_delimits, original_contents_used, contents_delimits);
       }
       else {
-        fss_embedded_list_read_process_delimits_objects(data, data->delimit_depth, original_objects_delimits, original_objects_used, objects_delimits);
+        fss_embedded_list_read_process_delimits_objects(data, 0, original_objects_delimits, original_objects_used, objects_delimits);
       }
 
       fss_embedded_list_read_process_delimits_contents(data, data->delimit_depth, original_contents_delimits, original_contents_used, contents_delimits);
@@ -862,7 +872,14 @@ extern "C" {
         } // for
       }
       else if (data->delimit_mode == fss_embedded_list_read_delimit_mode_depth_greater_e) {
-        for (f_array_length_t i = data->delimit_depth; i < data->nest.used; ++i) {
+
+        // Only depth 0 objects are stored in objects_delimits.
+        if (!data->delimit_depth) {
+          fss_embedded_list_read_process_delimits_objects(data, 0, original_objects_delimits, original_objects_used, objects_delimits);
+          fss_embedded_list_read_process_delimits_contents(data, 0, original_contents_delimits, original_contents_used, contents_delimits);
+        }
+
+        for (f_array_length_t i = data->delimit_depth + 1; i < data->nest.used; ++i) {
 
           fss_embedded_list_read_process_delimits_objects(data, i, original_contents_delimits, original_contents_used, contents_delimits);
           fss_embedded_list_read_process_delimits_contents(data, i, original_contents_delimits, original_contents_used, contents_delimits);