Update the Object read functions to be in compliance with the latest specification changes.
Review and update the code, fixing any observed problems and perform some clean ups.
I noticed that several of the list functions for Object read are almost identical.
Move this logic into into a shared private function to reduce repeated code.
The runtime tests are also updated.
I still need to review the Content read functions.
I probably may be able to also find similar, if not identical, code for the list write functions as well.
I will review the code and create a private function similar to what is done here if deemed possible and reasonable.
build_sources_library conversion.c private-conversion.c conversion/common.c
build_sources_library directory.c private-directory.c
build_sources_library environment.c
-build_sources_library private-fss.c fss/basic.c fss/basic_list.c fss/embedded_list.c fss/extended.c fss/extended_list.c fss/payload.c fss/private-payload.c fss/private-payload-helper.c
+build_sources_library private-fss.c private-fss-list.c fss/basic.c fss/basic_list.c fss/embedded_list.c fss/extended.c fss/extended_list.c fss/payload.c fss/private-payload.c fss/private-payload-helper.c
build_sources_library iki.c
build_sources_library path.c
build_sources_library print.c private-print.c print/common.c
build_sources_library level_1/conversion.c level_1/private-conversion.c level_1/conversion/common.c
build_sources_library level_1/directory.c level_1/private-directory.c
build_sources_library level_1/environment.c
-build_sources_library level_1/private-fss.c level_1/fss/basic.c level_1/fss/basic_list.c level_1/fss/embedded_list.c level_1/fss/extended.c level_1/fss/extended_list.c level_1/fss/payload.c level_1/fss/private-payload.c level_1/fss/private-payload-helper.c
+build_sources_library level_1/private-fss.c level_1/private-fss-list.c level_1/fss/basic.c level_1/fss/basic_list.c level_1/fss/embedded_list.c level_1/fss/extended.c level_1/fss/extended_list.c level_1/fss/payload.c level_1/fss/private-payload.c level_1/fss/private-payload-helper.c
build_sources_library level_1/iki.c
build_sources_library level_1/path.c
build_sources_library level_1/print.c level_1/private-print.c level_1/print/common.c
build_sources_program fll/level_1/conversion.c fll/level_1/private-conversion.c fll/level_1/conversion/common.c
build_sources_program fll/level_1/directory.c fll/level_1/private-directory.c
build_sources_program fll/level_1/environment.c
-build_sources_program fll/level_1/private-fss.c fll/level_1/fss/basic.c fll/level_1/fss/basic_list.c fll/level_1/fss/embedded_list.c fll/level_1/fss/extended.c fll/level_1/fss/extended_list.c fll/level_1/fss/payload.c
+build_sources_program fll/level_1/private-fss.c fll/level_1/private-fss-list.c fll/level_1/fss/basic.c fll/level_1/fss/basic_list.c fll/level_1/fss/embedded_list.c fll/level_1/fss/extended.c fll/level_1/fss/extended_list.c fll/level_1/fss/payload.c
build_sources_program fll/level_1/iki.c
build_sources_program fll/level_1/path.c
build_sources_program fll/level_1/print.c fll/level_1/private-print.c fll/level_1/print/common.c
build_sources_program fll/level_1/control_group.c
build_sources_program fll/level_1/conversion.c fll/level_1/private-conversion.c fll/level_1/conversion/common.c
build_sources_program fll/level_1/environment.c
-build_sources_program fll/level_1/private-fss.c fll/level_1/fss/basic.c fll/level_1/fss/basic_list.c fll/level_1/fss/embedded_list.c fll/level_1/fss/extended.c fll/level_1/fss/extended_list.c fll/level_1/fss/payload.c
+build_sources_program fll/level_1/private-fss.c fll/level_1/private-fss-list.c fll/level_1/fss/basic.c fll/level_1/fss/basic_list.c fll/level_1/fss/embedded_list.c fll/level_1/fss/extended.c fll/level_1/fss/extended_list.c fll/level_1/fss/payload.c
build_sources_program fll/level_1/print.c fll/level_1/private-print.c fll/level_1/print/common.c
build_sources_program fll/level_2/error.c fll/level_2/private-error.c fll/level_2/error/common.c
}
#endif // _di_fl_fss_basic_object_read_
-#ifndef _di_fl_fss_basic_object_write_
+#ifndef _di_fl_fss_basic_list_object_read_
void fl_fss_basic_object_write(const f_string_static_t object, const uint8_t quote, const uint8_t complete, f_range_t * const range, f_string_dynamic_t * const destination, f_state_t * const state) {
#ifndef _di_level_1_parameter_checking_
if (!state) return;
destination->used = destination_used;
}
}
-#endif // _di_fl_fss_basic_object_write_
+#endif // _di_fl_fss_basic_list_object_read_
#ifdef __cplusplus
} // extern "C"
#include "basic_list.h"
#include "../private-fss.h"
+#include "../private-fss-list.h"
#ifdef __cplusplus
extern "C" {
}
#endif // _di_level_1_parameter_checking_
- const f_number_unsigned_t delimits_used = delimits->used;
- const f_number_unsigned_t comments_used = comments->used;
-
f_fss_skip_past_delimit(buffer, range, state);
- if (F_status_is_error(state->status)) return;
- if (state->status == F_data_not) return;
+ if (F_status_is_error(state->status) || state->status == F_data_not) return;
if (range->start >= buffer.used || range->start > range->stop) {
- delimits->used = delimits_used;
- comments->used = comments_used;
-
if (range->start >= buffer.used) {
found->array[found->used].stop = buffer.used - 1;
state->status = F_okay_eos;
state->status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &found->array, &found->used, &found->size);
if (F_status_is_error(state->status)) return;
+ const f_number_unsigned_t delimits_used = delimits->used;
+ const f_number_unsigned_t comments_used = comments->used;
+
const f_number_unsigned_t begin = range->start;
found->array[found->used].start = range->start;
}
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;
- }
+ if (f_fss_is_space(buffer, *range, state) == F_false) break;
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;
- }
+ if (f_fss_is_space(buffer, *range, state) == F_false) break;
state->status = f_utf_buffer_increment(buffer, range, 1);
if (F_status_is_error(state->status)) break;
range->start = start + 1;
- private_fl_fss_basic_list_write_add_until_end(content, range, destination, state);
+ private_fl_fss_list_write_add_until_end(content, range, destination, state);
if (F_status_is_error(state->status)) break;
continue;
range->start = start + 1;
- private_fl_fss_basic_list_write_add_until_end(content, range, destination, state);
+ private_fl_fss_list_write_add_until_end(content, range, destination, state);
if (F_status_is_error(state->status)) break;
continue;
}
#endif // _di_level_1_parameter_checking_
- const f_number_unsigned_t delimits_used = delimits->used;
-
- f_fss_skip_past_space(buffer, range, state);
- if (F_status_is_error(state->status)) return;
- if (state->status == F_data_not) return;
-
- if (state->status == F_okay_eol) {
-
- // Move the start position to after the EOL.
- ++range->start;
- state->status = F_fss_found_object_not;
-
- return;
- }
-
- 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.
- 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_okay_stop) {
- state->status = state->status == F_okay_eos ? F_data_not_eos : F_data_not_stop;
-
- return;
- }
-
- // Move the start position to after the EOL.
- ++range->start;
- state->status = F_fss_found_object_not;
-
- return;
- }
-
- f_number_unsigned_t slash_first = 0;
- f_number_unsigned_t slash_count = 0;
- f_number_unsigned_t start = 1;
- f_number_unsigned_t stop = 0;
-
- 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 (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) break;
- }
-
- if (buffer.string[range->start] == f_fss_slash_s.string[0]) {
- slash_first = range->start;
- slash_count = 1;
-
- for (++range->start; range->start <= range->stop && range->start < buffer.used; ++range->start) {
-
- if (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) break;
- }
-
- if (buffer.string[range->start] == f_fss_placeholder_s.string[0]) continue;
- else if (buffer.string[range->start] != f_fss_slash_s.string[0]) break;
-
- ++slash_count;
- } // for
-
- if (range->start >= buffer.used || range->start > range->stop) {
- delimits->used = delimits_used;
- 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]) {
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) return;
-
- while (range->start <= range->stop && range->start < buffer.used) {
-
- if (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) 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_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
- } // while
-
- if (range->start >= buffer.used || range->start > range->stop) {
- delimits->used = delimits_used;
- 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]) {
- 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)) break;
-
- if (slash_count % 2 == 0) {
- while (slash_count > 0) {
-
- if (buffer.string[range->start] == f_fss_slash_s.string[0]) {
- if (slash_count % 2 == 1) {
- delimits->array[delimits->used] = range->start;
- ++delimits->used;
- }
-
- --slash_count;
- }
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
-
- if (F_status_is_error(state->status)) {
- delimits->used = delimits_used;
- found->start = 1;
- found->stop = 0;
-
- return;
- }
- } // while
-
- 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 = 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]) {
- 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;
- 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]) {
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
-
- while (range->start <= range->stop && range->start < buffer.used) {
-
- if (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) break;
- }
-
- if (buffer.string[range->start] == f_fss_eol_s.string[0]) 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 || 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]) {
- 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 {
- state->status = f_fss_is_space(buffer, *range, state);
- if (F_status_is_error(state->status)) break;
-
- if (state->status == F_false) {
- if (graph_first) {
- graph_first = F_false;
- start = range->start;
- }
-
- stop = range->start;
- }
- }
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
- 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_okay_stop) {
- state->status = state->status == F_okay_eos ? F_data_not_eos : F_data_not_stop;
-
- return;
- }
-
- // Seek to the end of the line when no valid object is found.
- f_fss_seek_to_eol(buffer, range, state);
-
- // Move the start position to after the EOL.
- ++range->start;
- state->status = F_fss_found_object_not;
+ return private_fl_fss_list_object_read(f_fss_basic_list_open_s, buffer, range, found, delimits, state);
}
#endif // _di_fl_fss_basic_list_object_read_
if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_trim_e) {
if (complete == f_fss_complete_full_trim_e || complete == f_fss_complete_trim_e) {
- private_fl_fss_basic_list_write_object_trim(destination_used, destination, state);
+ private_fl_fss_list_write_object_trim(destination_used, destination, state);
if (F_status_is_error(state->status)) {
destination->used = destination_used;
#include "embedded_list.h"
#include "../private-fss.h"
+#include "../private-fss-list.h"
#ifdef __cplusplus
extern "C" {
#endif // _di_level_1_parameter_checking_
f_fss_skip_past_delimit(buffer, range, state);
- if (F_status_is_error(state->status)) return;
- if (state->status == F_data_not || state->status == F_okay_eos || state->status == F_okay_stop) return;
+ if (F_status_is_error(state->status) || state->status == F_data_not || state->status == F_okay_eos || state->status == F_okay_stop) return;
fl_fss_data_embedded_list_t * const cache = (fl_fss_data_embedded_list_t *) state->data;
cache->slashes->used = 0;
state->status = f_memory_array_increase(state->step_small, sizeof(f_fss_nest_t), (void **) &found->depth, &found->used, &found->size);
- if (F_status_is_error(state->status)) return;
- state->status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &cache->objects->array, &cache->objects->used, &cache->objects->size);
- if (F_status_is_error(state->status)) return;
+ if (F_status_is_error_not(state->status)) {
+ state->status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &cache->objects->array, &cache->objects->used, &cache->objects->size);
+ }
- state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &cache->positions->array, &cache->positions->used, &cache->positions->size);
- if (F_status_is_error(state->status)) return;
+ if (F_status_is_error_not(state->status)) {
+ state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &cache->positions->array, &cache->positions->used, &cache->positions->size);
+ }
+
+ if (F_status_is_error_not(state->status)) {
+ state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &cache->slashes->array, &cache->slashes->used, &cache->slashes->size);
+ }
- state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &cache->slashes->array, &cache->slashes->used, &cache->slashes->size);
if (F_status_is_error(state->status)) return;
const f_number_unsigned_t delimits_used = delimits->used;
f_number_unsigned_t depth = 0;
f_number_unsigned_t position = 0;
-
f_number_unsigned_t position_previous = range->start;
f_number_unsigned_t line_start = range->start;
f_number_unsigned_t newline_last = range->start;
f_number_unsigned_t comment_delimit = 0;
-
f_number_unsigned_t slash_first = 0;
f_number_unsigned_t slash_last = 0;
-
f_number_unsigned_t before_list_open = position_previous;
- uint8_t is_open = F_false;
-
// 0x0 = false, 0x1 = true, 0x2 = false, but there is a delimited comment, comment_delimit is set.
uint8_t graph_first = 0x1;
+ uint8_t is_open = F_false;
+ uint8_t is_object = F_false;
// Initialize depth 1 start position.
// Positions_start.used is used as a max depth (such that cache->positions->used == max depth + 1).
if (state->interrupt) {
state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) break;
+
+ if (F_status_set_fine(state->status) == F_interrupt) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
}
if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
if (graph_first == 0x2) {
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;
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
delimits->array[delimits->used++] = comment_delimit;
}
graph_first = 0x1;
line_start = range->start;
- if (depth) {
- if (range->start >= buffer.used || range->start > range->stop) {
- delimits->used = delimits_used;
- comments->used = comments_used;
+ if (range->start >= buffer.used || range->start > range->stop) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+ if (depth) {
state->status = (range->start >= buffer.used) ? F_end_not_nest_eos : F_end_not_nest_stop;
-
- return;
}
- }
- else {
- if (range->start >= buffer.used || range->start > range->stop) {
- state->status = (range->start >= buffer.used) ? F_okay_eos : F_okay_stop;
-
- return;
+ else {
+ state->status = (range->start >= buffer.used) ? F_data_not_eos : F_data_not_stop;
}
+
+ return;
}
continue;
slash_first = range->start;
slash_last = range->start;
cache->slashes->array[depth] = 1;
-
position_previous = range->start++;
- while (range->start <= range->stop && range->start < buffer.used && (buffer.string[range->start] == f_fss_placeholder_s.string[0] || buffer.string[range->start] == f_fss_slash_s.string[0])) {
+ for (; range->start <= range->stop && range->start < buffer.used && (buffer.string[range->start] == f_fss_placeholder_s.string[0] || buffer.string[range->start] == f_fss_slash_s.string[0]); ++range->start) {
if (state->interrupt) {
state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) break;
+
+ if (F_status_set_fine(state->status) == F_interrupt) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
}
position_previous = range->start;
- if (buffer.string[range->start] == f_fss_slash_s.string[0]) {
- slash_last = range->start++;
+ if (buffer.string[position_previous] == f_fss_slash_s.string[0]) {
+ slash_last = position_previous;
++cache->slashes->array[depth];
}
- else {
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
- }
- } // while
-
- if (F_status_is_error(state->status)) break;
+ } // for
- if (depth) {
- if (range->start >= buffer.used || range->start > range->stop) {
- delimits->used = delimits_used;
- comments->used = comments_used;
+ if (range->start >= buffer.used || range->start > range->stop) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+ if (depth) {
state->status = (range->start >= buffer.used) ? F_end_not_nest_eos : F_end_not_nest_stop;
-
- return;
}
- }
- else {
- if (range->start >= buffer.used || range->start > range->stop) {
- delimits->used = delimits_used;
- comments->used = comments_used;
-
+ else {
state->status = (range->start >= buffer.used) ? F_data_not_eos : F_data_not_stop;
-
- return;
}
+
+ return;
}
// All slashes for an open are delimited (because it could represent a slash in the object name).
if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
if (graph_first == 0x2) {
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;
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
delimits->array[delimits->used++] = comment_delimit;
}
if (state->interrupt) {
state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) break;
+
+ if (F_status_set_fine(state->status) == F_interrupt) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
}
if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
}
if (buffer.string[range->start] != f_fss_placeholder_s.string[0]) {
- if (f_fss_is_space(buffer, *range, state) == F_false) {
- if (F_status_is_error(state->status)) break;
-
- break;
- }
+ if (f_fss_is_space(buffer, *range, state) == F_false) break;
}
position_previous = range->start;
if (F_status_is_error(state->status)) break;
} // while
- if (F_status_is_error(state->status)) break;
-
- if (depth) {
- if (range->start >= buffer.used || range->start > range->stop) {
- delimits->used = delimits_used;
- comments->used = comments_used;
-
- state->status = (range->start >= buffer.used) ? F_end_not_nest_eos : F_end_not_nest_stop;
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
- return;
- }
+ return;
}
- else {
- if (range->start >= buffer.used || range->start > range->stop) {
- delimits->used = delimits_used;
- comments->used = comments_used;
- state->status = (range->start >= buffer.used) ? F_data_not_eos : F_data_not_stop;
+ if (F_status_is_error(state->status) || range->start >= buffer.used || range->start > range->stop) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
- return;
+ if (F_status_is_error_not(state->status)) {
+ if (depth) {
+ state->status = (range->start >= buffer.used) ? F_end_not_nest_eos : F_end_not_nest_stop;
+ }
+ else {
+ state->status = (range->start >= buffer.used) ? F_data_not_eos : F_data_not_stop;
+ }
}
+
+ return;
}
// This is a valid object open/close that has been delimited, save the slash delimit positions.
graph_first = 0x1;
if (is_open) {
- bool is_object = F_false;
-
- if (cache->slashes->array[depth] % 2 == 0) {
- is_object = F_true;
- }
-
+ is_object = cache->slashes->array[depth] % 2 == 0 ? F_true : F_false;
range->start = slash_first;
state->status = f_memory_array_increase_by((cache->slashes->array[depth] / 2) + 1, sizeof(f_number_unsigned_t), (void **) &delimits->array, &delimits->used, &delimits->size);
- if (F_status_is_error(state->status)) break;
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
// Apply slash delimits, only slashes and placeholders should be present.
while (cache->slashes->array[depth]) {
position_previous = range->start++;
} // while
- if (F_status_is_error(state->status)) break;
-
// When slashes are even, the object is valid and needs to be processed.
if (is_object) {
if (++depth >= cache->objects->size) {
state->status = f_memory_array_resize(depth + 2, sizeof(f_range_t), (void **) &cache->objects->array, &cache->objects->used, &cache->objects->size);
- if (F_status_is_error(state->status)) break;
}
if (depth >= cache->positions->size) {
- state->status = f_memory_array_resize(depth + 2, sizeof(f_number_unsigned_t), (void **) &cache->positions->array, &cache->positions->used, &cache->positions->size);
- if (F_status_is_error(state->status)) break;
+ if (F_status_is_error_not(state->status)) {
+ state->status = f_memory_array_resize(depth + 2, sizeof(f_number_unsigned_t), (void **) &cache->positions->array, &cache->positions->used, &cache->positions->size);
+ }
}
if (depth >= cache->slashes->size) {
- state->status = f_memory_array_resize(depth + 2, sizeof(f_number_unsigned_t), (void **) &cache->slashes->array, &cache->slashes->used, &cache->slashes->size);
- if (F_status_is_error(state->status)) break;
+ if (F_status_is_error_not(state->status)) {
+ state->status = f_memory_array_resize(depth + 2, sizeof(f_number_unsigned_t), (void **) &cache->slashes->array, &cache->slashes->used, &cache->slashes->size);
+ }
+ }
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
}
cache->objects->array[depth].start = line_start;
}
else {
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;
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
delimits->array[delimits->used++] = slash_last;
}
position_previous = range->start;
state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
while (range->start <= range->stop && range->start < buffer.used) {
if (state->interrupt) {
state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) break;
+
+ if (F_status_set_fine(state->status) == F_interrupt) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
}
if (buffer.string[range->start] == f_fss_eol_s.string[0]) break;
if (buffer.string[range->start] != f_fss_placeholder_s.string[0]) {
- if (f_fss_is_space(buffer, *range, state) == F_false) {
- if (F_status_is_error(state->status)) break;
-
- break;
- }
+ if (f_fss_is_space(buffer, *range, state) == F_false) break;
}
position_previous = range->start;
if (F_status_is_error(state->status)) break;
} // while
- if (F_status_is_error(state->status)) break;
-
- if (depth) {
- if (range->start >= buffer.used || range->start > range->stop) {
- delimits->used = delimits_used;
- comments->used = comments_used;
-
- state->status = (range->start >= buffer.used) ? F_end_not_nest_eos : F_end_not_nest_stop;
-
- return;
- }
- }
- else {
- if (range->start >= buffer.used || range->start > range->stop) {
+ if (F_status_is_error(state->status) || range->start >= buffer.used || range->start > range->stop) {
delimits->used = delimits_used;
comments->used = comments_used;
- state->status = (range->start >= buffer.used) ? F_data_not_eos : F_data_not_stop;
+ if (F_status_is_error_not(state->status)) {
+ if (depth) {
+ state->status = (range->start >= buffer.used) ? F_end_not_nest_eos : F_end_not_nest_stop;
+ }
+ else {
+ 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]) {
if (++depth >= cache->objects->size) {
state->status = f_memory_array_resize(depth + 2, sizeof(f_range_t), (void **) &cache->objects->array, &cache->objects->used, &cache->objects->size);
- if (F_status_is_error(state->status)) break;
}
if (depth >= cache->positions->size) {
- state->status = f_memory_array_resize(depth + 2, sizeof(f_number_unsigned_t), (void **) &cache->positions->array, &cache->positions->used, &cache->positions->size);
- if (F_status_is_error(state->status)) break;
+ if (F_status_is_error_not(state->status)) {
+ state->status = f_memory_array_resize(depth + 2, sizeof(f_number_unsigned_t), (void **) &cache->positions->array, &cache->positions->used, &cache->positions->size);
+ }
}
if (depth >= cache->slashes->size) {
- state->status = f_memory_array_resize(depth + 2, sizeof(f_number_unsigned_t), (void **) &cache->slashes->array, &cache->slashes->used, &cache->slashes->size);
- if (F_status_is_error(state->status)) break;
+ if (F_status_is_error_not(state->status)) {
+ state->status = f_memory_array_resize(depth + 2, sizeof(f_number_unsigned_t), (void **) &cache->slashes->array, &cache->slashes->used, &cache->slashes->size);
+ }
+ }
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
}
cache->objects->array[depth].start = line_start;
if (graph_first == 0x2) {
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;
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
delimits->array[delimits->used++] = comment_delimit;
}
// No valid object close found, seek until EOL.
f_fss_seek_to_eol(buffer, range, state);
- if (F_status_is_error(state->status)) break;
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
if (graph_first == 0x2) {
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;
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
delimits->array[delimits->used++] = comment_delimit;
}
if (state->interrupt) {
state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) break;
+
+ if (F_status_set_fine(state->status) == F_interrupt) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
}
if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
position_previous = range->start;
state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
- } // while
-
- if (F_status_is_error(state->status)) break;
- if (depth) {
- if (range->start >= buffer.used || range->start > range->stop) {
+ if (F_status_is_error(state->status)) {
delimits->used = delimits_used;
comments->used = comments_used;
- state->status = (range->start >= buffer.used) ? F_end_not_nest_eos : F_end_not_nest_stop;
-
return;
}
- }
- else {
- if (range->start >= buffer.used || range->start > range->stop) {
- delimits->used = delimits_used;
- comments->used = comments_used;
+ } // while
- state->status = (range->start >= buffer.used) ? F_data_not_eos : F_data_not_stop;
+ if (range->start >= buffer.used || range->start > range->stop) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
- return;
+ if (depth) {
+ state->status = (range->start >= buffer.used) ? F_end_not_nest_eos : F_end_not_nest_stop;
+ }
+ else {
+ state->status = (range->start >= buffer.used) ? F_data_not_eos : F_data_not_stop;
}
+
+ return;
}
}
}
if (state->interrupt) {
state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) break;
+
+ if (F_status_set_fine(state->status) == F_interrupt) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
}
position_previous = 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_status_is_error(state->status) || buffer.string[range->start] == f_fss_eol_s.string[0]) break;
if (buffer.string[range->start] != f_fss_placeholder_s.string[0]) {
- if (f_fss_is_space(buffer, *range, state) == F_false) {
- if (F_status_is_error(state->status)) break;
-
- break;
- }
+ if (f_fss_is_space(buffer, *range, state) == F_false) break;
}
} // while
- if (F_status_is_error(state->status)) break;
+ if (F_status_is_error(state->status) || range->start >= buffer.used || range->start > range->stop) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
- if (depth) {
- if (range->start >= buffer.used || range->start > range->stop) {
- delimits->used = delimits_used;
- comments->used = comments_used;
+ if (F_status_is_error_not(state->status)) {
+ if (depth) {
+ state->status = (range->start >= buffer.used) ? F_end_not_nest_eos : F_end_not_nest_stop;
+ }
+ else {
+ state->status = (range->start >= buffer.used) ? F_data_not_eos : F_data_not_stop;
+ }
+ }
- state->status = (range->start >= buffer.used) ? F_end_not_nest_eos : F_end_not_nest_stop;
-
- return;
- }
- }
- else {
- if (range->start >= buffer.used || range->start > range->stop) {
- delimits->used = delimits_used;
- comments->used = comments_used;
-
- state->status = (range->start >= buffer.used) ? F_data_not_eos : F_data_not_stop;
-
- return;
- }
- }
+ return;
+ }
if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
if (depth >= found->used) {
state->status = f_memory_array_resize(depth + 2, sizeof(f_fss_nest_t), (void **) &found->depth, &found->used, &found->size);
- if (F_status_is_error(state->status)) break;
}
if (found->depth[depth].used >= found->depth[depth].size) {
- state->status = f_memory_array_increase(state->step_small, sizeof(f_fss_item_t), (void **) &found->depth[depth].array, &found->depth[depth].used, &found->depth[depth].size);
- if (F_status_is_error(state->status)) break;
+ if (F_status_is_error_not(state->status)) {
+ state->status = f_memory_array_increase(state->step_small, sizeof(f_fss_item_t), (void **) &found->depth[depth].array, &found->depth[depth].used, &found->depth[depth].size);
+ }
}
position = found->depth[depth].used;
if (found->depth[depth].array[position].content.size != 1) {
- state->status = f_memory_array_resize(1, sizeof(f_range_t), (void **) &found->depth[depth].array[position].content.array, &found->depth[depth].array[position].content.used, &found->depth[depth].array[position].content.size);
- if (F_status_is_error(state->status)) break;
+ if (F_status_is_error_not(state->status)) {
+ state->status = f_memory_array_resize(1, sizeof(f_range_t), (void **) &found->depth[depth].array[position].content.array, &found->depth[depth].array[position].content.used, &found->depth[depth].array[position].content.size);
+ }
+ }
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
}
if (depth) {
if (graph_first == 0x2) {
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;
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
delimits->array[delimits->used++] = comment_delimit;
}
if (!depth) {
state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
if (range->start >= buffer.used) {
state->status = F_okay_eos;
if (state->interrupt) {
state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) break;
+
+ if (F_status_set_fine(state->status) == F_interrupt) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
}
if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
if (graph_first == 0x2) {
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;
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
delimits->array[delimits->used++] = comment_delimit;
}
position_previous = range->start;
state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
- } // while
- if (F_status_is_error(state->status)) break;
-
- if (depth) {
- if (range->start >= buffer.used || range->start > range->stop) {
+ if (F_status_is_error(state->status)) {
delimits->used = delimits_used;
comments->used = comments_used;
- state->status = (range->start >= buffer.used) ? F_end_not_nest_eos : F_end_not_nest_stop;
-
return;
}
- }
- else {
- if (range->start >= buffer.used || range->start > range->stop) {
- delimits->used = delimits_used;
- comments->used = comments_used;
+ } // while
- state->status = (range->start >= buffer.used) ? F_data_not_eos : F_data_not_stop;
+ if (range->start >= buffer.used || range->start > range->stop) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
- return;
+ if (depth) {
+ state->status = (range->start >= buffer.used) ? F_end_not_nest_eos : F_end_not_nest_stop;
+ }
+ else {
+ state->status = (range->start >= buffer.used) ? F_data_not_eos : F_data_not_stop;
}
+
+ return;
}
}
}
position = (buffer.string[newline_last] == f_string_eol_s.string[0]) ? newline_last + 1 : newline_last;
f_fss_seek_to_eol(buffer, range, state);
- if (F_status_is_error(state->status)) break;
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
if (range->start > range->stop || range->start >= buffer.used) {
--range->start;
else {
if (graph_first == 0x2) {
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;
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
delimits->array[delimits->used++] = comment_delimit;
}
}
state->status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &comments->array, &comments->used, &comments->size);
- if (F_status_is_error(state->status)) break;
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
comments->array[comments->used].start = position;
comments->array[comments->used++].stop = range->start++;
if (graph_first == 0x1) {
if (f_fss_is_space(buffer, *range, state) == F_false) {
- if (F_status_is_error(state->status)) break;
-
graph_first = 0x0;
}
}
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
+ if (F_status_is_error_not(state->status)) {
+ state->status = f_utf_buffer_increment(buffer, range, 1);
+ }
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
if (range->start >= buffer.used || range->start > range->stop) break;
position_previous = range->start;
state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ comments->used = comments_used;
+
+ return;
+ }
} // while
delimits->used = delimits_used;
comments->used = comments_used;
- if (F_status_is_error(state->status)) return;
-
if (range->start > range->stop) {
state->status = F_status_set_error(depth ? F_end_not_nest_stop : F_end_not_stop);
-
- return;
}
-
- state->status = F_status_set_error(depth ? F_end_not_nest_eos : F_end_not_eos);
+ else {
+ state->status = F_status_set_error(depth ? F_end_not_nest_eos : F_end_not_eos);
+ }
}
#endif // _di_fl_fss_embedded_list_content_read_
range->start = start + 1;
- private_fl_fss_basic_list_write_add_until_end(content, range, destination, state);
+ private_fl_fss_list_write_add_until_end(content, range, destination, state);
if (F_status_is_error(state->status)) break;
if (content.string[range->start] != f_fss_eol_s.string[0]) {
range->start = start + 1;
- private_fl_fss_basic_list_write_add_until_end(content, range, destination, state);
+ private_fl_fss_list_write_add_until_end(content, range, destination, state);
if (F_status_is_error(state->status)) break;
continue;
}
#endif // _di_level_1_parameter_checking_
- const f_number_unsigned_t delimits_used = delimits->used;
-
- f_fss_skip_past_space(buffer, range, state);
- if (F_status_is_error(state->status)) return;
- if (state->status == F_data_not) return;
-
- if (state->status == F_okay_eol) {
-
- // Move the start position to after the EOL.
- ++range->start;
- state->status = F_fss_found_object_not;
-
- 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;
-
- return;
- }
-
- // Return found nothing if this line only contains white space and delimit placeholders.
- if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
-
- // Move the start position to after the EOL.
- ++range->start;
- state->status = F_fss_found_object_not;
-
- 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]) {
- f_fss_seek_to_eol(buffer, range, state);
-
- 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;
-
- return;
- }
-
- // Move the start position to after the EOL.
- ++range->start;
- state->status = F_fss_found_object_not;
-
- return;
- }
-
- f_number_unsigned_t start = 0;
- f_number_unsigned_t stop = 0;
- f_number_unsigned_t slash_first = 0;
- f_number_unsigned_t slash_count = 0;
-
- bool 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 (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) break;
- }
-
- if (buffer.string[range->start] == f_fss_slash_s.string[0]) {
- slash_first = range->start;
- slash_count = 1;
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
-
- while (range->start <= range->stop && range->start < buffer.used && (buffer.string[range->start] == f_fss_placeholder_s.string[0] || buffer.string[range->start] == f_fss_slash_s.string[0])) {
-
- if (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) break;
- }
-
- if (buffer.string[range->start] == f_fss_slash_s.string[0]) slash_count++;
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
- } // while
-
- if (F_status_is_error(state->status)) break;
-
- 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;
- }
-
- return;
- }
-
- if (buffer.string[range->start] == f_fss_embedded_list_open_s.string[0]) {
- graph_first = F_false;
- stop = range->start++;
-
- while (range->start <= range->stop && range->start < buffer.used) {
-
- if (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) break;
- }
-
- if (buffer.string[range->start] == f_fss_eol_s.string[0]) break;
-
- if (f_fss_is_graph(buffer, *range, state) == F_false) {
- if (F_status_is_error(state->status)) break;
- }
- else {
- break;
- }
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
- } // while
-
- 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;
- }
-
- return;
- }
-
- if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
- start = 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)) break;
-
- if (slash_count % 2 == 0) {
- while (slash_count > 0) {
-
- if (buffer.string[range->start] == f_fss_slash_s.string[0]) {
- if (slash_count % 2 == 1) {
- delimits->array[delimits->used++] = range->start;
- }
-
- --slash_count;
- }
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
- } // while
-
- if (F_status_is_error(state->status)) break;
-
- if (stop > begin) {
- found->stop = stop - 1;
- }
- else {
- found->start = 1;
- found->stop = 0;
- }
-
- range->start = start + 1;
- state->status = F_fss_found_object;
-
- return;
- }
-
- range->start = start + 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;
-
- // 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;
- }
- else {
- graph_first = F_false;
- }
-
- continue;
- }
- else if (buffer.string[range->start] == f_fss_embedded_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;
-
- while (range->start <= range->stop && range->start < buffer.used) {
-
- if (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) 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_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
- } // while
-
- if (F_status_is_error(state->status)) break;
-
- 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;
-
- 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;
- }
-
- // Move the start position to after the EOL.
- ++range->start;
- state->status = F_fss_found_object;
-
- return;
- }
-
- continue;
- }
- else if (graph_first) {
- if (f_fss_is_space(buffer, *range, state) == F_false) {
- if (F_status_is_error(state->status)) break;
-
- graph_first = F_false;
- }
- }
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
- } // while
-
- if (F_status_is_error(state->status)) {
- delimits->used = delimits_used;
-
- return;
- }
-
- // Seek to the end of the line when no valid object is found.
- while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol_s.string[0]) {
-
- if (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) break;
- }
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
-
- if (F_status_is_error(state->status)) {
- delimits->used = delimits_used;
-
- return;
- }
- } // while
-
- 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;
- }
-
- return;
- }
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
-
- if (F_status_is_error(state->status)) {
- delimits->used = delimits_used;
-
- return;
- }
-
- state->status = F_fss_found_object_not;
+ return private_fl_fss_list_object_read(f_fss_embedded_list_open_s, buffer, range, found, delimits, state);
}
#endif // _di_fl_fss_embedded_list_object_read_
if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_trim_e) {
if (complete == f_fss_complete_full_trim_e || complete == f_fss_complete_trim_e) {
- private_fl_fss_basic_list_write_object_trim(destination_used, destination, state);
+ private_fl_fss_list_write_object_trim(destination_used, destination, state);
if (F_status_is_error(state->status)) {
destination->used = destination_used;
uint8_t content_found = 0;
uint8_t quote = f_fss_quote_type_none_e;
+ f_range_t content_partial = f_range_t_initialize;
f_status_t status = F_okay;
while (range->start <= range->stop && range->start < buffer.used) {
- f_range_t content_partial = f_range_t_initialize;
+ content_partial.start = 1;
+ content_partial.stop = 0;
private_fl_fss_basic_or_extended_read(buffer, (state->flag & f_fss_state_quote_not_e) ? 0x2 : 0x0, range, &content_partial, "e, delimits, state);
#include "extended_list.h"
#include "../private-fss.h"
+#include "../private-fss-list.h"
#ifdef __cplusplus
extern "C" {
}
#endif // _di_level_1_parameter_checking_
- const f_number_unsigned_t delimits_used = delimits->used;
- const f_number_unsigned_t comments_used = comments->used;
-
f_fss_skip_past_delimit(buffer, range, state);
- if (F_status_is_error(state->status)) return;
- if (state->status == F_data_not) return;
+ if (F_status_is_error(state->status) || state->status == F_data_not) return;
if (range->start >= buffer.used || range->start > range->stop) {
- delimits->used = delimits_used;
- comments->used = comments_used;
-
if (range->start >= buffer.used) {
found->array[found->used].stop = buffer.used - 1;
state->status = F_okay_eos;
state->status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &found->array, &found->used, &found->size);
if (F_status_is_error(state->status)) return;
- found->array[found->used].start = range->start;
+ const f_number_unsigned_t delimits_used = delimits->used;
+ const f_number_unsigned_t comments_used = comments->used;
f_number_unsigned_t line_start = range->start;
f_number_unsigned_t newline_last = range->start;
f_number_unsigned_t slash_count = 0;
f_number_unsigned_t comment_start = 0;
+ found->array[found->used].start = range->start;
+
// Identify where the content ends.
while (range->start <= range->stop && range->start < buffer.used) {
range->start = start + 1;
- private_fl_fss_basic_list_write_add_until_end(content, range, destination, state);
+ private_fl_fss_list_write_add_until_end(content, range, destination, state);
if (F_status_is_error(state->status)) break;
if (content.string[range->start] != f_fss_eol_s.string[0]) {
range->start = start + 1;
- private_fl_fss_basic_list_write_add_until_end(content, range, destination, state);
+ private_fl_fss_list_write_add_until_end(content, range, destination, state);
if (F_status_is_error(state->status)) break;
continue;
}
#endif // _di_level_1_parameter_checking_
- const f_number_unsigned_t delimits_used = delimits->used;
-
- f_fss_skip_past_space(buffer, range, state);
- if (F_status_is_error(state->status)) return;
- if (state->status == F_data_not) return;
-
- if (state->status == F_okay_eol) {
-
- // Move the start position to after the EOL.
- ++range->start;
- state->status = F_fss_found_object_not;
-
- 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;
-
- return;
- }
-
- // Return found nothing if this line only contains white space and delimit placeholders.
- if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
-
- // Move the start position to after the EOL.
- ++range->start;
- state->status = F_fss_found_object_not;
-
- 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]) {
- f_fss_seek_to_eol(buffer, range, state);
-
- 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;
-
- return;
- }
-
- // Move the start position to after the EOL.
- ++range->start;
- state->status = F_fss_found_object_not;
-
- return;
- }
-
- f_number_unsigned_t start = 0;
- f_number_unsigned_t stop = 0;
- f_number_unsigned_t slash_first = 0;
- f_number_unsigned_t slash_count = 0;
-
- 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 (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) break;
- }
-
- if (buffer.string[range->start] == f_fss_slash_s.string[0]) {
- slash_first = range->start;
- slash_count = 1;
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
-
- while (range->start <= range->stop && range->start < buffer.used && (buffer.string[range->start] == f_fss_placeholder_s.string[0] || buffer.string[range->start] == f_fss_slash_s.string[0])) {
-
- if (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) break;
- }
-
- if (buffer.string[range->start] == f_fss_slash_s.string[0]) ++slash_count;
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
- } // while
-
- if (F_status_is_error(state->status)) break;
-
- 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;
- }
-
- return;
- }
-
- if (buffer.string[range->start] == f_fss_extended_list_open_s.string[0]) {
- graph_first = F_false;
- stop = range->start++;
-
- while (range->start <= range->stop && range->start < buffer.used) {
-
- if (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) break;
- }
-
- if (buffer.string[range->start] == f_fss_eol_s.string[0]) break;
-
- if (f_fss_is_graph(buffer, *range, state) == F_false) {
- if (F_status_is_error(state->status)) break;
- }
- else {
- break;
- }
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
- } // while
-
- 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 {
- if (stop > begin) {
- found->stop = stop - 1;
- }
- else {
- found->start = 1;
- found->stop = 0;
- }
-
- state->status = F_data_not_stop;
- }
-
- return;
- }
-
- if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
- start = 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)) break;
-
- if (slash_count % 2 == 0) {
- while (slash_count > 0) {
-
- if (buffer.string[range->start] == f_fss_slash_s.string[0]) {
- if (slash_count % 2 == 1) {
- delimits->array[delimits->used++] = range->start;
- }
-
- --slash_count;
- }
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
- } // while
-
- if (F_status_is_error(state->status)) break;
-
- if (stop > begin) {
- found->stop = stop - 1;
- }
- else {
- found->start = 1;
- found->stop = 0;
- }
-
- range->start = start + 1;
- state->status = F_fss_found_object;
-
- return;
- }
-
- range->start = start + 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;
-
- // 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;
- }
- else {
- graph_first = F_false;
- }
-
- continue;
- }
- else if (buffer.string[range->start] == f_fss_extended_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;
-
- while (range->start <= range->stop && range->start < buffer.used) {
-
- if (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) 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_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
- } // while
-
- if (F_status_is_error(state->status)) break;
-
- 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;
-
- 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;
- }
-
- // Move the start position to after the EOL.
- ++range->start;
- state->status = F_fss_found_object;
-
- return;
- }
-
- continue;
- }
- else if (graph_first) {
- if (f_fss_is_space(buffer, *range, state) == F_false) {
- if (F_status_is_error(state->status)) break;
-
- graph_first = F_false;
- }
- }
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
- } // while
-
- if (F_status_is_error(state->status)) {
- delimits->used = delimits_used;
-
- return;
- }
-
- // Seek to the end of the line when no valid object is found.
- while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol_s.string[0]) {
-
- if (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) break;
- }
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
-
- if (F_status_is_error(state->status)) {
- delimits->used = delimits_used;
-
- return;
- }
- } // while
-
- 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;
- }
-
- return;
- }
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
-
- if (F_status_is_error(state->status)) {
- delimits->used = delimits_used;
-
- return;
- }
-
- state->status = F_fss_found_object_not;
+ return private_fl_fss_list_object_read(f_fss_extended_list_open_s, buffer, range, found, delimits, state);
}
#endif // _di_fl_fss_extended_list_object_read_
if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_trim_e) {
if (complete == f_fss_complete_full_trim_e || complete == f_fss_complete_trim_e) {
- private_fl_fss_basic_list_write_object_trim(destination_used, destination, state);
+ private_fl_fss_list_write_object_trim(destination_used, destination, state);
if (F_status_is_error(state->status)) {
destination->used = destination_used;
--- /dev/null
+#include "fss.h"
+#include "private-fss-list.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if !defined(_di_fl_fss_basic_list_object_read_) || !defined(_di_fl_fss_embedded_list_object_read_) || !defined(_di_fl_fss_extended_list_object_read_)
+ void private_fl_fss_list_object_read(const f_string_static_t list_open, const f_string_static_t buffer, f_range_t * const range, f_range_t * const found, f_number_unsigneds_t * const delimits, f_state_t * const state) {
+
+ f_fss_skip_past_space(buffer, range, state);
+ if (F_status_is_error(state->status) || state->status == F_data_not) return;
+
+ if (state->status == F_okay_eol) {
+
+ // Move the start position to after the EOL.
+ ++range->start;
+ state->status = F_fss_found_object_not;
+
+ return;
+ }
+
+ 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;
+ }
+
+ // Return found nothing if this line only contains white space and delimit placeholders.
+ if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
+
+ // Move the start position to after the EOL.
+ ++range->start;
+ state->status = F_fss_found_object_not;
+
+ return;
+ }
+
+ // Ignore all comment lines.
+ if (buffer.string[range->start] == f_fss_comment_s.string[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_okay_stop) {
+ state->status = state->status == F_okay_eos ? F_data_not_eos : F_data_not_stop;
+
+ return;
+ }
+
+ // Move the start position to after the EOL.
+ ++range->start;
+ state->status = F_fss_found_object_not;
+
+ return;
+ }
+
+ const f_number_unsigned_t delimits_used = delimits->used;
+
+ f_number_unsigned_t slash_first = 0;
+ f_number_unsigned_t slash_count = 0;
+ f_number_unsigned_t start = 1;
+ f_number_unsigned_t stop = 0;
+
+ uint8_t graph_first = F_true;
+
+ found->start = range->start;
+
+ // 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 (state->interrupt) {
+ state->interrupt((void *) state, 0);
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+
+ return;
+ }
+ }
+
+ if (buffer.string[range->start] == f_fss_slash_s.string[0]) {
+ slash_first = range->start++;
+ slash_count = 1;
+
+ for (; range->start <= range->stop && range->start < buffer.used && (buffer.string[range->start] == f_fss_placeholder_s.string[0] || buffer.string[range->start] == f_fss_slash_s.string[0]); ++range->start) {
+
+ if (state->interrupt) {
+ state->interrupt((void *) state, 0);
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+
+ return;
+ }
+ }
+
+ if (buffer.string[range->start] == f_fss_slash_s.string[0]) ++slash_count;
+ } // for
+
+ 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;
+ }
+
+ return;
+ }
+
+ if (buffer.string[range->start] == list_open.string[0]) {
+ graph_first = F_false;
+ stop = range->start++;
+
+ while (range->start <= range->stop && range->start < buffer.used) {
+
+ if (state->interrupt) {
+ state->interrupt((void *) state, 0);
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+
+ return;
+ }
+ }
+
+ if (buffer.string[range->start] == f_fss_eol_s.string[0] || f_fss_is_space(buffer, *range, state) == F_false) break;
+
+ state->status = f_utf_buffer_increment(buffer, range, 1);
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+
+ return;
+ }
+ } // while
+
+ 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;
+ }
+
+ return;
+ }
+
+ if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
+ 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)) {
+ range->start = found->stop;
+ delimits->used = delimits_used;
+
+ return;
+ }
+
+ if (slash_count % 2 == 0) {
+ while (slash_count > 0) {
+
+ if (buffer.string[range->start] == f_fss_slash_s.string[0]) {
+ if (slash_count % 2 == 1) {
+ delimits->array[delimits->used++] = range->start;
+ }
+
+ --slash_count;
+ ++range->start;
+ }
+ else {
+ state->status = f_utf_buffer_increment(buffer, range, 1);
+
+ if (F_status_is_error(state->status)) {
+ range->start = found->stop;
+ delimits->used = delimits_used;
+
+ return;
+ }
+ }
+ } // while
+
+ 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;
+ }
+ else {
+ 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]) {
+ 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)) {
+ range->start = found->stop;
+ delimits->used = delimits_used;
+
+ return;
+ }
+
+ delimits->array[delimits->used++] = slash_first;
+ stop = range->start++;
+ }
+ else {
+ graph_first = F_false;
+ stop = range->start;
+ }
+
+ continue;
+ }
+
+ if (buffer.string[range->start] == list_open.string[0]) {
+ ++range->start;
+
+ while (range->start <= range->stop && range->start < buffer.used) {
+
+ if (state->interrupt) {
+ state->interrupt((void *) state, 0);
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+
+ return;
+ }
+ }
+
+ if (buffer.string[range->start] == f_fss_eol_s.string[0] || f_fss_is_space(buffer, *range, state) == F_false) break;
+
+ state->status = f_utf_buffer_increment(buffer, range, 1);
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+
+ return;
+ }
+ } // 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;
+
+ return;
+ }
+
+ if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
+ 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 (f_fss_is_space(buffer, *range, state) == F_false) {
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+
+ return;
+ }
+
+ if (graph_first) {
+ graph_first = F_false;
+ start = range->start;
+ }
+
+ stop = range->start;
+ }
+ }
+
+ state->status = f_utf_buffer_increment(buffer, range, 1);
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+
+ return;
+ }
+ } // while
+
+ if (range->start >= buffer.used) {
+ found->stop = buffer.used - 1;
+ state->status = F_data_not_eos;
+
+ return;
+ }
+
+ if (range->start > range->stop) {
+ found->stop = range->stop;
+ state->status = F_data_not_stop;
+
+ return;
+ }
+
+ // Seek to the end of the line when no valid object is found.
+ f_fss_seek_to_eol(buffer, range, state);
+
+ if (F_status_is_error(state->status)) {
+ delimits->used = delimits_used;
+ }
+ else {
+ state->status = F_fss_found_object_not;
+
+ // Move the start position to after the EOL.
+ ++range->start;
+ }
+ }
+#endif // !defined(_di_fl_fss_basic_list_object_read_) || !defined(_di_fl_fss_embedded_list_object_read_) || !defined(_di_fl_fss_extended_list_object_read_)
+
+#if !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_list_content_write_) || !defined(_di_fl_fss_embedded_list_content_write_)
+ void private_fl_fss_list_write_add_until_end(const f_string_static_t buffer, f_range_t * const range, f_string_dynamic_t * const destination, f_state_t * const state) {
+
+ state->status = F_okay;
+
+ for (; range->start <= range->stop && range->start < buffer.used; ++range->start) {
+
+ if (state->interrupt) {
+ state->interrupt((void *) state, 0);
+ if (F_status_set_fine(state->status) == F_interrupt) return;
+ }
+
+ if (buffer.string[range->start] == f_fss_placeholder_s.string[0]) continue;
+ if (buffer.string[range->start] == f_fss_eol_s.string[0]) break;
+
+ state->status = f_memory_array_increase(state->step_large, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+ if (F_status_is_error(state->status)) break;
+
+ destination->string[destination->used++] = buffer.string[range->start];
+ } // for
+ }
+#endif // !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_list_content_write_) || !defined(_di_fl_fss_embedded_list_content_write_)
+
+#if !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_extended_list_object_write_)
+ void private_fl_fss_list_write_object_trim(const f_number_unsigned_t used_start, f_string_dynamic_t * const destination, f_state_t * const state) {
+
+ f_range_t destination_range = macro_f_range_t_initialize_2(destination->used);
+ f_number_unsigned_t i = 0;
+ uint8_t width = 0;
+
+ state->status = F_okay;
+
+ for (; destination_range.start < destination->used; ++destination_range.start) {
+
+ if (state->interrupt) {
+ state->interrupt((void *) state, 0);
+ if (F_status_set_fine(state->status) == F_interrupt) return;
+ }
+
+ if (destination->string[destination_range.start] == f_fss_placeholder_s.string[0]) continue;
+
+ if (f_fss_is_space(*destination, destination_range, state) == F_false) {
+ if (F_status_is_error(state->status)) {
+ destination->used = used_start;
+
+ return;
+ }
+
+ break;
+ }
+
+ width = macro_f_utf_byte_width(destination->string[destination_range.start]);
+
+ for (i = 0; i < width; ++i) {
+ destination->string[destination_range.start + i] = f_fss_placeholder_s.string[0];
+ } // for
+ } // for
+
+ for (destination_range.start = destination->used - 1; destination_range.start > 0; --destination_range.start) {
+
+ if (state->interrupt) {
+ state->interrupt((void *) state, 0);
+ if (F_status_set_fine(state->status) == F_interrupt) return;
+ }
+
+ if (destination->string[destination_range.start] == f_fss_placeholder_s.string[0]) {
+ --destination->used;
+
+ continue;
+ }
+
+ if (f_fss_is_space(*destination, destination_range, state) == F_false) {
+
+ // When going backwards, getting incomplete UTF-8 sequences is not an error.
+ if (F_status_set_fine(state->status) == F_complete_not_utf) continue;
+
+ if (F_status_is_error(state->status)) {
+ destination->used = used_start;
+
+ return;
+ }
+
+ break;
+ }
+
+ destination->used -= macro_f_utf_byte_width(destination->string[destination_range.start]);
+ } // for
+
+ if (destination_range.start == 0) {
+ if (f_fss_is_space(*destination, destination_range, state) == F_false) {
+ if (F_status_is_error(state->status)) {
+ destination->used = used_start;
+
+ return;
+ }
+ }
+ else {
+ destination->used = 0;
+ }
+ }
+
+ state->status = F_okay;
+ }
+#endif // !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_extended_list_object_write_)
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 1
+ *
+ * Project: FSS
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * These are provided for internal reduction in redundant code.
+ * These should not be exposed/used outside of this project.
+ */
+#ifndef _PRIVATE_FL_fss_list_h
+#define _PRIVATE_FL_fss_list_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Read a standard list Object where the list open is specific to a given FSS standard.
+ *
+ * This will record where delimit placeholders exist but will not apply the delimits.
+ *
+ * @param list_open
+ * The list open character for the given standard.
+ * This must be defined where list_open.used = 1.
+ * @param buffer
+ * The buffer to read from.
+ * @param range
+ * The start/stop location within the buffer to be processed.
+ * The start location will be updated as the buffer is being processed.
+ * The start location will represent where the read stopped on return.
+ * A start location past the stop location or buffer used means that the entire range was processed.
+ *
+ * Must not be NULL.
+ * @param found
+ * A location where a valid Object is found.
+ *
+ * Must not be NULL.
+ * @param delimits
+ * A delimits array representing where delimits exist within the buffer.
+ *
+ * Must not be NULL.
+ * @param state
+ * A state for providing flags and handling interrupts during long running operations.
+ * There is no state.handle().
+ * There is no "callbacks" structure.
+ * There is no data structure passed to these functions.
+ *
+ * When state.interrupt() returns, only F_interrupt and F_interrupt_not are processed.
+ * Error bit designates an error but must be passed along with F_interrupt.
+ * All other statuses are ignored.
+ *
+ * Must not be NULL.
+ *
+ * This alters state.status:
+ * 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).
+ * F_end_not_group_eos if EOS was reached before the a group termination was reached.
+ * F_end_not_group_stop if stop point was reached before the a group termination was reached.
+ *
+ * F_interrupt (with error bit) if stopping due to an interrupt.
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_fss_is_graph().
+ * Errors (with error bit) from: f_fss_is_space().
+ * Errors (with error bit) from: f_fss_is_zero_width().
+ * Errors (with error bit) from: f_fss_seek_to_eol().
+ * Errors (with error bit) from: f_fss_skip_past_delimit().
+ * Errors (with error bit) from: f_fss_skip_past_space().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ * Errors (with error bit) from: f_utf_buffer_increment().
+ *
+ * @see f_fss_is_graph()
+ * @see f_fss_is_space()
+ * @see f_fss_is_zero_width()
+ * @see f_fss_seek_to_eol()
+ * @see f_fss_skip_past_delimit()
+ * @see f_fss_skip_past_space()
+ * @see f_memory_array_increase_by()
+ * @see f_utf_buffer_increment()
+ *
+ * @see fl_fss_basic_list_object_read()
+ * @see fl_fss_embedded_list_object_read()
+ * @see fl_fss_extended_list_object_read()
+ */
+#if !defined(_di_fl_fss_basic_list_object_read_) || !defined(_di_fl_fss_embedded_list_object_read_) || !defined(_di_fl_fss_extended_list_object_read_)
+ extern void private_fl_fss_list_object_read(const f_string_static_t list_open, const f_string_static_t buffer, f_range_t * const range, f_range_t * const found, f_number_unsigneds_t * const delimits, f_state_t * const state) F_attribute_visibility_internal_d;
+#endif // !defined(_di_fl_fss_basic_list_object_read_) || !defined(_di_fl_fss_embedded_list_object_read_) || !defined(_di_fl_fss_extended_list_object_read_)
+
+/**
+ * Add all bytes to destination until stop point, buffer end, or EOL.
+ *
+ * @param buffer
+ * The buffer to seek through.
+ * @param range
+ * The start/stop location within the buffer string to process.
+ * @param destination
+ * The buffer where the bytes are written to.
+ * @param state
+ * A state for providing flags and handling interrupts during long running operations.
+ * There is no state.handle().
+ * There is no "callbacks" structure.
+ * There is no data structure passed to these functions.
+ *
+ * When state.interrupt() returns, only F_interrupt and F_interrupt_not are processed.
+ * Error bit designates an error but must be passed along with F_interrupt.
+ * All other statuses are ignored.
+ *
+ * This alters state.status:
+ * F_okay on success.
+ *
+ * F_interrupt (with error bit) if stopping due to an interrupt.
+ *
+ * Errors (with error bit) from: f_memory_array_increase().
+ *
+ * @see f_memory_array_increase()
+ * @see fl_fss_basic_list_content_write()
+ * @see fl_fss_embedded_list_content_write()
+ * @see fl_fss_extended_list_content_write()
+ */
+#if !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_list_content_write_) || !defined(_di_fl_fss_embedded_list_content_write_)
+ extern void private_fl_fss_list_write_add_until_end(const f_string_static_t buffer, f_range_t * const range, f_string_dynamic_t * const destination, f_state_t * const state) F_attribute_visibility_internal_d;
+#endif // !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_list_content_write_) || !defined(_di_fl_fss_embedded_list_content_write_)
+
+/**
+ * Trim a given object used by the basic list and extended list object write functions.
+ *
+ * @param used_start
+ * The destination.used value before any operations were performed.
+ * @param destination
+ * The buffer where the object is written to.
+ * @param state
+ * A state for providing flags and handling interrupts during long running operations.
+ * There is no state.handle().
+ * There is no "callbacks" structure.
+ * There is no data structure passed to these functions.
+ *
+ * When state.interrupt() returns, only F_interrupt and F_interrupt_not are processed.
+ * Error bit designates an error but must be passed along with F_interrupt.
+ * All other statuses are ignored.
+ *
+ * This alters state.status:
+ * F_okay on success.
+ *
+ * F_interrupt (with error bit) if stopping due to an interrupt.
+ *
+ * Errors (with error bit) from: f_fss_is_space().
+ *
+ * @see f_fss_is_space()
+ * @see fl_fss_basic_list_object_write()
+ * @see fl_fss_extended_list_object_write()
+ */
+#if !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_extended_list_object_write_)
+ extern void private_fl_fss_list_write_object_trim(const f_number_unsigned_t used_start, f_string_dynamic_t * const destination, f_state_t * const state) F_attribute_visibility_internal_d;
+#endif // !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_extended_list_object_write_)
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _PRIVATE_FL_fss_list_h
extern "C" {
#endif
-#if !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_list_content_write_) || !defined(_di_fl_fss_embedded_list_content_write_)
- void private_fl_fss_basic_list_write_add_until_end(const f_string_static_t buffer, f_range_t * const range, f_string_dynamic_t * const destination, f_state_t * const state) {
-
- state->status = F_okay;
-
- for (; range->start <= range->stop && range->start < buffer.used; ++range->start) {
-
- if (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) return;
- }
-
- if (buffer.string[range->start] == f_fss_placeholder_s.string[0]) continue;
- if (buffer.string[range->start] == f_fss_eol_s.string[0]) break;
-
- state->status = f_memory_array_increase(state->step_large, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
- if (F_status_is_error(state->status)) break;
-
- destination->string[destination->used++] = buffer.string[range->start];
- } // for
- }
-#endif // !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_list_content_write_) || !defined(_di_fl_fss_embedded_list_content_write_)
-
-#if !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_extended_list_object_write_)
- void private_fl_fss_basic_list_write_object_trim(const f_number_unsigned_t used_start, f_string_dynamic_t * const destination, f_state_t * const state) {
-
- f_range_t destination_range = macro_f_range_t_initialize_2(destination->used);
- f_number_unsigned_t i = 0;
- uint8_t width = 0;
-
- state->status = F_okay;
-
- for (; destination_range.start < destination->used; ++destination_range.start) {
-
- if (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) return;
- }
-
- if (destination->string[destination_range.start] == f_fss_placeholder_s.string[0]) continue;
-
- if (f_fss_is_space(*destination, destination_range, state) == F_false) {
- if (F_status_is_error(state->status)) {
- destination->used = used_start;
-
- return;
- }
-
- break;
- }
-
- width = macro_f_utf_byte_width(destination->string[destination_range.start]);
-
- for (i = 0; i < width; ++i) {
- destination->string[destination_range.start + i] = f_fss_placeholder_s.string[0];
- } // for
- } // for
-
- for (destination_range.start = destination->used - 1; destination_range.start > 0; --destination_range.start) {
-
- if (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) return;
- }
-
- if (destination->string[destination_range.start] == f_fss_placeholder_s.string[0]) {
- --destination->used;
-
- continue;
- }
-
- if (f_fss_is_space(*destination, destination_range, state) == F_false) {
-
- // When going backwards, getting incomplete UTF-8 sequences is not an error.
- if (F_status_set_fine(state->status) == F_complete_not_utf) continue;
-
- if (F_status_is_error(state->status)) {
- destination->used = used_start;
-
- return;
- }
-
- break;
- }
-
- destination->used -= macro_f_utf_byte_width(destination->string[destination_range.start]);
- } // for
-
- if (destination_range.start == 0) {
- if (f_fss_is_space(*destination, destination_range, state) == F_false) {
- if (F_status_is_error(state->status)) {
- destination->used = used_start;
-
- return;
- }
- }
- else {
- destination->used = 0;
- }
- }
-
- state->status = F_okay;
- }
-#endif // !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_extended_list_object_write_)
-
#if !defined(_di_fl_fss_basic_object_read_) || !defined(_di_fl_fss_extended_object_read_) || !defined(_di_fl_fss_extended_content_read_)
void private_fl_fss_basic_or_extended_read(const f_string_static_t buffer, const uint8_t flag, f_range_t * const range, f_range_t * const found, uint8_t * const quote, f_number_unsigneds_t * const delimits, f_state_t * const state) {
f_fss_skip_past_space(buffer, range, state);
- if (F_status_is_error(state->status)) return;
- if (state->status == F_data_not) return;
+ if (F_status_is_error(state->status) || state->status == F_data_not) return;
if (state->status == F_okay_eol) {
-
// Move the start position to after the EOL.
++range->start;
state->status = F_fss_found_object_not;
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;
}
// Ignore all comment lines.
if ((flag & 0x1) && buffer.string[range->start] == f_fss_comment_s.string[0]) {
+ f_fss_seek_to_eol(buffer, range, state);
+ if (F_status_is_error(state->status)) return;
- while (buffer.string[range->start] != f_fss_eol_s.string[0]) {
-
- if (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) return;
- }
-
- ++range->start;
-
- if (range->start >= buffer.used) {
- state->status = F_data_not_eos;
-
- return;
- }
-
- if (range->start > range->stop) {
- state->status = F_data_not_stop;
+ if (range->start >= buffer.used || range->start > range->stop) {
+ state->status = range->start >= buffer.used ? F_data_not_eos : F_data_not_stop;
- return;
- }
- } // while
+ return;
+ }
// Move the start position to after the EOL.
++range->start;
// Handle quote support.
f_char_t quote_found = 0;
- if (quote) {
- *quote = f_fss_quote_type_none_e;
- }
+ if (quote) *quote = f_fss_quote_type_none_e;
// Identify where the object begins.
if (buffer.string[range->start] == f_fss_slash_s.string[0]) {
found->start = range->start;
state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) return;
-
- while (range->start <= range->stop && range->start < buffer.used) {
-
- if (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) return;
- }
- if (f_fss_is_zero_width(buffer, *range, state) == F_false) {
- if (F_status_is_error(state->status)) return;
- }
- else {
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
+ if (F_status_is_error_not(state->status)) {
+ while (range->start <= range->stop && range->start < buffer.used) {
- continue;
- }
+ if (state->interrupt) {
+ state->interrupt((void *) state, 0);
+ if (F_status_is_error(state->status)) return;
+ }
- if (buffer.string[range->start] != f_fss_slash_s.string[0]) {
- if (f_fss_is_space(buffer, *range, state) == F_false) {
+ if (f_fss_is_zero_width(buffer, *range, state) == F_false) {
if (F_status_is_error(state->status)) return;
}
+ else {
+ state->status = f_utf_buffer_increment(buffer, range, 1);
+ if (F_status_is_error(state->status)) return;
- // Found the end of the object while processing the slash for potential delimits.
- if (state->status == F_true) {
- if (range->start > begin) {
- found->stop = range->start - 1;
- }
- else {
- found->start = 1;
- found->stop = 0;
+ continue;
+ }
+
+ if (buffer.string[range->start] != f_fss_slash_s.string[0]) {
+ if (f_fss_is_space(buffer, *range, state) == F_false) {
+ if (F_status_is_error(state->status)) return;
}
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
+ // Found the end of the object while processing the slash for potential delimits.
+ if (state->status == F_true) {
+ if (range->start > begin) {
+ found->stop = range->start - 1;
+ }
+ else {
+ found->start = 1;
+ found->stop = 0;
+ }
- if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
- state->status = F_fss_found_object_content_not;
+ state->status = f_utf_buffer_increment(buffer, range, 1);
+
+ if (F_status_is_error_not(state->status)) {
+ state->status = buffer.string[range->start] == f_fss_eol_s.string[0] ? F_fss_found_object_content_not : F_fss_found_object;
+ }
return;
}
- state->status = F_fss_found_object;
-
- return;
+ break;
}
- break;
- }
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
- } // while
-
- if (F_status_is_error(state->status)) return;
+ state->status = f_utf_buffer_increment(buffer, range, 1);
+ if (F_status_is_error(state->status)) return;
+ } // while
+ }
if (range->start >= buffer.used) {
found->stop = buffer.used - 1;
if (F_status_is_error(state->status)) return;
delimits->array[delimits->used++] = first_slash;
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) return;
+ ++range->start;
}
}
else if (!(flag & 0x2) && (buffer.string[range->start] == f_fss_quote_single_s.string[0] || buffer.string[range->start] == f_fss_quote_double_s.string[0] || buffer.string[range->start] == f_fss_quote_grave_s.string[0])) {
quote_found = buffer.string[range->start];
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) return;
-
- found->start = range->start;
+ found->start = ++range->start;
}
// Identify where the object ends.
state->status = f_memory_array_increase_by(slash_count / 2, sizeof(f_number_unsigned_t), (void **) &delimits->array, &delimits->used, &delimits->size);
if (F_status_is_error(state->status)) return;
- while (slash_count > 0) {
+ while (slash_count) {
if (buffer.string[range->start] == f_fss_slash_s.string[0]) {
if (slash_count % 2 == 1) {
}
--slash_count;
+ ++range->start;
+ }
+ else {
+ state->status = f_utf_buffer_increment(buffer, range, 1);
+ if (F_status_is_error(state->status)) return;
}
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) return;
} // while
range->start = location + 1;
if (F_status_is_error(state->status)) return;
}
else {
-
while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol_s.string[0]) {
if (state->interrupt) {
if (F_status_is_error(state->status)) return;
} // while
- if (range->start >= buffer.used) {
- found->stop = buffer.used - 1;
- state->status = F_data_not_eos;
+ if (F_status_is_error_not(state->status)) {
+ if (range->start >= buffer.used) {
+ found->stop = buffer.used - 1;
+ state->status = F_data_not_eos;
- return;
- }
+ return;
+ }
- if (range->start > range->stop) {
- found->stop = range->stop;
- state->status = F_data_not_stop;
+ if (range->start > range->stop) {
+ found->stop = range->stop;
+ state->status = F_data_not_stop;
- return;
- }
+ return;
+ }
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) return;
+ state->status = f_utf_buffer_increment(buffer, range, 1);
+ }
- state->status = F_fss_found_object_not;
+ if (F_status_is_error_not(state->status)) {
+ state->status = F_fss_found_object_not;
+ }
return;
}
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)) return;
- while (slash_count > 0) {
+ while (slash_count) {
if (buffer.string[range->start] == f_fss_slash_s.string[0]) {
if (slash_count % 2 == 1) {
}
--slash_count;
+ ++range->start;
+ }
+ else {
+ state->status = f_utf_buffer_increment(buffer, range, 1);
+ if (F_status_is_error(state->status)) return;
}
-
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) return;
} // while
range->start = location;
if (F_status_is_error(state->status)) return;
}
else {
- state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) return;
+ if (F_status_is_error_not(state->status)) {
+ state->status = f_utf_buffer_increment(buffer, range, 1);
- state->status = F_fss_found_object;
+ if (F_status_is_error_not(state->status)) {
+ state->status = F_fss_found_object;
+ }
+ }
return;
}
}
state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) return;
- state->status = F_fss_found_object_not;
+ if (F_status_is_error_not(state->status)) {
+ state->status = F_fss_found_object_not;
+ }
return;
}
if (state->interrupt) {
state->interrupt((void *) state, 0);
- if (F_status_set_fine(state->status) == F_interrupt) break;
+ if (F_status_set_fine(state->status) == F_interrupt) return;
}
if (f_fss_is_space(buffer, *range, state) == F_false) {
}
state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) break;
+ if (F_status_is_error(state->status)) return;
} // while
- if (F_status_is_error(state->status)) return;
-
if (range->start > begin) {
found->stop = range->start - 1;
}
void private_fl_fss_basic_write(const uint8_t flag, const f_string_static_t object, const uint8_t quote, f_range_t * const range, f_string_dynamic_t * const destination, f_state_t * const state, void * const internal) {
f_fss_skip_past_space(object, range, state);
- if (F_status_is_error(state->status)) return;
- if (state->status == F_data_not) return;
+ if (F_status_is_error(state->status) || state->status == F_data_not) return;
if (state->status == F_okay_eos) {
state->status = F_data_not_eos;
const f_number_unsigned_t input_start = range->start;
const f_number_unsigned_t used_start = destination->used;
- bool quoted_is = F_false;
- bool commented = F_false;
+ uint8_t quoted_is = F_false;
+ uint8_t commented = F_false;
+ uint8_t width = 0;
f_number_unsigned_t item_first = 0;
f_number_unsigned_t item_total = 0;
f_number_unsigned_t i = 0;
- uint8_t width = 0;
-
const f_char_t quote_char = quote ? quote : f_string_ascii_quote_double_s.string[0];
// Use placeholders for potential quote and potential delimited quote to avoid doing things such as memmove().
if (F_status_is_error(state->status)) break;
if (range->start > range->stop || range->start >= object.used) {
-
state->status = f_memory_array_increase_by(item_total + 1, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error(state->status)) break;
f_fss_skip_past_delimit(object, range, state);
if (F_status_is_error(state->status)) return;
- if (range->start > range->stop || range->start >= object.used) {
- quoted_is = F_true;
- }
- else if (object.string[range->start] == object.string[item_first]) {
+ if (range->start > range->stop || range->start >= object.used || object.string[range->start] == object.string[item_first]) {
quoted_is = F_true;
}
else if (f_fss_is_space(object, *range, state) == F_true) {
// The start quote may or may not need to be delimited in this case.
if (destination->string[input_start] == quote_char) {
-
for (i = input_start + macro_f_utf_byte_width(object.string[input_start]); i <= range->stop && i < object.used; i += macro_f_utf_byte_width(object.string[i])) {
if (state->interrupt) {
#endif
/**
- * Add all bytes to destination until stop point, buffer end, or EOL.
- *
- * @param buffer
- * The buffer to seek through.
- * @param range
- * The start/stop location within the buffer string to process.
- * @param destination
- * The buffer where the bytes are written to.
- * @param state
- * A state for providing flags and handling interrupts during long running operations.
- * There is no state.handle().
- * There is no "callbacks" structure.
- * There is no data structure passed to these functions.
- *
- * When state.interrupt() returns, only F_interrupt and F_interrupt_not are processed.
- * Error bit designates an error but must be passed along with F_interrupt.
- * All other statuses are ignored.
- *
- * This alters state.status:
- * F_okay on success.
- *
- * F_interrupt (with error bit) if stopping due to an interrupt.
- *
- * Errors (with error bit) from: f_memory_array_increase().
- *
- * @see f_memory_array_increase()
- * @see fl_fss_basic_list_content_write()
- * @see fl_fss_embedded_list_content_write()
- * @see fl_fss_extended_list_content_write()
- */
-#if !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_list_content_write_) || !defined(_di_fl_fss_embedded_list_content_write_)
- extern void private_fl_fss_basic_list_write_add_until_end(const f_string_static_t buffer, f_range_t * const range, f_string_dynamic_t * const destination, f_state_t * const state) F_attribute_visibility_internal_d;
-#endif // !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_list_content_write_) || !defined(_di_fl_fss_embedded_list_content_write_)
-
-/**
- * Trim a given object used by the basic list and extended list object write functions.
- *
- * @param used_start
- * The destination.used value before any operations were performed.
- * @param destination
- * The buffer where the object is written to.
- * @param state
- * A state for providing flags and handling interrupts during long running operations.
- * There is no state.handle().
- * There is no "callbacks" structure.
- * There is no data structure passed to these functions.
- *
- * When state.interrupt() returns, only F_interrupt and F_interrupt_not are processed.
- * Error bit designates an error but must be passed along with F_interrupt.
- * All other statuses are ignored.
- *
- * This alters state.status:
- * F_okay on success.
- *
- * F_interrupt (with error bit) if stopping due to an interrupt.
- *
- * Errors (with error bit) from: f_fss_is_space().
- *
- * @see f_fss_is_space()
- * @see fl_fss_basic_list_object_write()
- * @see fl_fss_extended_list_object_write()
- */
-#if !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_extended_list_object_write_)
- extern void private_fl_fss_basic_list_write_object_trim(const f_number_unsigned_t used_start, f_string_dynamic_t * const destination, f_state_t * const state) F_attribute_visibility_internal_d;
-#endif // !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_extended_list_object_write_)
-
-/**
* Provide common processing for Basic and Extended Object and Content read.
*
* @param buffer
build_libraries -lc
build_libraries-individual -lf_abstruse -lf_conversion -lf_file -lf_fss -lf_memory -lf_string -lf_type_array -lf_utf
-build_sources_library private-fss.c fss/basic.c fss/basic_list.c fss/embedded_list.c fss/extended.c fss/extended_list.c fss/payload.c fss/private-payload.c fss/private-payload-helper.c
+build_sources_library private-fss.c private-fss-list.c fss/basic.c fss/basic_list.c fss/embedded_list.c fss/extended.c fss/extended_list.c fss/payload.c fss/private-payload.c fss/private-payload-helper.c
build_sources_headers fss.h fss/basic.h fss/basic_list.h fss/embedded_list.h fss/extended.h fss/extended_list.h fss/payload.h fss/payload/define.h fss/payload/type.h
привет has space
-привет has space
+привет has space
d
a
привет
-y
+y
"мир"
привет has space
"This is quoted"
AlsoGood
-hi
-привет has space
+hi
+привет has space
a
also_empty
d
a
привет
-y
+y
"мир"
привет has space
"This is quoted"
AlsoGood
-hi
-привет has space
+hi
+привет has space
a
also_empty
d
a
привет
-y
+y
"мир"
привет has space
"This is quoted"
AlsoGood
-hi
-привет has space
+hi
+привет has space
a
also_empty
d
a
привет
-y
+y
"мир"
привет has space
"This is quoted"
AlsoGood
-hi
-привет has space
+hi
+привет has space
a
also_empty
привет has space{
\"and so does this" "have space"
}
-привет has space {
+привет has space{
...
}
привет{
мир
}
-y {
+y{
z
}
"мир"{
}
AlsoGood{
}
-hi {
+hi{
Check this.
}
-привет has space {
+привет has space{
...
}
a{
привет{
мир
}
-y {
+y{
z
}
"мир"{
}
AlsoGood{
}
-hi {
+hi{
Check this.
}
-привет has space {
+привет has space{
...
}
a{
привет{
мир
}
-y {
+y{
z
}
"мир"{
}
AlsoGood{
}
-hi {
+hi{
Check this.
}
-привет has space {
+привет has space{
...
}
a{
привет{
мир
}
-y {
+y{
z
}
"мир"{
}
AlsoGood{
}
-hi {
+hi{
Check this.
}
-привет has space {
+привет has space{
...
}
a{
}
a{
}
-a {
+a{
}
{
The object name is an empty string.
}
a{
}
-a {
+a{
}
{
The object name is an empty string.
}
a{
}
-a {
+a{
}
{
The object name is an empty string.
}
a{
}
-a {
+a{
}
{
The object name is an empty string.
привет has space
empty
hi
-has spaces
+has spaces
привет has space
empty
hi
-has spaces
+has spaces
привет has space
empty
hi
-has spaces
+has spaces
привет has space
empty
hi
-has spaces
+has spaces
-has spaces {
+has spaces{
yep.
fin
}
привет мир a
}
-has spaces {
+has spaces{
yep.
fin
}
привет мир a
}
-has spaces {
+has spaces{
yep.
fin
}
привет мир a
}
-has spaces {
+has spaces{
yep.
fin
}
привет мир a
}
-has spaces {
+has spaces{
yep.
fin
}
привет has space
-привет has space
+привет has space
d
a
привет
-y
+y
"мир"
привет has space
"This is quoted"
AlsoGood
-hi
-привет has space
+hi
+привет has space
a
also_empty
d
a
привет
-y
+y
"мир"
привет has space
"This is quoted"
AlsoGood
-hi
-привет has space
+hi
+привет has space
a
also_empty
d
a
привет
-y
+y
"мир"
привет has space
"This is quoted"
AlsoGood
-hi
-привет has space
+hi
+привет has space
a
also_empty
d
a
привет
-y
+y
"мир"
привет has space
"This is quoted"
AlsoGood
-hi
-привет has space
+hi
+привет has space
a
also_empty
привет has space{
\"and so does this" "have space"
}
-привет has space {
+привет has space{
...
}
привет{
мир
}
-y {
+y{
z
}
"мир"{
}
AlsoGood{
}
-hi {
+hi{
Check this.
}
-привет has space {
+привет has space{
...
}
a{
привет{
мир
}
-y {
+y{
z
}
"мир"{
}
AlsoGood{
}
-hi {
+hi{
Check this.
}
-привет has space {
+привет has space{
...
}
a{
привет{
мир
}
-y {
+y{
z
}
"мир"{
}
AlsoGood{
}
-hi {
+hi{
Check this.
}
-привет has space {
+привет has space{
...
}
a{
привет{
мир
}
-y {
+y{
z
}
"мир"{
}
AlsoGood{
}
-hi {
+hi{
Check this.
}
-привет has space {
+привет has space{
...
}
a{
}
a{
}
-a {
+a{
}
{
The object name is an empty string.
}
a{
}
-a {
+a{
}
{
The object name is an empty string.
}
a{
}
-a {
+a{
}
{
The object name is an empty string.
}
a{
}
-a {
+a{
}
{
The object name is an empty string.
привет has space
empty
hi
-has spaces
+has spaces
привет has space
empty
hi
-has spaces
+has spaces
привет has space
empty
hi
-has spaces
+has spaces
привет has space
empty
hi
-has spaces
+has spaces
-has spaces {
+has spaces{
yep.
fin
}
привет мир a
}
-has spaces {
+has spaces{
yep.
fin
}
привет мир a
}
-has spaces {
+has spaces{
yep.
fin
}
привет мир a
}
-has spaces {
+has spaces{
yep.
fin
}
привет мир a
}
-has spaces {
+has spaces{
yep.
fin
}