From: Kevin Day Date: Sat, 24 Mar 2012 22:20:03 +0000 (-0500) Subject: Bugfix: don't write comment lines (wrap the # in quotes) X-Git-Tag: 0.3.0~49 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=5b3967e686e4ab39db010bdc01b1f0ce31258ba5;p=fll 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. --- 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.