When the start position is say, 0, and the determined stop position ends up being 0, then an incorrect stop range is calculated.
This happens because the stop position is subtracting one from the current position.
Add checks to ensure that the stop position is never subtracted beyond the initial start position.
The initial start position is saved at the beginning of each affected FSS read function.
This now potentially returns a start range before the stop range.
The FSS read programs should also need to be updated following this commit to handle these cases.
status = f_string_ranges_increase(state.step_small, found);
if (F_status_is_error(status)) return status;
+ const f_number_unsigned_t begin = range->start;
found->array[found->used].start = range->start;
for (;; ++range->start) {
if (F_status_is_error(status)) return status;
- found->array[found->used++].stop = range->start - 1;
+ if (range->start > begin) {
+ found->array[found->used++].stop = range->start - 1;
+ }
+ else {
+ found->array[found->used].start = 1;
+ found->array[found->used++].stop = 0;
+ }
status = f_utf_buffer_increment(buffer, range, 1);
if (F_status_is_error(status)) return status;
status = f_string_ranges_increase(state.step_small, found);
if (F_status_is_error(status)) return status;
+ const f_number_unsigned_t begin = range->start;
found->array[found->used].start = range->start;
f_array_length_t newline_last = range->start;
return F_none_stop;
}
- found->array[found->used++].stop = range->start - 1;
+ if (range->start > begin) {
+ found->array[found->used++].stop = range->start - 1;
+ }
+ else {
+ found->array[found->used].start = 1;
+ found->array[found->used++].stop = 0;
+ }
return F_fss_found_content;
}
if (status == F_none_stop) return F_data_not_stop;
// 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_basic_list_open_s.string[0]) {
graph_first = F_false;
- stop = range->start - 1;
+ stop = range->start;
status = f_utf_buffer_increment(buffer, range, 1);
if (F_status_is_error(status)) return status;
}
} // while
- found->stop = stop;
+ if (stop > begin) {
+ found->stop = stop - 1;
+ }
+ else {
+ found->start = 1;
+ found->stop = 0;
+ }
+
range->start = start + 1;
return F_fss_found_object;
if (buffer.string[range->start] == f_fss_basic_list_open_s.string[0]) {
graph_first = F_false;
- stop = range->start - 1;
+ stop = range->start;
status = f_utf_buffer_increment(buffer, range, 1);
if (F_status_is_error(status)) break;
private_macro_fl_fss_object_return_on_overflow_delimited((buffer), (*range), (*found), F_none_eos, F_none_stop);
if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
- found->stop = stop;
+ if (stop > begin) {
+ found->stop = stop - 1;
+ }
+ else {
+ found->start = 1;
+ found->stop = 0;
+ }
status = f_utf_buffer_increment(buffer, range, 1);
if (F_status_is_error(status)) break;
}
// 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_embedded_list_open_s.string[0]) {
graph_first = F_false;
- stop = range->start++ - 1;
+ stop = range->start++;
while (range->start <= range->stop && range->start < buffer.used) {
if (F_status_is_error(status)) break;
- found->stop = stop;
+ if (stop > begin) {
+ found->stop = stop - 1;
+ }
+ else {
+ found->start = 1;
+ found->stop = 0;
+ }
+
range->start = start + 1;
return F_fss_found_object;
}
else if (buffer.string[range->start] == f_fss_embedded_list_open_s.string[0]) {
graph_first = F_false;
- stop = range->start - 1;
+ stop = range->start;
status = f_utf_buffer_increment(buffer, range, 1);
if (F_status_is_error(status)) break;
private_macro_fl_fss_object_return_on_overflow_delimited((buffer), (*range), (*found), F_none_eos, F_none_stop);
if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
- found->stop = stop;
+ if (stop > begin) {
+ found->stop = stop - 1;
+ }
+ else {
+ found->start = 1;
+ found->stop = 0;
+ }
// Move the start position to after the EOL.
++range->start;
}
// 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_extended_list_open_s.string[0]) {
graph_first = F_false;
- stop = range->start++ - 1;
+ stop = range->start++;
while (range->start <= range->stop && range->start < buffer.used) {
if (F_status_is_error(status)) break;
- found->stop = stop;
+ if (stop > begin) {
+ found->stop = stop - 1;
+ }
+ else {
+ found->start = 1;
+ found->stop = 0;
+ }
+
range->start = start + 1;
return F_fss_found_object;
}
else if (buffer.string[range->start] == f_fss_extended_list_open_s.string[0]) {
graph_first = F_false;
- stop = range->start - 1;
+ stop = range->start;
status = f_utf_buffer_increment(buffer, range, 1);
if (F_status_is_error(status)) break;
private_macro_fl_fss_object_return_on_overflow_delimited((buffer), (*range), (*found), F_none_eos, F_none_stop);
if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
- found->stop = stop;
+ if (stop > begin) {
+ found->stop = stop - 1;
+ }
+ else {
+ found->start = 1;
+ found->stop = 0;
+ }
// Move the start position to after the EOL.
++range->start;