const f_number_unsigned_t destination_used = destination->used;
- bool is_comment = F_false;
- bool has_graph = F_false;
- bool do_prepend = prepend ? F_true : F_false;
+ uint8_t is_comment = F_false;
+ uint8_t has_graph = F_false;
+ uint8_t do_prepend = prepend ? F_true : F_false;
+ uint8_t width = 0;
f_number_unsigned_t i = 0;
f_number_unsigned_t slash_count = 0;
f_number_unsigned_t start = 0;
- uint8_t width = 0;
-
while (range->start <= range->stop && range->start < content.used) {
if (state->interrupt) {
return;
}
- if (state->status == F_okay_eos) {
- state->status = F_data_not_eos;
-
- return;
- }
-
- if (state->status == F_okay_stop) {
- state->status = F_data_not_stop;
+ if (state->status == F_okay_eos || state->status == F_okay_stop) {
+ state->status = state->status == F_okay_eos ? F_data_not_eos : F_data_not_stop;
return;
}
// Begin the search.
- const f_number_unsigned_t begin = range->start;
found->start = range->start;
// Ignore all comment lines.
if (buffer.string[range->start] == f_fss_comment_s.string[0]) {
+ found->start = 1;
+ found->stop = 0;
f_fss_seek_to_eol(buffer, range, state);
if (F_status_is_error(state->status)) return;
- if (state->status == F_okay_eos) {
- state->status = F_data_not_eos;
-
- return;
- }
-
- if (state->status == F_okay_stop) {
- state->status = F_data_not_stop;
+ if (state->status == F_okay_eos || state->status == F_okay_stop) {
+ state->status = state->status == F_okay_eos ? F_data_not_eos : F_data_not_stop;
return;
}
f_number_unsigned_t slash_first = 0;
f_number_unsigned_t slash_count = 0;
- f_number_unsigned_t start = 0;
+ f_number_unsigned_t start = 1;
f_number_unsigned_t stop = 0;
- bool graph_first = F_true;
+ uint8_t graph_first = F_true;
// Identify where the object ends.
while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol_s.string[0]) {
if (range->start >= buffer.used || range->start > range->stop) {
delimits->used = delimits_used;
-
- if (range->start >= buffer.used) {
- found->stop = buffer.used - 1;
- state->status = F_data_not_eos;
- }
- else {
- found->stop = range->stop;
- state->status = F_data_not_stop;
- }
+ found->start = 1;
+ found->stop = 0;
+ state->status = (range->start >= buffer.used) ? F_data_not_eos : F_data_not_stop;
return;
}
if (buffer.string[range->start] == f_fss_basic_list_open_s.string[0]) {
- graph_first = F_false;
- stop = range->start;
-
state->status = f_utf_buffer_increment(buffer, range, 1);
if (F_status_is_error(state->status)) return;
if (range->start >= buffer.used || range->start > range->stop) {
delimits->used = delimits_used;
-
- if (range->start >= buffer.used) {
- found->stop = buffer.used - 1;
- state->status = F_data_not_eos;
- }
- else {
- found->stop = range->stop;
- state->status = F_data_not_stop;
- }
+ found->start = 1;
+ found->stop = 0;
+ state->status = range->start >= buffer.used ? F_data_not_eos : F_data_not_stop;
return;
}
if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
- start = range->start;
-
+ found->stop = range->start;
range->start = slash_first;
state->status = f_memory_array_increase_by((slash_count / 2) + 1, sizeof(f_number_unsigned_t), (void **) &delimits->array, &delimits->used, &delimits->size);
if (F_status_is_error(state->status)) {
delimits->used = delimits_used;
+ found->start = 1;
+ found->stop = 0;
return;
}
} // while
- if (stop > begin) {
- found->stop = stop - 1;
- }
- else {
- found->start = 1;
- found->stop = 0;
- }
-
- range->start = start + 1;
+ range->start = found->stop + 1;
+ found->start = start;
+ found->stop = stop + macro_f_utf_byte_width(buffer.string[stop]) - 1;
state->status = F_fss_found_object;
return;
}
- range->start = start + 1;
+ range->start = found->stop + 1;
state->status = F_fss_found_object_not;
return;
}
}
else if (graph_first && buffer.string[range->start] == f_fss_comment_s.string[0]) {
- graph_first = F_false;
+ if (graph_first) {
+ graph_first = F_false;
+ start = slash_first;
+ }
// Comments may only have white space before the '#', therefore only the first slash needs to be delimited.
state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &delimits->array, &delimits->used, &delimits->size);
if (F_status_is_error(state->status)) break;
delimits->array[delimits->used++] = slash_first;
- ++range->start;
+ stop = range->start++;
}
else {
graph_first = F_false;
+ stop = range->start;
}
continue;
}
if (buffer.string[range->start] == f_fss_basic_list_open_s.string[0]) {
- graph_first = F_false;
- stop = range->start;
-
state->status = f_utf_buffer_increment(buffer, range, 1);
if (F_status_is_error(state->status)) break;
if (buffer.string[range->start] == f_fss_eol_s.string[0]) break;
- if (f_fss_is_space(buffer, *range, state) == F_false) {
- if (F_status_is_error(state->status)) break;
-
- break;
- }
+ state->status = f_fss_is_space(buffer, *range, state);
+ if (F_status_is_error(state->status) || state->status == F_false) break;
state->status = f_utf_buffer_increment(buffer, range, 1);
if (F_status_is_error(state->status)) break;
} // while
- if (range->start >= buffer.used) {
- found->stop = buffer.used - 1;
- state->status = F_okay_eos;
-
- return;
- }
-
- if (range->start > range->stop) {
- found->stop = range->stop;
- state->status = F_okay_stop;
+ if (range->start >= buffer.used || range->start > range->stop) {
+ found->start = 1;
+ found->stop = 0;
+ state->status = range->start >= buffer.used ? F_okay_eos : F_okay_stop;
return;
}
if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
- if (stop > begin) {
- found->stop = stop - 1;
- }
- else {
- found->start = 1;
- found->stop = 0;
- }
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
-
+ found->start = start;
+ found->stop = stop + macro_f_utf_byte_width(buffer.string[stop]) - 1;
+ ++range->start;
state->status = F_fss_found_object;
return;
}
+ if (graph_first) {
+ graph_first = F_false;
+ start = 1;
+ stop = 0;
+ }
+ else {
+ stop = range->start;
+ }
+
continue;
}
- else if (graph_first) {
- if (f_fss_is_space(buffer, *range, state) == F_false) {
- if (F_status_is_error(state->status)) break;
+ else {
+ state->status = f_fss_is_space(buffer, *range, state);
+ if (F_status_is_error(state->status)) break;
- graph_first = F_false;
+ if (state->status == F_false) {
+ if (graph_first) {
+ graph_first = F_false;
+ start = range->start;
+ }
+
+ stop = range->start;
}
}
if (F_status_is_error(state->status)) break;
} // while
+ found->start = 1;
+ found->stop = 0;
+
if (F_status_is_error(state->status)) {
delimits->used = delimits_used;
return;
}
- if (state->status == F_okay_eos) {
- state->status = F_data_not_eos;
-
- return;
- }
-
- if (state->status == F_okay_stop) {
- state->status = F_data_not_stop;
+ if (state->status == F_okay_eos || state->status == F_okay_stop) {
+ state->status = state->status == F_okay_eos ? F_data_not_eos : F_data_not_stop;
return;
}
#endif
/**
- * Read an fss-0002 content from a given string.
+ * Read an fss-0002 Content from a given string.
*
* This will record where delimit placeholders exist but will not apply the delimits.
*
*
* Must not be NULL.
* @param found
- * A set of all locations where a valid content was found.
+ * A set of all locations where a valid Content is found.
*
* Must not be NULL.
* @param delimits
*
* Must not be NULL.
* @param comments
- * An array of ranges representing where comments are found within any valid content.
- * This only stores comments found within valid content only.
+ * An array of ranges representing where comments are found within any valid Content.
+ * This only stores comments found within valid Content only.
* The comment range will include the trailing newline.
*
* Must not be NULL.
* Must not be NULL.
*
* This alters state.status:
- * F_fss_found_content on success and content was found (start location is at end of content).
- * F_fss_found_content_not on success and no content was found (start location is after character designating this is not a content).
- * F_okay_eos on success after reaching the end of the buffer (a valid object is not yet confirmed).
- * F_okay_stop on success after reaching stopping point (a valid object is not yet confirmed).
+ * F_fss_found_content on success and Content is found (start location is at end of Content).
+ * F_fss_found_content_not on success and no Content is found (start location is after character designating this is not a Content).
+ * F_okay_eos on success after reaching the end of the buffer (a valid Object is not yet confirmed).
+ * F_okay_stop on success after reaching stopping point (a valid Object is not yet confirmed).
* F_data_not if buffer is empty (buffer.used is 0).
* F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found).
* F_data_not_stop no data found after reaching stopping point (essentially only comments are found).
#endif // _di_fl_fss_basic_list_content_read_
/**
- * Write an fss-0002 content from a given string.
+ * Write an fss-0002 Content from a given string.
*
- * This will write the given string range as a valid content.
+ * This will write the given string range as a valid Content.
* Anything within this range will be escaped as necessary.
*
* The destination string may have NULLs.
* @param content
* The string to write as (does not stop at NULLS, they are ignored and not written).
* @param complete
- * If f_fss_complete_none_e, then only the content is written.
- * If f_fss_complete_next_e, then the content followed by any appropriate "next" character separating one content from the next, if applicable.
- * If f_fss_complete_end_e, then the content followed by any appropriate "end" character designating the last content for some object, printing final newline, if applicable.
- * If f_fss_complete_partial_e, this will write any appropriate open and close aspects of this content, except for the final newline.
- * If f_fss_complete_full_e, this will write any appropriate open and close aspects of this content, including the final newline.
+ * If f_fss_complete_none_e, then only the Content is written.
+ * If f_fss_complete_next_e, then the Content followed by any appropriate "next" character separating one Content from the next, if applicable.
+ * If f_fss_complete_end_e, then the Content followed by any appropriate "end" character designating the last Content for some Object, printing final newline, if applicable.
+ * If f_fss_complete_partial_e, this will write any appropriate open and close aspects of this Content, except for the final newline.
+ * If f_fss_complete_full_e, this will write any appropriate open and close aspects of this Content, including the final newline.
* @param prepend
* (optional) A string of whitespace to prepend at the start of each line.
- * This should only be whitespace, anything else could produce invalid content.
+ * This should only be whitespace, anything else could produce invalid Content.
*
* Set to NULL to not use.
* @param range
- * The start/stop location within the content string to write as an content.
+ * The start/stop location within the Content string to write as an Content.
*
* Must not be NULL.
* @param destination
- * The buffer where the content is written to.
+ * The buffer where the Content is written to.
*
* Must not be NULL.
* @param state
* F_okay on success.
* F_okay_eol on success after reaching the end of the line.
* F_okay_eos on success after reaching the end of the buffer.
- * F_data_not if content is empty (content.used is 0).
+ * F_data_not if Content is empty (content.used is 0).
* F_data_not_eos no data to write due start location being greater than or equal to buffer size.
* F_data_not_stop no data to write due start location being greater than stop location.
* F_okay_stop on success after reaching stopping point.
#endif // _di_fl_fss_basic_list_content_write_
/**
- * Read an fss-0002 object.
+ * Read an fss-0002 Object.
*
* This will record where delimit placeholders exist but will not apply the delimits.
*
*
* Must not be NULL.
* @param found
- * A location where a valid object was found.
+ * A location where a valid Object is found.
*
* Must not be NULL.
* @param delimits
* Must not be NULL.
*
* This alters state.status:
- * F_fss_found_object on success and object was found (start location is at end of object).
- * F_fss_found_object_not on success and no object was found (start location is after character designating this is not an object).
- * F_okay_eos on success after reaching the end of the buffer (a valid object is not yet confirmed).
- * F_okay_stop on success after reaching stopping point (a valid object is not yet confirmed).
+ * F_fss_found_object on success and Object is found (start location is at end of Object).
+ * F_fss_found_object_not on success and no Object is found (start location is after character designating this is not an Object).
+ * F_okay_eos on success after reaching the end of the buffer (a valid Object is not yet confirmed).
+ * F_okay_stop on success after reaching stopping point (a valid Object is not yet confirmed).
* F_data_not if buffer is empty (buffer.used is 0).
* F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found).
* F_data_not_stop no data found after reaching stopping point (essentially only comments are found).
#endif // _di_fl_fss_basic_list_object_read_
/**
- * Write an fss-0002 object.
+ * Write an fss-0002 Object.
*
- * This will write the given string range as a valid object.
+ * This will write the given string range as a valid Object.
* Anything within this range will be escaped as necessary.
* This will stop if EOL is reached.
*
* @param object
* The string to write as (does not stop at NULLS, they are ignored and not written).
* @param complete
- * If f_fss_complete_none_e, then only the object name is written.
- * If f_fss_complete_full_e, this will write any appropriate open and close aspects of this object.
- * If f_fss_complete_full_trim_e, this will write any appropriate open and close aspects of this object, but will omit whitespace before and after the object.
- * If f_fss_complete_partial_e, this will write any appropriate open and close aspects of this object.
- * If f_fss_complete_partial_tim, this will write any appropriate open and close aspects of this object, but will omit whitespace before and after the object.
+ * If f_fss_complete_none_e, then only the Object name is written.
+ * If f_fss_complete_full_e, this will write any appropriate open and close aspects of this Object.
+ * If f_fss_complete_full_trim_e, this will write any appropriate open and close aspects of this Object, but will omit whitespace before and after the Object.
+ * If f_fss_complete_partial_e, this will write any appropriate open and close aspects of this Object.
+ * If f_fss_complete_partial_tim, this will write any appropriate open and close aspects of this Object, but will omit whitespace before and after the Object.
* @param range
- * The start/stop location within the object string to write as an object.
+ * The start/stop location within the Object string to write as an Object.
*
* Must not be NULL.
* @param destination
- * The buffer where the object is written to.
+ * The buffer where the Object is written to.
*
* Must not be NULL.
* @param state
* This alters state.status:
* F_okay on success.
* F_okay_eos on success after reaching the end of the buffer.
- * F_data_not if object is empty (object.used is 0).
+ * F_data_not if Object is empty (object.used is 0).
* F_data_not_eos no data to write due start location being greater than or equal to buffer size.
* F_data_not_stop no data to write due start location being greater than stop location.
* F_okay_stop on success after reaching stopping point.