]> Kevux Git Server - fll/commitdiff
Bugfix: The quotes are always being defined even when there are no quotes in the...
authorKevin Day <thekevinday@gmail.com>
Thu, 26 May 2022 01:00:40 +0000 (20:00 -0500)
committerKevin Day <thekevinday@gmail.com>
Thu, 26 May 2022 01:02:01 +0000 (20:02 -0500)
Do not force either double or single quote by default.
If there are no quotes, then they should be treated as unquoted.

level_0/f_fss/c/fss/quote.h
level_1/fl_fss/c/fss/extended.c
level_1/fl_fss/c/fss/extended.h
level_1/fl_fss/c/private-fss.c
level_2/fll_fss/c/fss/basic.c
level_2/fll_fss/c/fss/basic_list.c
level_2/fll_fss/c/fss/extended.c
level_2/fll_fss/c/fss/extended_list.c
level_2/fll_fss/c/fss/payload.c

index 1741b0a44ba31565f1527c4e85ce57f7a2931636..3b58b6c418f998a935a30626965a3acc2b6f14c9 100644 (file)
@@ -20,12 +20,14 @@ extern "C" {
  * Types for FSS quote.
  *
  * f_fss_quote_type_*:
+ *   - none:   Not a quote.
  *   - single: Quote type is a single quote.
  *   - double: Quote type is a double quote.
  */
 #ifndef _di_f_fss_quote_type_
   enum {
-    f_fss_quote_type_single_e = 1,
+    f_fss_quote_type_none_e = 0,
+    f_fss_quote_type_single_e,
     f_fss_quote_type_double_e,
   };
 #endif // _di_f_fss_quote_type_
index d7458c1e83ffe68d44aeba9e4259c4d164f396a5..32cfb79b9f993d27fca98013c4283c0b9079ca9e 100644 (file)
@@ -35,38 +35,49 @@ extern "C" {
     }
 
     const f_array_length_t delimits_used = delimits->used;
+    const f_array_length_t quotes_used = quotes ? quotes->used : 0;
 
     uint8_t content_found = 0;
-    f_fss_quote_t quoted = 0;
+    f_fss_quote_t quoted = f_fss_quote_type_none_e;
 
     while (range->start <= range->stop && range->start < buffer.used) {
 
       f_string_range_t content_partial = f_string_range_t_initialize;
 
-      quoted = 0;
+      quoted = f_fss_quote_type_none_e;
 
       status = private_fl_fss_basic_read(buffer, F_false, state, range, &content_partial, &quoted, delimits);
 
       if (status == F_fss_found_object || status == F_fss_found_object_content_not) {
+        status_allocate = f_string_ranges_increase(state.step_small, found);
 
-        if (found->used + 1 > found->size) {
-          status_allocate = f_string_ranges_increase(state.step_small, found);
-
-          if (F_status_is_fine(status_allocate) && quotes) {
-            status_allocate = f_uint8s_resize(found->size, quotes);
-          }
+        if (F_status_is_error_not(status_allocate) && quotes) {
+          status_allocate = f_uint8s_increase(state.step_small, quotes);
+        }
 
-          if (F_status_is_error(status_allocate)) {
-            delimits->used = delimits_used;
+        if (F_status_is_error(status_allocate)) {
+          delimits->used = delimits_used;
 
-            return status_allocate;
+          if (quotes) {
+            quotes->used = quotes_used;
           }
+
+          return status_allocate;
         }
 
         found->array[found->used++] = content_partial;
 
         if (quotes) {
-          quotes->array[quotes->used] = quoted == f_fss_quote_type_double_e ? f_string_ascii_quote_double_s.string[0] : f_string_ascii_quote_single_s.string[0];
+          if (quoted == f_fss_quote_type_double_e) {
+            quotes->array[quotes->used] = f_string_ascii_quote_double_s.string[0];
+          }
+          else if (quoted == f_fss_quote_type_double_e) {
+            quotes->array[quotes->used] = f_string_ascii_quote_single_s.string[0];
+          }
+          else {
+            quotes->array[quotes->used] = 0;
+          }
+
           quotes->used = found->used;
         }
 
index 6fbfaec71db2d042cc866292deb158f4cedcb726..256cf42609de604314f970c76c70c1d99f0168cd 100644 (file)
@@ -211,6 +211,8 @@ extern "C" {
  *   Errors (with error bit) from: f_fss_is_zero_width().
  *   Errors (with error bit) from: f_fss_skip_past_delimit().
  *   Errors (with error bit) from: f_fss_skip_past_space().
+ *   Errors (with error bit) from: f_string_ranges_increase().
+ *   Errors (with error bit) from: f_uint8s_increase().
  *   Errors (with error bit) from: f_utf_buffer_increment().
  *
  * @see f_array_lengths_increase()
@@ -220,6 +222,8 @@ extern "C" {
  * @see f_fss_is_zero_width()
  * @see f_fss_skip_past_delimit()
  * @see f_fss_skip_past_space()
+ * @see f_string_ranges_increase()
+ * @see f_uint8s_increase()
  * @see f_utf_buffer_increment()
  * @see fl_fss_basic_object_read()
  * @see fl_fss_extended_object_read()
index 1d87675758e88e8f1bb5e1768a37f09a3838c041..46a5597c1eabf37aa1e18707b954b08f23da3a7e 100644 (file)
@@ -181,7 +181,7 @@ extern "C" {
     f_char_t quote_found = 0;
 
     if (quoted) {
-      *quoted = 0;
+      *quoted = f_fss_quote_type_none_e;
     }
 
     // Identify where the object begins.
@@ -414,6 +414,9 @@ extern "C" {
                 else if (quote_found == f_fss_delimit_quote_double_s.string[0]) {
                   *quoted = f_fss_quote_type_double_e;
                 }
+                else {
+                  *quoted = f_fss_quote_type_none_e;
+                }
               }
 
               range->start = first_slash;
@@ -571,6 +574,9 @@ extern "C" {
               else if (quote_found == f_fss_delimit_quote_double_s.string[0]) {
                 *quoted = f_fss_quote_type_double_e;
               }
+              else {
+                *quoted = f_fss_quote_type_none_e;
+              }
             }
 
             found->stop = range->start - 1;
index 5cd6150ac811b5f6957eb62a8c03536c285ffce9..6bfd86bc4e10e9f4827b1709ed69a3a547301e7c 100644 (file)
@@ -52,7 +52,7 @@ extern "C" {
             status2 = f_string_ranges_increase(state.step_small, &contents->array[contents->used]);
             if (F_status_is_error(status2)) return status2;
 
-            ++contents->used;
+            contents->array[contents->used++].used = 0;
 
             return F_fss_found_object_content_not;
           }
index 9646a7d416d228d025d8032cd142e57b3879f446..ef953f6fc23657cfad7c3efb62852e2c21b989a1 100644 (file)
@@ -37,7 +37,7 @@ extern "C" {
             status2 = f_string_ranges_increase(state.step_small, &contents->array[contents->used]);
             if (F_status_is_error(status2)) return status2;
 
-            ++contents->used;
+            contents->array[contents->used++].used = 0;
 
             return F_fss_found_object_content_not;
           }
index b156c024689d5f0adc536b3b69d02b073c86d3f0..6b0acd3a71c234fd5c3a95d0fefce53fcffa67ff 100644 (file)
@@ -58,13 +58,13 @@ extern "C" {
             status2 = f_string_ranges_increase(state.step_small, &contents->array[contents->used]);
             if (F_status_is_error(status2)) return status2;
 
-            ++contents->used;
+            contents->array[contents->used++].used = 0;
 
             if (contents_quoted) {
               status2 = f_uint8s_increase(state.step_small, &contents_quoted->array[contents_quoted->used]);
               if (F_status_is_error(status2)) return status2;
 
-              ++contents_quoted->used;
+              contents_quoted->array[contents_quoted->used++].used = 0;
             }
 
             return F_fss_found_object_content_not;
@@ -95,6 +95,7 @@ extern "C" {
             if (F_status_is_error(status2)) return status2;
 
             quoted_content = &contents_quoted->array[contents_quoted->used];
+            quoted_content->used = 0;
           }
 
           status = fl_fss_extended_content_read(buffer, state, range, &contents->array[contents->used], quoted_content, contents_delimits ? contents_delimits : objects_delimits);
index 3c289b3d1b48b53996d24b161a41e42ee388c073..2fabc40a6f2d2f2bb7e626527181eb13a9386b86 100644 (file)
@@ -37,7 +37,7 @@ extern "C" {
             status2 = f_string_ranges_increase(state.step_small, &contents->array[contents->used]);
             if (F_status_is_error(status2)) return status2;
 
-            ++contents->used;
+            contents->array[contents->used++].used = 0;
 
             return F_fss_found_object_content_not;
           }
index a9b20814f0a6758ee41a17d78ece1e9543e60914..1278be11c216e0b7014c4202658d179f91ac9280 100644 (file)
@@ -46,7 +46,7 @@ extern "C" {
             status2 = f_string_ranges_increase(state.step_small, &contents->array[contents->used]);
             if (F_status_is_error(status2)) return status2;
 
-            ++contents->used;
+            contents->array[contents->used++].used = 0;
 
             return status;
           }