From: Kevin Day Date: Sat, 7 Nov 2026 15:46:35 +0000 (-0600) Subject: Progress: Add new fss state flag and continue work. X-Git-Url: https://www.git.kevux.org/?a=commitdiff_plain;h=ee2c40898e98092b0a83c14250aab9d3f6b5a07d;p=fll Progress: Add new fss state flag and continue work. Whether stopping on an EOL is an error or not should be handled by the caller. Add a flag that allows designating this to avoid making breaking changes. Update documentation. Remove incorrect documentation on a read function regarding the `F_okay_eol` with error bit being returned. Continue work regarding the write functions. --- diff --git a/level_0/f_fss/c/fss/common.h b/level_0/f_fss/c/fss/common.h index 7505a1dfd..b6b29bc39 100644 --- a/level_0/f_fss/c/fss/common.h +++ b/level_0/f_fss/c/fss/common.h @@ -280,16 +280,20 @@ extern "C" { * * The f_fss_state_flag_none_e is expected to be 0, therefore it must be safe to use 0 directly. * + * Future versions (0.9.x+) will change the bit values. + * * f_fss_state_flag_*_e: * - none: No flags are set. + * - eol_okay: Treat EOL as a stop point rather than an error, returning F_okay_eol without the error bit set. * - utf_fail_on_valid_not: Immediately fail on invalid UTF-8 character (including incomplete). * - quote_not: Disable processing as quoted text (all found quotes are ignored and no quote-escaping is performed). */ #ifndef _di_f_fss_state_flag_e_ enum { f_fss_state_flag_none_e = 0x0, + f_fss_state_flag_eol_stop_e = 0x4, + f_fss_state_flag_quote_not_e = 0x2, f_fss_state_flag_utf_fail_on_valid_not_e = 0x1, - f_fss_state_quote_not_e = 0x2, }; // enum #endif // _di_f_fss_state_flag_e_ diff --git a/level_1/fl_fss/c/fss/basic.c b/level_1/fl_fss/c/fss/basic.c index 8de9dda02..77158eabd 100644 --- a/level_1/fl_fss/c/fss/basic.c +++ b/level_1/fl_fss/c/fss/basic.c @@ -128,7 +128,7 @@ extern "C" { if (content.string[range->start] == f_fss_eol_s.string[0]) { destination->used = destination_used; - state->status = F_status_set_error(F_okay_eol); + state->status = F_status_set_error(F_okay_eol); // TODO: don't reset position and instead return as-is without error bit set. return; } diff --git a/level_1/fl_fss/c/fss/basic.h b/level_1/fl_fss/c/fss/basic.h index 20c0919db..f99c2956c 100644 --- a/level_1/fl_fss/c/fss/basic.h +++ b/level_1/fl_fss/c/fss/basic.h @@ -132,6 +132,7 @@ extern "C" { * * This alters state.status: * F_okay on success. + * F_okay_eol after reaching an EOL and f_fss_state_flag_eol_error_e is set, which is not supported by the standard and is considered a stopping point. * F_okay_eos on success after reaching the end of the buffer. * F_okay_stop on success after reaching the range stop. * F_data_not if content is empty (content.used is 0). @@ -139,7 +140,7 @@ extern "C" { * F_data_not_stop no data to write due start location being greater than stop location. * * F_interrupt (with error bit) if stopping due to an interrupt. - * F_okay_eol (with error bit) after reaching an EOL, which is not supported by the standard. + * F_okay_eol (with error bit) after reaching an EOL and f_fss_state_flag_eol_error_e is not set, which is not supported by the standard. * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_fss_skip_past_delimit(). @@ -280,6 +281,7 @@ extern "C" { * * This alters state.status: * F_okay on success. + * F_okay_eol after reaching an EOL and f_fss_state_flag_eol_error_e is set, which is not supported by the standard and is considered a stopping point. * F_okay_eos on success after reaching the end of the buffer. * F_okay_stop on success after reaching the range stop. * F_data_not if object is empty (object.used is 0). @@ -287,7 +289,7 @@ extern "C" { * F_data_not_stop no data to write due start location being greater than stop location. * * F_interrupt (with error bit) if stopping due to an interrupt. - * F_okay_eol (with error bit) after reaching an EOL, which is not supported by the standard. + * F_okay_eol (with error bit) after reaching an EOL and f_fss_state_flag_eol_error_e is not set, which is not supported by the standard. * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_fss_is_space(). diff --git a/level_1/fl_fss/c/fss/basic_list.c b/level_1/fl_fss/c/fss/basic_list.c index dd3c066d8..c6733daae 100644 --- a/level_1/fl_fss/c/fss/basic_list.c +++ b/level_1/fl_fss/c/fss/basic_list.c @@ -833,7 +833,7 @@ extern "C" { // Objects will not have leading white spaces, but having this does not result in an invalid object, so just write the provided spaces. if (object.string[range->start] != f_fss_placeholder_s.string[0]) { if (object.string[range->start] == f_fss_eol_s.string[0]) { - state->status = F_status_set_error(F_okay_eol); + state->status = F_status_set_error(F_okay_eol); // TODO: don't reset position and instead return as-is without error bit set. break; } @@ -843,7 +843,7 @@ extern "C" { } else { if (object.string[range->start] == f_fss_eol_s.string[0]) { - state->status = F_status_set_error(F_okay_eol); + state->status = F_status_set_error(F_okay_eol); // TODO: don't reset position and instead return as-is without error bit set. break; } @@ -902,7 +902,7 @@ extern "C" { if (object.string[range->start] != f_fss_placeholder_s.string[0]) { if (object.string[range->start] == f_fss_eol_s.string[0]) { - state->status = F_status_set_error(F_okay_eol); + state->status = F_status_set_error(F_okay_eol); // TODO: don't reset position and instead return as-is without error bit set. break; } diff --git a/level_1/fl_fss/c/fss/basic_list.h b/level_1/fl_fss/c/fss/basic_list.h index a3c858400..5fcc49dbb 100644 --- a/level_1/fl_fss/c/fss/basic_list.h +++ b/level_1/fl_fss/c/fss/basic_list.h @@ -305,6 +305,7 @@ extern "C" { * * This alters state.status: * F_okay on success. + * F_okay_eol after reaching an EOL and f_fss_state_flag_eol_error_e is set, which is not supported by the standard and is considered a stopping point. * F_okay_eos on success after reaching the end of the buffer. * F_data_not if Object is empty (object.used is 0). * F_data_not_eos no data to write due start location being greater than or equal to buffer size. @@ -312,7 +313,7 @@ extern "C" { * F_okay_stop on success after reaching stopping point. * * F_interrupt (with error bit) if stopping due to an interrupt. - * F_okay_eol (with error bit) after reaching an EOL, which is not supported by the standard. + * F_okay_eol (with error bit) after reaching an EOL and f_fss_state_flag_eol_error_e is not set, which is not supported by the standard. * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_fss_is_combining(). diff --git a/level_1/fl_fss/c/fss/embedded_list.c b/level_1/fl_fss/c/fss/embedded_list.c index eef32a450..49d37eed3 100644 --- a/level_1/fl_fss/c/fss/embedded_list.c +++ b/level_1/fl_fss/c/fss/embedded_list.c @@ -1090,7 +1090,7 @@ extern "C" { // Objects will not have leading white spaces, but having this does not result in an invalid object, so just write the provided spaces. if (object.string[range->start] != f_fss_placeholder_s.string[0]) { if (object.string[range->start] == f_fss_eol_s.string[0]) { - state->status = F_status_set_error(F_okay_eol); + state->status = F_status_set_error(F_okay_eol); // TODO: don't reset position and instead return as-is without error bit set. break; } @@ -1100,7 +1100,7 @@ extern "C" { } else { if (object.string[range->start] == f_fss_eol_s.string[0]) { - state->status = F_status_set_error(F_okay_eol); + state->status = F_status_set_error(F_okay_eol); // TODO: don't reset position and instead return as-is without error bit set. break; } @@ -1163,7 +1163,7 @@ extern "C" { if (object.string[range->start] != f_fss_placeholder_s.string[0]) { if (object.string[range->start] == f_fss_eol_s.string[0]) { - state->status = F_status_set_error(F_okay_eol); + state->status = F_status_set_error(F_okay_eol); // TODO: don't reset position and instead return as-is without error bit set. break; } @@ -1175,7 +1175,7 @@ extern "C" { flag |= ___fl_flag_ends_on_space___; if (object.string[range->start] == f_fss_eol_s.string[0]) { - state->status = F_status_set_error(F_okay_eol); + state->status = F_status_set_error(F_okay_eol); // TODO: don't reset position and instead return as-is without error bit set. break; } diff --git a/level_1/fl_fss/c/fss/embedded_list.h b/level_1/fl_fss/c/fss/embedded_list.h index d366e0365..4e0915b4a 100644 --- a/level_1/fl_fss/c/fss/embedded_list.h +++ b/level_1/fl_fss/c/fss/embedded_list.h @@ -350,6 +350,7 @@ extern "C" { * * This alters state.status: * F_okay on success. + * F_okay_eol after reaching an EOL and f_fss_state_flag_eol_error_e is set, which is not supported by the standard and is considered a stopping point. * F_okay_eos on success after reaching the end of the buffer. * F_data_not if object is empty (object.used is 0). * F_data_not_eos no data to write due start location being greater than or equal to buffer size. @@ -357,7 +358,7 @@ extern "C" { * F_okay_stop on success after reaching stopping point. * * F_interrupt (with error bit) if stopping due to an interrupt. - * F_okay_eol (with error bit) after reaching an EOL, which is not supported by the standard. + * F_okay_eol (with error bit) after reaching an EOL and f_fss_state_flag_eol_error_e is not set, which is not supported by the standard. * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_fss_is_combining(). diff --git a/level_1/fl_fss/c/fss/extended.c b/level_1/fl_fss/c/fss/extended.c index 5be7c9109..4087d4dfd 100644 --- a/level_1/fl_fss/c/fss/extended.c +++ b/level_1/fl_fss/c/fss/extended.c @@ -52,7 +52,7 @@ extern "C" { content_partial.start = 1; content_partial.stop = 0; - private_fl_fss_basic_or_extended_read(buffer, (state->flag & f_fss_state_quote_not_e) ? 0x2 : 0x0, range, &content_partial, "e, delimits, state); + private_fl_fss_basic_or_extended_read(buffer, (state->flag & f_fss_state_flag_quote_not_e) ? 0x2 : 0x0, range, &content_partial, "e, delimits, state); // Quote is unterminated, retry with quotes disabled as per-specification (this error should not be reported when quotes are disabled). if (state->status == F_status_set_error(F_fss_found_object_content_not)) { diff --git a/level_1/fl_fss/c/fss/extended.h b/level_1/fl_fss/c/fss/extended.h index f99d7c1dc..99cdb6372 100644 --- a/level_1/fl_fss/c/fss/extended.h +++ b/level_1/fl_fss/c/fss/extended.h @@ -69,7 +69,7 @@ extern "C" { * All other statuses are ignored. * * The following bits are supported when set on state.flags: - * - f_fss_state_quote_not_e: Explicitly disable quotes, treating quotes and their respective delimits as normal characters. + * - f_fss_state_flag_quote_not_e: Explicitly disable quotes, treating quotes and their respective delimits as normal characters. * * Must not be NULL. * @@ -156,6 +156,7 @@ extern "C" { * * This alters state.status: * F_okay on success. + * F_okay_eol after reaching an EOL and f_fss_state_flag_eol_error_e is set, which is not supported by the standard and is considered a stopping point. * F_okay_eos on success after reaching the end of the buffer. * F_okay_stop on success after reaching the range stop. * F_data_not if content is empty (content.used is 0). @@ -163,7 +164,7 @@ extern "C" { * F_data_not_stop no data to write due start location being greater than stop location. * * F_interrupt (with error bit) if stopping due to an interrupt. - * F_okay_eol (with error bit) after reaching an EOL, which is not supported by the standard. + * F_okay_eol (with error bit) after reaching an EOL and f_fss_state_flag_eol_error_e is not set, which is not supported by the standard. * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_fss_is_space(). @@ -311,6 +312,7 @@ extern "C" { * * This alters state.status: * F_okay on success. + * F_okay_eol after reaching an EOL and f_fss_state_flag_eol_error_e is set, which is not supported by the standard and is considered a stopping point. * F_okay_eos on success after reaching the end of the buffer. * F_okay_stop on success after reaching the range stop. * F_data_not if object is empty (object.used is 0). @@ -318,7 +320,7 @@ extern "C" { * F_data_not_stop no data to write due start location being greater than stop location. * * F_interrupt (with error bit) if stopping due to an interrupt. - * F_okay_eol (with error bit) after reaching an EOL, which is not supported by the standard. + * F_okay_eol (with error bit) after reaching an EOL and f_fss_state_flag_eol_error_e is not set, which is not supported by the standard. * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_fss_is_space(). diff --git a/level_1/fl_fss/c/fss/extended_list.c b/level_1/fl_fss/c/fss/extended_list.c index 3fcf98e80..0bf238ef9 100644 --- a/level_1/fl_fss/c/fss/extended_list.c +++ b/level_1/fl_fss/c/fss/extended_list.c @@ -825,7 +825,7 @@ extern "C" { // Objects will not have leading white spaces, but having this does not result in an invalid object, so just write the provided spaces. if (object.string[range->start] != f_fss_placeholder_s.string[0]) { if (object.string[range->start] == f_fss_eol_s.string[0]) { - state->status = F_status_set_error(F_okay_eol); + state->status = F_status_set_error(F_okay_eol); // TODO: don't reset position and instead return as-is without error bit set. break; } @@ -835,7 +835,7 @@ extern "C" { } else { if (object.string[range->start] == f_fss_eol_s.string[0]) { - state->status = F_status_set_error(F_okay_eol); + state->status = F_status_set_error(F_okay_eol); // TODO: don't reset position and instead return as-is without error bit set. break; } @@ -898,7 +898,7 @@ extern "C" { if (object.string[range->start] != f_fss_placeholder_s.string[0]) { if (object.string[range->start] == f_fss_eol_s.string[0]) { - state->status = F_status_set_error(F_okay_eol); + state->status = F_status_set_error(F_okay_eol); // TODO: don't reset position and instead return as-is without error bit set. break; } @@ -910,7 +910,7 @@ extern "C" { flag |= ___fl_flag_ends_on_space___; if (object.string[range->start] == f_fss_eol_s.string[0]) { - state->status = F_status_set_error(F_okay_eol); + state->status = F_status_set_error(F_okay_eol); // TODO: don't reset position and instead return as-is without error bit set. break; } diff --git a/level_1/fl_fss/c/fss/extended_list.h b/level_1/fl_fss/c/fss/extended_list.h index 5a67368e5..30ddb1697 100644 --- a/level_1/fl_fss/c/fss/extended_list.h +++ b/level_1/fl_fss/c/fss/extended_list.h @@ -310,6 +310,7 @@ extern "C" { * * This alters state.status: * F_okay on success. + * F_okay_eol after reaching an EOL and f_fss_state_flag_eol_error_e is set, which is not supported by the standard and is considered a stopping point. * F_okay_eos on success after reaching the end of the buffer. * F_data_not if object is empty (object.used is 0). * F_data_not_eos no data to write due start location being greater than or equal to buffer size. @@ -317,7 +318,7 @@ extern "C" { * F_okay_stop on success after reaching stopping point. * * F_interrupt (with error bit) if stopping due to an interrupt. - * F_okay_eol (with error bit) after reaching an EOL, which is not supported by the standard. + * F_okay_eol (with error bit) after reaching an EOL and f_fss_state_flag_eol_error_e is not set, which is not supported by the standard. * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_fss_is_combining(). diff --git a/level_1/fl_fss/c/private-fss.c b/level_1/fl_fss/c/private-fss.c index cabf10008..4ffa3bc69 100644 --- a/level_1/fl_fss/c/private-fss.c +++ b/level_1/fl_fss/c/private-fss.c @@ -802,30 +802,33 @@ extern "C" { } 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; @@ -874,8 +877,8 @@ extern "C" { 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)) { @@ -887,12 +890,9 @@ extern "C" { 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___; } } @@ -933,7 +933,12 @@ extern "C" { } 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; } @@ -1021,10 +1026,12 @@ extern "C" { } 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; } @@ -1044,8 +1051,8 @@ extern "C" { 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) { @@ -1065,9 +1072,13 @@ extern "C" { } 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; } @@ -1085,8 +1096,8 @@ extern "C" { 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) { @@ -1117,8 +1128,8 @@ extern "C" { 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; @@ -1129,8 +1140,8 @@ extern "C" { 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; @@ -1145,14 +1156,18 @@ extern "C" { } 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]; @@ -1162,8 +1177,8 @@ extern "C" { 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; @@ -1175,8 +1190,12 @@ extern "C" { 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; } @@ -1186,8 +1205,8 @@ extern "C" { 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); @@ -1228,8 +1247,8 @@ extern "C" { 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); @@ -1246,8 +1265,8 @@ extern "C" { 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); @@ -1257,8 +1276,8 @@ extern "C" { } 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) { @@ -1291,12 +1310,20 @@ extern "C" { 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___ diff --git a/level_1/fl_fss/c/private-fss.h b/level_1/fl_fss/c/private-fss.h index f85248402..16e1e52cb 100644 --- a/level_1/fl_fss/c/private-fss.h +++ b/level_1/fl_fss/c/private-fss.h @@ -71,7 +71,6 @@ extern "C" { * * F_fss_found_object_content_not (with error bit) If an unterminated quoted Object is found. * F_interrupt (with error bit) if stopping due to an interrupt. - * F_okay_eol (with error bit) after reaching an EOL, which is not supported by the standard. * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_memory_array_increase(). @@ -152,6 +151,7 @@ extern "C" { * * This alters state.status: * F_okay on success. + * F_okay_eol after reaching an EOL and f_fss_state_flag_eol_error_e is set, which is not supported by the standard and is considered a stopping point. * F_okay_eos on success after reaching the end of the buffer. * F_okay_stop on success after reaching the range stop. * F_data_not if object is empty (object.used is 0). @@ -159,14 +159,13 @@ extern "C" { * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * * F_interrupt (with error bit) if stopping due to an interrupt. - * F_okay_eol (with error bit) after reaching an EOL, which is not supported by the standard. + * F_okay_eol (with error bit) after reaching an EOL and f_fss_state_flag_eol_error_e is not set, which is not supported by the standard. * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_fss_is_space(). * Errors (with error bit) from: f_fss_skip_past_combining_joiner(). * 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(). * @param internal @@ -178,7 +177,6 @@ extern "C" { * @see f_fss_skip_past_combining_joiner_joiner() * @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() * @see fl_fss_basic_content_read()