#define ___fl_flag_as_object___ 0x1
#define ___fl_flag_has_combining___ 0x1
- #define ___fl_flag_has_combining_joiner___ 0x5
- #define ___fl_flag_has_increased___ 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
+ #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
const f_number_unsigned_t input_start = range->start;
const f_number_unsigned_t used_start = destination->used;
if (F_status_is_error(state->status)) break;
if (range->start > range->stop || range->start >= object.used) {
- state->status = f_memory_array_increase(state->step_large, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+
+ // 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);
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.
- state->status = f_memory_array_increase(state->step_large, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+
+ // 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);
if (F_status_is_error(state->status)) break;
destination->string[destination->used++] = quote_char;
break;
}
- state->status = f_memory_array_increase(state->step_large, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+ // 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);
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);
if (F_status_is_error(state->status)) break;
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);
break;
flag_fl &= ~___fl_flag_save_partial___;
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);
if (F_status_is_error_not(state->status)) {
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);
if (F_status_is_error(state->status)) break;
if (flag_fl & ___fl_flag_save_partial___) {
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);
if (F_status_is_error_not(state->status)) {
- flag_fl |= ___fl_flag_has_increased___;
-
state->status = f_string_dynamic_partial_append_nulless(object, partial, destination);
}
}
}
}
- if (F_status_is_error_not(state->status) && (flag_fl & ___fl_flag_is_quoted___) && !(flag_fl & ___fl_flag_has_increased___)) {
- state->status = f_memory_array_increase_by(state->step_small + 3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
- }
-
if (F_status_is_error(state->status)) {
destination->used = used_start;
if (flag_fl & ___fl_flag_is_quoted___) {
destination->string[used_start] = quote_char;
destination->string[destination->used++] = quote_char;
-
- // The start quote may or may not need to be delimited in this case. // TODO: save start quote position? Review this logic.
- if (destination->string[input_start] == quote_char) {
- for (i = input_start + macro_f_utf_byte_width(object.string[input_start]); i <= range->stop && i < object.used; i += macro_f_utf_byte_width(object.string[i])) {
-
- if (state->interrupt) {
- state->interrupt((void *) state, internal);
-
- if (F_status_set_fine(state->status) == F_interrupt) {
- destination->used = used_start;
-
- return;
- }
- }
-
- if (object.string[i] != f_fss_placeholder_s.string[0]) break;
- } // for
-
- // Only when followed by a space must the start quote be delimited.
- // TODO: is this logic now redundant/irrelevant?
- if (i <= range->stop && i < object.used) {
- f_range_t range_i = *range;
-
- range_i.start = i;
-
- if (f_fss_is_space(object, range_i, state) == F_false) { // TODO: Verify no combining joiners following.
- destination->string[used_start + 1] = f_fss_placeholder_s.string[0];
- }
- else if (object.string[i] == f_fss_eol_s.string[0]) {
- state->status = F_status_set_error(F_okay_eol);
- }
-
- if (F_status_is_error(state->status)) {
- destination->used = used_start;
-
- return;
- }
- }
- }
}
else if (flag_fl & ___fl_flag_is_commented___) {
destination->string[used_start] = f_fss_slash_s.string[0];
#undef ___fl_flag_has_combining___
#undef ___fl_flag_has_combining_joiner___
- #undef ___fl_flag_has_increased___
#undef ___fl_flag_has_joiner___
#undef ___fl_flag_is_quoted___
#undef ___fl_flag_is_commented___