}
if (state->status == F_okay_eol) {
- state->status = F_status_set_error(F_okay_eol);
+ state->status = state->flag & f_fss_state_flag_eol_stop_e
+ ? F_okay_eol
+ : F_status_set_error(F_okay_eol);
return;
}
- // Ensure that there is room for the potential start and stop quotes, a potential delimit at start, and the potential object open character.
- state->status = f_memory_array_increase_by(state->step_small + 5, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+ // Ensure that there is room for the potential start and stop quotes, a potential delimit at start, the potential object open character, and possible NULL termination.
+ state->status = f_memory_array_increase_by(state->step_small + 6, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error(state->status)) return;
#define ___fl_flag_as_object___ 0x1
#define ___fl_flag_has_combining___ 0x1
- #define ___fl_flag_has_combining_joiner___ 0x3
- #define ___fl_flag_has_joiner___ 0x2
- #define ___fl_flag_is_quoted___ 0x4
- #define ___fl_flag_is_commented___ 0x8
- #define ___fl_flag_save_character___ 0x10
- #define ___fl_flag_save_comment___ 0x20
- #define ___fl_flag_save_normal___ 0x40
- #define ___fl_flag_save_partial___ 0x80
- #define ___fl_flag_save_quote___ 0x100
- #define ___fl_flag_save_quote_character___ 0x110
- #define ___fl_flag_save_slash___ 0x200
- #define ___fl_flag_save_slash_quote___ 0x300
+ #define ___fl_flag_has_combining_joiner___ 0x5
+ #define ___fl_flag_has_eol___ 0x2
+ #define ___fl_flag_has_joiner___ 0x4
+ #define ___fl_flag_is_quoted___ 0x8
+ #define ___fl_flag_is_commented___ 0x10
+ #define ___fl_flag_save_character___ 0x20
+ #define ___fl_flag_save_comment___ 0x40
+ #define ___fl_flag_save_normal___ 0x80
+ #define ___fl_flag_save_partial___ 0x100
+ #define ___fl_flag_save_quote___ 0x200
+ #define ___fl_flag_save_quote_character___ 0x220
+ #define ___fl_flag_save_slash___ 0x400
+ #define ___fl_flag_save_slash_quote___ 0x600
const f_number_unsigned_t input_start = range->start;
const f_number_unsigned_t used_start = destination->used;
if (F_status_is_error_not(state->status)) {
partial.stop = range->start;
- // (partial.stop - partial.start) + 1 (range), 2 (for both open and close quotes), 1 (for terminating NULL).
- state->status = f_memory_array_increase_by((partial.stop - partial.start) + 4, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+ // (partial.stop - partial.start) + 1 (range), 6 for reservations as described above.
+ state->status = f_memory_array_increase_by((partial.stop - partial.start) + 7, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
}
if (F_status_is_error_not(state->status)) {
else if (F_status_is_error_not(state->status)) {
range->start = input_start;
- if (object.string[input_start] == quote_char) {
- flag_fl |= ___fl_flag_is_quoted___;
- }
- else {
- flag_fl |= ___fl_flag_is_commented___;
- }
+ flag_fl |= object.string[input_start] == quote_char
+ ? ___fl_flag_is_quoted___
+ : ___fl_flag_is_commented___;
}
}
}
if (object.string[range->start] == f_fss_eol_s.string[0]) {
- state->status = F_status_set_error(F_okay_eol);
+ if (state->flag & f_fss_state_flag_eol_stop_e) {
+ flag_fl |= ___fl_flag_has_eol___;
+ }
+ else {
+ state->status = F_status_set_error(F_okay_eol);
+ }
break;
}
}
else {
if (object.string[range->start] == f_fss_eol_s.string[0]) {
- // TODO: add flag or ending on eol with this status.
- // TODO: is this really an error?
- // TODO: set flag_fl |= ___fl_flag_save_slash_quote___; appropriately here.
- state->status = F_status_set_error(F_okay_eol);
+ if (state->flag & f_fss_state_flag_eol_stop_e) {
+ flag_fl |= ___fl_flag_has_eol___;
+ }
+ else {
+ state->status = F_status_set_error(F_okay_eol);
+ }
break;
}
flag_fl |= ___fl_flag_is_commented___;
}
- // item_total (slashes), 2 (for both open and close quotes), 1 (for terminating NULL).
- state->status = f_memory_array_increase_by(item_total + 3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+ // item_total (slashes), 6 for reservations as described above.
+ state->status = f_memory_array_increase_by(item_total + 6, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error(state->status)) break;
for (i = 0; i < item_total; ++i) {
}
else {
// TODO: combining joiner check against space.
- // TODO: handle EOL just like above.
if (object.string[range->start] == f_fss_eol_s.string[0]) {
- state->status = F_status_set_error(F_okay_eol);
+ if (state->flag & f_fss_state_flag_eol_stop_e) {
+ flag_fl |= ___fl_flag_has_eol___;
+ }
+ else {
+ state->status = F_status_set_error(F_okay_eol);
+ }
break;
}
item_total *= 2;
}
- // item_total (slashes), width (current character), 2 (for both open and close quotes), 1 (for terminating NULL).
- state->status = f_memory_array_increase_by(item_total + width + 3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+ // item_total (slashes), width (current character), 6 for reservations as described above.
+ state->status = f_memory_array_increase_by(item_total + width + 6, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error(state->status)) break;
if (item_total) {
if (range->start > range->stop || range->start >= object.used) {
- // quote, 2 (for both open and close quotes), 1 (for terminating NULL).
- state->status = f_memory_array_increase_by(4, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+ // quote, 6 for reservations as described above.
+ state->status = f_memory_array_increase_by(7, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error(state->status)) break;
destination->string[destination->used++] = quote_char;
if (object.string[range->start] == quote_char) {
// TODO: Verify no combining joiners following.
- // quote, 2 (for both open and close quotes), 1 (for terminating NULL).
- state->status = f_memory_array_increase_by(4, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+ // quote, 6 for reservations as described above.
+ state->status = f_memory_array_increase_by(7, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error(state->status)) break;
destination->string[destination->used++] = quote_char;
}
else {
if (object.string[range->start] == f_fss_eol_s.string[0]) {
- // TODO: same as above EOL cases.
- state->status = F_status_set_error(F_okay_eol);
+ if (state->flag & f_fss_state_flag_eol_stop_e) {
+ flag_fl |= ___fl_flag_has_eol___;
+ }
+ else {
+ state->status = F_status_set_error(F_okay_eol);
+ }
break;
}
- // slash, 2 (for both open and close quotes), 1 (for terminating NULL).
- state->status = f_memory_array_increase_by(4, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+ // slash, 6 for reservations as described above.
+ state->status = f_memory_array_increase_by(7, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error(state->status)) break;
destination->string[destination->used++] = f_fss_slash_s.string[0];
width = macro_f_utf_byte_width(object.string[range->start]);
- // width, 2 (for both open and close quotes), 1 (for terminating NULL).
- state->status = f_memory_array_increase_by(width + 3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+ // width, 6 for reservations as described above.
+ state->status = f_memory_array_increase_by(width + 6, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error(state->status)) break;
destination->string[destination->used++] = quote_char;
flag_fl &= ~___fl_flag_save_normal___;
}
else if (object.string[range->start] == f_fss_eol_s.string[0]) {
- // TODO: same as above EOL cases.
- state->status = F_status_set_error(F_okay_eol);
+ if (state->flag & f_fss_state_flag_eol_stop_e) {
+ flag_fl |= ___fl_flag_has_eol___;
+ }
+ else {
+ state->status = F_status_set_error(F_okay_eol);
+ }
break;
}
if (partial.start <= partial.stop) {
- // (partial.stop - partial.start) + 1 (range), 2 (for both open and close quotes), 1 (for terminating NULL).
- state->status = f_memory_array_increase_by((partial.stop - partial.start) + 4, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+ // (partial.stop - partial.start) + 1 (range), 6 for reservations as described above.
+ state->status = f_memory_array_increase_by((partial.stop - partial.start) + 7, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error_not(state->status)) {
state->status = f_string_dynamic_partial_append_nulless(object, partial, destination);
width = macro_f_utf_byte_width(object.string[range->start]);
- // width, 2 (for both open and close quotes), 1 (for terminating NULL).
- state->status = f_memory_array_increase_by(width + 3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+ // width, 6 for reservations as described above.
+ state->status = f_memory_array_increase_by(width + 6, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error(state->status)) break;
memcpy(destination->string + destination->used, object.string + range->start, width);
if (range->start > range->stop || range->start >= object.used) {
if (partial.start <= partial.stop) {
- // (partial.stop - partial.start) + 1 (range), 2 (for both open and close quotes), 1 (for terminating NULL).
- state->status = f_memory_array_increase_by((partial.stop - partial.start) + 4, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+ // (partial.stop - partial.start) + 1 (range), 6 for reservations as described above.
+ state->status = f_memory_array_increase_by((partial.stop - partial.start) + 7, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error_not(state->status)) {
state->status = f_string_dynamic_partial_append_nulless(object, partial, destination);
}
else if (flag_fl & ___fl_flag_save_slash___) {
- // item_total (slashes), width (current character), 2 (for both open and close quotes or one for comment), 1 (for terminating NULL).
- state->status = f_memory_array_increase_by(item_total + 3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+ // item_total (slashes), 6 for reservations as described above.
+ state->status = f_memory_array_increase_by(item_total + 6, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error_not(state->status)) {
if (item_total) {
destination->string[used_start] = f_fss_slash_s.string[0];
}
- state->status = range->start > range->stop ? F_okay_stop : F_okay_eos;
+ if (flag_fl & ___fl_flag_has_eol___) {
+ state->status = F_okay_eol;
+ }
+ else {
+ state->status = range->start > range->stop
+ ? F_okay_stop
+ : F_okay_eos;
+ }
#undef ___fl_flag_as_object___
#undef ___fl_flag_has_combining___
#undef ___fl_flag_has_combining_joiner___
+ #undef ___fl_flag_has_eol___
#undef ___fl_flag_has_joiner___
#undef ___fl_flag_is_quoted___
#undef ___fl_flag_is_commented___