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_comment_s.string[0]) {
+ found->start = 1;
+ found->stop = 0;
status = f_fss_seek_to_eol(state, buffer, range);
if (F_status_is_error(status)) return status;
-
if (status == F_none_eos) return F_data_not_eos;
if (status == F_none_stop) return F_data_not_stop;
f_array_length_t slash_first = 0;
f_array_length_t slash_count = 0;
- f_array_length_t start = 0;
+ f_array_length_t start = 1;
f_array_length_t stop = 0;
- bool graph_first = F_true;
+ uint8_t graph_first = F_true;
// Identify where the object ends.
while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol_s.string[0]) {
}
}
- if (buffer.string[range->start] == f_fss_delimit_placeholder_s.string[0]) {
- continue;
- } else if (buffer.string[range->start] != f_fss_delimit_slash_s.string[0]) {
- break;
- }
+ if (buffer.string[range->start] == f_fss_delimit_placeholder_s.string[0]) continue;
+ else if (buffer.string[range->start] != f_fss_delimit_slash_s.string[0]) break;
++slash_count;
} // for
if (buffer.string[range->start] == f_fss_basic_list_open_s.string[0]) {
graph_first = F_false;
- stop = range->start;
status = f_utf_buffer_increment(buffer, range, 1);
if (F_status_is_error(status)) return status;
if (buffer.string[range->start] == f_fss_eol_s.string[0]) break;
status = f_fss_is_space(state, buffer, *range);
- if (F_status_is_error(status)) break;
-
- if (status == F_false) break;
+ if (F_status_is_error(status) || status == F_false) break;
status = f_utf_buffer_increment(buffer, range, 1);
if (F_status_is_error(status)) break;
private_macro_fl_fss_object_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop);
if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
- start = range->start;
-
+ found->stop = range->start;
range->start = slash_first;
status = f_array_lengths_increase_by((slash_count / 2) + 1, delimits);
- if (F_status_is_error(status)) break;
+
+ if (F_status_is_error(status)) {
+ range->start = found->stop;
+
+ break;
+ }
if (slash_count % 2 == 0) {
while (slash_count > 0) {
status = f_utf_buffer_increment(buffer, range, 1);
if (F_status_is_error(status)) {
+ range->start = found->stop + 1;
+ found->start = 1;
+ found->stop = 0;
delimits->used = delimits_used;
return status;
}
} // while
- if (stop > begin) {
- found->stop = stop - 1;
- }
- else {
- found->start = 1;
- found->stop = 0;
- }
-
- range->start = start + 1;
+ range->start = found->stop + 1;
+ found->start = start;
+ found->stop = stop + macro_f_utf_byte_width(buffer.string[stop]) - 1;
return F_fss_found_object;
}
- range->start = start + 1;
+ range->start = found->stop + 1;
return F_fss_found_object_not;
}
}
else if (graph_first && buffer.string[range->start] == f_fss_comment_s.string[0]) {
- graph_first = F_false;
+ if (graph_first) {
+ graph_first = F_false;
+ start = slash_first;
+ }
// Comments may only have white space before the '#', therefore only the first slash needs to be delimited.
status = f_array_lengths_increase(state.step_small, delimits);
if (F_status_is_error(status)) break;
delimits->array[delimits->used++] = slash_first;
- ++range->start;
+ stop = range->start++;
}
else {
graph_first = F_false;
+ stop = range->start;
}
continue;
}
if (buffer.string[range->start] == f_fss_basic_list_open_s.string[0]) {
- graph_first = F_false;
- stop = range->start;
-
status = f_utf_buffer_increment(buffer, range, 1);
if (F_status_is_error(status)) break;
if (buffer.string[range->start] == f_fss_eol_s.string[0]) break;
status = f_fss_is_space(state, buffer, *range);
- if (F_status_is_error(status)) break;
-
- if (status == F_false) break;
+ if (F_status_is_error(status) || status == F_false) break;
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]) {
- 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;
+ found->start = start;
+ found->stop = stop + macro_f_utf_byte_width(buffer.string[stop]) - 1;
+ ++range->start;
return F_fss_found_object;
}
+ if (graph_first) {
+ graph_first = F_false;
+ start = 1;
+ stop = 0;
+ }
+ else {
+ stop = range->start;
+ }
+
continue;
}
- else if (graph_first) {
+ else {
status = f_fss_is_space(state, buffer, *range);
if (F_status_is_error(status)) break;
if (status == F_false) {
- graph_first = F_false;
+ if (graph_first) {
+ graph_first = F_false;
+ start = range->start;
+ }
+
+ stop = range->start;
}
}
if (F_status_is_error(status)) break;
} // while
+ found->start = 1;
+ found->stop = 0;
+
if (F_status_is_error(status)) {
delimits->used = delimits_used;
if (status == F_none_eos) return F_data_not_eos;
if (status == F_none_stop) return F_data_not_stop;
- // seek to the end of the line when no valid object is found.
+ // Seek to the end of the line when no valid object is found.
status = f_fss_seek_to_eol(state, buffer, range);
- // move the start position to after the EOL.
+ // Move the start position to after the EOL.
++range->start;
return F_fss_found_object_not;