From 5642352f976e24d92d7a178637c8b5aebc996976 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 21 Mar 2012 19:43:44 -0500 Subject: [PATCH] Bugfix: initial slash + quote only needs one additional slash on match at start when writing If the object or content group begins with any number of slashes followed by a single or double quite, only a single slash is needed to delimit the quote. This is done because no valid object or content group can start with a slash and expected to be treated as if it were quoted. That means the quote is meaningless. The initial slash delimit is necessary in case the object name starts with a single or double quote but it should not be treated as such. This for an object name of " would be written as \". --- level_1/fl_fss/c/fss_basic.c | 16 ++++------------ level_1/fl_fss/c/fss_extended.c | 32 ++++++++------------------------ 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/level_1/fl_fss/c/fss_basic.c b/level_1/fl_fss/c/fss_basic.c index 05b11c1..d9acabf 100644 --- a/level_1/fl_fss/c/fss_basic.c +++ b/level_1/fl_fss/c/fss_basic.c @@ -300,8 +300,6 @@ extern "C"{ object_position.stop = object->used; if (buffer.string[input->start] == f_fss_delimit_slash) { - f_string_length slash_count = 0; - while (input->start <= input->stop && input->start < buffer.used) { if (buffer.string[input->start] == f_fss_delimit_placeholder) { input->start++; @@ -312,12 +310,11 @@ extern "C"{ object->string[object_position.stop] = buffer.string[input->start]; object_position.stop++; - slash_count++; input->start++; } // while if (buffer.string[input->start] == f_fss_delimit_single_quote || buffer.string[input->start] == f_fss_delimit_double_quote) { - pre_allocate_size += slash_count + 1; + pre_allocate_size++; if (pre_allocate_size > object->size) { f_resize_dynamic_string(status, (*object), pre_allocate_size + f_fss_default_allocation_step); @@ -325,14 +322,9 @@ extern "C"{ if (f_macro_test_for_allocation_errors(status)) return status; } - while (slash_count > 0) { - object->string[object_position.stop] = f_fss_delimit_slash; - object_position.stop++; - slash_count--; - } // while - - object->string[object_position.stop] = buffer.string[input->start]; - object_position.stop++; + object->string[object_position.stop] = f_fss_delimit_slash; + object->string[object_position.stop + 1] = buffer.string[input->start]; + object_position.stop += 2; input->start++; } } else if (buffer.string[input->start] == f_fss_delimit_single_quote || buffer.string[input->start] == f_fss_delimit_double_quote) { diff --git a/level_1/fl_fss/c/fss_extended.c b/level_1/fl_fss/c/fss_extended.c index 7bd68b3..a2ed202 100644 --- a/level_1/fl_fss/c/fss_extended.c +++ b/level_1/fl_fss/c/fss_extended.c @@ -432,8 +432,6 @@ extern "C"{ object_position.stop = object->used; if (buffer.string[input->start] == f_fss_delimit_slash) { - f_string_length slash_count = 0; - while (input->start <= input->stop && input->start < buffer.used) { if (buffer.string[input->start] == f_fss_delimit_placeholder) { input->start++; @@ -444,12 +442,11 @@ extern "C"{ object->string[object_position.stop] = buffer.string[input->start]; object_position.stop++; - slash_count++; input->start++; } // while if (buffer.string[input->start] == f_fss_delimit_single_quote || buffer.string[input->start] == f_fss_delimit_double_quote) { - pre_allocate_size += slash_count + 1; + pre_allocate_size++; if (pre_allocate_size > object->size) { f_resize_dynamic_string(status, (*object), pre_allocate_size + f_fss_default_allocation_step); @@ -457,14 +454,9 @@ extern "C"{ if (f_macro_test_for_allocation_errors(status)) return status; } - while (slash_count > 0) { - object->string[object_position.stop] = f_fss_delimit_slash; - object_position.stop++; - slash_count--; - } // while - - object->string[object_position.stop] = buffer.string[input->start]; - object_position.stop++; + object->string[object_position.stop] = f_fss_delimit_slash; + object->string[object_position.stop + 1] = buffer.string[input->start]; + object_position.stop += 2; input->start++; } } else if (buffer.string[input->start] == f_fss_delimit_single_quote || buffer.string[input->start] == f_fss_delimit_double_quote) { @@ -631,8 +623,6 @@ extern "C"{ // if this first slash is followed by a quote, then that quote must be delimited. if (buffer.string[input->start] == f_fss_delimit_slash) { - f_string_length slash_count = 1; - content->string[content_position.stop] = f_fss_delimit_slash; content_position.stop++; input->start++; @@ -649,7 +639,6 @@ extern "C"{ content->string[content_position.stop] = f_fss_delimit_slash; content_position.stop++; - slash_count++; input->start++; } // while @@ -664,7 +653,7 @@ extern "C"{ } if (buffer.string[input->start] == f_fss_delimit_single_quote || buffer.string[input->start] == f_fss_delimit_double_quote) { - pre_allocate_size += slash_count + 1; + pre_allocate_size++; if (pre_allocate_size > content->size) { f_resize_dynamic_string(status, (*content), pre_allocate_size + f_fss_default_allocation_step); @@ -672,14 +661,9 @@ extern "C"{ if (f_macro_test_for_allocation_errors(status)) return status; } - while (slash_count > 0) { - content->string[content_position.stop] = f_fss_delimit_slash; - content_position.stop++; - slash_count--; - } // while - - content->string[content_position.stop] = buffer.string[input->start]; - content_position.stop++; + content->string[content_position.stop] = f_fss_delimit_slash; + content->string[content_position.stop + 1] = buffer.string[input->start]; + content_position.stop += 2; input->start++; } } else if (buffer.string[input->start] == f_fss_delimit_single_quote || buffer.string[input->start] == f_fss_delimit_double_quote) { -- 1.8.3.1