}
if (F_status_is_error_not(state->status)) {
+ 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;
// The EOS and stop cases only happen here when EOL is not found, so do not increment found.used.
if (range->start >= buffer.used) {
#define ___fl_flag_has_graph_first___ 0x4
#define ___fl_flag_has_graph_first_delimit_comment___ 0x6
#define ___fl_flag_has_graph_first_do_escape___ 0x5
+ #define ___fl_flag_has_line_first___ 0x8
+ #define ___fl_flag_has_line_first_graph_first___ 0xc
+ #define ___fl_flag_has_line_first_delimit_comment___ 0xa
const f_number_unsigned_t delimits_used = delimits->used;
const f_number_unsigned_t comments_used = comments->used;
f_number_unsigned_t slash_count = 0;
f_number_unsigned_t line_start = begin;
- uint8_t flag_fl = ___fl_flag_has_graph_first___;
+ uint8_t flag_fl = ___fl_flag_has_line_first_graph_first___;
// The start position with a combining/joiner must be treated as Content and not as an Object.
if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) {
if (F_status_is_error(state->status)) return;
- // Identify where the content ends.
while (range->start <= range->stop && range->start < buffer.used) {
if (state->interrupt) {
delimits->array[delimits->used++] = comment_delimit;
}
- newline_last = range->start;
flag_fl |= ___fl_flag_has_graph_first___;
- flag_fl &= ~___fl_flag_has_delimit_comment___;
- ++range->start;
+ flag_fl &= ~___fl_flag_has_line_first_delimit_comment___;
+ newline_last = range->start;
+ line_start = ++range->start;
// Any line that starts with a combining/joiner must be treated as Content and not as an Object.
f_fss_skip_past_delimit(buffer, range, state);
// If any slash has a combining/joiner following it, then there is no escaping at all for that slash and therefore it is not considered an escaping character.
if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) {
flag_fl &= ~___fl_flag_has_graph_first_do_escape___;
- slash_count = 0;
f_fss_skip_past_combining_joiner(buffer, range, state);
flag_fl &= ~___fl_flag_do_escape___;
if (buffer.string[range->start] == f_fss_basic_list_open_s.string[0]) {
- flag_fl &= ~___fl_flag_has_graph_first_delimit_comment___;
+ flag_fl &= ~___fl_flag_has_graph_first___;
++range->start;
f_fss_skip_past_space(buffer, range, state);
if (F_status_is_error(state->status) || range->start > range->stop || range->start >= buffer.used) break;
if (state->status == F_okay_eol) {
- newline_last = line_start;
- line_start = range->start;
+ previous = range->start;
range->start = slash_first;
if (slash_count % 2 == 0) {
+ 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)) break;
+
found->array[found->used++].stop = newline_last;
- range->start = newline_last + 1;
+ range->start = previous + 1;
state->status = F_fss_found_content;
return;
if (F_status_is_error(state->status)) break;
- if (flag_fl & ___fl_flag_has_delimit_comment___) {
- 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++] = comment_delimit;
- }
-
- flag_fl |= ___fl_flag_has_graph_first___;
- range->start = line_start + 1;
+ range->start = previous;
+ state->status = F_okay_eol;
}
}
else if ((flag_fl & ___fl_flag_has_graph_first___) && buffer.string[range->start] == f_fss_comment_s.string[0]) {
else {
if (F_status_is_error(state->status)) break;
- flag_fl &= ___fl_flag_has_delimit_comment___;
+ flag_fl |= ___fl_flag_has_delimit_comment___;
comment_delimit = slash_first;
}
}
if (buffer.string[range->start] == f_fss_basic_list_open_s.string[0]) {
++range->start;
- flag_fl &= ~___fl_flag_has_graph_first_delimit_comment___;
+ flag_fl &= ~___fl_flag_has_graph_first___;
f_fss_skip_past_space(buffer, range, state);
// Found a valid object, set stop point to last newline (if newline_last is begin, there newline_last is not a new line).
if (state->status == F_okay_eol) {
- if (begin != newline_last && newline_last == found->array[found->used].start) {
+ 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)) break;
+
+ if (flag_fl & ___fl_flag_has_delimit_comment___) {
+ 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++] = comment_delimit;
+ }
+
+ if (flag_fl & ___fl_flag_has_line_first___) {
found->array[found->used].start = 1;
found->array[found->used++].stop = 0;
range->start = newline_last;
+ state->status = F_fss_found_content_not;
}
else {
range->start = begin == newline_last ? newline_last : newline_last + 1;
found->array[found->used++].stop = newline_last;
+ state->status = F_fss_found_content;
}
- state->status = F_fss_found_content;
-
return;
}
range->start = previous;
- // The newline_last is initialized to the range->start, which may not actually be a new line.
- line_start = buffer.string[newline_last] == f_string_eol_s.string[0]
- ? newline_last + 1
- : newline_last;
+ line_start = flag_fl & ___fl_flag_has_line_first___
+ ? begin
+ : newline_last + 1;
f_fss_seek_to_eol(buffer, range, state);
if (F_status_is_error(state->status)) break;
- if (range->start > range->stop || range->start >= buffer.used) {
- --range->start;
- }
- else {
- newline_last = range->start;
- }
-
comments->array[comments->used].start = line_start;
- comments->array[comments->used++].stop = range->start++;
+ comments->array[comments->used++].stop = range->start;
+ newline_last = range->start;
+ state->status = F_okay_eol;
continue;
}
if (f_fss_is_space(buffer, *range, state) == F_false) {
if (F_status_is_error(state->status)) break;
- flag_fl &= ~___fl_flag_has_graph_first_delimit_comment___;
+ flag_fl &= ~___fl_flag_has_graph_first___;
}
}
if (F_status_is_error(state->status)) break;
} // while
+ if (flag_fl & ___fl_flag_has_delimit_comment___) {
+ 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_not(state->status)) {
+ delimits->array[delimits->used++] = comment_delimit;
+ }
+ }
+
if (F_status_is_error(state->status)) {
delimits->used = delimits_used;
comments->used = comments_used;
return;
}
+ 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;
+
// The EOS and stop cases only happen here when the next object is not found, so do not increment found.used and let caller handle.
if (range->start >= buffer.used) {
found->array[found->used].stop = buffer.used - 1;
return;
}
- state->status = F_fss_found_content;
+ if (flag_fl & ___fl_flag_has_line_first___) {
+ state->status = F_fss_found_content_not;
- 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;
}
+ else {
+ state->status = F_fss_found_content;
+
+ found->array[found->used++].stop = range->start - 1;
+ }
#undef ___fl_flag_do_escape___
#undef ___fl_flag_has_delimit_comment___
#undef ___fl_flag_has_graph_first___
#undef ___fl_flag_has_graph_first_delimit_comment___
+ #undef ___fl_flag_has_graph_first_do_escape___
+ #undef ___fl_flag_has_line_first___
+ #undef ___fl_flag_has_line_first_graph_first___
}
#endif // _di_fl_fss_basic_list_content_read_
*
* This alters state.status:
* F_fss_found_content on success and Content is found (start location is at end of Content).
- * F_fss_found_content_not on success and no Content is found (start location is after character designating this is not a Content).
+ * F_fss_found_content_not on success and no Content is found or a valid Object is found before any Content is found (start location is after the character designating this is not a Content).
* F_okay_eos on success after reaching the end of the buffer (a valid Object is not yet confirmed).
* F_okay_stop on success after reaching stopping point (a valid Object is not yet confirmed).
* F_data_not if buffer is empty (buffer.used is 0).
* Errors (with error bit) from: f_fss_is_space().
* 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().
* Errors (with error bit) from: f_memory_array_increase_by().
* Errors (with error bit) from: f_utf_buffer_increment().
* @see f_fss_is_space()
* @see f_fss_seek_to_eol()
* @see f_fss_skip_past_delimit()
+ * @see f_fss_skip_past_space()
* @see f_memory_array_increase()
* @see f_memory_array_increase_by()
* @see f_utf_buffer_increment()
}
if (state->status == F_fss_found_object || state->status == F_fss_found_object_content_not) {
- status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &found->array, &found->used, &found->size);
// The private function sets the error bit on unterminated quoted Object.
if (state->status == F_status_set_error(F_fss_found_object_content_not)) {
state->status = F_fss_found_object_content_not;
}
+ status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &found->array, &found->used, &found->size);
+
if (F_status_is_error_not(status) && quotes) {
status = f_memory_array_increase(state->step_small, sizeof(uint8_t), (void **) "es->array, "es->used, "es->size);
}
// Found a valid content close, set stop point to last newline.
if (state->status == F_okay_eol) {
+ 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)) break;
+
close->start = line_start;
close->stop = range->start - 1;
found->array[found->used++].stop = 0;
state->status = F_fss_found_content_not;
-
- return;
}
-
- found->array[found->used++].stop = newline_last;
- state->status = F_fss_found_content;
+ else {
+ found->array[found->used++].stop = newline_last;
+ state->status = F_fss_found_content;
+ }
return;
}
// Ignore all comment lines.
if (buffer.string[begin] == f_fss_comment_s.string[0]) {
state->status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(state->status)) return;
- f_fss_skip_past_delimit(buffer, range, state);
+ if (F_status_is_error_not(state->status)) {
+ f_fss_skip_past_delimit(buffer, range, state);
+ }
+
if (F_status_is_error(state->status)) return;
if (range->start >= buffer.used || range->start > range->stop) {
slash_count = 1;
flag_fl |= ___fl_flag_do_escape___;
- f_fss_skip_past_delimit(buffer, range, state);
-
- // If first slash has a combining/joiner following it, then there is no escaping at all but this is not a valid escaping slash.
- if (F_status_is_error_not(state->status) && f_fss_is_combining_joiner(buffer, *range, state) == F_true) {
- flag_fl &= ~___fl_flag_do_escape___;
-
- f_fss_skip_past_combining_joiner(buffer, range, state);
+ if (flag_fl & ___fl_flag_has_graph_first___) {
+ line_start = slash_first;
}
- if (flag_fl & ___fl_flag_do_escape___) {
- while (F_status_is_error_not(state->status) && range->start <= range->stop && range->start < buffer.used) {
+ // If any slash has a combining/joiner following it, then there is no escaping at all but this is not a valid escaping slash.
+ while (F_status_is_error_not(state->status) && range->start <= range->stop && range->start < buffer.used) {
- if (state->interrupt) {
- state->interrupt((void *) state, 0);
- if (F_status_is_error(state->status)) break;
- }
+ if (state->interrupt) {
+ state->interrupt((void *) state, 0);
+ if (F_status_is_error(state->status)) break;
+ }
- if (buffer.string[range->start] == f_fss_placeholder_s.string[0]) {
- // Do nothing.
- }
- else if (buffer.string[range->start] == f_fss_slash_s.string[0]) {
- ++slash_count;
- }
- else if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) {
- flag_fl &= ~___fl_flag_do_escape___;
+ if (buffer.string[range->start] == f_fss_placeholder_s.string[0]) {
+ // Do nothing.
+ }
+ else if (buffer.string[range->start] == f_fss_slash_s.string[0]) {
+ ++slash_count;
+ }
+ else if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) {
+ flag_fl &= ~___fl_flag_do_escape___;
- f_fss_skip_past_combining_joiner(buffer, range, state);
+ f_fss_skip_past_combining_joiner(buffer, range, state);
- break;
- }
- else {
- break;
- }
+ break;
+ }
+ else {
+ break;
+ }
- if (F_status_is_error_not(state->status)) {
- state->status = f_utf_buffer_increment(buffer, range, 1);
- }
- } // while
- }
+ if (F_status_is_error_not(state->status)) {
+ state->status = f_utf_buffer_increment(buffer, range, 1);
+ }
+ } // while
if (F_status_is_error(state->status)) break;
+ if (!(flag_fl & ___fl_flag_do_escape___)) continue;
- if (!(flag_fl & ___fl_flag_do_escape___)) {
- slash_count = 0;
-
- continue;
- }
+ flag_fl &= ~___fl_flag_do_escape___;
if (range->start >= buffer.used || range->start > range->stop) {
delimits->used = delimits_used;
f_fss_skip_past_delimit(buffer, range, state);
if (F_status_is_error_not(state->status) && f_fss_is_combining_joiner(buffer, *range, state) == F_true) {
- flag_fl &= ~___fl_flag_do_escape___;
slash_count = 0;
f_fss_skip_past_combining_joiner(buffer, range, state);
else if ((flag_fl & ___fl_flag_has_graph_first___) && buffer.string[range->start] == f_fss_comment_s.string[0]) {
flag_fl &= ~___fl_flag_has_graph_first___;
line_start = slash_first;
- location = range->start++;
+ line_stop = location = range->start++;
f_fss_skip_past_delimit(buffer, range, state);
if (F_status_is_error_not(state->status) && f_fss_is_combining_joiner(buffer, *range, state) == F_true) {
- flag_fl &= ~___fl_flag_do_escape___;
slash_count = 0;
f_fss_skip_past_combining_joiner(buffer, range, state);
line_stop = range->start++;
}
else {
- flag_fl &= ~___fl_flag_has_graph_first___;
+ if (flag_fl & ___fl_flag_has_graph_first___) {
+ flag_fl &= ~___fl_flag_has_graph_first___;
+ line_start = slash_first;
+ }
+
line_stop = range->start;
}
}
if (buffer.string[range->start] == list_open.string[0]) {
+ if (flag_fl & ___fl_flag_has_graph_first___) {
+ line_start = range->start;
+ }
+
++range->start;
f_fss_skip_past_delimit(buffer, range, state);
}
if (state->status == F_okay_eol) {
- found->start = line_start;
- found->stop = line_stop + macro_f_utf_byte_width(buffer.string[line_stop]) - 1;
+ if (flag_fl & ___fl_flag_has_graph_first___) {
+ found->start = 1;
+ found->stop = 0;
+ }
+ else {
+ found->start = line_start;
+ found->stop = line_stop + macro_f_utf_byte_width(buffer.string[line_stop]) - 1;
+ }
+
++range->start;
state->status = F_fss_found_object;
if (flag_fl & ___fl_flag_has_graph_first___) {
flag_fl &= ~___fl_flag_has_graph_first___;
- line_start = 1;
- line_stop = 0;
- }
- else {
- line_stop = range->start;
+ line_start = range->start;
}
+ line_stop = range->start;
+
continue;
}
if (f_fss_is_space(buffer, *range, state) == F_false) {
- if (F_status_is_error_not(state->status) && f_fss_is_combining_joiner(buffer, *range, state) == F_true) {
- f_fss_skip_past_combining_joiner(buffer, range, state);
+ if ((flag_fl & ___fl_flag_has_graph_first___) && range->start > begin) {
+ if (F_status_is_error_not(state->status) && f_fss_is_combining_joiner(buffer, *range, state) == F_true) {
+ location = range->start;
+
+ state->status = f_utf_buffer_decrement(buffer, range, 1);
+ }
}
if (F_status_is_error_not(state->status)) {
} // for
} // for
- // If there is no whitespace between the quotes, post-trimming, then remove the quotes.
+ // If there is no white space between the quotes, post-trimming, then remove the quotes.
for (destination_range.start = front; destination_range.start < rear; ++destination_range.start) {
if (state->interrupt) {
}
fl_fss_basic_object_read(buffer, range, &objects->array[objects->used], quoted_object, objects_delimits, state);
+
+ // Skip lines with combining/joiners at the start.
+ if (F_status_set_fine(state->status) == F_complete_not_utf_start) {
+ f_fss_seek_to_eol(buffer, range, state);
+
+ if (F_status_is_error_not(state->status)) {
+ state->status = F_fss_found_object_not;
+ continue;
+ }
+ }
+
if (F_status_is_error(state->status)) return;
if (range->start >= range->stop || range->start >= buffer.used) {
* F_number_overflow (with error bit) if the maximum buffer size is reached.
* F_parameter (with error bit) if a parameter is invalid.
*
+ * Errors (with error bit) from: f_fss_seek_to_eol().
* Errors (with error bit) from: f_memory_array_increase().
* Errors (with error bit) from: fl_fss_basic_content_read().
* Errors (with error bit) from: fl_fss_basic_object_read().
*
+ * @see f_fss_seek_to_eol()
* @see f_memory_array_increase()
* @see fl_fss_basic_content_read()
* @see fl_fss_basic_object_read()
do {
fl_fss_basic_list_object_read(buffer, range, &objects->array[objects->used], objects_delimits, state);
+
+ // Skip lines with combining/joiners at the start.
+ if (F_status_set_fine(state->status) == F_complete_not_utf_start) {
+ f_fss_seek_to_eol(buffer, range, state);
+
+ if (F_status_is_error_not(state->status)) {
+ state->status = F_fss_found_object_not;
+ continue;
+ }
+ }
+
if (F_status_is_error(state->status)) return;
if (range->start >= range->stop || range->start >= buffer.used) {
* F_number_overflow (with error bit) if the maximum buffer size is reached.
* F_parameter (with error bit) if a parameter is invalid.
*
+ * Errors (with error bit) from: f_fss_seek_to_eol().
* Errors (with error bit) from: f_memory_array_increase().
* Errors (with error bit) from: fl_fss_basic_list_content_read().
* Errors (with error bit) from: fl_fss_basic_list_object_read().
*
+ * @see f_fss_seek_to_eol()
* @see f_memory_array_increase()
* @see fl_fss_basic_list_content_read()
* @see fl_fss_basic_list_object_read()
nest->depth[nest->used].used = 0;
fl_fss_embedded_list_object_read(buffer, range, &nest->depth[0].array[nest->depth[0].used].object, objects_delimits, state);
+
+ // Skip lines with combining/joiners at the start.
+ if (F_status_set_fine(state->status) == F_complete_not_utf_start) {
+ f_fss_seek_to_eol(buffer, range, state);
+
+ if (F_status_is_error_not(state->status)) {
+ state->status = F_fss_found_object_not;
+ continue;
+ }
+ }
+
if (F_status_is_error(state->status)) return;
if (range->start >= range->stop || range->start >= buffer.used) {
* F_number_overflow (with error bit) if the maximum buffer size is reached.
* F_parameter (with error bit) if a parameter is invalid.
*
+ * Errors (with error bit) from: f_fss_seek_to_eol().
* Errors (with error bit) from: f_memory_array_increase().
* Errors (with error bit) from: fl_fss_embedded_list_content_read().
* Errors (with error bit) from: fl_fss_embedded_list_object_read().
*
+ * @see f_fss_seek_to_eol()
* @see f_memory_array_increase()
* @see fl_fss_embedded_list_content_read()
* @see fl_fss_embedded_list_object_read()
}
fl_fss_extended_object_read(buffer, range, &objects->array[objects->used], quoted_object, objects_delimits, state);
+
+ // Skip lines with combining/joiners at the start.
+ if (F_status_set_fine(state->status) == F_complete_not_utf_start) {
+ f_fss_seek_to_eol(buffer, range, state);
+
+ if (F_status_is_error_not(state->status)) {
+ state->status = F_fss_found_object_not;
+ continue;
+ }
+ }
+
if (F_status_is_error(state->status)) return;
if (range->start >= range->stop || range->start >= buffer.used) {
* F_number_overflow (with error bit) if the maximum buffer size is reached.
* F_parameter (with error bit) if a parameter is invalid.
*
+ * Errors (with error bit) from: f_fss_seek_to_eol().
* Errors (with error bit) from: f_memory_array_increase().
* Errors (with error bit) from: fl_fss_extended_content_read().
* Errors (with error bit) from: fl_fss_extended_object_read().
*
+ * @see f_fss_seek_to_eol()
* @see f_memory_array_increase()
* @see fl_fss_extended_content_read()
* @see fl_fss_extended_object_read()
do {
fl_fss_extended_list_object_read(buffer, range, &objects->array[objects->used], objects_delimits, state);
+
+ // Skip lines with combining/joiners at the start.
+ if (F_status_set_fine(state->status) == F_complete_not_utf_start) {
+ f_fss_seek_to_eol(buffer, range, state);
+
+ if (F_status_is_error_not(state->status)) {
+ state->status = F_fss_found_object_not;
+ continue;
+ }
+ }
+
if (F_status_is_error(state->status)) return;
if (range->start >= range->stop || range->start >= buffer.used) {
* F_number_overflow (with error bit) if the maximum buffer size is reached.
* F_parameter (with error bit) if a parameter is invalid.
*
+ * Errors (with error bit) from: f_fss_seek_to_eol().
* Errors (with error bit) from: f_memory_array_increase().
* Errors (with error bit) from: fl_fss_extended_list_content_read().
* Errors (with error bit) from: fl_fss_extended_list_object_read().
*
+ * @see f_fss_seek_to_eol()
* @see f_memory_array_increase()
* @see fl_fss_extended_list_content_read()
* @see fl_fss_extended_list_object_read()
do {
fl_fss_basic_list_object_read(buffer, range, &objects->array[objects->used], objects_delimits, state);
+
+ // Skip lines with combining/joiners at the start.
+ if (F_status_set_fine(state->status) == F_complete_not_utf_start) {
+ f_fss_seek_to_eol(buffer, range, state);
+
+ if (F_status_is_error_not(state->status)) {
+ state->status = F_fss_found_object_not;
+ continue;
+ }
+ }
+
if (F_status_is_error(state->status)) return;
if (range->start >= range->stop || range->start >= buffer.used) {
*
* F_number_overflow (with error bit) if the maximum buffer size is reached.
*
+ * Errors (with error bit) from: f_fss_seek_to_eol().
* Errors (with error bit) from: f_memory_array_increase().
* Errors (with error bit) from: fl_fss_basic_list_content_read().
* Errors (with error bit) from: fl_fss_basic_list_object_read().
*
+ * @see f_fss_seek_to_eol()
* @see f_memory_array_increase()
* @see fl_fss_basic_list_content_read()
* @see fl_fss_basic_list_object_read()