When F_none_eos or F_none_stop is returned, the content ends up having an additional size than the actual size.
This is happening because found->used++ is incremented immediately before returning.
When either F_none_eos or F_none_stop is returned, the content is not to be incremented.
Only the caller should know when to assume this is a proper ending representing the content end.
The macro private_macro_fl_fss_content_return_on_overflow_delimited() is only used in one place so remove it.
Make sure to initialize the content for all content read functions to ensure the content count is consistent.
bool graph_first = F_true;
- // identify where the object ends.
+ // 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) {
return status;
}
- found->array[found->used++].stop = range->start - 1;
+ if (range->start >= buffer.used) {
+ found->array[found->used].stop = buffer.used - 1;
+
+ return F_none_eos;
+ }
+
+ if (range->start > range->stop) {
+ found->array[found->used].stop = range->stop;
- private_macro_fl_fss_content_return_on_overflow_delimited((buffer), (*range), (*found), F_none_eos, F_none_stop);
+ return F_none_stop;
+ }
+
+ found->array[found->used++].stop = range->start - 1;
return F_fss_found_content;
}
}
#endif // _di_macro_fl_fss_content_with_comments_return_on_overflow_
-#ifndef _di_macro_fl_fss_content_return_on_overflow_delimited_
- #define private_macro_fl_fss_content_return_on_overflow_delimited(buffer, range, found, eos_status, stop_status) \
- if (range.start >= buffer.used) { \
- found.array[found.used].stop = buffer.used - 1; \
- return eos_status; \
- } \
- else if (range.start > range.stop) { \
- found.array[found.used].stop = range.stop; \
- return stop_status; \
- }
-#endif // _di_macro_fl_fss_content_return_on_overflow_delimited_
-
#ifndef _di_macro_fl_fss_nest_return_on_overflow_
#define private_macro_fl_fss_nest_return_on_overflow(buffer, range, found, delimits, delimits_used, comments, comments_used, positions, objects, slashes, eos_status, stop_status) \
if (range.start >= buffer.used) { \
if (status == F_fss_found_object) {
found_data = F_true;
+ contents->array[contents->used].used = 0;
+
status = fl_fss_basic_content_read(buffer, state, range, &contents->array[contents->used], contents_delimits ? contents_delimits : objects_delimits);
if (F_status_is_error(status)) return status;
if (status == F_fss_found_object) {
found_data = F_true;
+ contents->array[contents->used].used = 0;
+
status = fl_fss_basic_list_content_read(buffer, state, range, &contents->array[contents->used], contents_delimits ? contents_delimits : objects_delimits, comments);
if (F_status_is_error(status)) return status;
break;
}
- else if (status == F_fss_found_object_content_not) {
+
+ if (status == F_fss_found_object_content_not) {
found_data = F_true;
break;
if (status == F_fss_found_object) {
found_data = F_true;
+ contents->array[contents->used].used = 0;
+
if (contents_quoted) {
status2 = f_uint8s_increase(state.step_small, &contents_quoted->array[contents_quoted->used]);
if (F_status_is_error(status2)) return status2;
}
else if (status == F_fss_found_object_content_not) {
found_data = F_true;
+
break;
}
if (status == F_none_eos || status == F_none_stop) {
contents->array[contents->used].used++;
-
++objects->used;
++contents->used;
if (status == F_fss_found_object) {
found_data = F_true;
+ contents->array[contents->used].used = 0;
+
status = fl_fss_extended_list_content_read(buffer, state, range, &contents->array[contents->used], contents_delimits ? contents_delimits : objects_delimits, comments);
if (F_status_is_error(status)) return status;
if (status == F_fss_found_object) {
found_data = F_true;
+ contents->array[contents->used].used = 0;
+
if (fl_string_dynamic_partial_compare_string(f_fss_string_payload_s.string, buffer, f_fss_string_payload_s.used, objects->array[objects->used]) == F_equal_to) {
status2 = f_string_ranges_increase(state.step_small, &contents->array[contents->used]);
if (F_status_is_error(status)) return status;