From 5b3967e686e4ab39db010bdc01b1f0ce31258ba5 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 24 Mar 2012 17:20:03 -0500 Subject: [PATCH] Bugfix: don't write comment lines (wrap the # in quotes) 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 | 13 ++++++++++++- level_1/fl_fss/c/fss_extended.c | 31 ++++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/level_1/fl_fss/c/fss_basic.c b/level_1/fl_fss/c/fss_basic.c index 1101a04..2388acb 100644 --- a/level_1/fl_fss/c/fss_basic.c +++ b/level_1/fl_fss/c/fss_basic.c @@ -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; diff --git a/level_1/fl_fss/c/fss_extended.c b/level_1/fl_fss/c/fss_extended.c index ace09b2..4b85bf2 100644 --- a/level_1/fl_fss/c/fss_extended.c +++ b/level_1/fl_fss/c/fss_extended.c @@ -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. -- 1.8.3.1