From 2e5255c37a7743914bcaabb7ef0035aef517d9ab Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 29 Mar 2012 19:47:03 -0500 Subject: [PATCH] Update: rewrite basic list object and content read functions Follow the new approach. Also, it occured to me that there is no reason to support quoted object names for a basic list. The reasoning behind this is that the basic list object always terminates on a newline and there cannot be any content on that newline. If there is no content, then there is no reason to protect the object by wrapping it in quotes as done in basic an extended. Quote support has been removed and as a result the implementation of the object and content reads are much simpler. --- level_1/fl_fss/c/fss_basic_list.c | 569 +++++++++++--------------------------- level_1/fl_fss/c/fss_basic_list.h | 10 + 2 files changed, 168 insertions(+), 411 deletions(-) diff --git a/level_1/fl_fss/c/fss_basic_list.c b/level_1/fl_fss/c/fss_basic_list.c index 097ab41..b20ffaa 100644 --- a/level_1/fl_fss/c/fss_basic_list.c +++ b/level_1/fl_fss/c/fss_basic_list.c @@ -23,219 +23,122 @@ extern "C"{ #endif // _di_level_1_parameter_checking_ fl_macro_fss_skip_past_whitespace((*buffer), (*input)) - fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop) + fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_no_data_on_eos, f_no_data_on_stop) // return found nothing if this line only contains whitespace and delimit placeholders if (buffer->string[input->start] == f_eol) { input->start++; return fl_fss_found_no_object; - } else if (buffer->string[input->start] == f_fss_basic_list_open) { - fl_macro_fss_object_seek_till_newline((*buffer), (*input), f_error_on_eos, f_error_on_stop) - - input->start++; - return fl_fss_found_no_object; } - // when handling delimits, the only time they should be applied is when a valid object would exist - // however, the delimits will appear before a valid object, so remember their positions and only apply them after a would be valid object is confirmed - f_bool has_quote_delimit = f_false; - f_string_length quote_delimit = f_string_length_initialize; - // begin the search found->start = input->start; // ignore all comment lines if (buffer->string[input->start] == f_fss_comment) { - fl_macro_fss_object_seek_till_newline((*buffer), (*input), f_error_on_eos, f_error_on_stop) + fl_macro_fss_object_seek_till_newline((*buffer), (*input), f_no_data_on_eos, f_no_data_on_stop) input->start++; return fl_fss_found_no_object; } - // handle quote support - f_autochar quoted = f_eos; - - // identify where the object begins - if (buffer->string[input->start] == f_fss_delimit_slash) { - f_string_length first_slash = input->start; - input->start++; + // identify where the object ends + while (input->start < buffer->used && input->start <= input->stop && buffer->string[input->start] != f_eol) { + if (buffer->string[input->start] == f_fss_delimit_slash) { + f_string_length first_slash = input->start; + f_string_length slash_count = 1; - fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input)) - fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop) - - // A slash only delimits if a delimit quote would follow the slash (or a slash and a delimit quote follows) - if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) { - // because the slash properly delimited the quote, the quote then becomes the start of the content - found->start = first_slash + 1; - quote_delimit = first_slash; - has_quote_delimit = f_true; - } else if (buffer->string[input->start] == f_fss_delimit_slash) { - // only apply a slash delimit if the line begins with slashes followed by a quote - do { - ++input->start; - - fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input)) - fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop) - - if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) { - found->start = first_slash + 1; - quote_delimit = first_slash; - has_quote_delimit = f_true; - break; - } else if (!isgraph(buffer->string[input->start])) { - fl_macro_fss_object_seek_till_newline((*buffer), (*input), f_error_on_eos, f_error_on_stop) + input->start++; - input->start++; - return fl_fss_found_no_object; + while (input->start < buffer->used && input->start <= input->stop && (buffer->string[input->start] == f_fss_delimit_placeholder || buffer->string[input->start] == f_fss_delimit_slash)) { + if (buffer->string[input->start] == f_fss_delimit_slash) { + slash_count++; } - } while (buffer->string[input->start] == f_fss_delimit_slash); - } - } else if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) { - quoted = buffer->string[input->start]; - input->start++; - - fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input)) - fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_unterminated_group_on_eos, f_unterminated_group_on_stop) - found->start = input->start; - } else if (isgraph(buffer->string[input->start])) { - found->start = input->start; - } - - // identify where the object ends - if (quoted == f_eos) { - do { - fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input)) - fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop) + input->start++; + } // while - if (!isgraph(buffer->string[input->start])) { - break; - } else if (buffer->string[input->start] == f_fss_delimit_slash) { - f_string_length first_slash = input->start; - ++input->start; + fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_no_data_on_eos, f_no_data_on_stop) - fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input)) - fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop) + if (buffer->string[input->start] == f_fss_basic_list_open) { + f_string_length stop_point = input->start - 1; - // A slash only delimits here if a basic list opener would follow the slash - if (buffer->string[input->start] == f_fss_basic_list_open) { - ++input->start; + input->start++; - fl_macro_fss_skip_past_whitespace((*buffer), (*input)) - fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop) + while (input->start < buffer->used && input->start <= input->stop) { + if (buffer->string[input->start] == f_eol || isgraph(buffer->string[input->start])) { + break; + } - // found a would be valid basic list object that has been delimited to not be a valid objecy, so exit - if (buffer->string[input->start] == f_fss_basic_list_close) { - input->start++; - return fl_fss_found_no_object; - } else { - // otherwise we now know this could never be a valid object so seek to the end of line and return without applying a delimit - fl_macro_fss_object_seek_till_newline((*buffer), (*input), f_error_on_eos, f_error_on_stop) + input->start++; + } // while - input->start++; - return fl_fss_found_no_object; - } - } else if (buffer->string[input->start] == f_fss_delimit_slash) { - f_string_length second_slash = input->start; - ++input->start; + fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_no_data_on_eos, f_no_data_on_stop) - fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input)) - fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop) + if (buffer->string[input->start] == f_eol) { + f_string_length location = input->start; - if (buffer->string[input->start] == f_fss_basic_list_open) { - f_string_length open_position = input->start; - ++input->start; + input->start = first_slash; - fl_macro_fss_skip_past_whitespace((*buffer), (*input)) - fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop) + if (slash_count % 2 == 0) { + while (slash_count > 0) { + if (buffer->string[input->start] == f_fss_delimit_slash) { + if (slash_count % 2 != 0) { + buffer->string[input->start] = f_fss_delimit_placeholder; + } - // found a valid basic list object, so apply the delimit - if (buffer->string[input->start] == f_eol) { - if (has_quote_delimit) { - buffer->string[quote_delimit] = f_fss_delimit_placeholder; + slash_count--; } - buffer->string[first_slash] = f_fss_delimit_placeholder; - found->stop = open_position - 1; input->start++; - return fl_fss_found_object; - } - } else { - // return to the second slash, this way if there is a third or more, the quote test can be repeated - input->start = second_slash; - } - } - } else if (buffer->string[input->start] == f_fss_basic_list_open) { - f_string_length open_position = input->start; - input->start++; + } // while - fl_macro_fss_skip_past_whitespace((*buffer), (*input)) - fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop) + found->stop = stop_point; + input->start = location + 1; - // found a valid basic list object - if (buffer->string[input->start] == f_eol) { - if (has_quote_delimit) { - buffer->string[quote_delimit] = f_fss_delimit_placeholder; + return fl_fss_found_object; } - found->stop = open_position - 1; - input->start++; - return fl_fss_found_object; + input->start = location + 1; + return fl_fss_found_no_object; } } - ++input->start; - } while (f_true); - } else { - f_string_length quote_location = f_string_length_initialize; + continue; + } else if (buffer->string[input->start] == f_fss_basic_list_open) { + f_string_length stop_point = input->start - 1; - // the quote must end before the opener begins, in this case the colon ':', so a quoted object would look like: "quoted object":\n - do { - fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input)) - fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop) + input->start++; - if (buffer->string[input->start] == f_eol) { - input->start++; - return fl_fss_found_no_object; - } + while (input->start < buffer->used && input->start <= input->stop) { + if (buffer->string[input->start] == f_eol || isgraph(buffer->string[input->start])) { + break; + } - // close quotes do not need to be delimited in this case as a valid quoted object must end with: ":\n - if (buffer->string[input->start] == quoted) { - // at this point, a valid object will need to be determined - // if nothing else is between the colon and the newline, then a valid object has been found - // otherwise restart the loop at this new position, looking for the next proper close quote - // This allows for an object name like the following to be valid: - // "My "Weird" Object": - // Whose object name is seen as: My "Weird" Object - quote_location = input->start; input->start++; + } // while - fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input)) - fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_unterminated_group_on_eos, f_unterminated_group_on_stop) + fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop) - if (buffer->string[input->start] == f_fss_basic_list_open) { - input->start++; - - fl_macro_fss_skip_past_whitespace((*buffer), (*input)) - fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop) + if (buffer->string[input->start] == f_eol) { + found->stop = stop_point; + input->start++; - if (buffer->string[input->start] == f_eol) { - found->stop = quote_location - 1; - input->start++; - return fl_fss_found_object; - } else { - continue; - } - } else { - continue; - } + return fl_fss_found_object; } - ++input->start; - } while (f_true); - } + continue; + } + + input->start++; + } // while + + // seek to the end of the line when no valid object is found + while (input->start < buffer->used && input->start <= input->stop && buffer->string[input->start] != f_eol) { + input->start++; + } // while - fl_macro_fss_object_seek_till_newline((*buffer), (*input), f_error_on_eos, f_error_on_stop) + fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_no_data_on_eos, f_no_data_on_stop) input->start++; return fl_fss_found_no_object; @@ -252,7 +155,6 @@ extern "C"{ if (input->stop < input->start) return f_invalid_parameter; if (buffer->used <= 0) return f_invalid_parameter; if (input->start >= buffer->used) return f_invalid_parameter; - if (found->used > found->size) return f_invalid_parameter; #endif // _di_level_1_parameter_checking_ fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input)) @@ -261,295 +163,140 @@ extern "C"{ fl_macro_fss_allocate_content_if_necessary((*found)); found->array[found->used].start = input->start; - f_string_length last_newline = input->start; - f_bool has_newlines = f_false; - - // when handling delimits, the only time they should be applied is when a valid object would exist - // however, the delimits will appear before a valid object, so remember their positions and only apply them after a would be valid object is confirmed - f_bool has_quote_delimit = f_false; - f_string_length quote_delimit = f_string_length_initialize; - - // search until stop point, end of string, or until a valid basic list object is found - do { - if (has_quote_delimit) { - has_quote_delimit = f_false; - } - - fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input)) - fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop) + f_string_length last_newline = input->start; + f_bool found_newline = f_false; + // identify where the content ends + while (input->start < buffer->used && input->start <= input->stop) { if (buffer->string[input->start] == f_eol) { - has_newlines = f_true; - last_newline = input->start; - ++input->start; - continue; - } else if (buffer->string[input->start] == f_fss_basic_list_open) { - // a line that begins with only the basic list opener cannot be a valid list object so skip to next line - fl_macro_fss_content_seek_till_newline((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop) - - has_newlines = f_true; + found_newline = f_true; last_newline = input->start; - ++input->start; + input->start++; continue; - } else if (buffer->string[input->start] == f_fss_comment) { - // comment lines are not valid objects so skip to next line - fl_macro_fss_content_seek_till_newline((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop) - - has_newlines = f_true; - last_newline = input->start; - ++input->start; - continue; - } else { - // handle quote support - f_autochar quoted = f_eos; - - // identify where the object begins - if (buffer->string[input->start] == f_fss_delimit_slash) { - f_string_length first_slash = input->start; - input->start++; + } - fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input)) - fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop) + if (buffer->string[input->start] == f_fss_delimit_slash) { + f_string_length first_slash = input->start; + f_string_length slash_count = 1; - // A slash only delimits if a delimit quote would follow the slash (or a slash and a delimit quote follows) - if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) { - // because the slash properly delimited the quote, the quote then becomes the start of the content - quote_delimit = first_slash; - has_quote_delimit = f_true; - } else if (buffer->string[input->start] == f_fss_delimit_slash) { - // only apply a slash delimit if the line begins with slashes followed by a quote - do { - ++input->start; - - fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input)) - fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop) - - if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) { - quote_delimit = first_slash; - has_quote_delimit = f_true; - break; - } else if (!isgraph(buffer->string[input->start])) { - fl_macro_fss_content_seek_till_newline((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop) - - break; - } - } while (buffer->string[input->start] == f_fss_delimit_slash); + input->start++; - // if exited from above loop while at an EOL, then continue the main loop - if (buffer->string[input->start] == f_eol) { - continue; - } + while (input->start < buffer->used && input->start <= input->stop && (buffer->string[input->start] == f_fss_delimit_placeholder || buffer->string[input->start] == f_fss_delimit_slash)) { + if (buffer->string[input->start] == f_fss_delimit_slash) { + slash_count++; } - } else if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) { - quoted = buffer->string[input->start]; + input->start++; + } // while - fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input)) - fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_unterminated_group_on_eos, f_unterminated_group_on_stop) - } else if (!isgraph(buffer->string[input->start])) { - fl_macro_fss_content_seek_till_newline((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop) - continue; + if (found_newline) { + fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop) + } else { + fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_no_data_on_eos, f_no_data_on_stop) } - // identify where the potential object ends - if (quoted == f_eos) { - do { - fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input)) - fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop) - - if (!isgraph(buffer->string[input->start])) { - while (buffer->string[input->start] != f_eol) { - ++input->start; - - if (input->start >= buffer->used) { - found->array[found->used].stop = input->stop; - found->used++; - return f_none_on_eos; - } + if (buffer->string[input->start] == f_fss_basic_list_open) { + f_string_length stop_point = input->start - 1; - if (input->start > input->stop) { - found->array[found->used].stop = input->stop; - found->used++; - return f_none_on_stop; - } - } // while + input->start++; - has_newlines = f_true; - last_newline = input->start; + while (input->start < buffer->used && input->start <= input->stop) { + if (buffer->string[input->start] == f_eol || isgraph(buffer->string[input->start])) { break; - } else if (buffer->string[input->start] == f_fss_delimit_slash) { - f_string_length first_slash = input->start; - ++input->start; - - fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input)) - fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop) - - // A slash only delimits here if a basic list opener would follow the slash - if (buffer->string[input->start] == f_fss_basic_list_open) { - f_string_length open_position = input->start; - ++input->start; + } - fl_macro_fss_skip_past_whitespace((*buffer), (*input)) + input->start++; + } // while - if (has_newlines) { - // In this case, assume a valid object was found when eos/eof was reached and reset the start position - fl_macro_fss_content_return_on_overflow_reset((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop, last_newline) - } else { - fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop) - } + if (found_newline) { + fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop) + } else { + fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_no_data_on_eos, f_no_data_on_stop) + } - // found a would be valid basic list object, so apply the delimit - if (buffer->string[input->start] == f_eol) { - buffer->string[first_slash] = f_fss_delimit_placeholder; - has_newlines = f_true; - last_newline = input->start; - break; - } else { - input->start = open_position; - ++input->start; - continue; - } - } else if (buffer->string[input->start] == f_fss_delimit_slash) { - f_string_length second_slash = input->start; - ++input->start; + if (buffer->string[input->start] == f_eol) { + f_string_length location = input->start; - fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input)) - fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop) + input->start = first_slash; - if (buffer->string[input->start] == f_fss_basic_list_open) { - f_string_length open_position = input->start; - ++input->start; + if (slash_count % 2 == 0) { + if (found_newline) { + found->array[found->used].stop = last_newline; + input->start = last_newline + 1; + found->used++; - fl_macro_fss_skip_past_whitespace((*buffer), (*input)) + return fl_fss_found_content; + } - if (has_newlines) { - // In this case, assume a valid object was found when eos/eof was reached and reset the start position - fl_macro_fss_content_return_on_overflow_reset((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop, last_newline) - } else { - fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop) - } + return fl_fss_found_no_content; + } - // found a valid basic list object - if (buffer->string[input->start] == f_eol) { - // the content should not apply delimits for valid objects - if (has_newlines) { - input->start = last_newline; - found->array[found->used].stop = input->start - 1; - input->start++; - found->used++; - return fl_fss_found_content; - } - - // when there is no newline and an object was found, then no content was found because the starting line is the next object line! - input->start = last_newline; - return fl_fss_found_no_content; - } else { - input->start = open_position; - ++input->start; - continue; - } - } else { - // return to the second slash, this way if there is a third or more, the quote test can be repeated - input->start = second_slash; - ++input->start; - continue; + while (slash_count > 0) { + if (buffer->string[input->start] == f_fss_delimit_slash) { + if (slash_count % 2 != 0) { + buffer->string[input->start] = f_fss_delimit_placeholder; } + + slash_count--; } - } else if (buffer->string[input->start] == f_fss_basic_list_open) { - f_string_length open_position = input->start; + input->start++; + } // while - fl_macro_fss_skip_past_whitespace((*buffer), (*input)) + found_newline = f_true; + input->start = location + 1; + } + } - if (has_newlines) { - // In this case, assume a valid object was found when eos/eof was reached and reset the start position - fl_macro_fss_content_return_on_overflow_reset((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop, last_newline) - } else { - fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop) - } + continue; + } else if (buffer->string[input->start] == f_fss_basic_list_open) { + input->start++; - // found a valid basic list object - if (buffer->string[input->start] == f_eol) { - // the content should not apply delimits for valid objects - if (has_newlines) { - input->start = last_newline; - found->array[found->used].stop = input->start - 1; - input->start++; - found->used++; - return fl_fss_found_content; - } + while (input->start < buffer->used && input->start <= input->stop) { + if (buffer->string[input->start] == f_eol || isgraph(buffer->string[input->start])) { + break; + } - // when there is no newline and an object was found, then no content was found because the starting line is the next object line! - input->start = last_newline; - return fl_fss_found_no_content; - } else { - input->start = open_position; - } - } + input->start++; + } // while - ++input->start; - } while (f_true); + if (found_newline) { + fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop) } else { - // the quote must end before the opener begins, in this case the colon ':', so a quoted object would look like: "quoted object":\n - do { - fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input)) - fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_unterminated_group_on_eos, f_unterminated_group_on_stop) - - if (buffer->string[input->start] == f_eol) { - has_newlines = f_true; - last_newline = input->start; - break; - } + fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_no_data_on_eos, f_no_data_on_stop) + } - // close quotes do not need to be delimited in this case as a valid quoted object must end with: ":\n - if (buffer->string[input->start] == quoted) { - // at this point, a valid object will need to be determined - // if nothing else is between the colon and the newline, then a valid object has been found - // otherwise restart the loop at this new position, looking for the next proper close quote - // This allows for an object name like the following to be valid: - // "My "Weird" Object": - // Whose object name is seen as: My "Weird" Object - input->start++; + if (buffer->string[input->start] == f_eol) { + if (found_newline) { + found->array[found->used].stop = last_newline; + input->start = last_newline + 1; + found->used++; - fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input)) - fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_unterminated_group_on_eos, f_unterminated_group_on_stop) + return fl_fss_found_content; + } - if (buffer->string[input->start] == f_fss_basic_list_open) { - input->start++; + return fl_fss_found_no_content; + } - fl_macro_fss_skip_past_whitespace((*buffer), (*input)) - fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop) + continue; + } - if (buffer->string[input->start] == f_eol) { - if (has_newlines) { - input->start = last_newline; - found->array[found->used].stop = input->start - 1; - input->start++; - found->used++; - return fl_fss_found_content; - } + input->start++; + } // while - // when there is no newline and an object was found, then no content was found because the starting line is the next object line! - input->start = last_newline; - return fl_fss_found_no_content; - } else { - continue; - } - } else { - continue; - } - } + if (found_newline) { + found->array[found->used].stop = last_newline - 1; + input->start = last_newline + 1; + found->used++; - ++input->start; - } while (f_true); - } - } + fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop) + + return fl_fss_found_content; + } - ++input->start; - } while (f_true); + fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_no_data_on_eos, f_no_data_on_stop) - // should never get here - return f_unknown; + return fl_fss_found_no_content; } #endif // _di_fl_fss_basic_list_content_read_ diff --git a/level_1/fl_fss/c/fss_basic_list.h b/level_1/fl_fss/c/fss_basic_list.h index c5b028c..1b8d41f 100644 --- a/level_1/fl_fss/c/fss_basic_list.h +++ b/level_1/fl_fss/c/fss_basic_list.h @@ -41,6 +41,16 @@ extern "C"{ extern f_return_status fl_fss_basic_list_content_read(f_dynamic_string *buffer, f_string_location *input, f_fss_content *found); #endif // _di_fl_fss_basic_list_content_read_ +#ifndef _di_fl_fss_basic_list_object_write_ + // write an fss-0002 object + //extern f_return_status fl_fss_basic_list_object_write(const f_dynamic_string object, f_string_location *input, f_dynamic_string *buffer); +#endif // _di_fl_fss_basic_list_object_write_ + +#ifndef _di_fl_fss_basic_list_content_write_ + // write an fss-0002 content + //extern f_return_status fl_fss_basic_list_content_write(const f_dynamic_string content, f_string_location *input, f_dynamic_string *buffer); +#endif // _di_fl_fss_basic_list_content_write_ + #ifdef __cplusplus } // extern "C" #endif -- 1.8.3.1