]> Kevux Git Server - fll/commitdiff
Bugfix: don't write comment lines (wrap the # in quotes)
authorKevin Day <kevin@kevux.org>
Sat, 24 Mar 2012 22:20:03 +0000 (17:20 -0500)
committerKevin Day <kevin@kevux.org>
Sat, 24 Mar 2012 22:20:03 +0000 (17:20 -0500)
The object write functions should not write comments.
The comments are not valid objects, so if passed a leading #, then be sure to wrap it in quotes.

level_1/fl_fss/c/fss_basic.c
level_1/fl_fss/c/fss_extended.c

index 1101a047a49974183cc5d83a7fc056afd79f5ff1..2388acb22f8109102f98aa8fc69e6605245177f0 100644 (file)
@@ -272,6 +272,7 @@ extern "C"{
     #endif // _di_level_1_parameter_checking_
 
     f_status status = f_status_initialize;
+    f_bool   quoted = f_false;
 
     f_string_location buffer_position   = f_string_location_initialize;
     f_string_length   start_position    = f_string_initialize;
@@ -340,13 +341,23 @@ extern "C"{
       buffer->string[buffer_position.stop + 1] = object.string[input->start];
       buffer_position.stop += 2;
       input->start++;
+    } else if (object.string[input->start] == f_fss_comment) {
+      quoted = f_true;
     }
 
     while (input->start <= input->stop && input->start < object.used) {
       if (object.string[input->start] == f_fss_delimit_placeholder) {
         input->start++;
         continue;
-      } else if (isspace(object.string[input->start])) {
+      } else if (isspace(object.string[input->start]) || quoted) {
+        pre_allocate_size++;
+
+        if (pre_allocate_size > buffer->size) {
+          f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
+
+          if (f_macro_test_for_allocation_errors(status)) return status;
+        }
+
         // restart the loop searching for f_fss_delimit_double_quote.
         input->start = start_position;
         buffer_position.stop = buffer_position.start;
index ace09b2968b9afdc773f1871f73557059baeae81..4b85bf2ea79b7442b28ce2f95a6a699792f197de 100644 (file)
@@ -492,6 +492,7 @@ extern "C"{
     #endif // _di_level_1_parameter_checking_
 
     f_status status = f_status_initialize;
+    f_bool   quoted = f_false;
 
     f_string_location buffer_position   = f_string_location_initialize;
     f_string_length   start_position    = f_string_initialize;
@@ -560,25 +561,37 @@ extern "C"{
       buffer->string[buffer_position.stop + 1] = object.string[input->start];
       buffer_position.stop += 2;
       input->start++;
+    } else if (object.string[input->start] == f_fss_comment) {
+      quoted = f_true;
     }
 
     while (input->start <= input->stop && input->start < object.used) {
       if (object.string[input->start] == f_fss_delimit_placeholder) {
         input->start++;
         continue;
-      } else if (isspace(object.string[input->start])) {
+      } else if (isspace(object.string[input->start]) || quoted) {
         f_string_length first_space = input->start;
 
-        input->start++;
-
-        while (input->start <= input->stop && input->start < object.used && isspace(object.string[input->start])) {
+        if (!quoted) {
           input->start++;
-        } // while
 
-        if (input->start > input->stop || input->start >= object.used) {
-          buffer->string[first_space] = f_fss_extended_open;
-          buffer->used = buffer_position.stop + 1;
-          break;
+          while (input->start <= input->stop && input->start < object.used && isspace(object.string[input->start])) {
+            input->start++;
+          } // while
+
+          if (input->start > input->stop || input->start >= object.used) {
+            buffer->string[first_space] = f_fss_extended_open;
+            buffer->used = buffer_position.stop + 1;
+            break;
+          }
+        }
+
+        pre_allocate_size++;
+
+        if (pre_allocate_size > buffer->size) {
+          f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
+
+          if (f_macro_test_for_allocation_errors(status)) return status;
         }
 
         // restart the loop searching for f_fss_delimit_double_quote.