From: Kevin Day Date: Sun, 22 May 2022 03:06:56 +0000 (-0500) Subject: Update: Use F_utf_not instead of F_utf and other resulting changes. X-Git-Tag: 0.5.10~109 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=b0287f0bbba08a1e6129152ec2f2daf2df521a41;p=fll Update: Use F_utf_not instead of F_utf and other resulting changes. The F_utf_not is semantically more correct than F_utf when returning an error for an invalid UTF-8 sequence. Use F_utf_fragment where appropriate as well. Updating all of the appropriate comments revealed some documentation and code structure problems in the fss projects. These are cleaned up as well. --- diff --git a/level_0/f_console/c/console.c b/level_0/f_console/c/console.c index bfaac29..dbaf73e 100644 --- a/level_0/f_console/c/console.c +++ b/level_0/f_console/c/console.c @@ -223,7 +223,7 @@ extern "C" { return F_data_not; } - f_status_t status = status = f_string_dynamics_increase_by(arguments.argc, ¶meters->arguments); + f_status_t status = f_string_dynamics_increase_by(arguments.argc, ¶meters->arguments); if (F_status_is_error(status)) return status; // Append the program name parameter. @@ -383,10 +383,8 @@ extern "C" { } if (parameters->array[i].values_total) { - if (needs_value.used + parameters->array[i].values_total > needs_value.size) { - status = f_array_lengths_resize(needs_value.used + parameters->array[i].values_total, &needs_value); - if (F_status_is_error(status)) break; - } + status = f_array_lengths_increase_by(parameters->array[i].values_total, &needs_value); + if (F_status_is_error(status)) break; for (values = 0; values < parameters->array[i].values_total; ++values) { needs_value.array[needs_value.used++] = i; diff --git a/level_0/f_console/c/console.h b/level_0/f_console/c/console.h index f091d14..1338aa1 100644 --- a/level_0/f_console/c/console.h +++ b/level_0/f_console/c/console.h @@ -166,11 +166,14 @@ extern "C" { * F_array_too_large (with error bit) if a buffer would exceed max length. * F_failure (with error bit) if width is not long enough to convert when processing arguments as UTF-8. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if character is an invalid UTF-8 character, when processing arguments. * - * Errors (with error bit) from: f_string_dynamics_increase_by(). + * Errors (with error bit) from: f_array_lengths_increase(). + * Errors (with error bit) from: f_array_lengths_increase_by(). + * Errors (with error bit) from: f_utf_char_to_character(). * - * @see f_string_dynamics_increase_by() + * @see f_array_lengths_increase() + * @see f_array_lengths_increase_by() + * @see f_utf_char_to_character() */ #ifndef _di_f_console_parameter_process_ extern f_status_t f_console_parameter_process(const f_console_arguments_t arguments, f_console_parameters_t * const parameters); diff --git a/level_0/f_fss/c/fss.c b/level_0/f_fss/c/fss.c index d66289c..342f9ea 100644 --- a/level_0/f_fss/c/fss.c +++ b/level_0/f_fss/c/fss.c @@ -93,7 +93,7 @@ extern "C" { f_status_t f_fss_fail_utf(f_state_t state, const f_status_t status) { if (F_status_is_error(status)) { - if (F_status_set_fine(status) == F_utf_fragment || F_status_set_fine(status) == F_complete_not_utf || F_status_set_fine(status) == F_utf) { + if (F_status_set_fine(status) == F_utf_fragment || F_status_set_fine(status) == F_complete_not_utf || F_status_set_fine(status) == F_utf_not) { if (!(state.flag & f_fss_state_flag_utf_fail_on_valid_not_e)) { return F_status_set_fine(status); } @@ -108,7 +108,7 @@ extern "C" { f_status_t f_fss_fail_utf_to_false(f_state_t state, const f_status_t status) { if (F_status_is_error(status)) { - if (F_status_set_fine(status) == F_utf_fragment || F_status_set_fine(status) == F_complete_not_utf || F_status_set_fine(status) == F_utf) { + if (F_status_set_fine(status) == F_utf_fragment || F_status_set_fine(status) == F_complete_not_utf || F_status_set_fine(status) == F_utf_not) { if (!(state.flag & f_fss_state_flag_utf_fail_on_valid_not_e)) { return F_false; } @@ -237,7 +237,7 @@ extern "C" { // Not enough space in buffer or in range range to process UTF-8 character. if (position + utf_width >= buffer->used || position + utf_width > range.stop) { - return f_fss_fail_utf(state, F_status_set_error(F_utf)); + return f_fss_fail_utf(state, F_status_set_error(F_utf_not)); } if (distance > 0) { diff --git a/level_0/f_fss/c/fss.h b/level_0/f_fss/c/fss.h index ca2ab49..c0d2867 100644 --- a/level_0/f_fss/c/fss.h +++ b/level_0/f_fss/c/fss.h @@ -142,8 +142,8 @@ extern "C" { * The status code to check. * This handles status codes (with error bit set): * - F_complete_not_utf - * - F_utf * - F_utf_fragment + * - F_utf_not * * @return * Status is either directly passed through or the error bit is removed depending on state.flag. @@ -164,8 +164,8 @@ extern "C" { * The status code to check. * This handles status codes (with error bit set): * - F_complete_not_utf - * - F_utf * - F_utf_fragment + * - F_utf_not * * @return * Status is either directly passed through or F_false is returned depending on state.flag. @@ -297,7 +297,7 @@ extern "C" { * F_none_stop on success and stop point was reached. * * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if UTF-8 cannot be fully processed (buffer or range range not long enough). + * F_utf_not (with error bit) if UTF-8 cannot be fully processed (buffer or range range not long enough). */ #ifndef _di_f_fss_shift_delimit_ extern f_status_t f_fss_shift_delimit(f_state_t state, const f_string_range_t range, f_string_dynamic_t * const buffer); diff --git a/level_0/f_utf/c/private-utf.c b/level_0/f_utf/c/private-utf.c index 37e7132..5e43955 100644 --- a/level_0/f_utf/c/private-utf.c +++ b/level_0/f_utf/c/private-utf.c @@ -3924,7 +3924,7 @@ extern "C" { } if (private_f_utf_character_is_valid(character) == F_false) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } // U+0000 -> U+007F (ASCII). diff --git a/level_0/f_utf/c/private-utf.h b/level_0/f_utf/c/private-utf.h index 468fe3f..ced5d0b 100644 --- a/level_0/f_utf/c/private-utf.h +++ b/level_0/f_utf/c/private-utf.h @@ -37,8 +37,8 @@ extern "C" { * * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 sequence. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_char_to_character() * @see f_utf_character_is_valid() @@ -89,8 +89,8 @@ extern "C" { * F_true if a UTF-8 control character. * F_false if not a UTF-8 control character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_alpha() * @see f_utf_is_alpha() @@ -113,8 +113,8 @@ extern "C" { * F_true if a UTF-8 control character. * F_false if not a UTF-8 control character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_alpha_digit() * @see f_utf_is_alpha_digit() @@ -137,8 +137,8 @@ extern "C" { * F_true if a UTF-8 control character. * F_false if not a UTF-8 control character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_alpha_numeric() * @see f_utf_is_alpha_numeric() @@ -161,8 +161,8 @@ extern "C" { * F_true if a UTF-8 combining character. * F_false if not a UTF-8 combining character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_combining() * @see f_utf_is_combining() @@ -185,8 +185,8 @@ extern "C" { * F_true if a UTF-8 control character. * F_false if not a UTF-8 control character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_control() * @see f_utf_is_control() @@ -209,8 +209,8 @@ extern "C" { * F_true if a UTF-8 control character. * F_false if not a UTF-8 control character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_control_code() * @see f_utf_is_control_code() @@ -233,8 +233,8 @@ extern "C" { * F_true if a UTF-8 control character. * F_false if not a UTF-8 control character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_control_format() * @see f_utf_is_control_format() @@ -257,8 +257,8 @@ extern "C" { * F_true if a UTF-8 control picture character. * F_false if not a UTF-8 control picture character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_control_picture() * @see f_utf_is_control_picture() @@ -281,8 +281,8 @@ extern "C" { * F_true if a UTF-8 control character. * F_false if not a UTF-8 control character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_digit() * @see f_utf_is_digit() @@ -305,8 +305,8 @@ extern "C" { * F_true if a UTF-8 control character. * F_false if not a UTF-8 control character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_emoji() * @see f_utf_is_emoji() @@ -329,8 +329,8 @@ extern "C" { * F_true if a UTF-8 control character. * F_false if not a UTF-8 control character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_numeric() * @see f_utf_is_numeric() @@ -353,8 +353,8 @@ extern "C" { * F_true if a UTF-8 control character. * F_false if not a UTF-8 control character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_phonetic() * @see f_utf_is_phonetic() @@ -377,8 +377,8 @@ extern "C" { * F_true if a UTF-8 character. * F_false if not a UTF-8 character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_private() * @see f_utf_is_private() @@ -401,8 +401,8 @@ extern "C" { * F_true if a UTF-8 control character. * F_false if not a UTF-8 control character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_punctuation() * @see f_utf_is_punctuation() @@ -425,8 +425,8 @@ extern "C" { * F_true if a UTF-8 subscript character. * F_false if not a UTF-8 subscript character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_subscript() * @see f_utf_is_subscript() @@ -449,8 +449,8 @@ extern "C" { * F_true if a UTF-8 superscript character. * F_false if not a UTF-8 superscript character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_superscript() * @see f_utf_is_superscript() @@ -473,8 +473,8 @@ extern "C" { * F_true if a UTF-8 control character. * F_false if not a UTF-8 control character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_surrogate() * @see f_utf_is_surrogate() @@ -497,8 +497,8 @@ extern "C" { * F_true if a UTF-8 control character. * F_false if not a UTF-8 control character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_symbol() * @see f_utf_is_symbol() @@ -521,8 +521,8 @@ extern "C" { * F_true if a UTF-8 character. * F_false if not a UTF-8 character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_valid() * @see f_utf_is_valid() @@ -545,8 +545,8 @@ extern "C" { * F_true if a UTF-8 whitespace. * F_false if not a UTF-8 whitespace. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_whitespace() * @see f_utf_is_whitespace() @@ -569,8 +569,8 @@ extern "C" { * F_true if a UTF-8 phonetic whitespace. * F_false if not a UTF-8 phonetic whitespace. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_whitespace_modifier() * @see f_utf_is_whitespace_modifier() @@ -593,8 +593,8 @@ extern "C" { * F_true if a UTF-8 whitespace. * F_false if not a UTF-8 whitespace. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_whitespace_other() * @see f_utf_is_whitespace_other() @@ -617,8 +617,8 @@ extern "C" { * F_true if a UTF-8 wide character. * F_false if not a UTF-8 wide character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. */ #if !defined(_di_f_utf_character_is_wide_) || !defined(_di_f_utf_is_wide_) extern f_status_t private_f_utf_character_is_wide(const f_utf_char_t character) F_attribute_visibility_internal_d; @@ -642,8 +642,8 @@ extern "C" { * F_true if a UTF-8 control character. * F_false if not a UTF-8 control character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_word() * @see f_utf_is_word() @@ -670,8 +670,8 @@ extern "C" { * F_true if a UTF-8 control character. * F_false if not a UTF-8 control character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_word_dash() * @see f_utf_is_word_dash() @@ -698,8 +698,8 @@ extern "C" { * F_true if a UTF-8 control character. * F_false if not a UTF-8 control character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_word_dash_plus() * @see f_utf_is_word_dash_plus() @@ -722,8 +722,8 @@ extern "C" { * F_true if a UTF-8 non-printing or zero-width character. * F_false if not a UTF-8 non-printing or zero-width character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_zero_width() * @see f_utf_is_zero_width() @@ -749,8 +749,8 @@ extern "C" { * * F_failure (with error bit) if width is not long enough to convert. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_unicode_to() * @see f_utf_unicode_to() diff --git a/level_0/f_utf/c/utf/convert.c b/level_0/f_utf/c/utf/convert.c index 7f738e3..3c8c7ad 100644 --- a/level_0/f_utf/c/utf/convert.c +++ b/level_0/f_utf/c/utf/convert.c @@ -27,7 +27,6 @@ extern "C" { #ifndef _di_f_utf_char_to_char_ f_status_t f_utf_char_to_char(const f_utf_char_t utf_character, f_string_t *character, f_array_length_t *width_max) { #ifndef _di_level_0_parameter_checking_ - if (!utf_character) return F_status_set_error(F_parameter); if (!character) return F_status_set_error(F_parameter); if (!width_max) return F_status_set_error(F_parameter); if (!*width_max) return F_status_set_error(F_parameter); @@ -99,7 +98,7 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (unicode > 0x10ffff) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } // U+0000 -> U+007F. @@ -138,7 +137,6 @@ extern "C" { #ifndef _di_f_utf_character_unicode_string_to_ f_status_t f_utf_character_unicode_string_to(const f_utf_string_t string, const f_array_length_t length, f_utf_char_t *unicode) { #ifndef _di_level_0_parameter_checking_ - if (!string) return F_status_set_error(F_parameter); if (!unicode) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -217,7 +215,7 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (unicode > 0x10ffff) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } if (unicode < 0x80) { @@ -239,7 +237,7 @@ extern "C" { } else if (unicode < 0x800) { if (width_max < 2) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } // U+0080 -> U+07FF @@ -256,7 +254,7 @@ extern "C" { } else if (unicode < 0x10000) { if (width_max < 3) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } // U+0800 -> U+FFFF @@ -270,7 +268,7 @@ extern "C" { } else { if (width_max < 4) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } // U+10000 -> U+10FFFF diff --git a/level_0/f_utf/c/utf/convert.h b/level_0/f_utf/c/utf/convert.h index a9de7a8..0a0a0a8 100644 --- a/level_0/f_utf/c/utf/convert.h +++ b/level_0/f_utf/c/utf/convert.h @@ -36,8 +36,8 @@ extern "C" { * * F_failure (with error bit) if width is not long enough to convert. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. */ #ifndef _di_f_utf_char_to_char_ extern f_status_t f_utf_char_to_char(const f_utf_char_t utf_character, f_string_t *character, f_array_length_t *width_max); @@ -59,8 +59,8 @@ extern "C" { * F_none on success. * * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_valid() */ @@ -84,8 +84,8 @@ extern "C" { * F_none on success. * * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. */ #ifndef _di_f_utf_character_unicode_from_ extern f_status_t f_utf_character_unicode_from(const f_utf_char_t unicode, f_utf_char_t *character); @@ -136,8 +136,8 @@ extern "C" { * * F_failure (with error bit) if width is not long enough to convert. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. */ #ifndef _di_f_utf_char_to_character_ extern f_status_t f_utf_char_to_character(const f_string_t character, const f_array_length_t width_max, f_utf_char_t *character_utf); @@ -162,8 +162,8 @@ extern "C" { * * F_failure (with error bit) if width_max is not long enough to convert. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. */ #ifndef _di_f_utf_unicode_from_ extern f_status_t f_utf_unicode_from(const f_utf_char_t unicode, const f_array_length_t width_max, f_string_t *character); @@ -188,8 +188,8 @@ extern "C" { * * F_failure (with error bit) if width is not long enough to convert. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_valid() */ diff --git a/level_0/f_utf/c/utf/dynamic.c b/level_0/f_utf/c/utf/dynamic.c index 91719b6..76ef4f9 100644 --- a/level_0/f_utf/c/utf/dynamic.c +++ b/level_0/f_utf/c/utf/dynamic.c @@ -682,7 +682,7 @@ extern "C" { while (buffer.string[range->start] != f_utf_char_t_eol_s) { if (macro_f_utf_char_t_width_is(buffer.string[range->start]) == 1) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_fragment); } ++range->start; @@ -707,7 +707,7 @@ extern "C" { while (buffer.string[range->start] != seek_to_this) { if (macro_f_utf_char_t_width_is(buffer.string[range->start]) == 1) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_fragment); } if (buffer.string[range->start] == f_utf_char_t_eol_s) return F_none_eol; @@ -734,7 +734,7 @@ extern "C" { while (buffer.string[range->start] != seek_to_this) { if (macro_f_utf_char_t_width_is(buffer.string[range->start]) == 1) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_fragment); } ++range->start; diff --git a/level_0/f_utf/c/utf/dynamic.h b/level_0/f_utf/c/utf/dynamic.h index 51e93e5..76986e1 100644 --- a/level_0/f_utf/c/utf/dynamic.h +++ b/level_0/f_utf/c/utf/dynamic.h @@ -887,6 +887,7 @@ extern "C" { * F_data_not_stop on success, but the range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. * * Errors (with error bit) from: f_memory_resize(). */ @@ -913,6 +914,7 @@ extern "C" { * F_data_not_stop on success, but the range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. * * Errors (with error bit) from: f_memory_resize(). */ @@ -939,6 +941,7 @@ extern "C" { * F_data_not_stop on success, but the range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. * * Errors (with error bit) from: f_memory_resize(). */ diff --git a/level_0/f_utf/c/utf/is.h b/level_0/f_utf/c/utf/is.h index 4251c68..b2bb589 100644 --- a/level_0/f_utf/c/utf/is.h +++ b/level_0/f_utf/c/utf/is.h @@ -48,8 +48,8 @@ extern "C" { * F_false if not a UTF-8 alphabet character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. * * @see isalpha() */ @@ -76,8 +76,8 @@ extern "C" { * F_false if not a UTF-8 alpha-numeric character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. * * @see isalnum() */ @@ -102,8 +102,8 @@ extern "C" { * F_false if not a UTF-8 alpha-numeric character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. * * @see isalnum() */ @@ -126,8 +126,8 @@ extern "C" { * F_false if not an ASCII character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. */ #ifndef _di_f_utf_is_ascii_ extern f_status_t f_utf_is_ascii(const f_string_t character, const f_array_length_t width_max); @@ -148,8 +148,8 @@ extern "C" { * F_false if not a UTF-8 combining character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. */ #ifndef _di_f_utf_is_combining_ extern f_status_t f_utf_is_combining(const f_string_t character, const f_array_length_t width_max); @@ -172,8 +172,8 @@ extern "C" { * F_false if not a UTF-8 control character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. * * @see iscntrl() */ @@ -198,8 +198,8 @@ extern "C" { * F_false if not a UTF-8 control code character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. */ #ifndef _di_f_utf_is_control_code_ extern f_status_t f_utf_is_control_code(const f_string_t character, const f_array_length_t width_max); @@ -223,8 +223,8 @@ extern "C" { * F_false if not a UTF-8 control format character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. */ #ifndef _di_f_utf_is_control_format_ extern f_status_t f_utf_is_control_format(const f_string_t character, const f_array_length_t width_max); @@ -247,8 +247,8 @@ extern "C" { * F_false if not a UTF-8 control picture character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. */ #ifndef _di_f_utf_is_control_picture_ extern f_status_t f_utf_is_control_picture(const f_string_t character, const f_array_length_t width_max); @@ -269,8 +269,8 @@ extern "C" { * F_false if not a UTF-8 digit character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. * * @see isdigit() */ @@ -295,8 +295,8 @@ extern "C" { * F_false if not a UTF-8 emoji character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. */ #ifndef _di_f_utf_is_emoji_ extern f_status_t f_utf_is_emoji(const f_string_t character, const f_array_length_t width_max); @@ -350,8 +350,8 @@ extern "C" { * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. * F_maybe (with error bit) if this could be a graph but width is not long enough. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. * * @see isgraph() */ @@ -376,8 +376,8 @@ extern "C" { * F_false if not a UTF-8 numeric character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. * * @see isdigit() */ @@ -400,8 +400,8 @@ extern "C" { * F_false if not a UTF-8 phonetic character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. */ #ifndef _di_f_utf_is_phonetic_ extern f_status_t f_utf_is_phonetic(const f_string_t character, const f_array_length_t width_max); @@ -422,8 +422,8 @@ extern "C" { * F_false if not a UTF-8 punctuation character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. */ #ifndef _di_f_utf_is_private_ extern f_status_t f_utf_is_private(const f_string_t character, const f_array_length_t width_max); @@ -446,8 +446,8 @@ extern "C" { * F_false if not a UTF-8 punctuation character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. */ #ifndef _di_f_utf_is_punctuation_ extern f_status_t f_utf_is_punctuation(const f_string_t character, const f_array_length_t width_max); @@ -468,8 +468,8 @@ extern "C" { * F_false if not a UTF-8 subscript character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. */ #ifndef _di_f_utf_is_subscript_ extern f_status_t f_utf_is_subscript(const f_string_t character, const f_array_length_t width_max); @@ -490,8 +490,8 @@ extern "C" { * F_false if not a UTF-8 superscript character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. */ #ifndef _di_f_utf_is_superscript_ extern f_status_t f_utf_is_superscript(const f_string_t character, const f_array_length_t width_max); @@ -512,8 +512,8 @@ extern "C" { * F_false if not a UTF-8 symbol character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. */ #ifndef _di_f_utf_is_surrogate_ extern f_status_t f_utf_is_surrogate(const f_string_t character, const f_array_length_t width_max); @@ -536,8 +536,8 @@ extern "C" { * F_false if not a UTF-8 symbol character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. */ #ifndef _di_f_utf_is_symbol_ extern f_status_t f_utf_is_symbol(const f_string_t character, const f_array_length_t width_max); @@ -559,8 +559,8 @@ extern "C" { * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. * F_parameter (with error bit) if a parameter is inunassigned. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. */ #ifndef _di_f_utf_is_unassigned_ extern f_status_t f_utf_is_unassigned(const f_string_t character, const f_array_length_t width_max); @@ -621,8 +621,8 @@ extern "C" { * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. * F_maybe (with error bit) if this could be a whitespace but width is not long enough. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. * * @see isspace() */ @@ -652,8 +652,8 @@ extern "C" { * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. * F_maybe (with error bit) if this could be a whitespace but width is not long enough. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. */ #ifndef _di_f_utf_is_whitespace_modifier_ extern f_status_t f_utf_is_whitespace_modifier(const f_string_t character, const f_array_length_t width_max); @@ -678,8 +678,8 @@ extern "C" { * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. * F_maybe (with error bit) if this could be a whitespace but width is not long enough. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. */ #ifndef _di_f_utf_is_whitespace_other_ extern f_status_t f_utf_is_whitespace_other(const f_string_t character, const f_array_length_t width_max); @@ -706,8 +706,8 @@ extern "C" { * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. */ #ifndef _di_f_utf_is_wide_ extern f_status_t f_utf_is_wide(const f_string_t character, const f_array_length_t width_max); @@ -734,8 +734,8 @@ extern "C" { * F_false if not a UTF-8 word character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. * * @see isalnum() */ @@ -769,8 +769,8 @@ extern "C" { * F_false if not a UTF-8 word or dash character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. * * @see isalnum() */ @@ -806,8 +806,8 @@ extern "C" { * F_false if not a UTF-8 word or dash character. * * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. * * @see isalnum() */ @@ -834,8 +834,8 @@ extern "C" { * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. * F_maybe (with error bit) if this could be a whitespace but width is not long enough. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if Unicode is an invalid Unicode character. * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if Unicode is an invalid Unicode character. */ #ifndef _di_f_utf_is_zero_width_ extern f_status_t f_utf_is_zero_width(const f_string_t character, const f_array_length_t width_max); diff --git a/level_0/f_utf/c/utf/is_character.h b/level_0/f_utf/c/utf/is_character.h index 0e90bb7..d4ca01e 100644 --- a/level_0/f_utf/c/utf/is_character.h +++ b/level_0/f_utf/c/utf/is_character.h @@ -45,8 +45,8 @@ extern "C" { * F_true if a UTF-8 alphabet character. * F_false if not a UTF-8 alphabet character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see isalpha() */ @@ -68,8 +68,8 @@ extern "C" { * F_true if a UTF-8 alpha-digit character. * F_false if not a UTF-8 alpha-digit character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see isalnum() */ @@ -89,8 +89,8 @@ extern "C" { * F_true if a UTF-8 alpha-numeric character. * F_false if not a UTF-8 alpha-numeric character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see isalnum() */ @@ -124,8 +124,8 @@ extern "C" { * F_true if a UTF-8 combining character. * F_false if not a UTF-8 combining character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. */ #ifndef _di_f_utf_character_is_combining_ extern f_status_t f_utf_character_is_combining(const f_utf_char_t character); @@ -143,8 +143,8 @@ extern "C" { * F_true if a UTF-8 control character. * F_false if not a UTF-8 control character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see iscntrl() */ @@ -164,8 +164,8 @@ extern "C" { * F_true if a UTF-8 control code character. * F_false if not a UTF-8 control code character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see iscntrl() */ @@ -186,8 +186,8 @@ extern "C" { * F_true if a UTF-8 control format character. * F_false if not a UTF-8 control format character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. */ #ifndef _di_f_utf_character_is_control_format_ extern f_status_t f_utf_character_is_control_format(const f_utf_char_t character); @@ -205,8 +205,8 @@ extern "C" { * F_true if a UTF-8 control picture character. * F_false if not a UTF-8 control picture character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. */ #ifndef _di_f_utf_character_is_control_picture_ extern f_status_t f_utf_character_is_control_picture(const f_utf_char_t character); @@ -226,8 +226,8 @@ extern "C" { * F_true if a UTF-8 digit character. * F_false if not a UTF-8 digit character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see isdigit() */ @@ -247,8 +247,8 @@ extern "C" { * F_true if a UTF-8 emoji character. * F_false if not a UTF-8 emoji character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. */ #ifndef _di_f_utf_character_is_emoji_ extern f_status_t f_utf_character_is_emoji(const f_utf_char_t character); @@ -280,8 +280,8 @@ extern "C" { * F_true if a UTF-8 character. * F_false if not a UTF-8 character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is() * @see f_utf_character_is_valid() @@ -300,8 +300,8 @@ extern "C" { * F_true if a UTF-8 graph. * F_false if not a UTF-8 graph. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see isgraph() */ @@ -321,8 +321,8 @@ extern "C" { * F_true if a UTF-8 numeric character. * F_false if not a UTF-8 numeric character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see isdigit() */ @@ -340,8 +340,8 @@ extern "C" { * F_true if a UTF-8 phonetic character. * F_false if not a UTF-8 phonetic character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. */ #ifndef _di_f_utf_character_is_phonetic_ extern f_status_t f_utf_character_is_phonetic(const f_utf_char_t character); @@ -357,8 +357,8 @@ extern "C" { * F_true if a UTF-8 private character. * F_false if not a UTF-8 private character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. */ #ifndef _di_f_utf_character_is_private_ extern f_status_t f_utf_character_is_private(const f_utf_char_t character); @@ -376,8 +376,8 @@ extern "C" { * F_true if a UTF-8 punctuation character. * F_false if not a UTF-8 punctuation character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. */ #ifndef _di_f_utf_character_is_punctuation_ extern f_status_t f_utf_character_is_punctuation(const f_utf_char_t character); @@ -395,8 +395,8 @@ extern "C" { * F_true if a UTF-8 subscript character. * F_false if not a UTF-8 subscript character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. */ #ifndef _di_f_utf_character_is_subscript_ extern f_status_t f_utf_character_is_subscript(const f_utf_char_t character); @@ -414,8 +414,8 @@ extern "C" { * F_true if a UTF-8 superscript character. * F_false if not a UTF-8 superscript character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. */ #ifndef _di_f_utf_character_is_superscript_ extern f_status_t f_utf_character_is_superscript(const f_utf_char_t character); @@ -433,8 +433,8 @@ extern "C" { * F_true if a UTF-8 symbol character. * F_false if not a UTF-8 symbol character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. */ #ifndef _di_f_utf_character_is_symbol_ extern f_status_t f_utf_character_is_symbol(const f_utf_char_t character); @@ -455,8 +455,8 @@ extern "C" { * F_true if a UTF-8 unassigned character. * F_false if not a UTF-8 unassigned character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is() * @see f_utf_character_is_fragment() @@ -482,8 +482,8 @@ extern "C" { * F_true if a UTF-8 character. * F_false if not a UTF-8 character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is() * @see f_utf_character_is_fragment() @@ -510,8 +510,8 @@ extern "C" { * F_true if a UTF-8 whitespace. * F_false if not a UTF-8 whitespace. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see isspace() */ @@ -534,8 +534,8 @@ extern "C" { * F_true if a UTF-8 modifier character. * F_false if not a UTF-8 modifier character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. */ #ifndef _di_f_utf_character_is_whitespace_modifier_ extern f_status_t f_utf_character_is_whitespace_modifier(const f_utf_char_t character); @@ -553,8 +553,8 @@ extern "C" { * F_true if a UTF-8 (other) whitespace. * F_false if not a UTF-8 (other) whitespace. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see isspace() */ @@ -578,8 +578,8 @@ extern "C" { * * F_failure (with error bit) if width is not long enough to convert. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. */ #ifndef _di_f_utf_character_is_wide_ extern f_status_t f_utf_character_is_wide(const f_utf_char_t character); @@ -601,8 +601,8 @@ extern "C" { * F_true if a UTF-8 word character. * F_false if not a UTF-8 word character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see isalnum() */ @@ -631,8 +631,8 @@ extern "C" { * F_true if a UTF-8 word or dash character. * F_false if not a UTF-8 word or dash character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see isalnum() */ @@ -663,8 +663,8 @@ extern "C" { * F_true if a UTF-8 word or dash character. * F_false if not a UTF-8 word or dash character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see isalnum() */ @@ -684,8 +684,8 @@ extern "C" { * F_true if a UTF-8 non-printing or zero-width character. * F_false if not a UTF-8 non-printing or zero-width character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. */ #ifndef _di_f_utf_character_is_zero_width_ extern f_status_t f_utf_character_is_zero_width(const f_utf_char_t character); diff --git a/level_0/f_utf/c/utf/private-is_unassigned.h b/level_0/f_utf/c/utf/private-is_unassigned.h index a44244d..f5ab95d 100644 --- a/level_0/f_utf/c/utf/private-is_unassigned.h +++ b/level_0/f_utf/c/utf/private-is_unassigned.h @@ -29,8 +29,8 @@ extern "C" { * F_true if a UTF-8 character. * F_false if not a UTF-8 character. * - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * @see f_utf_character_is_unassigned() * @see f_utf_is_unassigned() diff --git a/level_0/f_utf/c/utf/string.h b/level_0/f_utf/c/utf/string.h index 2a70f4e..ea8d519 100644 --- a/level_0/f_utf/c/utf/string.h +++ b/level_0/f_utf/c/utf/string.h @@ -362,8 +362,8 @@ extern "C" { * F_data_not_stop on success, but the range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. * * Errors (with error bit) from: f_memory_resize(). */ @@ -411,8 +411,8 @@ extern "C" { * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if unicode is an invalid Unicode character. - * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. */ #ifndef _di_f_utf_string_seek_to_ extern f_status_t f_utf_string_seek_to(const f_utf_string_t string, const f_utf_char_t seek_to, f_string_range_t * const range); diff --git a/level_1/fl_fss/c/fss/basic.c b/level_1/fl_fss/c/fss/basic.c index 961131a..cbc41e3 100644 --- a/level_1/fl_fss/c/fss/basic.c +++ b/level_1/fl_fss/c/fss/basic.c @@ -6,26 +6,6 @@ extern "C" { #endif -#ifndef _di_fl_fss_basic_object_read_ - f_status_t fl_fss_basic_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_quote_t * const quote, f_fss_delimits_t * const delimits) { - #ifndef _di_level_1_parameter_checking_ - if (!range) return F_status_set_error(F_parameter); - if (!found) return F_status_set_error(F_parameter); - if (!delimits) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - const f_array_length_t delimits_used = delimits->used; - - f_status_t status = private_fl_fss_basic_read(buffer, F_true, state, range, found, quote, delimits); - - if (F_status_is_error(status)) { - delimits->used = delimits_used; - } - - return status; - } -#endif // _di_fl_fss_basic_object_read_ - #ifndef _di_fl_fss_basic_content_read_ f_status_t fl_fss_basic_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_content_t * const found, f_fss_delimits_t * const delimits) { #ifndef _di_level_1_parameter_checking_ @@ -91,66 +71,6 @@ extern "C" { } #endif // _di_fl_fss_basic_content_read_ -#ifndef _di_fl_fss_basic_object_write_ - f_status_t fl_fss_basic_object_write(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination) { - #ifndef _di_level_1_parameter_checking_ - if (!range) return F_status_set_error(F_parameter); - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - const f_array_length_t destination_used = destination->used; - - f_status_t status = private_fl_fss_basic_write(F_true, object, quote ? quote : f_fss_delimit_quote_double_s.string[0], state, range, destination); - - if (status == F_data_not_stop || status == F_data_not_eos) { - - // Objects cannot be empty, so write a quoted empty string. - const f_status_t status_allocation = f_string_dynamic_increase_by(2, destination); - - if (F_status_is_error(status_allocation)) { - destination->used = destination_used; - - return status_allocation; - } - - destination->string[destination->used++] = quote ? f_fss_delimit_quote_single_s.string[0] : f_fss_delimit_quote_double_s.string[0]; - destination->string[destination->used++] = quote ? f_fss_delimit_quote_single_s.string[0] : f_fss_delimit_quote_double_s.string[0]; - } - - if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { - if (status == F_none_stop || status == F_none_eos || status == F_data_not_stop || status == F_data_not_eos) { - f_status_t status2 = F_none; - - if (complete == f_fss_complete_full_trim_e) { - status2 = private_fl_fss_basic_write_object_trim(quote ? quote : f_fss_delimit_quote_double_s.string[0], destination_used, state, destination); - - if (F_status_is_error(status2)) { - destination->used = destination_used; - - return status2; - } - } - - status2 = f_string_dynamic_increase(state.step_large, destination); - - if (F_status_is_error(status2)) { - destination->used = destination_used; - - return status2; - } - - destination->string[destination->used++] = f_fss_basic_open_s.string[0]; - } - } - - if (F_status_is_error(status)) { - destination->used = destination_used; - } - - return status; - } -#endif // _di_fl_fss_basic_object_write_ - #ifndef _di_fl_fss_basic_content_write_ f_status_t fl_fss_basic_content_write(const f_string_static_t content, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination) { #ifndef _di_level_1_parameter_checking_ @@ -219,6 +139,86 @@ extern "C" { } #endif // _di_fl_fss_basic_content_write_ +#ifndef _di_fl_fss_basic_object_read_ + f_status_t fl_fss_basic_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_quote_t * const quote, f_fss_delimits_t * const delimits) { + #ifndef _di_level_1_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + if (!found) return F_status_set_error(F_parameter); + if (!delimits) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + const f_array_length_t delimits_used = delimits->used; + + f_status_t status = private_fl_fss_basic_read(buffer, F_true, state, range, found, quote, delimits); + + if (F_status_is_error(status)) { + delimits->used = delimits_used; + } + + return status; + } +#endif // _di_fl_fss_basic_object_read_ + +#ifndef _di_fl_fss_basic_object_write_ + f_status_t fl_fss_basic_object_write(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination) { + #ifndef _di_level_1_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + const f_array_length_t destination_used = destination->used; + + f_status_t status = private_fl_fss_basic_write(F_true, object, quote ? quote : f_fss_delimit_quote_double_s.string[0], state, range, destination); + + if (status == F_data_not_stop || status == F_data_not_eos) { + + // Objects cannot be empty, so write a quoted empty string. + const f_status_t status_allocation = f_string_dynamic_increase_by(2, destination); + + if (F_status_is_error(status_allocation)) { + destination->used = destination_used; + + return status_allocation; + } + + destination->string[destination->used++] = quote ? f_fss_delimit_quote_single_s.string[0] : f_fss_delimit_quote_double_s.string[0]; + destination->string[destination->used++] = quote ? f_fss_delimit_quote_single_s.string[0] : f_fss_delimit_quote_double_s.string[0]; + } + + if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { + if (status == F_none_stop || status == F_none_eos || status == F_data_not_stop || status == F_data_not_eos) { + f_status_t status2 = F_none; + + if (complete == f_fss_complete_full_trim_e) { + status2 = private_fl_fss_basic_write_object_trim(quote ? quote : f_fss_delimit_quote_double_s.string[0], destination_used, state, destination); + + if (F_status_is_error(status2)) { + destination->used = destination_used; + + return status2; + } + } + + status2 = f_string_dynamic_increase(state.step_large, destination); + + if (F_status_is_error(status2)) { + destination->used = destination_used; + + return status2; + } + + destination->string[destination->used++] = f_fss_basic_open_s.string[0]; + } + } + + if (F_status_is_error(status)) { + destination->used = destination_used; + } + + return status; + } +#endif // _di_fl_fss_basic_object_write_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_1/fl_fss/c/fss/basic.h b/level_1/fl_fss/c/fss/basic.h index 5f27ad9..caab64e 100644 --- a/level_1/fl_fss/c/fss/basic.h +++ b/level_1/fl_fss/c/fss/basic.h @@ -30,7 +30,7 @@ extern "C" { #endif /** - * Read an fss-0000 object. + * Read an fss-0000 content. * * This will record where delimit placeholders exist but will not apply the delimits. * @@ -51,17 +51,13 @@ extern "C" { * The start location will represent where the read stopped on return. * A start location past the stop location or buffer used means that the entire range was processed. * @param found - * A location where a valid object was found. - * @param quote - * This will store whether or not this object is quote and what quote is in use. - * Set pointer address to 0 to not use. + * A set of all locations where a valid content was found. * @param delimits * A delimits array representing where delimits exist within the buffer. * * @return - * F_fss_found_object on success and object was found (start location is at end of object). - * F_fss_found_object_content_not on success but object ended at the line so there can be no content. - * F_fss_found_object_not on success and no object was found (start location is after character designating this is not an object). + * F_fss_found_content on success and content was found (start location is at end of content). + * F_fss_found_content_not on success and no content was found (start location is after character designating this is not a content). * F_none_eos on success after reaching the end of the buffer (a valid object is not yet confirmed). * F_none_stop on success after reaching stopping point (a valid object is not yet confirmed). * F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found). @@ -72,20 +68,74 @@ extern "C" { * F_interrupt (with error bit) if stopping due to an interrupt. * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_utf_buffer_increment(). - * Errors (with error bit) from: f_fss_is_graph(). - * Errors (with error bit) from: f_fss_is_space(). - * Errors (with error bit) from: f_fss_is_zero_width(). - * 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_string_ranges_increase(). + * Errors (with error bit) from: f_utf_buffer_increment(). + * + * @see f_fss_skip_past_delimit() + * @see f_fss_skip_past_space() + * @see f_string_ranges_increase() + * @see f_utf_buffer_increment() */ -#ifndef _di_fl_fss_basic_object_read_ - extern f_status_t fl_fss_basic_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_quote_t * const quote, f_fss_delimits_t * const delimits); -#endif // _di_fl_fss_basic_object_read_ +#ifndef _di_fl_fss_basic_content_read_ + extern f_status_t fl_fss_basic_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_content_t * const found, f_fss_delimits_t * const delimits); +#endif // _di_fl_fss_basic_content_read_ /** - * Read an fss-0000 content. + * Write an fss-0000 content from a given string. + * + * This will write the given string range as a valid content. + * Anything within this range will be escaped as necessary. + * + * The destination string may have NULLs. + * + * @param content + * The string to write as (does not stop at NULLS, they are ignored and not written). + * @param complete + * If f_fss_complete_none_e, then only the content is written. + * If f_fss_complete_next_e, then the content followed by any appropriate "next" character separating one content from the next, if applicable. + * If f_fss_complete_end_e, then the content followed by any appropriate "end" character designating the last content for some object, printing final newline, if applicable. + * If f_fss_complete_partial_e, this will write any appropriate open and close aspects of this content, except for the final newline. + * If f_fss_complete_full_e, this will write any appropriate open and close aspects of this content, including the final newline. + * @param state + * A state for providing flags and handling interrupts during long running operations. + * There is no print_error(). + * There is no functions structure. + * There is no data structure passed to these functions. + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. + * @param range + * The start/stop location within the content string to write as an content. + * @param destination + * The buffer where the content is written to. + * @return + * F_none on success. + * F_none_eos on success after reaching the end of the buffer. + * F_none_stop on success after reaching the range stop. + * F_data_not_stop no data to write due start location being greater than stop location. + * 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_none_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_fss_skip_past_delimit(). + * Errors (with error bit) from: f_string_dynamic_increase(). + * Errors (with error bit) from: f_string_dynamic_increase_by(). + * + * @see f_fss_skip_past_delimit() + * @see f_string_dynamic_increase() + * @see f_string_dynamic_increase_by() + */ +#ifndef _di_fl_fss_basic_content_write_ + extern f_status_t fl_fss_basic_content_write(const f_string_static_t content, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination); +#endif // _di_fl_fss_basic_content_write_ + +/** + * Read an fss-0000 object. * * This will record where delimit placeholders exist but will not apply the delimits. * @@ -106,13 +156,17 @@ extern "C" { * The start location will represent where the read stopped on return. * A start location past the stop location or buffer used means that the entire range was processed. * @param found - * A set of all locations where a valid content was found. + * A location where a valid object was found. + * @param quote + * This will store whether or not this object is quote and what quote is in use. + * Set pointer address to 0 to not use. * @param delimits * A delimits array representing where delimits exist within the buffer. * * @return - * F_fss_found_content on success and content was found (start location is at end of content). - * F_fss_found_content_not on success and no content was found (start location is after character designating this is not a content). + * F_fss_found_object on success and object was found (start location is at end of object). + * F_fss_found_object_content_not on success but object ended at the line so there can be no content. + * F_fss_found_object_not on success and no object was found (start location is after character designating this is not an object). * F_none_eos on success after reaching the end of the buffer (a valid object is not yet confirmed). * F_none_stop on success after reaching stopping point (a valid object is not yet confirmed). * F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found). @@ -123,13 +177,29 @@ extern "C" { * F_interrupt (with error bit) if stopping due to an interrupt. * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_utf_buffer_increment(). + * Errors (with error bit) from: f_array_lengths_increase(). + * Errors (with error bit) from: f_array_lengths_increase_by(). + * Errors (with error bit) from: f_fss_is_graph(). + * Errors (with error bit) from: f_fss_is_space(). + * Errors (with error bit) from: f_fss_is_zero_width(). + * 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_utf_buffer_increment(). + * + * @see f_array_lengths_increase() + * @see f_array_lengths_increase_by() + * @see f_fss_is_graph() + * @see f_fss_is_space() + * @see f_fss_is_zero_width() + * @see f_fss_seek_to_eol() + * @see f_fss_skip_past_delimit() + * @see f_fss_skip_past_space() + * @see f_utf_buffer_increment() */ -#ifndef _di_fl_fss_basic_content_read_ - extern f_status_t fl_fss_basic_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_content_t * const found, f_fss_delimits_t * const delimits); -#endif // _di_fl_fss_basic_content_read_ +#ifndef _di_fl_fss_basic_object_read_ + extern f_status_t fl_fss_basic_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_quote_t * const quote, f_fss_delimits_t * const delimits); +#endif // _di_fl_fss_basic_object_read_ /** * Write an fss-0000 object from a given string. @@ -172,67 +242,26 @@ extern "C" { * F_data_not_stop no data to write due start location being greater than stop location. * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. * F_none_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. - * F_string_too_large (with error bit) if appended string length is too large to store in the destination. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * * Errors (with error bit) from: f_fss_is_space(). - * Errors (with error bit) from: f_utf_buffer_increment(). + * 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_string_dynamic_increase(). + * Errors (with error bit) from: f_string_dynamic_increase_by(). + * + * @see f_fss_is_space() + * @see f_fss_skip_past_delimit() + * @see f_fss_skip_past_space() + * @see f_string_dynamic_increase() + * @see f_string_dynamic_increase_by() */ #ifndef _di_fl_fss_basic_object_write_ extern f_status_t fl_fss_basic_object_write(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination); #endif // _di_fl_fss_basic_object_write_ -/** - * Write an fss-0000 content from a given string. - * - * This will write the given string range as a valid content. - * Anything within this range will be escaped as necessary. - * - * The destination string may have NULLs. - * - * @param content - * The string to write as (does not stop at NULLS, they are ignored and not written). - * @param complete - * If f_fss_complete_none_e, then only the content is written. - * If f_fss_complete_next_e, then the content followed by any appropriate "next" character separating one content from the next, if applicable. - * If f_fss_complete_end_e, then the content followed by any appropriate "end" character designating the last content for some object, printing final newline, if applicable. - * If f_fss_complete_partial_e, this will write any appropriate open and close aspects of this content, except for the final newline. - * If f_fss_complete_full_e, this will write any appropriate open and close aspects of this content, including the final newline. - * @param state - * A state for providing flags and handling interrupts during long running operations. - * There is no print_error(). - * There is no functions structure. - * There is no data structure passed to these functions. - * - * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. - * Error bit designates an error but must be passed along with F_interrupt. - * All other statuses are ignored. - * @param range - * The start/stop location within the content string to write as an content. - * @param destination - * The buffer where the content is written to. - * @return - * F_none on success. - * F_none_eos on success after reaching the end of the buffer. - * F_none_stop on success after reaching the range stop. - * F_data_not_stop no data to write due start location being greater than stop location. - * 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_memory_not (with error bit) on out of memory. - * F_none_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. - * F_string_too_large (with error bit) if appended string length is too large to store in the destination. - */ -#ifndef _di_fl_fss_basic_content_write_ - extern f_status_t fl_fss_basic_content_write(const f_string_static_t content, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination); -#endif // _di_fl_fss_basic_content_write_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_1/fl_fss/c/fss/basic_list.c b/level_1/fl_fss/c/fss/basic_list.c index a7ad6ac..6bca029 100644 --- a/level_1/fl_fss/c/fss/basic_list.c +++ b/level_1/fl_fss/c/fss/basic_list.c @@ -6,67 +6,38 @@ extern "C" { #endif -#ifndef _di_fl_fss_basic_list_object_read_ - f_status_t fl_fss_basic_list_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_delimits_t * const delimits) { +#ifndef _di_fl_fss_basic_list_content_read_ + f_status_t fl_fss_basic_list_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_content_t * const found, f_fss_delimits_t * const delimits, f_fss_comments_t * const comments) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!found) return F_status_set_error(F_parameter); if (!delimits) return F_status_set_error(F_parameter); + if (!comments) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ const f_array_length_t delimits_used = delimits->used; + const f_array_length_t comments_used = comments->used; - f_status_t status = f_fss_skip_past_space(state, buffer, range); + f_status_t status = f_fss_skip_past_delimit(state, buffer, range); if (F_status_is_error(status)) return status; - if (status == F_none_eol) { - - // Move the start position to after the EOL. - ++range->start; - - return F_fss_found_object_not; - } - - if (status == F_none_eos) { - return F_data_not_eos; - } - - if (status == F_none_stop) { - return F_data_not_stop; - } - - // Begin the search. - found->start = range->start; - - // Ignore all comment lines. - if (buffer.string[range->start] == f_fss_comment_s.string[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; - } + private_macro_fl_fss_content_with_comments_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, F_none_eos, F_none_stop); - // Move the start position to after the EOL. - ++range->start; + status = f_string_ranges_increase(state.step_small, found); + if (F_status_is_error(status)) return status; - return F_fss_found_object_not; - } + found->array[found->used].start = range->start; + f_array_length_t newline_last = range->start; f_array_length_t slash_first = 0; f_array_length_t slash_count = 0; f_array_length_t start = 0; - f_array_length_t stop = 0; + f_array_length_t comment_delimit = 0; - bool graph_first = F_true; + uint8_t graph_first = 0x1; // 0x0 = false, 0x1 = true, 0x2 = false, but there is a delimited comment, comment_delimit is set. - // Identify where the object ends. - while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol_s.string[0]) { + // Identify where the content ends. + while (range->start <= range->stop && range->start < buffer.used) { if (state.interrupt) { status = state.interrupt((void *) &state, 0); @@ -78,6 +49,21 @@ extern "C" { } } + if (buffer.string[range->start] == f_fss_eol_s.string[0]) { + if (graph_first == 0x2) { + status = f_array_lengths_increase(state.step_small, delimits); + if (F_status_is_error(status)) break; + + delimits->array[delimits->used++] = comment_delimit; + } + + newline_last = range->start; + graph_first = 0x1; + ++range->start; + + continue; + } + if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) { slash_first = range->start; slash_count = 1; @@ -94,23 +80,17 @@ extern "C" { } } - 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; + if (buffer.string[range->start] != f_fss_delimit_slash_s.string[0]) break; ++slash_count; } // for - private_macro_fl_fss_object_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop); + if (range->start > range->stop || range->start >= buffer.used) break; if (buffer.string[range->start] == f_fss_basic_list_open_s.string[0]) { - graph_first = F_false; - stop = range->start - 1; - - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) return status; + graph_first = 0x0; + ++range->start; while (range->start <= range->stop && range->start < buffer.used) { @@ -135,71 +115,61 @@ extern "C" { if (F_status_is_error(status)) break; } // while - private_macro_fl_fss_object_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop); + if (range->start > range->stop || range->start >= buffer.used) break; if (buffer.string[range->start] == f_fss_eol_s.string[0]) { start = range->start; - range->start = slash_first; - macro_f_fss_delimits_t_increase_by(status, (*delimits), (slash_count / 2) + 1); - if (F_status_is_error(status)) break; - if (slash_count % 2 == 0) { - while (slash_count > 0) { + found->array[found->used++].stop = newline_last; + range->start = newline_last + 1; - if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) { - if (slash_count % 2 == 1) { - delimits->array[delimits->used] = range->start; - ++delimits->used; - } + return F_fss_found_content; + } - --slash_count; + status = f_array_lengths_increase_by((slash_count / 2) + 1, delimits); + if (F_status_is_error(status)) break; + + while (slash_count > 0) { + + if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) { + if (slash_count % 2 == 1) { + delimits->array[delimits->used++] = range->start; } - status = f_utf_buffer_increment(buffer, range, 1); + --slash_count; + } - if (F_status_is_error(status)) { - delimits->used = delimits_used; + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; + } // while - return status; - } - } // while + if (F_status_is_error(status)) break; - found->stop = stop; - range->start = start + 1; + if (graph_first == 0x2) { + status = f_array_lengths_increase(state.step_small, delimits); + if (F_status_is_error(status)) break; - return F_fss_found_object; + delimits->array[delimits->used++] = comment_delimit; } + graph_first = 0x1; range->start = start + 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; - - // Comments may only have whitespace before the '#', therefore only the first slash needs to be delimited. - macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); - if (F_status_is_error(status)) break; - - delimits->array[delimits->used++] = slash_first; + else if (graph_first == 0x1 && buffer.string[range->start] == f_fss_comment_s.string[0]) { + graph_first = 0x2; + comment_delimit = slash_first; ++range->start; } - else { - graph_first = F_false; - } continue; } if (buffer.string[range->start] == f_fss_basic_list_open_s.string[0]) { - graph_first = F_false; - stop = range->start - 1; - - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) break; + ++range->start; + graph_first = 0x0; while (range->start <= range->stop && range->start < buffer.used) { @@ -208,6 +178,7 @@ extern "C" { if (F_status_set_fine(status) == F_interrupt) { status = F_status_set_error(F_interrupt); + break; } } @@ -223,88 +194,401 @@ extern "C" { if (F_status_is_error(status)) break; } // while - private_macro_fl_fss_object_return_on_overflow_delimited((buffer), (*range), (*found), F_none_eos, F_none_stop); + if (F_status_is_error(status)) break; + if (range->start > range->stop || range->start >= buffer.used) break; + + // Found a valid object, set stop point to last newline. if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - found->stop = stop; - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) break; + if (newline_last == found->array[found->used].start && buffer.string[found->array[found->used].start] != f_fss_eol_s.string[0]) { + range->start = newline_last; - return F_fss_found_object; + return F_fss_found_content_not; + } + else { + range->start = newline_last + 1; + found->array[found->used++].stop = newline_last; + } + + return F_fss_found_content; + } + + if (buffer.string[range->start] == f_fss_eol_s.string[0]) { + if (graph_first == 0x2) { + status = f_array_lengths_increase(state.step_small, delimits); + if (F_status_is_error(status)) break; + + delimits->array[delimits->used++] = comment_delimit; + } + + newline_last = range->start; + graph_first = 0x1; } continue; } - else if (graph_first) { + + if (graph_first == 0x1 && buffer.string[range->start] == f_fss_comment_s.string[0]) { + start = newline_last + 1; + + status = f_fss_seek_to_eol(state, buffer, range); + if (F_status_is_error(status)) break; + + status = f_string_ranges_increase(state.step_small, comments); + if (F_status_is_error(status)) break; + + if (range->start > range->stop || range->start >= buffer.used) { + --range->start; + } + else { + newline_last = range->start; + } + + comments->array[comments->used].start = start; + comments->array[comments->used++].stop = range->start++; + + continue; + } + + if (graph_first == 0x1) { status = f_fss_is_space(state, buffer, *range); if (F_status_is_error(status)) break; - if (status == F_false) { - graph_first = F_false; - } + if (status == F_false) { + graph_first = 0x0; + } + } + + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; + } // while + + if (F_status_is_error(status)) { + delimits->used = delimits_used; + comments->used = comments_used; + + return status; + } + + if (range->start >= buffer.used) { + found->array[found->used].stop = buffer.used - 1; + + return F_none_eos; + } + + if (range->start > range->stop) { + found->array[found->used].stop = range->stop; + + return F_none_stop; + } + + found->array[found->used++].stop = range->start - 1; + + return F_fss_found_content; + } +#endif // _di_fl_fss_basic_list_content_read_ + +#ifndef _di_fl_fss_basic_list_content_write_ + f_status_t fl_fss_basic_list_content_write(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { + #ifndef _di_level_1_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + f_status_t status = f_fss_skip_past_delimit(state, content, range); + if (F_status_is_error(status)) return status; + + if (status == F_none_stop || status == F_none_eos) { + if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_end_e) { + const f_status_t status_allocation = f_string_dynamic_increase(state.step_large, destination); + if (F_status_is_error(status_allocation)) return status_allocation; + + destination->string[destination->used++] = f_fss_basic_list_close_s.string[0]; + } + + if (status == F_none_stop) { + return F_data_not_stop; + } + + return F_data_not_eos; + } + + // Ensure that there is room for a slash delimit and possibly the end of content character. + status = f_string_dynamic_increase_by(3, destination); + if (F_status_is_error(status)) return status; + + const f_array_length_t used_start = destination->used; + + bool is_comment = F_false; + bool has_graph = F_false; + bool do_prepend = prepend ? F_true : F_false; + + f_array_length_t i = 0; + f_array_length_t slash_count = 0; + f_array_length_t start = 0; + + uint8_t width = 0; + + while (range->start <= range->stop && range->start < content.used) { + + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + + break; + } + } + + if (content.string[range->start] == f_fss_delimit_slash_s.string[0] && !is_comment) { + slash_count = 1; + + if (do_prepend) { + status = f_string_dynamic_append(*prepend, destination); + if (F_status_is_error(status)) break; + + do_prepend = F_false; + } + + destination->string[destination->used++] = content.string[range->start]; + has_graph = F_true; + + for (++range->start; range->start <= range->stop && range->start < content.used; ++range->start) { + + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + + break; + } + } + + if (content.string[range->start] == f_fss_delimit_placeholder_s.string[0]) continue; + if (content.string[range->start] != f_fss_delimit_slash_s.string[0]) break; + + destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; + ++slash_count; + } // for + + if (content.string[range->start] == f_fss_basic_list_open_s.string[0]) { + start = range->start++; + + status = f_fss_skip_past_space(state, content, range); + if (F_status_is_error(status)) break; + + if (content.string[range->start] == f_fss_eol_s.string[0] || range->start >= content.used || range->start > range->stop) { + + // Increase by total slashes + 1, along with the basic list open and possible newline. + status = f_string_dynamic_increase_by(slash_count + 3, destination); + if (F_status_is_error(status)) break; + + while (--slash_count) { + destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; + } // while + + destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; + destination->string[destination->used++] = f_fss_basic_list_open_s.string[0]; + + range->start = start + 1; + + status = private_fl_fss_basic_list_write_add_until_end(content, state, range, destination); + if (F_status_is_error(status)) break; + + continue; + } + + status = f_string_dynamic_increase(state.step_large, destination); + if (F_status_is_error(status)) break; + + destination->string[destination->used++] = f_fss_basic_list_open_s.string[0]; + range->start = start + 1; + + continue; + } + } + else if (content.string[range->start] == f_fss_basic_list_open_s.string[0] && !is_comment) { + start = range->start++; + + if (do_prepend) { + status = f_string_dynamic_append(*prepend, destination); + if (F_status_is_error(status)) break; + + do_prepend = F_false; + } + + has_graph = F_true; + + status = f_fss_skip_past_space(state, content, range); + if (F_status_is_error(status)) break; + + if (content.string[range->start] == f_fss_eol_s.string[0] || range->start >= content.used || range->start > range->stop) { + + // Increase by slash and basic list open and possible newline. + status = f_string_dynamic_increase_by(3, destination); + if (F_status_is_error(status)) break; + + destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; + destination->string[destination->used++] = f_fss_basic_list_open_s.string[0]; + + range->start = start + 1; + + status = private_fl_fss_basic_list_write_add_until_end(content, state, range, destination); + if (F_status_is_error(status)) break; + + continue; + } + + status = f_string_dynamic_increase(state.step_large, destination); + if (F_status_is_error(status)) break; + + destination->string[destination->used++] = f_fss_basic_list_open_s.string[0]; + range->start = start + 1; + + continue; + } + else if (content.string[range->start] == f_fss_comment_s.string[0] && !has_graph) { + is_comment = F_true; + } + else if (content.string[range->start] == f_fss_eol_s.string[0]) { + has_graph = F_false; + is_comment = F_false; + } + else { + status = f_fss_is_graph(state, content, *range); + + if (status == F_true) { + has_graph = F_true; + } + else if (F_status_is_error(status)) { + break; + } + } + + if (content.string[range->start] != f_fss_delimit_placeholder_s.string[0]) { + if (do_prepend) { + status = f_string_dynamic_append(*prepend, destination); + if (F_status_is_error(status)) break; + + do_prepend = F_false; + } + + if (content.string[range->start] == f_fss_eol_s.string[0] && prepend) { + do_prepend = F_true; + } + + width = macro_f_utf_byte_width(content.string[range->start]); + + status = f_string_dynamic_increase_by(width, destination); + if (F_status_is_error(status)) break; + + for (i = 0; i < width; ++i) { + destination->string[destination->used++] = content.string[range->start + i]; + } // for } - status = f_utf_buffer_increment(buffer, range, 1); + status = f_utf_buffer_increment(content, range, 1); if (F_status_is_error(status)) break; } // while if (F_status_is_error(status)) { - delimits->used = delimits_used; + destination->used = used_start; return status; } - if (status == F_none_eos) { - return F_data_not_eos; - } + if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_end_e) { + status = f_string_dynamic_increase(state.step_large, destination); + if (F_status_is_error(status)) return status; - if (status == F_none_stop) { - return F_data_not_stop; + // Check to see if a newline exists, at the end. + if (destination->used) { + for (i = destination->used - 1; i > 0; --i) { + if (destination->string[i] != f_fss_delimit_placeholder_s.string[0]) break; + } // for + } + + if (!destination->used || destination->string[i] != f_fss_eol_s.string[0]) { + destination->string[destination->used++] = f_fss_basic_list_close_s.string[0]; + } } - // seek to the end of the line when no valid object is found. - status = f_fss_seek_to_eol(state, buffer, range); + if (range->start > range->stop) { + return F_none_stop; + } - // move the start position to after the EOL. - ++range->start; + if (range->start >= content.used) { + return F_none_eos; + } - return F_fss_found_object_not; + return F_none; } -#endif // _di_fl_fss_basic_list_object_read_ +#endif // _di_fl_fss_basic_list_content_write_ -#ifndef _di_fl_fss_basic_list_content_read_ - f_status_t fl_fss_basic_list_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_content_t * const found, f_fss_delimits_t * const delimits, f_fss_comments_t * const comments) { +#ifndef _di_fl_fss_basic_list_object_read_ + f_status_t fl_fss_basic_list_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_delimits_t * const delimits) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!found) return F_status_set_error(F_parameter); if (!delimits) return F_status_set_error(F_parameter); - if (!comments) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ const f_array_length_t delimits_used = delimits->used; - const f_array_length_t comments_used = comments->used; - f_status_t status = f_fss_skip_past_delimit(state, buffer, range); + f_status_t status = f_fss_skip_past_space(state, buffer, range); if (F_status_is_error(status)) return status; - private_macro_fl_fss_content_with_comments_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, F_none_eos, F_none_stop); + if (status == F_none_eol) { - status = f_string_ranges_increase(state.step_small, found); - if (F_status_is_error(status)) return status; + // Move the start position to after the EOL. + ++range->start; - found->array[found->used].start = range->start; + return F_fss_found_object_not; + } + + if (status == F_none_eos) { + return F_data_not_eos; + } + + if (status == F_none_stop) { + return F_data_not_stop; + } + + // Begin the search. + found->start = range->start; + + // Ignore all comment lines. + if (buffer.string[range->start] == f_fss_comment_s.string[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; + } + + // Move the start position to after the EOL. + ++range->start; + + return F_fss_found_object_not; + } - f_array_length_t newline_last = range->start; f_array_length_t slash_first = 0; f_array_length_t slash_count = 0; f_array_length_t start = 0; - f_array_length_t comment_delimit = 0; + f_array_length_t stop = 0; - uint8_t graph_first = 0x1; // 0x0 = false, 0x1 = true, 0x2 = false, but there is a delimited comment, comment_delimit is set. + bool graph_first = F_true; - // Identify where the content ends. - while (range->start <= range->stop && range->start < buffer.used) { + // 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 (state.interrupt) { status = state.interrupt((void *) &state, 0); @@ -316,21 +600,6 @@ extern "C" { } } - if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); - if (F_status_is_error(status)) break; - - delimits->array[delimits->used++] = comment_delimit; - } - - newline_last = range->start; - graph_first = 0x1; - ++range->start; - - continue; - } - if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) { slash_first = range->start; slash_count = 1; @@ -347,17 +616,23 @@ extern "C" { } } - if (buffer.string[range->start] == f_fss_delimit_placeholder_s.string[0]) continue; - 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 (range->start > range->stop || range->start >= buffer.used) 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_basic_list_open_s.string[0]) { - graph_first = 0x0; - ++range->start; + graph_first = F_false; + stop = range->start - 1; + + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) return status; while (range->start <= range->stop && range->start < buffer.used) { @@ -382,61 +657,71 @@ extern "C" { if (F_status_is_error(status)) break; } // while - if (range->start > range->stop || range->start >= buffer.used) 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; - range->start = slash_first; - - if (slash_count % 2 == 0) { - found->array[found->used++].stop = newline_last; - range->start = newline_last + 1; - return F_fss_found_content; - } + range->start = slash_first; - macro_f_fss_delimits_t_increase_by(status, (*delimits), (slash_count / 2) + 1); + status = f_array_lengths_increase_by((slash_count / 2) + 1, delimits); if (F_status_is_error(status)) break; - while (slash_count > 0) { + if (slash_count % 2 == 0) { + while (slash_count > 0) { - if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) { - if (slash_count % 2 == 1) { - delimits->array[delimits->used++] = range->start; + if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) { + if (slash_count % 2 == 1) { + delimits->array[delimits->used] = range->start; + ++delimits->used; + } + + --slash_count; } - --slash_count; - } + status = f_utf_buffer_increment(buffer, range, 1); - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) break; - } // while + if (F_status_is_error(status)) { + delimits->used = delimits_used; - if (F_status_is_error(status)) break; + return status; + } + } // while - if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); - if (F_status_is_error(status)) break; + found->stop = stop; + range->start = start + 1; - delimits->array[delimits->used++] = comment_delimit; + return F_fss_found_object; } - graph_first = 0x1; range->start = start + 1; + + return F_fss_found_object_not; } } - else if (graph_first == 0x1 && buffer.string[range->start] == f_fss_comment_s.string[0]) { - graph_first = 0x2; - comment_delimit = slash_first; + else if (graph_first && buffer.string[range->start] == f_fss_comment_s.string[0]) { + graph_first = F_false; + + // 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; } + else { + graph_first = F_false; + } continue; } if (buffer.string[range->start] == f_fss_basic_list_open_s.string[0]) { - ++range->start; - graph_first = 0x0; + graph_first = F_false; + stop = range->start - 1; + + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; while (range->start <= range->stop && range->start < buffer.used) { @@ -445,7 +730,6 @@ extern "C" { if (F_status_set_fine(status) == F_interrupt) { status = F_status_set_error(F_interrupt); - break; } } @@ -461,69 +745,25 @@ extern "C" { if (F_status_is_error(status)) break; } // while - if (F_status_is_error(status)) break; - - if (range->start > range->stop || range->start >= buffer.used) break; - - // Found a valid object, set stop point to last newline. - if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - - if (newline_last == found->array[found->used].start && buffer.string[found->array[found->used].start] != f_fss_eol_s.string[0]) { - range->start = newline_last; - - return F_fss_found_content_not; - } - else { - range->start = newline_last + 1; - found->array[found->used++].stop = newline_last; - } - - return F_fss_found_content; - } + 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 (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); - if (F_status_is_error(status)) break; - - delimits->array[delimits->used++] = comment_delimit; - } - - newline_last = range->start; - graph_first = 0x1; - } - - continue; - } - - if (graph_first == 0x1 && buffer.string[range->start] == f_fss_comment_s.string[0]) { - start = newline_last + 1; - - status = f_fss_seek_to_eol(state, buffer, range); - if (F_status_is_error(status)) break; + found->stop = stop; - macro_f_fss_comments_t_increase(status, state.step_small, (*comments)) - if (F_status_is_error(status)) break; + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; - if (range->start > range->stop || range->start >= buffer.used) { - --range->start; - } - else { - newline_last = range->start; + return F_fss_found_object; } - comments->array[comments->used].start = start; - comments->array[comments->used++].stop = range->start++; - continue; } - - if (graph_first == 0x1) { + else if (graph_first) { status = f_fss_is_space(state, buffer, *range); if (F_status_is_error(status)) break; if (status == F_false) { - graph_first = 0x0; + graph_first = F_false; } } @@ -533,28 +773,27 @@ extern "C" { if (F_status_is_error(status)) { delimits->used = delimits_used; - comments->used = comments_used; return status; } - if (range->start >= buffer.used) { - found->array[found->used].stop = buffer.used - 1; - - return F_none_eos; + if (status == F_none_eos) { + return F_data_not_eos; } - if (range->start > range->stop) { - found->array[found->used].stop = range->stop; - - return F_none_stop; + if (status == F_none_stop) { + return F_data_not_stop; } - found->array[found->used++].stop = range->start - 1; + // seek to the end of the line when no valid object is found. + status = f_fss_seek_to_eol(state, buffer, range); - return F_fss_found_content; + // move the start position to after the EOL. + ++range->start; + + return F_fss_found_object_not; } -#endif // _di_fl_fss_basic_list_content_read_ +#endif // _di_fl_fss_basic_list_object_read_ #ifndef _di_fl_fss_basic_list_object_write_ f_status_t fl_fss_basic_list_object_write(const f_string_static_t object, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination) { @@ -624,7 +863,7 @@ extern "C" { if (status == F_true) break; - // Objects will not have leading whitespaces, but having this does not result in an invalid object, so just write the provided spaces. + // 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_delimit_placeholder_s.string[0]) { if (object.string[range->start] == f_fss_eol_s.string[0]) { status = F_status_set_error(F_none_eol); @@ -779,245 +1018,6 @@ extern "C" { } #endif // _di_fl_fss_basic_list_object_write_ -#ifndef _di_fl_fss_basic_list_content_write_ - f_status_t fl_fss_basic_list_content_write(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { - #ifndef _di_level_1_parameter_checking_ - if (!range) return F_status_set_error(F_parameter); - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - f_status_t status = f_fss_skip_past_delimit(state, content, range); - if (F_status_is_error(status)) return status; - - if (status == F_none_stop || status == F_none_eos) { - if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_end_e) { - const f_status_t status_allocation = f_string_dynamic_increase(state.step_large, destination); - if (F_status_is_error(status_allocation)) return status_allocation; - - destination->string[destination->used++] = f_fss_basic_list_close_s.string[0]; - } - - if (status == F_none_stop) { - return F_data_not_stop; - } - - return F_data_not_eos; - } - - // Ensure that there is room for a slash delimit and possibly the end of content character. - status = f_string_dynamic_increase_by(3, destination); - if (F_status_is_error(status)) return status; - - const f_array_length_t used_start = destination->used; - - bool is_comment = F_false; - bool has_graph = F_false; - bool do_prepend = prepend ? F_true : F_false; - - f_array_length_t i = 0; - f_array_length_t slash_count = 0; - f_array_length_t start = 0; - - uint8_t width = 0; - - while (range->start <= range->stop && range->start < content.used) { - - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); - - if (F_status_set_fine(status) == F_interrupt) { - status = F_status_set_error(F_interrupt); - - break; - } - } - - if (content.string[range->start] == f_fss_delimit_slash_s.string[0] && !is_comment) { - slash_count = 1; - - if (do_prepend) { - status = f_string_dynamic_append(*prepend, destination); - if (F_status_is_error(status)) break; - - do_prepend = F_false; - } - - destination->string[destination->used++] = content.string[range->start]; - has_graph = F_true; - - for (++range->start; range->start <= range->stop && range->start < content.used; ++range->start) { - - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); - - if (F_status_set_fine(status) == F_interrupt) { - status = F_status_set_error(F_interrupt); - - break; - } - } - - if (content.string[range->start] == f_fss_delimit_placeholder_s.string[0]) continue; - if (content.string[range->start] != f_fss_delimit_slash_s.string[0]) break; - - destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; - ++slash_count; - } // for - - if (content.string[range->start] == f_fss_basic_list_open_s.string[0]) { - start = range->start++; - - status = f_fss_skip_past_space(state, content, range); - if (F_status_is_error(status)) break; - - if (content.string[range->start] == f_fss_eol_s.string[0] || range->start >= content.used || range->start > range->stop) { - - // Increase by total slashes + 1, along with the basic list open and possible newline. - status = f_string_dynamic_increase_by(slash_count + 3, destination); - if (F_status_is_error(status)) break; - - while (--slash_count) { - destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; - } // while - - destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; - destination->string[destination->used++] = f_fss_basic_list_open_s.string[0]; - - range->start = start + 1; - - status = private_fl_fss_basic_list_write_add_until_end(content, state, range, destination); - if (F_status_is_error(status)) break; - - continue; - } - - status = f_string_dynamic_increase(state.step_large, destination); - if (F_status_is_error(status)) break; - - destination->string[destination->used++] = f_fss_basic_list_open_s.string[0]; - range->start = start + 1; - - continue; - } - } - else if (content.string[range->start] == f_fss_basic_list_open_s.string[0] && !is_comment) { - start = range->start++; - - if (do_prepend) { - status = f_string_dynamic_append(*prepend, destination); - if (F_status_is_error(status)) break; - - do_prepend = F_false; - } - - has_graph = F_true; - - status = f_fss_skip_past_space(state, content, range); - if (F_status_is_error(status)) break; - - if (content.string[range->start] == f_fss_eol_s.string[0] || range->start >= content.used || range->start > range->stop) { - - // Increase by slash and basic list open and possible newline. - status = f_string_dynamic_increase_by(3, destination); - if (F_status_is_error(status)) break; - - destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; - destination->string[destination->used++] = f_fss_basic_list_open_s.string[0]; - - range->start = start + 1; - - status = private_fl_fss_basic_list_write_add_until_end(content, state, range, destination); - if (F_status_is_error(status)) break; - - continue; - } - - status = f_string_dynamic_increase(state.step_large, destination); - if (F_status_is_error(status)) break; - - destination->string[destination->used++] = f_fss_basic_list_open_s.string[0]; - range->start = start + 1; - - continue; - } - else if (content.string[range->start] == f_fss_comment_s.string[0] && !has_graph) { - is_comment = F_true; - } - else if (content.string[range->start] == f_fss_eol_s.string[0]) { - has_graph = F_false; - is_comment = F_false; - } - else { - status = f_fss_is_graph(state, content, *range); - - if (status == F_true) { - has_graph = F_true; - } - else if (F_status_is_error(status)) { - break; - } - } - - if (content.string[range->start] != f_fss_delimit_placeholder_s.string[0]) { - if (do_prepend) { - status = f_string_dynamic_append(*prepend, destination); - if (F_status_is_error(status)) break; - - do_prepend = F_false; - } - - if (content.string[range->start] == f_fss_eol_s.string[0] && prepend) { - do_prepend = F_true; - } - - width = macro_f_utf_byte_width(content.string[range->start]); - - status = f_string_dynamic_increase_by(width, destination); - if (F_status_is_error(status)) break; - - for (i = 0; i < width; ++i) { - destination->string[destination->used++] = content.string[range->start + i]; - } // for - } - - status = f_utf_buffer_increment(content, range, 1); - if (F_status_is_error(status)) break; - } // while - - if (F_status_is_error(status)) { - destination->used = used_start; - - return status; - } - - if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_end_e) { - status = f_string_dynamic_increase(state.step_large, destination); - if (F_status_is_error(status)) return status; - - // Check to see if a newline exists, at the end. - if (destination->used) { - for (i = destination->used - 1; i > 0; --i) { - if (destination->string[i] != f_fss_delimit_placeholder_s.string[0]) break; - } // for - } - - if (!destination->used || destination->string[i] != f_fss_eol_s.string[0]) { - destination->string[destination->used++] = f_fss_basic_list_close_s.string[0]; - } - } - - if (range->start > range->stop) { - return F_none_stop; - } - - if (range->start >= content.used) { - return F_none_eos; - } - - return F_none; - } -#endif // _di_fl_fss_basic_list_content_write_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_1/fl_fss/c/fss/basic_list.h b/level_1/fl_fss/c/fss/basic_list.h index 98385f9..bc5f7ac 100644 --- a/level_1/fl_fss/c/fss/basic_list.h +++ b/level_1/fl_fss/c/fss/basic_list.h @@ -31,7 +31,7 @@ extern "C" { #endif /** - * Read an fss-0002 object. + * Read an fss-0002 content from a given string. * * This will record where delimit placeholders exist but will not apply the delimits. * @@ -52,13 +52,17 @@ extern "C" { * The start location will represent where the read stopped on return. * A start location past the stop location or buffer used means that the entire range was processed. * @param found - * A location where a valid object was found. + * A set of all locations where a valid content was found. * @param delimits * A delimits array representing where delimits exist within the buffer. + * @param comments + * An array of ranges representing where comments are found within any valid content. + * This only stores comments found within valid content only. + * The comment range will include the trailing newline. * * @return - * F_fss_found_object on success and object was found (start location is at end of object). - * F_fss_found_object_not on success and no object was found (start location is after character designating this is not an object). + * F_fss_found_content on success and content was found (start location is at end of content). + * F_fss_found_content_not on success and no content was found (start location is after character designating this is not a content). * F_none_eos on success after reaching the end of the buffer (a valid object is not yet confirmed). * F_none_stop on success after reaching stopping point (a valid object is not yet confirmed). * F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found). @@ -66,27 +70,96 @@ extern "C" { * F_end_not_group_eos if EOS was reached before the a group termination was reached. * F_end_not_group_stop if stop point was reached before the a group termination was reached. * - * F_array_too_large (with error bit) if a buffer is too large. - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_complete_not_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. - * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * - * Errors (with error bit) from: f_utf_buffer_increment(). - * Errors (with error bit) from: f_fss_is_graph(). + * Errors (with error bit) from: f_array_lengths_increase(). + * Errors (with error bit) from: f_array_lengths_increase_by(). * 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_string_ranges_increase(). + * Errors (with error bit) from: f_utf_buffer_increment(). + * + * @see f_array_lengths_increase() + * @see f_array_lengths_increase_by() + * @see f_fss_is_space() + * @see f_fss_seek_to_eol() + * @see f_fss_skip_past_delimit() + * @see f_string_ranges_increase() + * @see f_utf_buffer_increment() + */ +#ifndef _di_fl_fss_basic_list_content_read_ + extern f_status_t fl_fss_basic_list_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_content_t * const found, f_fss_delimits_t * const delimits, f_fss_comments_t * const comments); +#endif // _di_fl_fss_basic_list_content_read_ + +/** + * Write an fss-0002 content from a given string. + * + * This will write the given string range as a valid content. + * Anything within this range will be escaped as necessary. + * + * The destination string may have NULLs. + * + * @param content + * The string to write as (does not stop at NULLS, they are ignored and not written). + * @param complete + * If f_fss_complete_none_e, then only the content is written. + * If f_fss_complete_next_e, then the content followed by any appropriate "next" character separating one content from the next, if applicable. + * If f_fss_complete_end_e, then the content followed by any appropriate "end" character designating the last content for some object, printing final newline, if applicable. + * If f_fss_complete_partial_e, this will write any appropriate open and close aspects of this content, except for the final newline. + * If f_fss_complete_full_e, this will write any appropriate open and close aspects of this content, including the final newline. + * @param prepend + * A string of whitespace to prepend at the start of each line. + * This should only be whitespace, anything else could produce invalid content. + * Set the pointer address to 0 to disable. + * @param state + * A state for providing flags and handling interrupts during long running operations. + * There is no print_error(). + * There is no functions structure. + * There is no data structure passed to these functions. + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. + * @param range + * The start/stop location within the content string to write as an content. + * @param destination + * The buffer where the content is written to. + * + * @return + * F_none on success. + * F_none_eol on success after reaching the end of the line. + * F_none_eos on success after reaching the end of the buffer. + * F_data_not_stop no data to write due start location being greater than stop location. + * F_data_not_eos no data to write due start location being greater than or equal to buffer size. + * F_none_stop on success after reaching stopping point. + * + * F_interrupt (with error bit) if stopping due to an interrupt. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_fss_is_graph(). + * 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_string_dynamic_append(). + * Errors (with error bit) from: f_string_dynamic_increase(). + * Errors (with error bit) from: f_string_dynamic_increase_by(). + * Errors (with error bit) from: f_utf_buffer_increment(). + * + * @see f_fss_is_graph() + * @see f_fss_skip_past_delimit() + * @see f_fss_skip_past_space() + * @see f_string_dynamic_append() + * @see f_string_dynamic_increase() + * @see f_string_dynamic_increase_by() + * @see f_utf_buffer_increment() */ -#ifndef _di_fl_fss_basic_list_object_read_ - extern f_status_t fl_fss_basic_list_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_delimits_t * const delimits); -#endif // _di_fl_fss_basic_list_object_read_ +#ifndef _di_fl_fss_basic_list_content_write_ + extern f_status_t fl_fss_basic_list_content_write(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination); +#endif // _di_fl_fss_basic_list_content_write_ /** - * Read an fss-0002 content from a given string. + * Read an fss-0002 object. * * This will record where delimit placeholders exist but will not apply the delimits. * @@ -107,17 +180,13 @@ extern "C" { * The start location will represent where the read stopped on return. * A start location past the stop location or buffer used means that the entire range was processed. * @param found - * A set of all locations where a valid content was found. + * A location where a valid object was found. * @param delimits * A delimits array representing where delimits exist within the buffer. - * @param comments - * An array of ranges representing where comments are found within any valid content. - * This only stores comments found within valid content only. - * The comment range will include the trailing newline. * * @return - * F_fss_found_content on success and content was found (start location is at end of content). - * F_fss_found_content_not on success and no content was found (start location is after character designating this is not a content). + * F_fss_found_object on success and object was found (start location is at end of object). + * F_fss_found_object_not on success and no object was found (start location is after character designating this is not an object). * F_none_eos on success after reaching the end of the buffer (a valid object is not yet confirmed). * F_none_stop on success after reaching stopping point (a valid object is not yet confirmed). * F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found). @@ -125,24 +194,30 @@ extern "C" { * F_end_not_group_eos if EOS was reached before the a group termination was reached. * F_end_not_group_stop if stop point was reached before the a group termination was reached. * - * F_array_too_large (with error bit) if a buffer is too large. - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_complete_not_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. - * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * - * Errors (with error bit) from: f_utf_buffer_increment(). + * Errors (with error bit) from: f_array_lengths_increase_by(). * Errors (with error bit) from: f_fss_is_graph(). * Errors (with error bit) from: f_fss_is_space(). + * Errors (with error bit) from: f_fss_is_zero_width(). + * 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_utf_buffer_increment(). + * + * @see f_array_lengths_increase_by() + * @see f_fss_is_graph() + * @see f_fss_is_space() + * @see f_fss_is_zero_width() + * @see f_fss_seek_to_eol() + * @see f_fss_skip_past_delimit() + * @see f_fss_skip_past_space() + * @see f_utf_buffer_increment() */ -#ifndef _di_fl_fss_basic_list_content_read_ - extern f_status_t fl_fss_basic_list_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_content_t * const found, f_fss_delimits_t * const delimits, f_fss_comments_t * const comments); -#endif // _di_fl_fss_basic_list_content_read_ +#ifndef _di_fl_fss_basic_list_object_read_ + extern f_status_t fl_fss_basic_list_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_delimits_t * const delimits); +#endif // _di_fl_fss_basic_list_object_read_ /** * Write an fss-0002 object. @@ -182,73 +257,28 @@ extern "C" { * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * F_none_stop on success after reaching stopping point. * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. * F_none_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. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * + * Errors (with error bit) from: f_fss_is_graph(). + * Errors (with error bit) from: f_fss_is_space(). + * Errors (with error bit) from: f_fss_skip_past_delimit(). + * Errors (with error bit) from: f_string_dynamic_increase(). + * Errors (with error bit) from: f_string_dynamic_increase_by(). * Errors (with error bit) from: f_utf_buffer_increment(). + * + * @see f_fss_is_graph() + * @see f_fss_is_space() + * @see f_fss_skip_past_delimit() + * @see f_string_dynamic_increase() + * @see f_string_dynamic_increase_by() + * @see f_utf_buffer_increment() */ #ifndef _di_fl_fss_basic_list_object_write_ extern f_status_t fl_fss_basic_list_object_write(const f_string_static_t object, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination); #endif // _di_fl_fss_basic_list_object_write_ -/** - * Write an fss-0002 content from a given string. - * - * This will write the given string range as a valid content. - * Anything within this range will be escaped as necessary. - * - * The destination string may have NULLs. - * - * @param content - * The string to write as (does not stop at NULLS, they are ignored and not written). - * @param complete - * If f_fss_complete_none_e, then only the content is written. - * If f_fss_complete_next_e, then the content followed by any appropriate "next" character separating one content from the next, if applicable. - * If f_fss_complete_end_e, then the content followed by any appropriate "end" character designating the last content for some object, printing final newline, if applicable. - * If f_fss_complete_partial_e, this will write any appropriate open and close aspects of this content, except for the final newline. - * If f_fss_complete_full_e, this will write any appropriate open and close aspects of this content, including the final newline. - * @param prepend - * A string of whitespace to prepend at the start of each line. - * This should only be whitespace, anything else could produce invalid content. - * Set the pointer address to 0 to disable. - * @param state - * A state for providing flags and handling interrupts during long running operations. - * There is no print_error(). - * There is no functions structure. - * There is no data structure passed to these functions. - * - * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. - * Error bit designates an error but must be passed along with F_interrupt. - * All other statuses are ignored. - * @param range - * The start/stop location within the content string to write as an content. - * @param destination - * The buffer where the content is written to. - * - * @return - * F_none on success. - * F_none_eol on success after reaching the end of the line. - * F_none_eos on success after reaching the end of the buffer. - * F_data_not_stop no data to write due start location being greater than stop location. - * F_data_not_eos no data to write due start location being greater than or equal to buffer size. - * F_none_stop on success after reaching stopping point . - * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. - * - * Errors (with error bit) from: f_utf_buffer_increment(). - */ -#ifndef _di_fl_fss_basic_list_content_write_ - extern f_status_t fl_fss_basic_list_content_write(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination); -#endif // _di_fl_fss_basic_list_content_write_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_1/fl_fss/c/fss/embedded_list.c b/level_1/fl_fss/c/fss/embedded_list.c index bd0e2e2..c2fbbf4 100644 --- a/level_1/fl_fss/c/fss/embedded_list.c +++ b/level_1/fl_fss/c/fss/embedded_list.c @@ -6,80 +6,81 @@ extern "C" { #endif -#ifndef _di_fl_fss_embedded_list_object_read_ - f_status_t fl_fss_embedded_list_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_delimits_t * const delimits) { +#ifndef _di_fl_fss_embedded_list_content_read_ + f_status_t fl_fss_embedded_list_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_nest_t * const found, f_fss_delimits_t * const delimits, f_fss_comments_t * const comments) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!found) return F_status_set_error(F_parameter); if (!delimits) return F_status_set_error(F_parameter); + if (!comments) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - const f_array_length_t delimits_used = delimits->used; + f_status_t status = f_fss_skip_past_delimit(state, buffer, range); + if (F_status_is_error(status)) return status; - f_status_t status = f_fss_skip_past_space(state, buffer, range); + if (status == F_none_eos || status == F_none_stop) { + return status; + } + + status = f_fss_nest_increase(state.step_small, found); if (F_status_is_error(status)) return status; - if (status == F_none_eol) { + f_array_lengths_t positions_start = f_array_lengths_t_initialize; - // Move the start position to after the EOL. - ++range->start; + status = f_array_lengths_increase(state.step_small, &positions_start); + if (F_status_is_error(status)) return status; - return F_fss_found_object_not; - } + f_fss_objects_t objects = f_fss_objects_t_initialize; - if (status == F_none_eos) { - return F_data_not_eos; - } + status = f_string_ranges_increase(state.step_small, &objects); - if (status == F_none_stop) { - return F_data_not_stop; + if (F_status_is_error(status)) { + f_array_lengths_resize(0, &positions_start); + + return status; } - // Return found nothing if this line only contains whitespace and delimit placeholders. - if (buffer.string[range->start] == f_fss_eol_s.string[0]) { + f_array_lengths_t slashes = f_array_lengths_t_initialize; - // Move the start position to after the EOL. - ++range->start; + status = f_array_lengths_increase(state.step_small, &slashes); - return F_fss_found_object_not; - } + if (F_status_is_error(status)) { + f_array_lengths_resize(0, &positions_start); + f_string_ranges_resize(0, &objects); - // Begin the search. - found->start = range->start; + return status; + } - // Ignore all comment lines. - if (buffer.string[range->start] == f_fss_comment_s.string[0]) { - status = f_fss_seek_to_eol(state, buffer, range); + const f_array_length_t delimits_used = delimits->used; + const f_array_length_t comments_used = comments->used; - if (F_status_is_error(status)) { - delimits->used = delimits_used; + f_array_length_t depth = 0; + f_array_length_t position = 0; - return status; - } + f_array_length_t position_previous = range->start; + f_array_length_t line_start = range->start; + f_array_length_t newline_last = range->start; + f_array_length_t comment_delimit = 0; - if (status == F_none_eos) { - return F_data_not_eos; - } + f_array_length_t slash_first = 0; + f_array_length_t slash_last = 0; - if (status == F_none_stop) { - return F_data_not_stop; - } + f_array_length_t before_list_open = position_previous; - // Move the start position to after the EOL. - ++range->start; + bool is_open = F_false; - return F_fss_found_object_not; - } + // 0x0 = false, 0x1 = true, 0x2 = false, but there is a delimited comment, comment_delimit is set. + uint8_t graph_first = 0x0; - f_array_length_t start = 0; - f_array_length_t stop = 0; - f_array_length_t slash_first = 0; - f_array_length_t slash_count = 0; + // Initialize depth 1 start position. + // Positions_start.used is used as a max depth (such that positions_start.used == max depth + 1). + positions_start.array[0] = range->start; + positions_start.used = 1; - bool graph_first = F_true; + slashes.array[0] = 0; + slashes.used = 1; - // Identify where the object ends. - while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol_s.string[0]) { + while (range->start <= range->stop && range->start < buffer.used) { if (state.interrupt) { status = state.interrupt((void *) &state, 0); @@ -91,12 +92,36 @@ extern "C" { } } + if (buffer.string[range->start] == f_fss_eol_s.string[0]) { + if (graph_first == 0x2) { + status = f_array_lengths_increase(state.step_small, delimits); + if (F_status_is_error(status)) break; + + delimits->array[delimits->used++] = comment_delimit; + } + + newline_last = range->start; + position_previous = range->start++; + graph_first = 0x1; + + if (depth) { + private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop); + } + else { + private_macro_fl_fss_nest_return_on_overflow_delimited((buffer), (*range), (*found), positions_start, objects, slashes, F_none_eos, F_none_stop); + } + + line_start = range->start; + + continue; + } + if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) { slash_first = range->start; - slash_count = 1; + slash_last = range->start; + slashes.array[depth] = 1; - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) break; + position_previous = range->start++; while (range->start <= range->stop && range->start < buffer.used && (buffer.string[range->start] == f_fss_delimit_placeholder_s.string[0] || buffer.string[range->start] == f_fss_delimit_slash_s.string[0])) { @@ -110,19 +135,55 @@ extern "C" { } } - if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) slash_count++; + position_previous = range->start; - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) break; + if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) { + slash_last = range->start++; + ++slashes.array[depth]; + } + else { + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; + } } // while 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 (depth) { + private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop); + } + else { + private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_data_not_eos, F_data_not_stop); + } - if (buffer.string[range->start] == f_fss_embedded_list_open_s.string[0]) { - graph_first = F_false; - stop = range->start++ - 1; + // All slashes for an open are delimited (because it could represent a slash in the object name). + // For example 'object {' = valid open, name 'object', 'object \{' represents 'object {', 'object \\{' = valid open, name 'object \', 'object \\\{' represents 'object \{', etc.. + // Only the first slash before a close is delimited, all others are maintained. + // For example '}' = valid close, '\}' represents '}', '\\}' represents '\}', '\\\}' represents '\\}', '\\\\}' represents '\\\}', and so on.. + // When slash is odd and a (delimited) valid open/close is found, then save delimited positions and continue. + if (buffer.string[range->start] == f_fss_eol_s.string[0]) { + if (graph_first == 0x2) { + status = f_array_lengths_increase(state.step_small, delimits); + if (F_status_is_error(status)) break; + + delimits->array[delimits->used++] = comment_delimit; + } + + newline_last = range->start; + position_previous = range->start++; + line_start = range->start; + graph_first = 0x1; + } + else if (buffer.string[range->start] == f_fss_embedded_list_open_s.string[0] || buffer.string[range->start] == f_fss_embedded_list_close_s.string[0]) { + before_list_open = position_previous; + is_open = F_false; + graph_first = 0x0; + + if (buffer.string[range->start] == f_fss_embedded_list_open_s.string[0]) { + is_open = F_true; + } + + position_previous = range->start++; while (range->start <= range->stop && range->start < buffer.used) { @@ -136,73 +197,126 @@ extern "C" { } } - if (buffer.string[range->start] == f_fss_eol_s.string[0]) break; + if (buffer.string[range->start] == f_fss_eol_s.string[0]) { + if (graph_first == 0x2) { + status = f_array_lengths_increase(state.step_small, delimits); + if (F_status_is_error(status)) break; - status = f_fss_is_graph(state, buffer, *range); - if (F_status_is_error(status)) break; + delimits->array[delimits->used++] = comment_delimit; + } - if (status == F_true) break; + newline_last = range->start; + line_start = range->start + 1; + graph_first = 0x1; + + break; + } + + if (buffer.string[range->start] != f_fss_delimit_placeholder_s.string[0]) { + status = f_fss_is_space(state, buffer, *range); + if (F_status_is_error(status)) break; + + if (status == F_false) break; + } + + position_previous = range->start; status = f_utf_buffer_increment(buffer, range, 1); if (F_status_is_error(status)) break; } // while - private_macro_fl_fss_object_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop); + if (F_status_is_error(status)) break; + + if (depth) { + private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop); + } + else { + private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_data_not_eos, F_data_not_stop); + } + // This is a valid object open/close that has been delimited, save the slash delimit positions. if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - start = range->start; + newline_last = range->start; + line_start = range->start + 1; + graph_first = 0x1; - range->start = slash_first; + if (is_open) { + bool is_object = F_false; - macro_f_fss_delimits_t_increase_by(status, (*delimits), (slash_count / 2) + 1); - if (F_status_is_error(status)) break; + if (slashes.array[depth] % 2 == 0) { + is_object = F_true; + } - if (slash_count % 2 == 0) { - while (slash_count > 0) { + range->start = slash_first; + + status = f_array_lengths_increase_by((slashes.array[depth] / 2) + 1, delimits); + if (F_status_is_error(status)) break; + + // Apply slash delimits, only slashes and placeholders should be present. + while (slashes.array[depth]) { if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) { - if (slash_count % 2 == 1) { + if (slashes.array[depth] % 2 == 1) { delimits->array[delimits->used++] = range->start; } - --slash_count; + --slashes.array[depth]; } - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) break; + // Delimit slashes and placeholders are required to be in the ASCII range. + position_previous = range->start++; } // while if (F_status_is_error(status)) break; - found->stop = stop; - range->start = start + 1; + // When slashes are even, the object is valid and needs to be processed. + if (is_object) { + if (++depth > positions_start.size) { + status = f_array_lengths_increase(state.step_small, &positions_start); + if (F_status_is_error(status)) break; - return F_fss_found_object; - } + status = f_string_ranges_increase(state.step_small, &objects); + if (F_status_is_error(status)) break; - range->start = start + 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; + status = f_array_lengths_increase(state.step_small, &slashes); + if (F_status_is_error(status)) break; + } - // Comments may only have whitespace before the '#', therefore only the first slash needs to be delimited. - macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); - if (F_status_is_error(status)) break; + if (positions_start.used < depth) { + positions_start.used = depth; + slashes.used = depth; + } - delimits->array[delimits->used++] = slash_first; - ++range->start; - } - else { - graph_first = F_false; - } + positions_start.array[depth] = newline_last + 1; - continue; + objects.array[depth].start = line_start; + objects.array[depth].stop = before_list_open; + + slashes.array[depth] = 0; + } + } + else { + status = f_array_lengths_increase(state.step_small, delimits); + if (F_status_is_error(status)) break; + + delimits->array[delimits->used++] = slash_last; + } + + range->start = newline_last; + } + } + else if (graph_first == 0x1 && buffer.string[range->start] == f_fss_comment_s.string[0]) { + graph_first = 0x2; + comment_delimit = slash_first; + } + else { + graph_first = 0x0; + } } else if (buffer.string[range->start] == f_fss_embedded_list_open_s.string[0]) { - graph_first = F_false; - stop = range->start - 1; + graph_first = 0x0; + before_list_open = position_previous; + position_previous = range->start; status = f_utf_buffer_increment(buffer, range, 1); if (F_status_is_error(status)) break; @@ -221,10 +335,14 @@ extern "C" { 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 (buffer.string[range->start] != f_fss_delimit_placeholder_s.string[0]) { + status = f_fss_is_space(state, buffer, *range); + if (F_status_is_error(status)) break; - if (status == F_false) break; + if (status == F_false) break; + } + + position_previous = range->start; status = f_utf_buffer_increment(buffer, range, 1); if (F_status_is_error(status)) break; @@ -232,253 +350,206 @@ extern "C" { 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 (depth) { + private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop); + } + else { + private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_data_not_eos, F_data_not_stop); + } if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - found->stop = stop; - - // Move the start position to after the EOL. - ++range->start; + ++depth; - return F_fss_found_object; - } + if (depth >= positions_start.size) { + status = f_array_lengths_increase(state.step_small, &positions_start); + if (F_status_is_error(status)) break; - continue; - } - else if (graph_first) { - status = f_fss_is_space(state, buffer, *range); - if (F_status_is_error(status)) break; + status = f_string_ranges_increase(state.step_small, &objects); + if (F_status_is_error(status)) break; - if (status == F_false) { - graph_first = F_false; - } - } + status = f_array_lengths_increase(state.step_small, &slashes); + if (F_status_is_error(status)) break; + } - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) break; - } // while + if (positions_start.used <= depth) { + positions_start.used = depth + 1; + slashes.used = depth + 1; + } - if (F_status_is_error(status)) { - delimits->used = delimits_used; + positions_start.array[depth] = range->start + 1; - return status; - } + objects.array[depth].start = line_start; + objects.array[depth].stop = before_list_open; - // Seek to the end of the line when no valid object is found. - while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol_s.string[0]) { + slashes.array[depth] = 0; - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); + if (graph_first == 0x2) { + status = f_array_lengths_increase(state.step_small, delimits); + if (F_status_is_error(status)) break; - if (F_status_set_fine(status) == F_interrupt) { - status = F_status_set_error(F_interrupt); + delimits->array[delimits->used++] = comment_delimit; + } - break; + newline_last = range->start; + line_start = range->start + 1; + graph_first = 0x1; } - } + else { - status = f_utf_buffer_increment(buffer, range, 1); + // No valid object close found, seek until EOL. + status = f_fss_seek_to_eol(state, buffer, range); + if (F_status_is_error(status)) break; - if (F_status_is_error(status)) { - delimits->used = delimits_used; + if (graph_first == 0x2) { + status = f_array_lengths_increase(state.step_small, delimits); + if (F_status_is_error(status)) break; - return status; - } - } // while + delimits->array[delimits->used++] = comment_delimit; + } - private_macro_fl_fss_object_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop); + newline_last = range->start; + line_start = range->start + 1; + graph_first = 0x1; - status = f_utf_buffer_increment(buffer, range, 1); + while (range->start <= range->stop && range->start < buffer.used) { - if (F_status_is_error(status)) { - delimits->used = delimits_used; + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); - return status; - } + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); - return F_fss_found_object_not; - } -#endif // _di_fl_fss_embedded_list_object_read_ + break; + } + } -#ifndef _di_fl_fss_embedded_list_content_read_ - f_status_t fl_fss_embedded_list_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_nest_t * const found, f_fss_delimits_t * const delimits, f_fss_comments_t * const comments) { - #ifndef _di_level_1_parameter_checking_ - if (!range) return F_status_set_error(F_parameter); - if (!found) return F_status_set_error(F_parameter); - if (!delimits) return F_status_set_error(F_parameter); - if (!comments) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (buffer.string[range->start] == f_fss_eol_s.string[0]) { + newline_last = range->start; + line_start = range->start + 1; - f_status_t status = f_fss_skip_past_delimit(state, buffer, range); - if (F_status_is_error(status)) return status; + break; + } - if (status == F_none_eos || status == F_none_stop) { - return status; - } + position_previous = range->start; - macro_f_fss_nest_t_increase(status, state.step_small, (*found)); - if (F_status_is_error(status)) return status; + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; + } // while - f_array_lengths_t positions_start = f_array_lengths_t_initialize; + if (F_status_is_error(status)) break; - macro_f_array_lengths_t_resize(status, positions_start, state.step_small) - if (F_status_is_error(status)) return status; + if (depth) { + private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop); + } + else { + private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_data_not_eos, F_data_not_stop); + } + } + } + else if (buffer.string[range->start] == f_fss_embedded_list_close_s.string[0]) { + graph_first = 0x0; - f_fss_objects_t objects = f_fss_objects_t_initialize; + while (range->start <= range->stop && range->start < buffer.used) { - macro_f_fss_objects_t_resize(status, objects, state.step_small) + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); - if (F_status_is_error(status)) { - f_array_lengths_resize(0, &positions_start); + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); - return status; - } + break; + } + } - f_array_lengths_t slashes = f_array_lengths_t_initialize; + position_previous = range->start; - macro_f_array_lengths_t_resize(status, slashes, state.step_small) + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; - if (F_status_is_error(status)) { - f_array_lengths_resize(0, &positions_start); - macro_f_fss_objects_t_delete_simple(objects); + if (buffer.string[range->start] == f_fss_eol_s.string[0]) break; - return status; - } + if (buffer.string[range->start] != f_fss_delimit_placeholder_s.string[0]) { + status = f_fss_is_space(state, buffer, *range); + if (F_status_is_error(status)) break; - const f_array_length_t delimits_used = delimits->used; - const f_array_length_t comments_used = comments->used; + if (status == F_false) break; + } + } // while - f_array_length_t depth = 0; - f_array_length_t position = 0; + if (F_status_is_error(status)) break; - f_array_length_t position_previous = range->start; - f_array_length_t line_start = range->start; - f_array_length_t newline_last = range->start; - f_array_length_t comment_delimit = 0; + if (depth) { + private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop); + } + else { + private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_data_not_eos, F_data_not_stop); + } - f_array_length_t slash_first = 0; - f_array_length_t slash_last = 0; + if (buffer.string[range->start] == f_fss_eol_s.string[0]) { + status = f_fss_nest_increase(state.step_small, found); + if (F_status_is_error(status)) break; - f_array_length_t before_list_open = position_previous; + if (found->depth[depth].used == found->depth[depth].size) { + status = f_fss_items_increase(state.step_small, &found->depth[depth]); + if (F_status_is_error(status)) break; + } - bool is_open = F_false; + position = found->depth[depth].used; - // 0x0 = false, 0x1 = true, 0x2 = false, but there is a delimited comment, comment_delimit is set. - uint8_t graph_first = 0x0; + if (found->depth[depth].array[position].content.size != 1) { + status = f_string_ranges_resize(1, &found->depth[depth].array[position].content); + if (F_status_is_error(status)) break; + } - // Initialize depth 1 start position. - // Positions_start.used is used as a max depth (such that positions_start.used == max depth + 1). - positions_start.array[0] = range->start; - positions_start.used = 1; + if (depth) { + found->depth[depth].array[position].parent = found->depth[depth - 1].used; - slashes.array[0] = 0; - slashes.used = 1; + // Only assign object positions for nested objects. + found->depth[depth].array[position].object.start = objects.array[depth].start; + found->depth[depth].array[position].object.stop = objects.array[depth].stop; + } - while (range->start <= range->stop && range->start < buffer.used) { + found->depth[depth].array[position].content.array[0].start = positions_start.array[depth]; + found->depth[depth].array[position].content.array[0].stop = newline_last; + found->depth[depth].array[position].content.used = 1; - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); + if (position >= found->depth[depth].used) { + found->depth[depth].used++; + } - if (F_status_set_fine(status) == F_interrupt) { - status = F_status_set_error(F_interrupt); + if (found->used < depth + 1) { + found->used = depth + 1; + } - break; - } - } + if (graph_first == 0x2) { + status = f_array_lengths_increase(state.step_small, delimits); + if (F_status_is_error(status)) break; - if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); - if (F_status_is_error(status)) break; - - delimits->array[delimits->used++] = comment_delimit; - } - - newline_last = range->start; - position_previous = range->start++; - graph_first = 0x1; - - if (depth) { - private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop); - } - else { - private_macro_fl_fss_nest_return_on_overflow_delimited((buffer), (*range), (*found), positions_start, objects, slashes, F_none_eos, F_none_stop); - } - - line_start = range->start; - - continue; - } - - if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) { - slash_first = range->start; - slash_last = range->start; - slashes.array[depth] = 1; - - position_previous = range->start++; - - while (range->start <= range->stop && range->start < buffer.used && (buffer.string[range->start] == f_fss_delimit_placeholder_s.string[0] || buffer.string[range->start] == f_fss_delimit_slash_s.string[0])) { - - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); - - if (F_status_set_fine(status) == F_interrupt) { - status = F_status_set_error(F_interrupt); - - break; - } + delimits->array[delimits->used++] = comment_delimit; } - position_previous = range->start; + newline_last = range->start; + line_start = range->start + 1; + graph_first = 0x1; - if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) { - slash_last = range->start++; - ++slashes.array[depth]; - } - else { + if (!depth) { status = f_utf_buffer_increment(buffer, range, 1); if (F_status_is_error(status)) break; - } - } // while - - if (F_status_is_error(status)) break; - if (depth) { - private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop); - } - else { - private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_data_not_eos, F_data_not_stop); - } + private_macro_fl_fss_nest_return_on_overflow_delimited((buffer), (*range), (*found), positions_start, objects, slashes, F_none_eos, F_none_stop) - // All slashes for an open are delimited (because it could represent a slash in the object name). - // For example 'object {' = valid open, name 'object', 'object \{' represents 'object {', 'object \\{' = valid open, name 'object \', 'object \\\{' represents 'object \{', etc.. - // Only the first slash before a close is delimited, all others are maintained. - // For example '}' = valid close, '\}' represents '}', '\\}' represents '\}', '\\\}' represents '\\}', '\\\\}' represents '\\\}', and so on.. - // When slash is odd and a (delimited) valid open/close is found, then save delimited positions and continue. - if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); - if (F_status_is_error(status)) break; + f_array_lengths_resize(0, &positions_start); + f_string_ranges_resize(0, &objects); + f_array_lengths_resize(0, &slashes); - delimits->array[delimits->used++] = comment_delimit; + return F_fss_found_content; } - newline_last = range->start; - position_previous = range->start++; - line_start = range->start; - graph_first = 0x1; + --depth; } - else if (buffer.string[range->start] == f_fss_embedded_list_open_s.string[0] || buffer.string[range->start] == f_fss_embedded_list_close_s.string[0]) { - before_list_open = position_previous; - is_open = F_false; - graph_first = 0x0; - - if (buffer.string[range->start] == f_fss_embedded_list_open_s.string[0]) { - is_open = F_true; - } - - position_previous = range->start++; + else { + // No valid object close found, seek until EOL. while (range->start <= range->stop && range->start < buffer.used) { if (state.interrupt) { @@ -493,7 +564,7 @@ extern "C" { if (buffer.string[range->start] == f_fss_eol_s.string[0]) { if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); + status = f_array_lengths_increase(state.step_small, delimits); if (F_status_is_error(status)) break; delimits->array[delimits->used++] = comment_delimit; @@ -506,13 +577,6 @@ extern "C" { break; } - if (buffer.string[range->start] != f_fss_delimit_placeholder_s.string[0]) { - status = f_fss_is_space(state, buffer, *range); - if (F_status_is_error(status)) break; - - if (status == F_false) break; - } - position_previous = range->start; status = f_utf_buffer_increment(buffer, range, 1); @@ -522,228 +586,168 @@ extern "C" { if (F_status_is_error(status)) break; if (depth) { - private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop); + private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop) } else { - private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_data_not_eos, F_data_not_stop); + private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_data_not_eos, F_data_not_stop) } + } + } + else if (graph_first == 0x1 && buffer.string[range->start] == f_fss_comment_s.string[0]) { + position = newline_last + 1; - // This is a valid object open/close that has been delimited, save the slash delimit positions. - if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - newline_last = range->start; - line_start = range->start + 1; - graph_first = 0x1; - - if (is_open) { - bool is_object = F_false; + status = f_fss_seek_to_eol(state, buffer, range); + if (F_status_is_error(status)) break; - if (slashes.array[depth] % 2 == 0) { - is_object = F_true; - } + status = f_string_ranges_increase(state.step_small, comments); + if (F_status_is_error(status)) break; - range->start = slash_first; + if (range->start > range->stop || range->start >= buffer.used) { + --range->start; + } + else { + if (graph_first == 0x2) { + status = f_array_lengths_increase(state.step_small, delimits); + if (F_status_is_error(status)) break; - macro_f_fss_delimits_t_increase_by(status, (*delimits), (slashes.array[depth] / 2) + 1); - if (F_status_is_error(status)) break; + delimits->array[delimits->used++] = comment_delimit; + } - // Apply slash delimits, only slashes and placeholders should be present. - while (slashes.array[depth]) { + newline_last = range->start; + graph_first = 0x1; + } - if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) { - if (slashes.array[depth] % 2 == 1) { - delimits->array[delimits->used++] = range->start; - } + comments->array[comments->used].start = position; + comments->array[comments->used++].stop = range->start++; - --slashes.array[depth]; - } + continue; + } + else if (buffer.string[range->start] != f_fss_eol_s.string[0]) { + position_previous = range->start; - // Delimit slashes and placeholders are required to be in the ASCII range. - position_previous = range->start++; - } // while + if (graph_first == 0x1) { + status = f_fss_is_space(state, buffer, *range); + if (F_status_is_error(status)) break; - if (F_status_is_error(status)) break; + if (status == F_false) { + graph_first = 0x0; + } + } - // When slashes are even, the object is valid and needs to be processed. - if (is_object) { - if (++depth > positions_start.size) { - macro_f_array_lengths_t_resize(status, positions_start, positions_start.size + state.step_small); - if (F_status_is_error(status)) break; + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; - macro_f_fss_objects_t_resize(status, objects, objects.size + state.step_small); - if (F_status_is_error(status)) break; + if (range->start >= buffer.used || range->start > range->stop) break; - macro_f_array_lengths_t_resize(status, slashes, slashes.size + state.step_small); - if (F_status_is_error(status)) break; - } + continue; + } - if (positions_start.used < depth) { - positions_start.used = depth; - slashes.used = depth; - } + position_previous = range->start; - positions_start.array[depth] = newline_last + 1; + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; + } // while - objects.array[depth].start = line_start; - objects.array[depth].stop = before_list_open; + f_array_lengths_resize(0, &positions_start); + f_string_ranges_resize(0, &objects); + f_array_lengths_resize(0, &slashes); - slashes.array[depth] = 0; - } - } - else { - macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); - if (F_status_is_error(status)) break; + delimits->used = delimits_used; + comments->used = comments_used; - delimits->array[delimits->used++] = slash_last; - } + if (F_status_is_error(status)) { + return status; + } - range->start = newline_last; - } - } - else if (graph_first == 0x1 && buffer.string[range->start] == f_fss_comment_s.string[0]) { - graph_first = 0x2; - comment_delimit = slash_first; - } - else { - graph_first = 0x0; - } + if (range->start > range->stop) { + if (!depth) { + return F_status_set_error(F_end_not_stop); } - else if (buffer.string[range->start] == f_fss_embedded_list_open_s.string[0]) { - graph_first = 0x0; - before_list_open = position_previous; - position_previous = range->start; - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) break; + return F_status_set_error(F_end_not_nest_stop); + } - while (range->start <= range->stop && range->start < buffer.used) { + if (!depth) { + return F_status_set_error(F_end_not_eos); + } - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); + return F_status_set_error(F_end_not_nest_eos); + } +#endif // _di_fl_fss_embedded_list_content_read_ - if (F_status_set_fine(status) == F_interrupt) { - status = F_status_set_error(F_interrupt); +#ifndef _di_fl_fss_embedded_list_content_write_ + f_status_t fl_fss_embedded_list_content_write(const f_string_static_t content, const uint8_t complete, const f_string_static_t * const prepend, const f_string_ranges_t * const ignore, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination) { + #ifndef _di_level_1_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ - break; - } - } + f_status_t status = f_fss_skip_past_delimit(state, content, range); + if (F_status_is_error(status)) return status; - if (buffer.string[range->start] == f_fss_eol_s.string[0]) break; + if (status == F_none_eos) { + status = F_data_not_eos; + } + else if (status == F_none_stop) { + status = F_data_not_stop; + } - if (buffer.string[range->start] != f_fss_delimit_placeholder_s.string[0]) { - status = f_fss_is_space(state, buffer, *range); - if (F_status_is_error(status)) break; + if (range->start > range->stop || range->start >= content.used) { + if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_end_e) { + const f_status_t status_allocation = f_string_dynamic_increase_by(2, destination); + if (F_status_is_error(status_allocation)) return status_allocation; - if (status == F_false) break; - } + destination->string[destination->used++] = f_fss_embedded_list_close_s.string[0]; + destination->string[destination->used++] = f_fss_embedded_list_close_end_s.string[0]; + } - position_previous = range->start; - - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) break; - } // while - - if (F_status_is_error(status)) break; - - if (depth) { - private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop); - } - else { - private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_data_not_eos, F_data_not_stop); - } - - if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - ++depth; + return status; + } - if (depth >= positions_start.size) { - macro_f_array_lengths_t_resize(status, positions_start, positions_start.size + state.step_small); - if (F_status_is_error(status)) break; + // Ensure that there is room for a slash delimit and possibly the end of content characters. + status = f_string_dynamic_increase_by(4, destination); + if (F_status_is_error(status)) return status; - macro_f_fss_objects_t_resize(status, objects, objects.size + state.step_small); - if (F_status_is_error(status)) break; + const f_array_length_t used_start = destination->used; - macro_f_array_lengths_t_resize(status, slashes, slashes.size + state.step_small); - if (F_status_is_error(status)) break; - } + bool is_comment = F_false; + bool ends_on_eol = F_false; + bool has_graph = F_false; + bool do_prepend = prepend ? F_true : F_false; - if (positions_start.used <= depth) { - positions_start.used = depth + 1; - slashes.used = depth + 1; - } + f_array_length_t i = 0; + f_array_length_t slash_count = 0; + f_array_length_t start = 0; - positions_start.array[depth] = range->start + 1; + f_array_length_t r = 0; - objects.array[depth].start = line_start; - objects.array[depth].stop = before_list_open; + uint8_t width = 0; - slashes.array[depth] = 0; + while (range->start <= range->stop && range->start < content.used) { - if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); - if (F_status_is_error(status)) break; + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); - delimits->array[delimits->used++] = comment_delimit; - } + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); - newline_last = range->start; - line_start = range->start + 1; - graph_first = 0x1; + break; } - else { - - // No valid object close found, seek until EOL. - status = f_fss_seek_to_eol(state, buffer, range); - if (F_status_is_error(status)) break; - - if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); - if (F_status_is_error(status)) break; - - delimits->array[delimits->used++] = comment_delimit; - } - - newline_last = range->start; - line_start = range->start + 1; - graph_first = 0x1; - - while (range->start <= range->stop && range->start < buffer.used) { - - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); - - if (F_status_set_fine(status) == F_interrupt) { - status = F_status_set_error(F_interrupt); - - break; - } - } - - if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - newline_last = range->start; - line_start = range->start + 1; - - break; - } - - position_previous = range->start; + } - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) break; - } // while + if (content.string[range->start] == f_fss_delimit_slash_s.string[0] && !is_comment) { + slash_count = 1; + if (do_prepend) { + status = f_string_dynamic_append(*prepend, destination); if (F_status_is_error(status)) break; - if (depth) { - private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop); - } - else { - private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_data_not_eos, F_data_not_stop); - } + do_prepend = F_false; } - } - else if (buffer.string[range->start] == f_fss_embedded_list_close_s.string[0]) { - graph_first = 0x0; - while (range->start <= range->stop && range->start < buffer.used) { + destination->string[destination->used++] = content.string[range->start]; + + for (++range->start; range->start <= range->stop && range->start < content.used; ++range->start) { if (state.interrupt) { status = state.interrupt((void *) &state, 0); @@ -755,348 +759,402 @@ extern "C" { } } - position_previous = range->start; + if (content.string[range->start] == f_fss_delimit_placeholder_s.string[0]) continue; + if (content.string[range->start] != f_fss_delimit_slash_s.string[0]) break; - status = f_utf_buffer_increment(buffer, range, 1); + destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; + ++slash_count; + } // for + + if (content.string[range->start] == f_fss_embedded_list_open_s.string[0] || content.string[range->start] == f_fss_embedded_list_close_s.string[0]) { + start = range->start++; + + status = f_fss_skip_past_space(state, content, range); if (F_status_is_error(status)) break; - if (buffer.string[range->start] == f_fss_eol_s.string[0]) break; + if (range->start >= content.used || range->start > range->stop || content.string[range->start] == f_fss_eol_s.string[0]) { - if (buffer.string[range->start] != f_fss_delimit_placeholder_s.string[0]) { - status = f_fss_is_space(state, buffer, *range); + // Increase by total slashes + 1 embedded list open/close. + status = f_string_dynamic_increase_by(slash_count + 2, destination); if (F_status_is_error(status)) break; - if (status == F_false) break; - } - } // while - - if (F_status_is_error(status)) break; + if (content.string[range->start] == f_fss_embedded_list_open_s.string[0]) { + while (--slash_count) { + destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; + } // while + } - if (depth) { - private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop); - } - else { - private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_data_not_eos, F_data_not_stop); - } + destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; + destination->string[destination->used++] = content.string[start]; - if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - macro_f_fss_nest_t_increase(status, state.step_small, (*found)); - if (F_status_is_error(status)) break; + range->start = start + 1; - if (found->depth[depth].used == found->depth[depth].size) { - macro_f_fss_items_t_resize(status, found->depth[depth], found->depth[depth].size + state.step_small); + status = private_fl_fss_basic_list_write_add_until_end(content, state, range, destination); if (F_status_is_error(status)) break; - } - position = found->depth[depth].used; + if (content.string[range->start] != f_fss_eol_s.string[0]) { + has_graph = F_true; + } - if (found->depth[depth].array[position].content.size != 1) { - macro_f_fss_content_t_resize(status, found->depth[depth].array[position].content, 1); - if (F_status_is_error(status)) break; + continue; } - if (depth) { - found->depth[depth].array[position].parent = found->depth[depth - 1].used; - - // Only assign object positions for nested objects. - found->depth[depth].array[position].object.start = objects.array[depth].start; - found->depth[depth].array[position].object.stop = objects.array[depth].stop; - } + // Increase by character at "start" and possible newline. + status = f_string_dynamic_increase_by(2, destination); + if (F_status_is_error(status)) break; - found->depth[depth].array[position].content.array[0].start = positions_start.array[depth]; - found->depth[depth].array[position].content.array[0].stop = newline_last; - found->depth[depth].array[position].content.used = 1; + destination->string[destination->used++] = content.string[start]; - if (position >= found->depth[depth].used) { - found->depth[depth].used++; + if (content.string[range->start] == f_fss_eol_s.string[0]) { + destination->string[destination->used++] = f_fss_eol_s.string[0]; + ends_on_eol = F_true; } - - if (found->used < depth + 1) { - found->used = depth + 1; + else { + ends_on_eol = F_false; } - if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); - if (F_status_is_error(status)) break; + range->start = start + 1; + continue; + } + } + else if ((content.string[range->start] == f_fss_embedded_list_open_s.string[0] || (!has_graph && content.string[range->start] == f_fss_embedded_list_close_s.string[0])) && !is_comment) { + start = range->start++; - delimits->array[delimits->used++] = comment_delimit; - } + if (do_prepend) { + status = f_string_dynamic_append(*prepend, destination); + if (F_status_is_error(status)) break; - newline_last = range->start; - line_start = range->start + 1; - graph_first = 0x1; + do_prepend = F_false; + } - if (!depth) { - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) break; + has_graph = F_true; - private_macro_fl_fss_nest_return_on_overflow_delimited((buffer), (*range), (*found), positions_start, objects, slashes, F_none_eos, F_none_stop) + status = f_fss_skip_past_space(state, content, range); + if (F_status_is_error(status)) break; - f_array_lengths_resize(0, &positions_start); - macro_f_fss_objects_t_delete_simple(objects); - f_array_lengths_resize(0, &slashes); + if (range->start >= content.used || range->start > range->stop || content.string[range->start] == f_fss_eol_s.string[0]) { - return F_fss_found_content; + if (content.string[range->start] == f_fss_eol_s.string[0] && prepend) { + do_prepend = F_true; + ends_on_eol = F_true; + } + else { + ends_on_eol = F_false; } - --depth; - } - else { - - // No valid object close found, seek until EOL. - while (range->start <= range->stop && range->start < buffer.used) { + if (ignore && ignore->used) { - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); + for (r = 0; r < ignore->used; ++r) { + if (start >= ignore->array[r].start && start <= ignore->array[r].stop) break; + } // for - if (F_status_set_fine(status) == F_interrupt) { - status = F_status_set_error(F_interrupt); + if (r < ignore->used) { + status = f_string_dynamic_increase(state.step_large, destination); + if (F_status_is_error(status)) break; - break; - } + destination->string[destination->used++] = content.string[start]; + range->start = start + 1; + continue; } + } - if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); - if (F_status_is_error(status)) break; - - delimits->array[delimits->used++] = comment_delimit; - } - - newline_last = range->start; - line_start = range->start + 1; - graph_first = 0x1; - - break; - } + // Increase by slash and extended list open and possible newline. + status = f_string_dynamic_increase_by(3, destination); + if (F_status_is_error(status)) break; - position_previous = range->start; + destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; + destination->string[destination->used++] = content.string[start]; - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) break; - } // while + range->start = start + 1; + status = private_fl_fss_basic_list_write_add_until_end(content, state, range, destination); if (F_status_is_error(status)) break; - if (depth) { - private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop) - } - else { - private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_data_not_eos, F_data_not_stop) - } + continue; } - } - else if (graph_first == 0x1 && buffer.string[range->start] == f_fss_comment_s.string[0]) { - position = newline_last + 1; - - status = f_fss_seek_to_eol(state, buffer, range); - if (F_status_is_error(status)) break; - macro_f_fss_comments_t_increase(status, state.step_small, (*comments)) + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; - if (range->start > range->stop || range->start >= buffer.used) { - --range->start; - } - else { - if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); - if (F_status_is_error(status)) break; - - delimits->array[delimits->used++] = comment_delimit; - } - - newline_last = range->start; - graph_first = 0x1; - } - - comments->array[comments->used].start = position; - comments->array[comments->used++].stop = range->start++; - + destination->string[destination->used++] = content.string[start]; + range->start = start + 1; continue; } - else if (buffer.string[range->start] != f_fss_eol_s.string[0]) { - position_previous = range->start; + else if (content.string[range->start] == f_fss_comment_s.string[0] && !has_graph) { + is_comment = F_true; + } + else if (content.string[range->start] == f_fss_eol_s.string[0]) { + has_graph = F_false; + is_comment = F_false; + } + else if ((status = f_fss_is_graph(state, content, *range)) == F_true) { + has_graph = F_true; + } + else if (F_status_is_error(status)) { + break; + } - if (graph_first == 0x1) { - status = f_fss_is_space(state, buffer, *range); + if (content.string[range->start] != f_fss_delimit_placeholder_s.string[0]) { + if (do_prepend) { + status = f_string_dynamic_append(*prepend, destination); if (F_status_is_error(status)) break; - if (status == F_false) { - graph_first = 0x0; - } + do_prepend = F_false; } - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) break; + if (content.string[range->start] == f_fss_eol_s.string[0] && prepend) { + do_prepend = F_true; + ends_on_eol = F_true; + } + else { + ends_on_eol = F_false; + } - if (range->start >= buffer.used || range->start > range->stop) break; + width = macro_f_utf_byte_width(content.string[range->start]); - continue; - } + status = f_string_dynamic_increase_by(width, destination); + if (F_status_is_error(status)) break; - position_previous = range->start; + for (i = 0; i < width; ++i) { + destination->string[destination->used++] = content.string[range->start + i]; + } // for + } - status = f_utf_buffer_increment(buffer, range, 1); + status = f_utf_buffer_increment(content, range, 1); if (F_status_is_error(status)) break; } // while - f_array_lengths_resize(0, &positions_start); - macro_f_fss_objects_t_delete_simple(objects); - f_array_lengths_resize(0, &slashes); - - delimits->used = delimits_used; - comments->used = comments_used; - if (F_status_is_error(status)) { + destination->used = used_start; return status; } - if (range->start > range->stop) { - if (!depth) { - return F_status_set_error(F_end_not_stop); + if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_end_e) { + status = f_string_dynamic_increase_by(3, destination); + if (F_status_is_error(status)) return status; + + if (!ends_on_eol) { + destination->string[destination->used++] = f_fss_eol_s.string[0]; } - return F_status_set_error(F_end_not_nest_stop); + destination->string[destination->used++] = f_fss_embedded_list_close_s.string[0]; + destination->string[destination->used++] = f_fss_embedded_list_close_end_s.string[0]; } - if (!depth) { - return F_status_set_error(F_end_not_eos); + if (range->start > range->stop) { + return F_none_stop; } - return F_status_set_error(F_end_not_nest_eos); + if (range->start >= content.used) { + return F_none_eos; + } + + return F_none; } -#endif // _di_fl_fss_embedded_list_content_read_ +#endif // _di_fl_fss_embedded_list_content_write_ -#ifndef _di_fl_fss_embedded_list_object_write_ - f_status_t fl_fss_embedded_list_object_write(const f_string_static_t object, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination) { +#ifndef _di_fl_fss_embedded_list_object_read_ + f_status_t fl_fss_embedded_list_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_delimits_t * const delimits) { #ifndef _di_level_1_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); + if (!range) return F_status_set_error(F_parameter); + if (!found) return F_status_set_error(F_parameter); + if (!delimits) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - f_status_t status = f_fss_skip_past_delimit(state, object, range); + const f_array_length_t delimits_used = delimits->used; + + f_status_t status = f_fss_skip_past_space(state, buffer, range); if (F_status_is_error(status)) return status; + if (status == F_none_eol) { + + // Move the start position to after the EOL. + ++range->start; + + return F_fss_found_object_not; + } + if (status == F_none_eos) { - status = F_data_not_eos; + return F_data_not_eos; } - else if (status == F_none_stop) { - status = F_data_not_stop; + + if (status == F_none_stop) { + return F_data_not_stop; } - if (status == F_data_not_stop || status == F_data_not_eos) { - if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { - const f_status_t status_allocation = f_string_dynamic_increase_by(2, destination); - if (F_status_is_error(status_allocation)) return status_allocation; + // Return found nothing if this line only contains white space and delimit placeholders. + if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - destination->string[destination->used++] = f_fss_embedded_list_open_s.string[0]; + // Move the start position to after the EOL. + ++range->start; - if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { - destination->string[destination->used++] = f_fss_embedded_list_open_end_s.string[0]; - } + return F_fss_found_object_not; + } + + // Begin the search. + found->start = range->start; + + // Ignore all comment lines. + if (buffer.string[range->start] == f_fss_comment_s.string[0]) { + status = f_fss_seek_to_eol(state, buffer, range); + + if (F_status_is_error(status)) { + delimits->used = delimits_used; + + return status; } - return status; - } + if (status == F_none_eos) { + return F_data_not_eos; + } - // Ensure that there is room for a slash delimit, the object open character, and the end of line character. - status = f_string_dynamic_increase_by(4, destination); - if (F_status_is_error(status)) return status; + if (status == F_none_stop) { + return F_data_not_stop; + } - const f_array_length_t used_start = destination->used; + // Move the start position to after the EOL. + ++range->start; - f_array_length_t i = 0; + return F_fss_found_object_not; + } + + f_array_length_t start = 0; + f_array_length_t stop = 0; + f_array_length_t slash_first = 0; f_array_length_t slash_count = 0; - bool ends_on_space = F_false; + bool graph_first = F_true; - uint8_t width = 0; + // 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 (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + + break; + } + } + + if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) { + slash_first = range->start; + slash_count = 1; + + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; + + while (range->start <= range->stop && range->start < buffer.used && (buffer.string[range->start] == f_fss_delimit_placeholder_s.string[0] || buffer.string[range->start] == f_fss_delimit_slash_s.string[0])) { + + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + + break; + } + } + + if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) slash_count++; + + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; + } // while - // Find the first graph character. - while (range->start <= range->stop && range->start < object.used) { + if (F_status_is_error(status)) break; - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); + private_macro_fl_fss_object_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop); - if (F_status_set_fine(status) == F_interrupt) { - status = F_status_set_error(F_interrupt); + if (buffer.string[range->start] == f_fss_embedded_list_open_s.string[0]) { + graph_first = F_false; + stop = range->start++ - 1; - break; - } - } + while (range->start <= range->stop && range->start < buffer.used) { - if (object.string[range->start] == f_fss_comment_s.string[0]) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); - // When a comment is found, escape it. - status = f_string_dynamic_increase(state.step_large, destination); - if (F_status_is_error(status)) break; + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); - destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; + break; + } + } - break; - } + if (buffer.string[range->start] == f_fss_eol_s.string[0]) break; - status = f_fss_is_graph(state, object, *range); - if (F_status_is_error(status)) break; + status = f_fss_is_graph(state, buffer, *range); + if (F_status_is_error(status)) break; - if (status == F_true) break; + if (status == F_true) break; - // Objects will not have leading whitespaces, but having this does not result in an invalid object, so just write the provided spaces. - if (object.string[range->start] != f_fss_delimit_placeholder_s.string[0]) { - if (object.string[range->start] == f_fss_eol_s.string[0]) { - status = F_status_set_error(F_none_eol); + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; + } // while - break; - } + private_macro_fl_fss_object_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop); - status = f_fss_is_space(state, object, *range); - if (F_status_is_error(status)) break; + if (buffer.string[range->start] == f_fss_eol_s.string[0]) { + start = range->start; - if (status == F_true) { - if (object.string[range->start] == f_fss_eol_s.string[0]) { - status = F_status_set_error(F_none_eol); + range->start = slash_first; - break; - } + status = f_array_lengths_increase_by((slash_count / 2) + 1, delimits); + if (F_status_is_error(status)) break; - width = macro_f_utf_byte_width(object.string[range->start]); + if (slash_count % 2 == 0) { + while (slash_count > 0) { - status = f_string_dynamic_increase_by(width, destination); - if (F_status_is_error(status)) break; + if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) { + if (slash_count % 2 == 1) { + delimits->array[delimits->used++] = range->start; + } - for (i = 0; i < width; ++i) { - destination->string[destination->used++] = object.string[range->start + i]; - } // for - } - } + --slash_count; + } - status = f_utf_buffer_increment(object, range, 1); - if (F_status_is_error(status)) break; - } // while + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; + } // while - if (F_status_is_error(status)) { - destination->used = used_start; + if (F_status_is_error(status)) break; - return status; - } + found->stop = stop; + range->start = start + 1; - while (range->start <= range->stop && range->start < object.used) { + return F_fss_found_object; + } - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); + range->start = start + 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 (F_status_set_fine(status) == F_interrupt) { - status = F_status_set_error(F_interrupt); + // 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; - break; + delimits->array[delimits->used++] = slash_first; + ++range->start; + } + else { + graph_first = F_false; } + + continue; } + else if (buffer.string[range->start] == f_fss_embedded_list_open_s.string[0]) { + graph_first = F_false; + stop = range->start - 1; - if (object.string[range->start] == f_fss_delimit_slash_s.string[0]) { - slash_count = 1; + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; - for (++range->start; range->start <= range->stop && range->start < object.used; ++range->start) { + while (range->start <= range->stop && range->start < buffer.used) { if (state.interrupt) { status = state.interrupt((void *) &state, 0); @@ -1108,125 +1166,94 @@ extern "C" { } } - if (object.string[range->start] == f_fss_delimit_placeholder_s.string[0]) continue; - if (object.string[range->start] != f_fss_delimit_slash_s.string[0]) break; - - ++slash_count; - } // for + if (buffer.string[range->start] == f_fss_eol_s.string[0]) break; - if (F_status_is_error(status)) break; + status = f_fss_is_space(state, buffer, *range); + if (F_status_is_error(status)) break; - if (range->start > range->stop || range->start >= object.used) { + if (status == F_false) break; - // Slashes at the end of the object must be delimited to avoid delimiting the object close character. - slash_count *= 2; - } + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; + } // while - status = f_string_dynamic_increase_by(slash_count, destination); if (F_status_is_error(status)) break; - while (--slash_count) { - destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; - } // while - - if (range->start > range->stop || range->start >= object.used) { - ends_on_space = F_false; + private_macro_fl_fss_object_return_on_overflow_delimited((buffer), (*range), (*found), F_none_eos, F_none_stop); - break; - } - } + if (buffer.string[range->start] == f_fss_eol_s.string[0]) { + found->stop = stop; - if (object.string[range->start] != f_fss_delimit_placeholder_s.string[0]) { - if (object.string[range->start] == f_fss_eol_s.string[0]) { - status = F_status_set_error(F_none_eol); + // Move the start position to after the EOL. + ++range->start; - break; + return F_fss_found_object; } - status = f_fss_is_space(state, object, *range); + continue; + } + else if (graph_first) { + status = f_fss_is_space(state, buffer, *range); if (F_status_is_error(status)) break; - if (ends_on_space = (status == F_true)) { - if (object.string[range->start] == f_fss_eol_s.string[0]) { - status = F_status_set_error(F_none_eol); - - break; - } + if (status == F_false) { + graph_first = F_false; } - - width = macro_f_utf_byte_width(object.string[range->start]); - - status = f_string_dynamic_increase_by(width, destination); - if (F_status_is_error(status)) break; - - for (i = 0; i < width; ++i) { - destination->string[destination->used++] = object.string[range->start + i]; - } // for } - status = f_utf_buffer_increment(object, range, 1); + status = f_utf_buffer_increment(buffer, range, 1); if (F_status_is_error(status)) break; } // while if (F_status_is_error(status)) { - destination->used = used_start; + delimits->used = delimits_used; return status; } - if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { - if (complete == f_fss_complete_full_trim_e) { - status = private_fl_fss_basic_list_write_object_trim(used_start, state, destination); + // Seek to the end of the line when no valid object is found. + while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol_s.string[0]) { - if (F_status_is_error(status)) { - destination->used = used_start; + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); - return status; - } + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); - // Prevent a space from being added post-trimming. - ends_on_space = F_true; + break; + } } - status = f_string_dynamic_increase_by(3, destination); + status = f_utf_buffer_increment(buffer, range, 1); if (F_status_is_error(status)) { - destination->used = used_start; + delimits->used = delimits_used; return status; } + } // while - if (!ends_on_space) { - destination->string[destination->used++] = f_fss_space_s.string[0]; - } - - destination->string[destination->used++] = f_fss_embedded_list_open_s.string[0]; + private_macro_fl_fss_object_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop); - if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { - destination->string[destination->used++] = f_fss_embedded_list_open_end_s.string[0]; - } - } + status = f_utf_buffer_increment(buffer, range, 1); - if (range->start > range->stop) { - return F_none_stop; - } + if (F_status_is_error(status)) { + delimits->used = delimits_used; - if (range->start >= object.used) { - return F_none_eos; + return status; } - return F_none; + return F_fss_found_object_not; } -#endif // _di_fl_fss_embedded_list_object_write_ +#endif // _di_fl_fss_embedded_list_object_read_ -#ifndef _di_fl_fss_embedded_list_content_write_ - f_status_t fl_fss_embedded_list_content_write(const f_string_static_t content, const uint8_t complete, const f_string_static_t * const prepend, const f_string_ranges_t * const ignore, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination) { +#ifndef _di_fl_fss_embedded_list_object_write_ + f_status_t fl_fss_embedded_list_object_write(const f_string_static_t object, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination) { #ifndef _di_level_1_parameter_checking_ - if (!range) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - f_status_t status = f_fss_skip_past_delimit(state, content, range); + f_status_t status = f_fss_skip_past_delimit(state, object, range); if (F_status_is_error(status)) return status; if (status == F_none_eos) { @@ -1236,38 +1263,36 @@ extern "C" { status = F_data_not_stop; } - if (range->start > range->stop || range->start >= content.used) { - if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_end_e) { + if (status == F_data_not_stop || status == F_data_not_eos) { + if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { const f_status_t status_allocation = f_string_dynamic_increase_by(2, destination); if (F_status_is_error(status_allocation)) return status_allocation; - destination->string[destination->used++] = f_fss_embedded_list_close_s.string[0]; - destination->string[destination->used++] = f_fss_embedded_list_close_end_s.string[0]; + destination->string[destination->used++] = f_fss_embedded_list_open_s.string[0]; + + if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { + destination->string[destination->used++] = f_fss_embedded_list_open_end_s.string[0]; + } } return status; } - // Ensure that there is room for a slash delimit and possibly the end of content characters. + // Ensure that there is room for a slash delimit, the object open character, and the end of line character. status = f_string_dynamic_increase_by(4, destination); if (F_status_is_error(status)) return status; const f_array_length_t used_start = destination->used; - bool is_comment = F_false; - bool ends_on_eol = F_false; - bool has_graph = F_false; - bool do_prepend = prepend ? F_true : F_false; - f_array_length_t i = 0; f_array_length_t slash_count = 0; - f_array_length_t start = 0; - f_array_length_t r = 0; + bool ends_on_space = F_false; uint8_t width = 0; - while (range->start <= range->stop && range->start < content.used) { + // Find the first graph character. + while (range->start <= range->stop && range->start < object.used) { if (state.interrupt) { status = state.interrupt((void *) &state, 0); @@ -1279,223 +1304,198 @@ extern "C" { } } - if (content.string[range->start] == f_fss_delimit_slash_s.string[0] && !is_comment) { - slash_count = 1; - - if (do_prepend) { - status = f_string_dynamic_append(*prepend, destination); - if (F_status_is_error(status)) break; - - do_prepend = F_false; - } - - destination->string[destination->used++] = content.string[range->start]; + if (object.string[range->start] == f_fss_comment_s.string[0]) { - for (++range->start; range->start <= range->stop && range->start < content.used; ++range->start) { + // When a comment is found, escape it. + status = f_string_dynamic_increase(state.step_large, destination); + if (F_status_is_error(status)) break; - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); + destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; - if (F_status_set_fine(status) == F_interrupt) { - status = F_status_set_error(F_interrupt); + break; + } - break; - } - } + status = f_fss_is_graph(state, object, *range); + if (F_status_is_error(status)) break; - if (content.string[range->start] == f_fss_delimit_placeholder_s.string[0]) continue; - if (content.string[range->start] != f_fss_delimit_slash_s.string[0]) break; + if (status == F_true) break; - destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; - ++slash_count; - } // for + // 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_delimit_placeholder_s.string[0]) { + if (object.string[range->start] == f_fss_eol_s.string[0]) { + status = F_status_set_error(F_none_eol); - if (content.string[range->start] == f_fss_embedded_list_open_s.string[0] || content.string[range->start] == f_fss_embedded_list_close_s.string[0]) { - start = range->start++; + break; + } - status = f_fss_skip_past_space(state, content, range); - if (F_status_is_error(status)) break; + status = f_fss_is_space(state, object, *range); + if (F_status_is_error(status)) break; - if (range->start >= content.used || range->start > range->stop || content.string[range->start] == f_fss_eol_s.string[0]) { + if (status == F_true) { + if (object.string[range->start] == f_fss_eol_s.string[0]) { + status = F_status_set_error(F_none_eol); - // Increase by total slashes + 1 embedded list open/close. - status = f_string_dynamic_increase_by(slash_count + 2, destination); - if (F_status_is_error(status)) break; + break; + } - if (content.string[range->start] == f_fss_embedded_list_open_s.string[0]) { - while (--slash_count) { - destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; - } // while - } + width = macro_f_utf_byte_width(object.string[range->start]); - destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; - destination->string[destination->used++] = content.string[start]; + status = f_string_dynamic_increase_by(width, destination); + if (F_status_is_error(status)) break; - range->start = start + 1; + for (i = 0; i < width; ++i) { + destination->string[destination->used++] = object.string[range->start + i]; + } // for + } + } - status = private_fl_fss_basic_list_write_add_until_end(content, state, range, destination); - if (F_status_is_error(status)) break; + status = f_utf_buffer_increment(object, range, 1); + if (F_status_is_error(status)) break; + } // while - if (content.string[range->start] != f_fss_eol_s.string[0]) { - has_graph = F_true; - } + if (F_status_is_error(status)) { + destination->used = used_start; - continue; - } + return status; + } - // Increase by character at "start" and possible newline. - status = f_string_dynamic_increase_by(2, destination); - if (F_status_is_error(status)) break; + while (range->start <= range->stop && range->start < object.used) { - destination->string[destination->used++] = content.string[start]; + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); - if (content.string[range->start] == f_fss_eol_s.string[0]) { - destination->string[destination->used++] = f_fss_eol_s.string[0]; - ends_on_eol = F_true; - } - else { - ends_on_eol = F_false; - } + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); - range->start = start + 1; - continue; + break; } } - else if ((content.string[range->start] == f_fss_embedded_list_open_s.string[0] || (!has_graph && content.string[range->start] == f_fss_embedded_list_close_s.string[0])) && !is_comment) { - start = range->start++; - - if (do_prepend) { - status = f_string_dynamic_append(*prepend, destination); - if (F_status_is_error(status)) break; - - do_prepend = F_false; - } - has_graph = F_true; - - status = f_fss_skip_past_space(state, content, range); - if (F_status_is_error(status)) break; - - if (range->start >= content.used || range->start > range->stop || content.string[range->start] == f_fss_eol_s.string[0]) { - - if (content.string[range->start] == f_fss_eol_s.string[0] && prepend) { - do_prepend = F_true; - ends_on_eol = F_true; - } - else { - ends_on_eol = F_false; - } + if (object.string[range->start] == f_fss_delimit_slash_s.string[0]) { + slash_count = 1; - if (ignore && ignore->used) { + for (++range->start; range->start <= range->stop && range->start < object.used; ++range->start) { - for (r = 0; r < ignore->used; ++r) { - if (start >= ignore->array[r].start && start <= ignore->array[r].stop) break; - } // for + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); - if (r < ignore->used) { - status = f_string_dynamic_increase(state.step_large, destination); - if (F_status_is_error(status)) break; + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); - destination->string[destination->used++] = content.string[start]; - range->start = start + 1; - continue; + break; } } - // Increase by slash and extended list open and possible newline. - status = f_string_dynamic_increase_by(3, destination); - if (F_status_is_error(status)) break; + if (object.string[range->start] == f_fss_delimit_placeholder_s.string[0]) continue; + if (object.string[range->start] != f_fss_delimit_slash_s.string[0]) break; - destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; - destination->string[destination->used++] = content.string[start]; + ++slash_count; + } // for - range->start = start + 1; + if (F_status_is_error(status)) break; - status = private_fl_fss_basic_list_write_add_until_end(content, state, range, destination); - if (F_status_is_error(status)) break; + if (range->start > range->stop || range->start >= object.used) { - continue; + // Slashes at the end of the object must be delimited to avoid delimiting the object close character. + slash_count *= 2; } - status = f_string_dynamic_increase(state.step_large, destination); + status = f_string_dynamic_increase_by(slash_count, destination); if (F_status_is_error(status)) break; - destination->string[destination->used++] = content.string[start]; - range->start = start + 1; - continue; - } - else if (content.string[range->start] == f_fss_comment_s.string[0] && !has_graph) { - is_comment = F_true; - } - else if (content.string[range->start] == f_fss_eol_s.string[0]) { - has_graph = F_false; - is_comment = F_false; - } - else if ((status = f_fss_is_graph(state, content, *range)) == F_true) { - has_graph = F_true; - } - else if (F_status_is_error(status)) { - break; - } + while (--slash_count) { + destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; + } // while - if (content.string[range->start] != f_fss_delimit_placeholder_s.string[0]) { - if (do_prepend) { - status = f_string_dynamic_append(*prepend, destination); - if (F_status_is_error(status)) break; + if (range->start > range->stop || range->start >= object.used) { + ends_on_space = F_false; - do_prepend = F_false; + break; } + } - if (content.string[range->start] == f_fss_eol_s.string[0] && prepend) { - do_prepend = F_true; - ends_on_eol = F_true; + if (object.string[range->start] != f_fss_delimit_placeholder_s.string[0]) { + if (object.string[range->start] == f_fss_eol_s.string[0]) { + status = F_status_set_error(F_none_eol); + + break; } - else { - ends_on_eol = F_false; + + status = f_fss_is_space(state, object, *range); + if (F_status_is_error(status)) break; + + if (ends_on_space = (status == F_true)) { + if (object.string[range->start] == f_fss_eol_s.string[0]) { + status = F_status_set_error(F_none_eol); + + break; + } } - width = macro_f_utf_byte_width(content.string[range->start]); + width = macro_f_utf_byte_width(object.string[range->start]); status = f_string_dynamic_increase_by(width, destination); if (F_status_is_error(status)) break; for (i = 0; i < width; ++i) { - destination->string[destination->used++] = content.string[range->start + i]; + destination->string[destination->used++] = object.string[range->start + i]; } // for } - status = f_utf_buffer_increment(content, range, 1); + status = f_utf_buffer_increment(object, range, 1); if (F_status_is_error(status)) break; } // while if (F_status_is_error(status)) { destination->used = used_start; + return status; } - if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_end_e) { + if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { + if (complete == f_fss_complete_full_trim_e) { + status = private_fl_fss_basic_list_write_object_trim(used_start, state, destination); + + if (F_status_is_error(status)) { + destination->used = used_start; + + return status; + } + + // Prevent a space from being added post-trimming. + ends_on_space = F_true; + } + status = f_string_dynamic_increase_by(3, destination); - if (F_status_is_error(status)) return status; - if (!ends_on_eol) { - destination->string[destination->used++] = f_fss_eol_s.string[0]; + if (F_status_is_error(status)) { + destination->used = used_start; + + return status; } - destination->string[destination->used++] = f_fss_embedded_list_close_s.string[0]; - destination->string[destination->used++] = f_fss_embedded_list_close_end_s.string[0]; + if (!ends_on_space) { + destination->string[destination->used++] = f_fss_space_s.string[0]; + } + + destination->string[destination->used++] = f_fss_embedded_list_open_s.string[0]; + + if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { + destination->string[destination->used++] = f_fss_embedded_list_open_end_s.string[0]; + } } if (range->start > range->stop) { return F_none_stop; } - if (range->start >= content.used) { + if (range->start >= object.used) { return F_none_eos; } return F_none; } -#endif // _di_fl_fss_embedded_list_content_write_ +#endif // _di_fl_fss_embedded_list_object_write_ #ifdef __cplusplus } // extern "C" diff --git a/level_1/fl_fss/c/fss/embedded_list.h b/level_1/fl_fss/c/fss/embedded_list.h index db9c066..2b33d19 100644 --- a/level_1/fl_fss/c/fss/embedded_list.h +++ b/level_1/fl_fss/c/fss/embedded_list.h @@ -31,10 +31,14 @@ extern "C" { #endif /** - * Read an fss-0008 object. + * Read an fss-0008 content. * * This will record where delimit placeholders exist but will not apply the delimits. * + * This operates on the assumption that found.array[0].array[found.array[0].used].content is the current content being processed. + * Therefore the object for this content will also need to be found.array[0].array[found.array[0].used].object. + * The object at depth 0 will not be populated, but all nested objects will be populated at their respective depth along with the content. + * * @param buffer * The buffer to read from. * @param state @@ -52,13 +56,17 @@ extern "C" { * The start location will represent where the read stopped on return. * A start location past the stop location or buffer used means that the entire range was processed. * @param found - * A location where a valid object was found. + * A set of all locations where a valid content was found. * @param delimits * A delimits array representing where delimits exist within the buffer. + * @param comments + * An array of ranges representing where comments are found within any valid content. + * This only stores comments found within valid content only. + * The comment range will include the trailing newline. * * @return - * F_fss_found_object on success and object was found (start location is at end of object). - * F_fss_found_object_not on success and no object was found (start location is after character designating this is not an object). + * F_fss_found_content on success and content was found (start location is at end of content). + * F_fss_found_content_not on success and no content was found (start location is after character designating this is not a content). * F_none_eos on success after reaching the end of the buffer (a valid object is not yet confirmed). * F_none_stop on success after reaching stopping point (a valid object is not yet confirmed). * F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found). @@ -66,34 +74,105 @@ extern "C" { * F_end_not_group_eos if EOS was reached before the a group termination was reached. * F_end_not_group_stop if stop point was reached before the a group termination was reached. * - * F_array_too_large (with error bit) if a buffer is too large. - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_complete_not_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. - * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * - * Errors (with error bit) from: f_utf_buffer_increment(). - * Errors (with error bit) from: f_fss_is_graph(). + * Errors (with error bit) from: f_array_lengths_increase(). + * Errors (with error bit) from: f_array_lengths_increase_by(). * Errors (with error bit) from: f_fss_is_space(). + * Errors (with error bit) from: f_fss_nest_increase(). * 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_string_ranges_increase(). + * Errors (with error bit) from: f_utf_buffer_increment(). + * + * @see f_array_lengths_increase() + * @see f_array_lengths_increase_by() + * @see f_fss_is_space() + * @see f_fss_nest_increase() + * @see f_fss_seek_to_eol() + * @see f_fss_skip_past_delimit() + * @see f_string_ranges_increase() + * @see f_utf_buffer_increment() + */ +#ifndef _di_fl_fss_embedded_list_content_read_ + extern f_status_t fl_fss_embedded_list_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_nest_t * const found, f_fss_delimits_t * const delimits, f_fss_comments_t * const comments); +#endif // _di_fl_fss_embedded_list_content_read_ + +/** + * Write an fss-0008 content from a given string. + * + * This will write the given string range as a valid content. + * Anything within this range will be escaped as necessary. + * + * The destination string may have NULLs. + * + * @param content + * The string to write as (does not stop at NULLS, they are ignored and not written). + * @param complete + * If f_fss_complete_none_e, then only the content is written. + * If f_fss_complete_next_e, then the content followed by any appropriate "next" character separating one content from the next, if applicable. + * If f_fss_complete_end_e, then the content followed by any appropriate "end" character designating the last content for some object, printing final newline, if applicable. + * If f_fss_complete_partial_e, this will write any appropriate open and close aspects of this content, except for the final newline. + * If f_fss_complete_full_e, this will write any appropriate open and close aspects of this content, including the final newline. + * @param prepend + * A string of whitespace to prepend at the start of each line. + * This should only be whitespace, anything else could produce invalid content. + * Set the pointer address to 0 to disable. + * @param ignore + * An optional list of ranges within the string to ignore. + * These ranges are only checked/ignored if there is a valid nested object open or a valid nested object close. + * Any valid nested object open or valid nested object close inside an ingore range will not be escaped. + * Set the pointer address to 0 to disable. + * @param state + * A state for providing flags and handling interrupts during long running operations. + * There is no print_error(). + * There is no functions structure. + * There is no data structure passed to these functions. + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. + * @param range + * The start/stop location within the content string to write as an content. + * @param destination + * The buffer where the content is written to. + * + * @return + * F_none on success. + * F_none_eos on success after reaching the end of the buffer. + * F_data_not_stop no data to write due start location being greater than stop location. + * F_data_not_eos no data to write due start location being greater than or equal to buffer size. + * F_none_stop on success after reaching stopping point. + * + * F_interrupt (with error bit) if stopping due to an interrupt. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_fss_is_graph(). + * 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_string_dynamic_append(). + * Errors (with error bit) from: f_string_dynamic_increase(). + * Errors (with error bit) from: f_string_dynamic_increase_by(). + * Errors (with error bit) from: f_utf_buffer_increment(). + * + * @see f_fss_is_graph() + * @see f_fss_skip_past_delimit() + * @see f_fss_skip_past_space() + * @see f_string_dynamic_append() + * @see f_string_dynamic_increase() + * @see f_string_dynamic_increase_by() + * @see f_utf_buffer_increment() */ -#ifndef _di_fl_fss_embedded_list_object_read_ - extern f_status_t fl_fss_embedded_list_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_delimits_t * const delimits); -#endif // _di_fl_fss_embedded_list_object_read_ +#ifndef _di_fl_fss_embedded_list_content_write_ + extern f_status_t fl_fss_embedded_list_content_write(const f_string_static_t content, const uint8_t complete, const f_string_static_t * const prepend, const f_string_ranges_t * const ignore, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination); +#endif // _di_fl_fss_embedded_list_content_write_ /** - * Read an fss-0008 content. + * Read an fss-0008 object. * * This will record where delimit placeholders exist but will not apply the delimits. * - * This operates on the assumption that found.array[0].array[found.array[0].used].content is the current content being processed. - * Therefore the object for this content will also need to be found.array[0].array[found.array[0].used].object. - * The object at depth 0 will not be populated, but all nested objects will be populated at their respective depth along with the content. - * * @param buffer * The buffer to read from. * @param state @@ -111,17 +190,13 @@ extern "C" { * The start location will represent where the read stopped on return. * A start location past the stop location or buffer used means that the entire range was processed. * @param found - * A set of all locations where a valid content was found. + * A location where a valid object was found. * @param delimits * A delimits array representing where delimits exist within the buffer. - * @param comments - * An array of ranges representing where comments are found within any valid content. - * This only stores comments found within valid content only. - * The comment range will include the trailing newline. * * @return - * F_fss_found_content on success and content was found (start location is at end of content). - * F_fss_found_content_not on success and no content was found (start location is after character designating this is not a content). + * F_fss_found_object on success and object was found (start location is at end of object). + * F_fss_found_object_not on success and no object was found (start location is after character designating this is not an object). * F_none_eos on success after reaching the end of the buffer (a valid object is not yet confirmed). * F_none_stop on success after reaching stopping point (a valid object is not yet confirmed). * F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found). @@ -129,23 +204,30 @@ extern "C" { * F_end_not_group_eos if EOS was reached before the a group termination was reached. * F_end_not_group_stop if stop point was reached before the a group termination was reached. * - * F_array_too_large (with error bit) if a buffer is too large. - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_complete_not_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. - * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * - * Errors (with error bit) from: f_utf_buffer_increment(). + * Errors (with error bit) from: f_array_lengths_increase_by(). * Errors (with error bit) from: f_fss_is_graph(). * Errors (with error bit) from: f_fss_is_space(). + * Errors (with error bit) from: f_fss_is_zero_width(). + * 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_utf_buffer_increment(). + * + * @see f_array_lengths_increase_by() + * @see f_fss_is_graph() + * @see f_fss_is_space() + * @see f_fss_is_zero_width() + * @see f_fss_seek_to_eol() + * @see f_fss_skip_past_delimit() + * @see f_fss_skip_past_space() + * @see f_utf_buffer_increment() */ -#ifndef _di_fl_fss_embedded_list_content_read_ - extern f_status_t fl_fss_embedded_list_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_nest_t * const found, f_fss_delimits_t * const delimits, f_fss_comments_t * const comments); -#endif // _di_fl_fss_embedded_list_content_read_ +#ifndef _di_fl_fss_embedded_list_object_read_ + extern f_status_t fl_fss_embedded_list_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_delimits_t * const delimits); +#endif // _di_fl_fss_embedded_list_object_read_ /** * Write an fss-0008 object from a given string. @@ -183,79 +265,30 @@ extern "C" { * F_none_eos on success after reaching the end of the buffer. * F_data_not_stop no data to write due start location being greater than stop location. * F_data_not_eos no data to write due start location being greater than or equal to buffer size. - * F_none_stop on success after reaching stopping point . + * F_none_stop on success after reaching stopping point. * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. * F_none_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. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * + * Errors (with error bit) from: f_fss_is_graph(). + * Errors (with error bit) from: f_fss_is_space(). + * Errors (with error bit) from: f_fss_skip_past_delimit(). + * Errors (with error bit) from: f_string_dynamic_increase(). + * Errors (with error bit) from: f_string_dynamic_increase_by(). * Errors (with error bit) from: f_utf_buffer_increment(). + * + * @see f_fss_is_graph() + * @see f_fss_is_space() + * @see f_fss_skip_past_delimit() + * @see f_string_dynamic_increase() + * @see f_string_dynamic_increase_by() + * @see f_utf_buffer_increment() */ #ifndef _di_fl_fss_embedded_list_object_write_ extern f_status_t fl_fss_embedded_list_object_write(const f_string_static_t object, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination); #endif // _di_fl_fss_embedded_list_object_write_ -/** - * Write an fss-0008 content from a given string. - * - * This will write the given string range as a valid content. - * Anything within this range will be escaped as necessary. - * - * The destination string may have NULLs. - * - * @param content - * The string to write as (does not stop at NULLS, they are ignored and not written). - * @param complete - * If f_fss_complete_none_e, then only the content is written. - * If f_fss_complete_next_e, then the content followed by any appropriate "next" character separating one content from the next, if applicable. - * If f_fss_complete_end_e, then the content followed by any appropriate "end" character designating the last content for some object, printing final newline, if applicable. - * If f_fss_complete_partial_e, this will write any appropriate open and close aspects of this content, except for the final newline. - * If f_fss_complete_full_e, this will write any appropriate open and close aspects of this content, including the final newline. - * @param prepend - * A string of whitespace to prepend at the start of each line. - * This should only be whitespace, anything else could produce invalid content. - * Set the pointer address to 0 to disable. - * @param ignore - * An optional list of ranges within the string to ignore. - * These ranges are only checked/ignored if there is a valid nested object open or a valid nested object close. - * Any valid nested object open or valid nested object close inside an ingore range will not be escaped. - * Set the pointer address to 0 to disable. - * @param state - * A state for providing flags and handling interrupts during long running operations. - * There is no print_error(). - * There is no functions structure. - * There is no data structure passed to these functions. - * - * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. - * Error bit designates an error but must be passed along with F_interrupt. - * All other statuses are ignored. - * @param range - * The start/stop location within the content string to write as an content. - * @param destination - * The buffer where the content is written to. - * - * @return - * F_none on success. - * F_none_eos on success after reaching the end of the buffer. - * F_data_not_stop no data to write due start location being greater than stop location. - * F_data_not_eos no data to write due start location being greater than or equal to buffer size. - * F_none_stop on success after reaching stopping point. - * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. - * - * Errors (with error bit) from: f_utf_buffer_increment(). - */ -#ifndef _di_fl_fss_embedded_list_content_write_ - extern f_status_t fl_fss_embedded_list_content_write(const f_string_static_t content, const uint8_t complete, const f_string_static_t * const prepend, const f_string_ranges_t * const ignore, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination); -#endif // _di_fl_fss_embedded_list_content_write_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_1/fl_fss/c/fss/extended.c b/level_1/fl_fss/c/fss/extended.c index 2c8f806..d7458c1 100644 --- a/level_1/fl_fss/c/fss/extended.c +++ b/level_1/fl_fss/c/fss/extended.c @@ -6,34 +6,6 @@ extern "C" { #endif -#ifndef _di_fl_fss_extended_object_read_ - f_status_t fl_fss_extended_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_quote_t * const quoted, f_fss_delimits_t * const delimits) { - #ifndef _di_level_1_parameter_checking_ - if (!range) return F_status_set_error(F_parameter); - if (!found) return F_status_set_error(F_parameter); - if (!delimits) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - const f_array_length_t delimits_used = delimits->used; - - f_status_t status = private_fl_fss_basic_read(buffer, F_true, state, range, found, quoted, delimits); - - if (F_status_is_error(status)) { - delimits->used = delimits_used; - - return status; - } - - if (status == F_fss_found_object_not || status == F_data_not || status == F_data_not_eos || status == F_data_not_stop) { - delimits->used = delimits_used; - - return status; - } - - return status; - } -#endif // _di_fl_fss_extended_object_read_ - #ifndef _di_fl_fss_extended_content_read_ f_status_t fl_fss_extended_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_content_t * const found, f_fss_quotes_t * const quotes, f_fss_delimits_t * const delimits) { #ifndef _di_level_1_parameter_checking_ @@ -78,10 +50,10 @@ extern "C" { if (status == F_fss_found_object || status == F_fss_found_object_content_not) { if (found->used + 1 > found->size) { - macro_f_string_ranges_t_increase(status_allocate, state.step_small, (*found)); + status_allocate = f_string_ranges_increase(state.step_small, found); if (F_status_is_fine(status_allocate) && quotes) { - macro_f_fss_quotes_t_resize(status_allocate, (*quotes), found->size); + status_allocate = f_uint8s_resize(found->size, quotes); } if (F_status_is_error(status_allocate)) { @@ -149,47 +121,6 @@ extern "C" { } #endif // _di_fl_fss_extended_content_read_ -#ifndef _di_fl_fss_extended_object_write_ -f_status_t fl_fss_extended_object_write(const f_string_static_t object, const f_fss_quote_t quoted, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination) { - #ifndef _di_level_1_parameter_checking_ - if (!range) return F_status_set_error(F_parameter); - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - const f_array_length_t used_start = destination->used; - - f_status_t status = private_fl_fss_basic_write(F_true, object, quoted ? quoted : f_fss_delimit_quote_double_s.string[0], state, range, destination); - - if (status == F_data_not_stop || status == F_data_not_eos) { - - // Objects cannot be empty, so write a quoted empty string. - const f_status_t status_allocation = f_string_dynamic_increase_by(2, destination); - if (F_status_is_error(status_allocation)) return status_allocation; - - destination->string[destination->used++] = quoted ? f_fss_delimit_quote_single_s.string[0] : f_fss_delimit_quote_double_s.string[0]; - destination->string[destination->used++] = quoted ? f_fss_delimit_quote_single_s.string[0] : f_fss_delimit_quote_double_s.string[0]; - } - - if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { - if (status == F_none_stop || status == F_none_eos || status == F_data_not_stop || status == F_data_not_eos) { - f_status_t status2 = F_none; - - if (complete == f_fss_complete_full_trim_e) { - status2 = private_fl_fss_basic_write_object_trim(quoted ? quoted : f_fss_delimit_quote_double_s.string[0], used_start, state, destination); - if (F_status_is_error(status2)) return status2; - } - - status2 = f_string_dynamic_increase(state.step_large, destination); - if (F_status_is_error(status2)) return status2; - - destination->string[destination->used++] = f_fss_extended_open_s.string[0]; - } - } - - return status; - } -#endif // _di_fl_fss_extended_object_write_ - #ifndef _di_fl_fss_extended_content_write_ f_status_t fl_fss_extended_content_write(const f_string_static_t content, const f_fss_quote_t quoted, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination) { #ifndef _di_level_1_parameter_checking_ @@ -242,6 +173,75 @@ f_status_t fl_fss_extended_object_write(const f_string_static_t object, const f_ } #endif // _di_fl_fss_extended_content_write_ +#ifndef _di_fl_fss_extended_object_read_ + f_status_t fl_fss_extended_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_quote_t * const quoted, f_fss_delimits_t * const delimits) { + #ifndef _di_level_1_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + if (!found) return F_status_set_error(F_parameter); + if (!delimits) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + const f_array_length_t delimits_used = delimits->used; + + f_status_t status = private_fl_fss_basic_read(buffer, F_true, state, range, found, quoted, delimits); + + if (F_status_is_error(status)) { + delimits->used = delimits_used; + + return status; + } + + if (status == F_fss_found_object_not || status == F_data_not || status == F_data_not_eos || status == F_data_not_stop) { + delimits->used = delimits_used; + + return status; + } + + return status; + } +#endif // _di_fl_fss_extended_object_read_ + +#ifndef _di_fl_fss_extended_object_write_ +f_status_t fl_fss_extended_object_write(const f_string_static_t object, const f_fss_quote_t quoted, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination) { + #ifndef _di_level_1_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + const f_array_length_t used_start = destination->used; + + f_status_t status = private_fl_fss_basic_write(F_true, object, quoted ? quoted : f_fss_delimit_quote_double_s.string[0], state, range, destination); + + if (status == F_data_not_stop || status == F_data_not_eos) { + + // Objects cannot be empty, so write a quoted empty string. + const f_status_t status_allocation = f_string_dynamic_increase_by(2, destination); + if (F_status_is_error(status_allocation)) return status_allocation; + + destination->string[destination->used++] = quoted ? f_fss_delimit_quote_single_s.string[0] : f_fss_delimit_quote_double_s.string[0]; + destination->string[destination->used++] = quoted ? f_fss_delimit_quote_single_s.string[0] : f_fss_delimit_quote_double_s.string[0]; + } + + if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { + if (status == F_none_stop || status == F_none_eos || status == F_data_not_stop || status == F_data_not_eos) { + f_status_t status2 = F_none; + + if (complete == f_fss_complete_full_trim_e) { + status2 = private_fl_fss_basic_write_object_trim(quoted ? quoted : f_fss_delimit_quote_double_s.string[0], used_start, state, destination); + if (F_status_is_error(status2)) return status2; + } + + status2 = f_string_dynamic_increase(state.step_large, destination); + if (F_status_is_error(status2)) return status2; + + destination->string[destination->used++] = f_fss_extended_open_s.string[0]; + } + } + + return status; + } +#endif // _di_fl_fss_extended_object_write_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_1/fl_fss/c/fss/extended.h b/level_1/fl_fss/c/fss/extended.h index d92e342..6fbfaec 100644 --- a/level_1/fl_fss/c/fss/extended.h +++ b/level_1/fl_fss/c/fss/extended.h @@ -30,7 +30,7 @@ extern "C" { #endif /** - * Read an fss-0001 object. + * Read an fss-0001 content. * * This will record where delimit placeholders exist but will not apply the delimits. * @@ -51,17 +51,16 @@ extern "C" { * The start location will represent where the read stopped on return. * A start location past the stop location or buffer used means that the entire range was processed. * @param found - * A location where a valid object was found. - * @param quoted - * This will store whether or not this object is quoted and what quote is in use. + * A set of all locations where a valid content was found. + * @param quotes + * An array of quotes designating whether or not content is quoted and what quote is in use. * Set pointer address to 0 to not use. * @param delimits * A delimits array representing where delimits exist within the buffer. * * @return - * F_fss_found_object on success and object was found (start location is at end of object). - * F_fss_found_object_content_not on success but object ended at the line so there can be no content. - * F_fss_found_object_not on success and no object was found (start location is after character designating this is not an object). + * F_fss_found_content on success and content was found (start location is at end of content). + * F_fss_found_content_not on success and no content was found (start location is after character designating this is not a content). * F_none_eos on success after reaching the end of the buffer (a valid object is not yet confirmed). * F_none_stop on success after reaching stopping point (a valid object is not yet confirmed). * F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found). @@ -72,20 +71,98 @@ extern "C" { * F_interrupt (with error bit) if stopping due to an interrupt. * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_utf_buffer_increment(). + * Errors (with error bit) from: f_array_lengths_increase(). + * Errors (with error bit) from: f_array_lengths_increase_by(). * Errors (with error bit) from: f_fss_is_graph(). * Errors (with error bit) from: f_fss_is_space(). * Errors (with error bit) from: f_fss_is_zero_width(). - * 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_utf_buffer_increment(). + * + * @see f_array_lengths_increase() + * @see f_array_lengths_increase_by() + * @see f_fss_is_graph() + * @see f_fss_is_space() + * @see f_fss_is_zero_width() + * @see f_fss_skip_past_delimit() + * @see f_fss_skip_past_space() + * @see f_utf_buffer_increment() + * @see fl_fss_basic_object_read() + * @see fl_fss_extended_object_read() + * @see fl_fss_extended_content_read() */ -#ifndef _di_fl_fss_extended_object_read_ - extern f_status_t fl_fss_extended_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_quote_t * const quoted, f_fss_delimits_t * const delimits); -#endif // _di_fl_fss_extended_object_read_ +#ifndef _di_fl_fss_extended_content_read_ + extern f_status_t fl_fss_extended_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_content_t * const found, f_fss_quotes_t * const quotes, f_fss_delimits_t * const delimits); +#endif // _di_fl_fss_extended_content_read_ /** - * Read an fss-0001 content. + * Write an fss-0001 content from a given string. + * + * This will write the given string range as a valid content. + * Anything within this range will be escaped as necessary. + * + * The destination string may have NULLs. + * + * @param content + * The string to write as (does not stop at NULLS, they are ignored and not written). + * @param quoted + * If 0, then double quotes are auto-inserted, when required. + * Otherwise, this is the type of quote to wrap the object in when writing. + * @param complete + * If f_fss_complete_none_e, then only the content is written. + * If f_fss_complete_next_e, then the content followed by any appropriate "next" character separating one content from the next, if applicable. + * If f_fss_complete_end_e, then the content followed by any appropriate "end" character designating the last content for some object, printing final newline, if applicable. + * If f_fss_complete_partial_e, this will write any appropriate open and close aspects of this content, except for the final newline. + * If f_fss_complete_full_e, this will write any appropriate open and close aspects of this content, including the final newline. + * @param state + * A state for providing flags and handling interrupts during long running operations. + * There is no print_error(). + * There is no functions structure. + * There is no data structure passed to these functions. + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. + * @param range + * The start/stop location within the content string to write as an content. + * @param destination + * The buffer where the content is written to. + * + * @return + * F_none on success. + * F_none_eos on success after reaching the end of the buffer. + * F_none_stop on success after reaching the range stop. + * F_data_not_stop no data to write due start location being greater than stop location. + * 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_none_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_fss_is_space(). + * 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_string_dynamic_increase(). + * Errors (with error bit) from: f_string_dynamic_increase_by(). + * Errors (with error bit) from: f_utf_buffer_increment(). + * + * @see f_fss_is_space() + * @see f_fss_skip_past_delimit() + * @see f_fss_skip_past_space() + * @see f_string_dynamic_increase() + * @see f_string_dynamic_increase_by() + * @see f_utf_buffer_increment() + * @see fl_fss_basic_object_write() + * @see fl_fss_extended_object_write() + * @see fl_fss_extended_content_write() + */ +#ifndef _di_fl_fss_extended_content_write_ + extern f_status_t fl_fss_extended_content_write(const f_string_static_t content, const f_fss_quote_t quoted, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination); +#endif // _di_fl_fss_extended_content_write_ + +/** + * Read an fss-0001 object. * * This will record where delimit placeholders exist but will not apply the delimits. * @@ -106,16 +183,17 @@ extern "C" { * The start location will represent where the read stopped on return. * A start location past the stop location or buffer used means that the entire range was processed. * @param found - * A set of all locations where a valid content was found. - * @param quotes - * An array of quotes designating whether or not content is quoted and what quote is in use. + * A location where a valid object was found. + * @param quoted + * This will store whether or not this object is quoted and what quote is in use. * Set pointer address to 0 to not use. * @param delimits * A delimits array representing where delimits exist within the buffer. * * @return - * F_fss_found_content on success and content was found (start location is at end of content). - * F_fss_found_content_not on success and no content was found (start location is after character designating this is not a content). + * F_fss_found_object on success and object was found (start location is at end of object). + * F_fss_found_object_content_not on success but object ended at the line so there can be no content. + * F_fss_found_object_not on success and no object was found (start location is after character designating this is not an object). * F_none_eos on success after reaching the end of the buffer (a valid object is not yet confirmed). * F_none_stop on success after reaching stopping point (a valid object is not yet confirmed). * F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found). @@ -126,16 +204,30 @@ extern "C" { * F_interrupt (with error bit) if stopping due to an interrupt. * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_utf_buffer_increment(). + * Errors (with error bit) from: f_array_lengths_increase(). + * Errors (with error bit) from: f_array_lengths_increase_by(). * Errors (with error bit) from: f_fss_is_graph(). * Errors (with error bit) from: f_fss_is_space(). * Errors (with error bit) from: f_fss_is_zero_width(). * 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_utf_buffer_increment(). + * + * @see f_array_lengths_increase() + * @see f_array_lengths_increase_by() + * @see f_fss_is_graph() + * @see f_fss_is_space() + * @see f_fss_is_zero_width() + * @see f_fss_skip_past_delimit() + * @see f_fss_skip_past_space() + * @see f_utf_buffer_increment() + * @see fl_fss_basic_object_read() + * @see fl_fss_extended_object_read() + * @see fl_fss_extended_content_read() */ -#ifndef _di_fl_fss_extended_content_read_ - extern f_status_t fl_fss_extended_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_content_t * const found, f_fss_quotes_t * const quotes, f_fss_delimits_t * const delimits); -#endif // _di_fl_fss_extended_content_read_ +#ifndef _di_fl_fss_extended_object_read_ + extern f_status_t fl_fss_extended_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_quote_t * const quoted, f_fss_delimits_t * const delimits); +#endif // _di_fl_fss_extended_object_read_ /** * Write an fss-0001 object from a given string. @@ -176,76 +268,26 @@ extern "C" { * F_data_not_stop no data to write due start location being greater than stop location. * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. * F_none_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. - * F_string_too_large (with error bit) if appended string length is too large to store in the destination. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * * Errors (with error bit) from: f_fss_is_space(). - * Errors (with error bit) from: f_utf_buffer_increment(). + * 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_string_dynamic_increase(). + * Errors (with error bit) from: f_string_dynamic_increase_by(). + * + * @see f_fss_is_space() + * @see f_fss_skip_past_delimit() + * @see f_fss_skip_past_space() + * @see f_string_dynamic_increase() + * @see f_string_dynamic_increase_by() */ #ifndef _di_fl_fss_extended_object_write_ extern f_status_t fl_fss_extended_object_write(const f_string_static_t object, const f_fss_quote_t quoted, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination); #endif // _di_fl_fss_extended_object_write_ -/** - * Write an fss-0001 content from a given string. - * - * This will write the given string range as a valid content. - * Anything within this range will be escaped as necessary. - * - * The destination string may have NULLs. - * - * @param content - * The string to write as (does not stop at NULLS, they are ignored and not written). - * @param quoted - * If 0, then double quotes are auto-inserted, when required. - * Otherwise, this is the type of quote to wrap the object in when writing. - * @param complete - * If f_fss_complete_none_e, then only the content is written. - * If f_fss_complete_next_e, then the content followed by any appropriate "next" character separating one content from the next, if applicable. - * If f_fss_complete_end_e, then the content followed by any appropriate "end" character designating the last content for some object, printing final newline, if applicable. - * If f_fss_complete_partial_e, this will write any appropriate open and close aspects of this content, except for the final newline. - * If f_fss_complete_full_e, this will write any appropriate open and close aspects of this content, including the final newline. - * @param state - * A state for providing flags and handling interrupts during long running operations. - * There is no print_error(). - * There is no functions structure. - * There is no data structure passed to these functions. - * - * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. - * Error bit designates an error but must be passed along with F_interrupt. - * All other statuses are ignored. - * @param range - * The start/stop location within the content string to write as an content. - * @param destination - * The buffer where the content is written to. - * - * @return - * F_none on success. - * F_none_eos on success after reaching the end of the buffer. - * F_none_stop on success after reaching the range stop. - * F_data_not_stop no data to write due start location being greater than stop location. - * F_data_not_eos no data to write due start location being greater than or equal to buffer size. - * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. - * F_none_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. - * F_string_too_large (with error bit) if appended string length is too large to store in the destination. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. - * - * Errors (with error bit) from: f_fss_is_space(). - * Errors (with error bit) from: f_utf_buffer_increment(). - */ -#ifndef _di_fl_fss_extended_content_write_ - extern f_status_t fl_fss_extended_content_write(const f_string_static_t content, const f_fss_quote_t quoted, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination); -#endif // _di_fl_fss_extended_content_write_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_1/fl_fss/c/fss/extended_list.c b/level_1/fl_fss/c/fss/extended_list.c index 8da1241..76875d3 100644 --- a/level_1/fl_fss/c/fss/extended_list.c +++ b/level_1/fl_fss/c/fss/extended_list.c @@ -6,80 +6,35 @@ extern "C" { #endif -#ifndef _di_fl_fss_extended_list_object_read_ - f_status_t fl_fss_extended_list_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_delimits_t * const delimits) { +#ifndef _di_fl_fss_extended_list_content_read_ + f_status_t fl_fss_extended_list_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_content_t * const found, f_fss_delimits_t * const delimits, f_fss_comments_t * const comments) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!found) return F_status_set_error(F_parameter); if (!delimits) return F_status_set_error(F_parameter); + if (!comments) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ const f_array_length_t delimits_used = delimits->used; + const f_array_length_t comments_used = comments->used; - f_status_t status = f_fss_skip_past_space(state, buffer, range); + f_status_t status = f_fss_skip_past_delimit(state, buffer, range); if (F_status_is_error(status)) return status; - if (status == F_none_eol) { - - // Move the start position to after the EOL. - ++range->start; - - return F_fss_found_object_not; - } - - if (status == F_none_eos) { - return F_data_not_eos; - } - - if (status == F_none_stop) { - return F_data_not_stop; - } - - // Return found nothing if this line only contains whitespace and delimit placeholders. - if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - - // Move the start position to after the EOL. - ++range->start; - - return F_fss_found_object_not; - } - - // Begin the search. - found->start = range->start; - - // Ignore all comment lines. - if (buffer.string[range->start] == f_fss_comment_s.string[0]) { - status = f_fss_seek_to_eol(state, buffer, range); - - if (F_status_is_error(status)) { - delimits->used = delimits_used; - - return status; - } - - if (status == F_none_eos) { - return F_data_not_eos; - } - - if (status == F_none_stop) { - return F_data_not_stop; - } + private_macro_fl_fss_content_with_comments_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, F_none_eos, F_none_stop); - // Move the start position to after the EOL. - ++range->start; + status = f_string_ranges_increase(state.step_small, found); + if (F_status_is_error(status)) return status; - return F_fss_found_object_not; - } + found->array[found->used].start = range->start; - f_array_length_t start = 0; - f_array_length_t stop = 0; + f_array_length_t newline_last = range->start; f_array_length_t slash_first = 0; f_array_length_t slash_count = 0; + f_array_length_t start = 0; - bool 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]) { + // Identify where the content ends. + while (range->start <= range->stop && range->start < buffer.used) { if (state.interrupt) { status = state.interrupt((void *) &state, 0); @@ -91,14 +46,22 @@ extern "C" { } } + status = f_fss_skip_past_space(state, buffer, range); + if (F_status_is_error(status)) break; + + if (status == F_none_eol) { + newline_last = range->start++; + + continue; + } + + if (status == F_none_eos || status == F_none_stop) break; + if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) { slash_first = range->start; slash_count = 1; - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) break; - - while (range->start <= range->stop && range->start < buffer.used && (buffer.string[range->start] == f_fss_delimit_placeholder_s.string[0] || buffer.string[range->start] == f_fss_delimit_slash_s.string[0])) { + for (++range->start; range->start <= range->stop && range->start < buffer.used; ++range->start) { if (state.interrupt) { status = state.interrupt((void *) &state, 0); @@ -110,19 +73,19 @@ extern "C" { } } - if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) ++slash_count; - - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) break; - } // while + if (buffer.string[range->start] == f_fss_delimit_placeholder_s.string[0]) continue; + if (buffer.string[range->start] != f_fss_delimit_slash_s.string[0]) break; - if (F_status_is_error(status)) break; + ++slash_count; + } // for - private_macro_fl_fss_object_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop); + if (range->start > range->stop || range->start >= buffer.used) break; - if (buffer.string[range->start] == f_fss_extended_list_open_s.string[0]) { - graph_first = F_false; - stop = range->start++ - 1; + // Only the first slash before a close is delimited, all others are maintained. + // For example '}' = valid close, '\}' represents '}', '\\}' represents '\}', '\\\}' represents '\\}', '\\\\}' represents '\\\}', and so on.. + // With one or more slashes, even if delimited, this line may never designate a valid content close. + if (buffer.string[range->start] == f_fss_extended_list_close_s.string[0]) { + ++range->start; while (range->start <= range->stop && range->start < buffer.used) { @@ -138,74 +101,41 @@ extern "C" { if (buffer.string[range->start] == f_fss_eol_s.string[0]) break; - status = f_fss_is_graph(state, buffer, *range); + status = f_fss_is_space(state, buffer, *range); if (F_status_is_error(status)) break; - if (status == F_true) break; + if (status == F_false) break; status = f_utf_buffer_increment(buffer, range, 1); if (F_status_is_error(status)) break; } // while - private_macro_fl_fss_object_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop); + if (range->start > range->stop || range->start >= buffer.used) break; if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - start = range->start; - range->start = slash_first; - - macro_f_fss_delimits_t_increase_by(status, (*delimits), (slash_count / 2) + 1); + status = f_array_lengths_increase(state.step_small, delimits); if (F_status_is_error(status)) break; - if (slash_count % 2 == 0) { - while (slash_count > 0) { - - if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) { - if (slash_count % 2 == 1) { - delimits->array[delimits->used++] = range->start; - } - - --slash_count; - } - - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) break; - } // while - - if (F_status_is_error(status)) break; - - found->stop = stop; - range->start = start + 1; - - return F_fss_found_object; - } - - range->start = start + 1; + delimits->array[delimits->used++] = slash_first; - return F_fss_found_object_not; + continue; } } - else if (graph_first && buffer.string[range->start] == f_fss_comment_s.string[0]) { - graph_first = F_false; - - // Comments may only have whitespace before the '#', therefore only the first slash needs to be delimited. - macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); + else if (buffer.string[range->start] == f_fss_comment_s.string[0]) { + status = f_array_lengths_increase(state.step_small, delimits); if (F_status_is_error(status)) break; delimits->array[delimits->used++] = slash_first; - ++range->start; - } - else { - graph_first = F_false; } + status = f_fss_seek_to_eol(state, buffer, range); + if (F_status_is_error(status)) break; + continue; } - else if (buffer.string[range->start] == f_fss_extended_list_open_s.string[0]) { - graph_first = F_false; - stop = range->start - 1; - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) break; + if (buffer.string[range->start] == f_fss_extended_list_close_s.string[0]) { + ++range->start; while (range->start <= range->stop && range->start < buffer.used) { @@ -232,103 +162,115 @@ extern "C" { 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 (range->start > range->stop || range->start >= buffer.used) break; + // Found a valid content close, set stop point to last newline. if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - found->stop = stop; - - // Move the start position to after the EOL. ++range->start; - return F_fss_found_object; - } - - continue; - } - else if (graph_first) { - status = f_fss_is_space(state, buffer, *range); - if (F_status_is_error(status)) break; + // If the last newline is the entire start, then there is no Content. + if (newline_last == found->array[found->used].start) { + found->array[found->used].start = 1; + found->array[found->used++].stop = 0; - if (status == F_false) { - graph_first = F_false; - } - } + return F_fss_found_content_not; + } - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) break; - } // while + found->array[found->used++].stop = newline_last; - if (F_status_is_error(status)) { - delimits->used = delimits_used; + return F_fss_found_content; + } - return status; - } + continue; + } - // Seek to the end of the line when no valid object is found. - 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_comment_s.string[0]) { + start = newline_last + 1; - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); + status = f_fss_seek_to_eol(state, buffer, range); + if (F_status_is_error(status)) break; - if (F_status_set_fine(status) == F_interrupt) { - status = F_status_set_error(F_interrupt); + status = f_string_ranges_increase(state.step_small, comments); + if (F_status_is_error(status)) break; - break; + if (range->start > range->stop || range->start >= buffer.used) { + --range->start; + } + else { + newline_last = range->start; } - } - - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) { - delimits->used = delimits_used; + comments->array[comments->used].start = start; + comments->array[comments->used++].stop = range->start++; - return status; + continue; } - } // while - - private_macro_fl_fss_object_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop); - status = f_utf_buffer_increment(buffer, range, 1); + // There is no possibility of a valid content close, so seek until newline. + status = f_fss_seek_to_eol(state, buffer, range); + if (F_status_is_error(status)) break; + } // while if (F_status_is_error(status)) { delimits->used = delimits_used; + comments->used = comments_used; return status; } - return F_fss_found_object_not; + return F_fss_found_content_not; } -#endif // _di_fl_fss_extended_list_object_read_ +#endif // _di_fl_fss_extended_list_content_read_ -#ifndef _di_fl_fss_extended_list_content_read_ - f_status_t fl_fss_extended_list_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_content_t * const found, f_fss_delimits_t * const delimits, f_fss_comments_t * const comments) { +#ifndef _di_fl_fss_extended_list_content_write_ + f_status_t fl_fss_extended_list_content_write(const f_string_static_t content, const uint8_t complete, const f_string_static_t * const prepend, const f_string_ranges_t * const ignore, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); - if (!found) return F_status_set_error(F_parameter); - if (!delimits) return F_status_set_error(F_parameter); - if (!comments) return F_status_set_error(F_parameter); + if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - const f_array_length_t delimits_used = delimits->used; - const f_array_length_t comments_used = comments->used; - - f_status_t status = f_fss_skip_past_delimit(state, buffer, range); + f_status_t status = f_fss_skip_past_delimit(state, content, range); if (F_status_is_error(status)) return status; - private_macro_fl_fss_content_with_comments_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, F_none_eos, F_none_stop); + if (status == F_none_eos) { + status = F_data_not_eos; + } + else if (status == F_none_stop) { + status = F_data_not_stop; + } - status = f_string_ranges_increase(state.step_small, found); + if (range->start > range->stop || range->start >= content.used) { + if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_end_e) { + const f_status_t status_allocation = f_string_dynamic_increase_by(2, destination); + if (F_status_is_error(status_allocation)) return status_allocation; + + destination->string[destination->used++] = f_fss_extended_list_close_s.string[0]; + destination->string[destination->used++] = f_fss_extended_list_close_end_s.string[0]; + } + + return status; + } + + // Ensure that there is room for a slash delimit and possibly the end of content characters. + status = f_string_dynamic_increase_by(4, destination); if (F_status_is_error(status)) return status; - found->array[found->used].start = range->start; + const f_array_length_t used_start = destination->used; - f_array_length_t newline_last = range->start; - f_array_length_t slash_first = 0; + bool is_comment = F_false; + bool ends_on_eol = F_false; + bool has_graph = F_false; + bool do_prepend = prepend ? F_true : F_false; + + f_array_length_t i = 0; f_array_length_t slash_count = 0; f_array_length_t start = 0; - // Identify where the content ends. - while (range->start <= range->stop && range->start < buffer.used) { + f_array_length_t r = 0; + + uint8_t width = 0; + + while (range->start <= range->stop && range->start < content.used) { if (state.interrupt) { status = state.interrupt((void *) &state, 0); @@ -340,22 +282,19 @@ extern "C" { } } - status = f_fss_skip_past_space(state, buffer, range); - if (F_status_is_error(status)) break; - - if (status == F_none_eol) { - newline_last = range->start++; + if (content.string[range->start] == f_fss_delimit_slash_s.string[0] && !is_comment) { + slash_count = 1; - continue; - } + if (do_prepend) { + status = f_string_dynamic_append(*prepend, destination); + if (F_status_is_error(status)) break; - if (status == F_none_eos || status == F_none_stop) break; + do_prepend = F_false; + } - if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) { - slash_first = range->start; - slash_count = 1; + destination->string[destination->used++] = content.string[range->start]; - for (++range->start; range->start <= range->stop && range->start < buffer.used; ++range->start) { + for (++range->start; range->start <= range->stop && range->start < content.used; ++range->start) { if (state.interrupt) { status = state.interrupt((void *) &state, 0); @@ -367,283 +306,403 @@ extern "C" { } } - if (buffer.string[range->start] == f_fss_delimit_placeholder_s.string[0]) continue; - if (buffer.string[range->start] != f_fss_delimit_slash_s.string[0]) break; + if (content.string[range->start] == f_fss_delimit_placeholder_s.string[0]) continue; + if (content.string[range->start] != f_fss_delimit_slash_s.string[0]) break; + destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; ++slash_count; } // for - if (range->start > range->stop || range->start >= buffer.used) break; - - // Only the first slash before a close is delimited, all others are maintained. - // For example '}' = valid close, '\}' represents '}', '\\}' represents '\}', '\\\}' represents '\\}', '\\\\}' represents '\\\}', and so on.. - // With one or more slashes, even if delimited, this line may never designate a valid content close. - if (buffer.string[range->start] == f_fss_extended_list_close_s.string[0]) { - ++range->start; + if (content.string[range->start] == f_fss_extended_list_close_s.string[0]) { + start = range->start++; - while (range->start <= range->stop && range->start < buffer.used) { + status = f_fss_skip_past_space(state, content, range); + if (F_status_is_error(status)) break; - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); + if (has_graph) { + // Do nothing. + } + else if (content.string[range->start] == f_fss_eol_s.string[0] || range->start >= content.used || range->start > range->stop) { - if (F_status_set_fine(status) == F_interrupt) { - status = F_status_set_error(F_interrupt); + // increase by total slashes + 1 and extended list close. + status = f_string_dynamic_increase_by(2, destination); + if (F_status_is_error(status)) break; - break; - } - } + destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; + destination->string[destination->used++] = f_fss_extended_list_close_s.string[0]; - if (buffer.string[range->start] == f_fss_eol_s.string[0]) break; + range->start = start + 1; - status = f_fss_is_space(state, buffer, *range); + status = private_fl_fss_basic_list_write_add_until_end(content, state, range, destination); if (F_status_is_error(status)) break; - if (status == F_false) break; - - status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) break; - } // while + if (content.string[range->start] != f_fss_eol_s.string[0]) { + has_graph = F_true; + } - if (range->start > range->stop || range->start >= buffer.used) break; + continue; + } - if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); - if (F_status_is_error(status)) break; + // Increase by character at "start" and possible newline. + status = f_string_dynamic_increase_by(2, destination); + if (F_status_is_error(status)) break; - delimits->array[delimits->used++] = slash_first; + destination->string[destination->used++] = content.string[start]; - continue; + if (content.string[range->start] == f_fss_eol_s.string[0]) { + destination->string[destination->used++] = f_fss_eol_s.string[0]; + ends_on_eol = F_true; + } + else { + ends_on_eol = F_false; } + + range->start = start + 1; + + continue; } - else if (buffer.string[range->start] == f_fss_comment_s.string[0]) { - macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); + } + else if (!has_graph && content.string[range->start] == f_fss_extended_list_close_s.string[0] && !is_comment) { + start = range->start++; + + if (do_prepend) { + status = f_string_dynamic_append(*prepend, destination); if (F_status_is_error(status)) break; - delimits->array[delimits->used++] = slash_first; + do_prepend = F_false; } - status = f_fss_seek_to_eol(state, buffer, range); + has_graph = F_true; + + status = f_fss_skip_past_space(state, content, range); if (F_status_is_error(status)) break; - continue; - } + if (content.string[range->start] == f_fss_eol_s.string[0] || range->start >= content.used || range->start > range->stop) { - if (buffer.string[range->start] == f_fss_extended_list_close_s.string[0]) { - ++range->start; + if (content.string[range->start] == f_fss_eol_s.string[0] && prepend) { + do_prepend = F_true; + ends_on_eol = F_true; + } + else { + ends_on_eol = F_false; + } - while (range->start <= range->stop && range->start < buffer.used) { + if (ignore && ignore->used) { - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); + for (r = 0; r < ignore->used; ++r) { + if (start >= ignore->array[r].start && start <= ignore->array[r].stop) break; + } // for - if (F_status_set_fine(status) == F_interrupt) { - status = F_status_set_error(F_interrupt); + if (r < ignore->used) { + status = f_string_dynamic_increase(state.step_large, destination); + if (F_status_is_error(status)) break; - break; + destination->string[destination->used++] = content.string[start]; + range->start = start + 1; + + continue; } } - 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; - - status = f_utf_buffer_increment(buffer, range, 1); + // Increase by slash and extended list close. + status = f_string_dynamic_increase_by(2, destination); if (F_status_is_error(status)) break; - } // while - if (F_status_is_error(status)) break; - - if (range->start > range->stop || range->start >= buffer.used) break; + destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; + destination->string[destination->used++] = content.string[start]; - // Found a valid content close, set stop point to last newline. - if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - ++range->start; + range->start = start + 1; - // If the last newline is the entire start, then there is no Content. - if (newline_last == found->array[found->used].start) { - found->array[found->used].start = 1; - found->array[found->used++].stop = 0; + status = private_fl_fss_basic_list_write_add_until_end(content, state, range, destination); + if (F_status_is_error(status)) break; - return F_fss_found_content_not; - } + continue; + } - found->array[found->used++].stop = newline_last; + status = f_string_dynamic_increase(state.step_large, destination); + if (F_status_is_error(status)) break; - return F_fss_found_content; - } + destination->string[destination->used++] = content.string[start]; + range->start = start + 1; continue; } + else if (content.string[range->start] == f_fss_comment_s.string[0] && !has_graph) { + is_comment = F_true; + } + else if (content.string[range->start] == f_fss_eol_s.string[0]) { + has_graph = F_false; + is_comment = F_false; + } + else if ((status = f_fss_is_graph(state, content, *range)) == F_true) { + has_graph = F_true; + } + else if (F_status_is_error(status)) { + break; + } - if (buffer.string[range->start] == f_fss_comment_s.string[0]) { - start = newline_last + 1; - - status = f_fss_seek_to_eol(state, buffer, range); - if (F_status_is_error(status)) break; + if (content.string[range->start] != f_fss_delimit_placeholder_s.string[0]) { + if (do_prepend) { + status = f_string_dynamic_append(*prepend, destination); + if (F_status_is_error(status)) break; - macro_f_fss_comments_t_increase(status, state.step_small, (*comments)) - if (F_status_is_error(status)) break; + do_prepend = F_false; + } - if (range->start > range->stop || range->start >= buffer.used) { - --range->start; + if (content.string[range->start] == f_fss_eol_s.string[0] && prepend) { + do_prepend = F_true; + ends_on_eol = F_true; } else { - newline_last = range->start; + ends_on_eol = F_false; } - comments->array[comments->used].start = start; - comments->array[comments->used++].stop = range->start++; + width = macro_f_utf_byte_width(content.string[range->start]); - continue; + status = f_string_dynamic_increase_by(width, destination); + if (F_status_is_error(status)) break; + + for (i = 0; i < width; ++i) { + destination->string[destination->used++] = content.string[range->start + i]; + } // for } - // There is no possibility of a valid content close, so seek until newline. - status = f_fss_seek_to_eol(state, buffer, range); + status = f_utf_buffer_increment(content, range, 1); if (F_status_is_error(status)) break; } // while if (F_status_is_error(status)) { - delimits->used = delimits_used; - comments->used = comments_used; + destination->used = used_start; return status; } - return F_fss_found_content_not; + if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_end_e) { + status = f_string_dynamic_increase_by(3, destination); + if (F_status_is_error(status)) return status; + + if (!ends_on_eol) { + destination->string[destination->used++] = f_fss_eol_s.string[0]; + } + + destination->string[destination->used++] = f_fss_extended_list_close_s.string[0]; + destination->string[destination->used++] = f_fss_extended_list_close_end_s.string[0]; + } + + if (range->start > range->stop) { + return F_none_stop; + } + + if (range->start >= content.used) { + return F_none_eos; + } + + return F_none; } -#endif // _di_fl_fss_extended_list_content_read_ +#endif // _di_fl_fss_extended_list_content_write_ -#ifndef _di_fl_fss_extended_list_object_write_ - f_status_t fl_fss_extended_list_object_write(const f_string_static_t object, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination) { +#ifndef _di_fl_fss_extended_list_object_read_ + f_status_t fl_fss_extended_list_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_delimits_t * const delimits) { #ifndef _di_level_1_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); + if (!range) return F_status_set_error(F_parameter); + if (!found) return F_status_set_error(F_parameter); + if (!delimits) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - f_status_t status = f_fss_skip_past_delimit(state, object, range); + const f_array_length_t delimits_used = delimits->used; + + f_status_t status = f_fss_skip_past_space(state, buffer, range); if (F_status_is_error(status)) return status; + if (status == F_none_eol) { + + // Move the start position to after the EOL. + ++range->start; + + return F_fss_found_object_not; + } + if (status == F_none_eos) { - status = F_data_not_eos; + return F_data_not_eos; } - else if (status == F_none_stop) { - status = F_data_not_stop; + + if (status == F_none_stop) { + return F_data_not_stop; } - if (status == F_data_not_stop || status == F_data_not_eos) { - if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { - const f_status_t status_allocation = f_string_dynamic_increase_by(2, destination); - if (F_status_is_error(status_allocation)) return status_allocation; + // Return found nothing if this line only contains white space and delimit placeholders. + if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - destination->string[destination->used++] = f_fss_extended_list_open_s.string[0]; + // Move the start position to after the EOL. + ++range->start; - if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { - destination->string[destination->used++] = f_fss_extended_list_open_end_s.string[0]; - } + return F_fss_found_object_not; + } + + // Begin the search. + found->start = range->start; + + // Ignore all comment lines. + if (buffer.string[range->start] == f_fss_comment_s.string[0]) { + status = f_fss_seek_to_eol(state, buffer, range); + + if (F_status_is_error(status)) { + delimits->used = delimits_used; + + return status; } - return status; - } + if (status == F_none_eos) { + return F_data_not_eos; + } - // Ensure that there is room for a slash delimit, the object open character, and the end of line character. - status = f_string_dynamic_increase_by(4, destination); - if (F_status_is_error(status)) return status; + if (status == F_none_stop) { + return F_data_not_stop; + } - const f_array_length_t used_start = destination->used; + // Move the start position to after the EOL. + ++range->start; - f_array_length_t i = 0; + return F_fss_found_object_not; + } + + f_array_length_t start = 0; + f_array_length_t stop = 0; + f_array_length_t slash_first = 0; f_array_length_t slash_count = 0; - bool ends_on_space = F_false; + bool 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 (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + + break; + } + } + + if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) { + slash_first = range->start; + slash_count = 1; + + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; + + while (range->start <= range->stop && range->start < buffer.used && (buffer.string[range->start] == f_fss_delimit_placeholder_s.string[0] || buffer.string[range->start] == f_fss_delimit_slash_s.string[0])) { + + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + + break; + } + } + + if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) ++slash_count; - uint8_t width = 0; + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; + } // while - // Find the first graph character. - while (range->start <= range->stop && range->start < object.used) { + if (F_status_is_error(status)) break; - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); + private_macro_fl_fss_object_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop); - if (F_status_set_fine(status) == F_interrupt) { - status = F_status_set_error(F_interrupt); + if (buffer.string[range->start] == f_fss_extended_list_open_s.string[0]) { + graph_first = F_false; + stop = range->start++ - 1; - break; - } - } + while (range->start <= range->stop && range->start < buffer.used) { - if (object.string[range->start] == f_fss_comment_s.string[0]) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); - // When a comment is found, escape it. - status = f_string_dynamic_increase(state.step_large, destination); - if (F_status_is_error(status)) break; + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); - destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; + break; + } + } - break; - } + if (buffer.string[range->start] == f_fss_eol_s.string[0]) break; - status = f_fss_is_graph(state, object, *range); - if (F_status_is_error(status)) break; + status = f_fss_is_graph(state, buffer, *range); + if (F_status_is_error(status)) break; - if (status == F_true) break; + if (status == F_true) break; - // Objects will not have leading whitespaces, but having this does not result in an invalid object, so just write the provided spaces. - if (object.string[range->start] != f_fss_delimit_placeholder_s.string[0]) { - if (object.string[range->start] == f_fss_eol_s.string[0]) { - status = F_status_set_error(F_none_eol); + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; + } // while - break; - } + private_macro_fl_fss_object_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop); - status = f_fss_is_space(state, object, *range); - if (F_status_is_error(status)) break; + if (buffer.string[range->start] == f_fss_eol_s.string[0]) { + start = range->start; + range->start = slash_first; - if (status == F_true) { - if (object.string[range->start] == f_fss_eol_s.string[0]) { - status = F_status_set_error(F_none_eol); + status = f_array_lengths_increase_by((slash_count / 2) + 1, delimits); + if (F_status_is_error(status)) break; - break; - } + if (slash_count % 2 == 0) { + while (slash_count > 0) { - width = macro_f_utf_byte_width(object.string[range->start]); + if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) { + if (slash_count % 2 == 1) { + delimits->array[delimits->used++] = range->start; + } - status = f_string_dynamic_increase_by(width, destination); - if (F_status_is_error(status)) break; + --slash_count; + } - for (i = 0; i < width; ++i) { - destination->string[destination->used++] = object.string[range->start + i]; - } // for - } - } + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; + } // while - status = f_utf_buffer_increment(object, range, 1); - if (F_status_is_error(status)) break; - } // while + if (F_status_is_error(status)) break; - if (F_status_is_error(status)) { - destination->used = used_start; + found->stop = stop; + range->start = start + 1; - return status; - } + return F_fss_found_object; + } - while (range->start <= range->stop && range->start < object.used) { + range->start = start + 1; - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); + 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 (F_status_set_fine(status) == F_interrupt) { - status = F_status_set_error(F_interrupt); + // 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; - break; + delimits->array[delimits->used++] = slash_first; + ++range->start; } + else { + graph_first = F_false; + } + + continue; } + else if (buffer.string[range->start] == f_fss_extended_list_open_s.string[0]) { + graph_first = F_false; + stop = range->start - 1; - if (object.string[range->start] == f_fss_delimit_slash_s.string[0]) { - slash_count = 1; + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; - for (++range->start; range->start <= range->stop && range->start < object.used; ++range->start) { + while (range->start <= range->stop && range->start < buffer.used) { if (state.interrupt) { status = state.interrupt((void *) &state, 0); @@ -655,125 +714,94 @@ extern "C" { } } - if (object.string[range->start] == f_fss_delimit_placeholder_s.string[0]) continue; - if (object.string[range->start] != f_fss_delimit_slash_s.string[0]) break; - - ++slash_count; - } // for + if (buffer.string[range->start] == f_fss_eol_s.string[0]) break; - if (F_status_is_error(status)) break; + status = f_fss_is_space(state, buffer, *range); + if (F_status_is_error(status)) break; - if (range->start > range->stop || range->start >= object.used) { + if (status == F_false) break; - // Slashes at the end of the object must be delimited to avoid delimiting the object close character. - slash_count *= 2; - } + status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(status)) break; + } // while - status = f_string_dynamic_increase_by(slash_count, destination); if (F_status_is_error(status)) break; - while (--slash_count) { - destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; - } // while - - if (range->start > range->stop || range->start >= object.used) { - ends_on_space = F_false; + private_macro_fl_fss_object_return_on_overflow_delimited((buffer), (*range), (*found), F_none_eos, F_none_stop); - break; - } - } + if (buffer.string[range->start] == f_fss_eol_s.string[0]) { + found->stop = stop; - if (object.string[range->start] != f_fss_delimit_placeholder_s.string[0]) { - if (object.string[range->start] == f_fss_eol_s.string[0]) { - status = F_status_set_error(F_none_eol); + // Move the start position to after the EOL. + ++range->start; - break; + return F_fss_found_object; } - status = f_fss_is_space(state, object, *range); + continue; + } + else if (graph_first) { + status = f_fss_is_space(state, buffer, *range); if (F_status_is_error(status)) break; - if (ends_on_space = (status == F_true)) { - if (object.string[range->start] == f_fss_eol_s.string[0]) { - status = F_status_set_error(F_none_eol); - - break; - } + if (status == F_false) { + graph_first = F_false; } - - width = macro_f_utf_byte_width(object.string[range->start]); - - status = f_string_dynamic_increase_by(width, destination); - if (F_status_is_error(status)) break; - - for (i = 0; i < width; ++i) { - destination->string[destination->used++] = object.string[range->start + i]; - } // for } - status = f_utf_buffer_increment(object, range, 1); + status = f_utf_buffer_increment(buffer, range, 1); if (F_status_is_error(status)) break; } // while if (F_status_is_error(status)) { - destination->used = used_start; + delimits->used = delimits_used; return status; } - if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { - if (complete == f_fss_complete_full_trim_e) { - status = private_fl_fss_basic_list_write_object_trim(used_start, state, destination); + // Seek to the end of the line when no valid object is found. + while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol_s.string[0]) { - if (F_status_is_error(status)) { - destination->used = used_start; + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); - return status; - } + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); - // Prevent a space from being added post-trimming. - ends_on_space = F_true; + break; + } } - status = f_string_dynamic_increase_by(3, destination); + status = f_utf_buffer_increment(buffer, range, 1); if (F_status_is_error(status)) { - destination->used = used_start; + delimits->used = delimits_used; return status; } + } // while - if (!ends_on_space) { - destination->string[destination->used++] = f_fss_space_s.string[0]; - } - - destination->string[destination->used++] = f_fss_extended_list_open_s.string[0]; + private_macro_fl_fss_object_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop); - if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { - destination->string[destination->used++] = f_fss_extended_list_open_end_s.string[0]; - } - } + status = f_utf_buffer_increment(buffer, range, 1); - if (range->start > range->stop) { - return F_none_stop; - } + if (F_status_is_error(status)) { + delimits->used = delimits_used; - if (range->start >= object.used) { - return F_none_eos; + return status; } - return F_none; + return F_fss_found_object_not; } -#endif // _di_fl_fss_extended_list_object_write_ +#endif // _di_fl_fss_extended_list_object_read_ -#ifndef _di_fl_fss_extended_list_content_write_ - f_status_t fl_fss_extended_list_content_write(const f_string_static_t content, const uint8_t complete, const f_string_static_t * const prepend, const f_string_ranges_t * const ignore, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination) { +#ifndef _di_fl_fss_extended_list_object_write_ + f_status_t fl_fss_extended_list_object_write(const f_string_static_t object, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination) { #ifndef _di_level_1_parameter_checking_ - if (!range) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - f_status_t status = f_fss_skip_past_delimit(state, content, range); + f_status_t status = f_fss_skip_past_delimit(state, object, range); if (F_status_is_error(status)) return status; if (status == F_none_eos) { @@ -783,38 +811,36 @@ extern "C" { status = F_data_not_stop; } - if (range->start > range->stop || range->start >= content.used) { - if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_end_e) { + if (status == F_data_not_stop || status == F_data_not_eos) { + if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { const f_status_t status_allocation = f_string_dynamic_increase_by(2, destination); if (F_status_is_error(status_allocation)) return status_allocation; - destination->string[destination->used++] = f_fss_extended_list_close_s.string[0]; - destination->string[destination->used++] = f_fss_extended_list_close_end_s.string[0]; + destination->string[destination->used++] = f_fss_extended_list_open_s.string[0]; + + if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { + destination->string[destination->used++] = f_fss_extended_list_open_end_s.string[0]; + } } return status; } - // Ensure that there is room for a slash delimit and possibly the end of content characters. + // Ensure that there is room for a slash delimit, the object open character, and the end of line character. status = f_string_dynamic_increase_by(4, destination); if (F_status_is_error(status)) return status; const f_array_length_t used_start = destination->used; - bool is_comment = F_false; - bool ends_on_eol = F_false; - bool has_graph = F_false; - bool do_prepend = prepend ? F_true : F_false; - f_array_length_t i = 0; f_array_length_t slash_count = 0; - f_array_length_t start = 0; - f_array_length_t r = 0; + bool ends_on_space = F_false; uint8_t width = 0; - while (range->start <= range->stop && range->start < content.used) { + // Find the first graph character. + while (range->start <= range->stop && range->start < object.used) { if (state.interrupt) { status = state.interrupt((void *) &state, 0); @@ -826,192 +852,145 @@ extern "C" { } } - if (content.string[range->start] == f_fss_delimit_slash_s.string[0] && !is_comment) { - slash_count = 1; - - if (do_prepend) { - status = f_string_dynamic_append(*prepend, destination); - if (F_status_is_error(status)) break; - - do_prepend = F_false; - } + if (object.string[range->start] == f_fss_comment_s.string[0]) { - destination->string[destination->used++] = content.string[range->start]; + // When a comment is found, escape it. + status = f_string_dynamic_increase(state.step_large, destination); + if (F_status_is_error(status)) break; - for (++range->start; range->start <= range->stop && range->start < content.used; ++range->start) { + destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); + break; + } - if (F_status_set_fine(status) == F_interrupt) { - status = F_status_set_error(F_interrupt); + status = f_fss_is_graph(state, object, *range); + if (F_status_is_error(status)) break; - break; - } - } + if (status == F_true) break; - if (content.string[range->start] == f_fss_delimit_placeholder_s.string[0]) continue; - if (content.string[range->start] != f_fss_delimit_slash_s.string[0]) break; + // 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_delimit_placeholder_s.string[0]) { + if (object.string[range->start] == f_fss_eol_s.string[0]) { + status = F_status_set_error(F_none_eol); - destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; - ++slash_count; - } // for + break; + } - if (content.string[range->start] == f_fss_extended_list_close_s.string[0]) { - start = range->start++; + status = f_fss_is_space(state, object, *range); + if (F_status_is_error(status)) break; - status = f_fss_skip_past_space(state, content, range); - if (F_status_is_error(status)) break; + if (status == F_true) { + if (object.string[range->start] == f_fss_eol_s.string[0]) { + status = F_status_set_error(F_none_eol); - if (has_graph) { - // Do nothing. + break; } - else if (content.string[range->start] == f_fss_eol_s.string[0] || range->start >= content.used || range->start > range->stop) { - - // increase by total slashes + 1 and extended list close. - status = f_string_dynamic_increase_by(2, destination); - if (F_status_is_error(status)) break; - - destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; - destination->string[destination->used++] = f_fss_extended_list_close_s.string[0]; - - range->start = start + 1; - - status = private_fl_fss_basic_list_write_add_until_end(content, state, range, destination); - if (F_status_is_error(status)) break; - - if (content.string[range->start] != f_fss_eol_s.string[0]) { - has_graph = F_true; - } - continue; - } + width = macro_f_utf_byte_width(object.string[range->start]); - // Increase by character at "start" and possible newline. - status = f_string_dynamic_increase_by(2, destination); + status = f_string_dynamic_increase_by(width, destination); if (F_status_is_error(status)) break; - destination->string[destination->used++] = content.string[start]; - - if (content.string[range->start] == f_fss_eol_s.string[0]) { - destination->string[destination->used++] = f_fss_eol_s.string[0]; - ends_on_eol = F_true; - } - else { - ends_on_eol = F_false; - } - - range->start = start + 1; - - continue; + for (i = 0; i < width; ++i) { + destination->string[destination->used++] = object.string[range->start + i]; + } // for } } - else if (!has_graph && content.string[range->start] == f_fss_extended_list_close_s.string[0] && !is_comment) { - start = range->start++; - if (do_prepend) { - status = f_string_dynamic_append(*prepend, destination); - if (F_status_is_error(status)) break; + status = f_utf_buffer_increment(object, range, 1); + if (F_status_is_error(status)) break; + } // while - do_prepend = F_false; - } + if (F_status_is_error(status)) { + destination->used = used_start; - has_graph = F_true; + return status; + } - status = f_fss_skip_past_space(state, content, range); - if (F_status_is_error(status)) break; + while (range->start <= range->stop && range->start < object.used) { - if (content.string[range->start] == f_fss_eol_s.string[0] || range->start >= content.used || range->start > range->stop) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); - if (content.string[range->start] == f_fss_eol_s.string[0] && prepend) { - do_prepend = F_true; - ends_on_eol = F_true; - } - else { - ends_on_eol = F_false; - } + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); - if (ignore && ignore->used) { + break; + } + } - for (r = 0; r < ignore->used; ++r) { - if (start >= ignore->array[r].start && start <= ignore->array[r].stop) break; - } // for + if (object.string[range->start] == f_fss_delimit_slash_s.string[0]) { + slash_count = 1; - if (r < ignore->used) { - status = f_string_dynamic_increase(state.step_large, destination); - if (F_status_is_error(status)) break; + for (++range->start; range->start <= range->stop && range->start < object.used; ++range->start) { - destination->string[destination->used++] = content.string[start]; - range->start = start + 1; + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); - continue; + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + + break; } } - // Increase by slash and extended list close. - status = f_string_dynamic_increase_by(2, destination); - if (F_status_is_error(status)) break; + if (object.string[range->start] == f_fss_delimit_placeholder_s.string[0]) continue; + if (object.string[range->start] != f_fss_delimit_slash_s.string[0]) break; - destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; - destination->string[destination->used++] = content.string[start]; + ++slash_count; + } // for - range->start = start + 1; + if (F_status_is_error(status)) break; - status = private_fl_fss_basic_list_write_add_until_end(content, state, range, destination); - if (F_status_is_error(status)) break; + if (range->start > range->stop || range->start >= object.used) { - continue; + // Slashes at the end of the object must be delimited to avoid delimiting the object close character. + slash_count *= 2; } - status = f_string_dynamic_increase(state.step_large, destination); + status = f_string_dynamic_increase_by(slash_count, destination); if (F_status_is_error(status)) break; - destination->string[destination->used++] = content.string[start]; - range->start = start + 1; + while (--slash_count) { + destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; + } // while - continue; - } - else if (content.string[range->start] == f_fss_comment_s.string[0] && !has_graph) { - is_comment = F_true; - } - else if (content.string[range->start] == f_fss_eol_s.string[0]) { - has_graph = F_false; - is_comment = F_false; - } - else if ((status = f_fss_is_graph(state, content, *range)) == F_true) { - has_graph = F_true; - } - else if (F_status_is_error(status)) { - break; + if (range->start > range->stop || range->start >= object.used) { + ends_on_space = F_false; + + break; + } } - if (content.string[range->start] != f_fss_delimit_placeholder_s.string[0]) { - if (do_prepend) { - status = f_string_dynamic_append(*prepend, destination); - if (F_status_is_error(status)) break; + if (object.string[range->start] != f_fss_delimit_placeholder_s.string[0]) { + if (object.string[range->start] == f_fss_eol_s.string[0]) { + status = F_status_set_error(F_none_eol); - do_prepend = F_false; + break; } - if (content.string[range->start] == f_fss_eol_s.string[0] && prepend) { - do_prepend = F_true; - ends_on_eol = F_true; - } - else { - ends_on_eol = F_false; + status = f_fss_is_space(state, object, *range); + if (F_status_is_error(status)) break; + + if (ends_on_space = (status == F_true)) { + if (object.string[range->start] == f_fss_eol_s.string[0]) { + status = F_status_set_error(F_none_eol); + + break; + } } - width = macro_f_utf_byte_width(content.string[range->start]); + width = macro_f_utf_byte_width(object.string[range->start]); status = f_string_dynamic_increase_by(width, destination); if (F_status_is_error(status)) break; for (i = 0; i < width; ++i) { - destination->string[destination->used++] = content.string[range->start + i]; + destination->string[destination->used++] = object.string[range->start + i]; } // for } - status = f_utf_buffer_increment(content, range, 1); + status = f_utf_buffer_increment(object, range, 1); if (F_status_is_error(status)) break; } // while @@ -1021,29 +1000,50 @@ extern "C" { return status; } - if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_end_e) { + if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { + if (complete == f_fss_complete_full_trim_e) { + status = private_fl_fss_basic_list_write_object_trim(used_start, state, destination); + + if (F_status_is_error(status)) { + destination->used = used_start; + + return status; + } + + // Prevent a space from being added post-trimming. + ends_on_space = F_true; + } + status = f_string_dynamic_increase_by(3, destination); - if (F_status_is_error(status)) return status; - if (!ends_on_eol) { - destination->string[destination->used++] = f_fss_eol_s.string[0]; + if (F_status_is_error(status)) { + destination->used = used_start; + + return status; } - destination->string[destination->used++] = f_fss_extended_list_close_s.string[0]; - destination->string[destination->used++] = f_fss_extended_list_close_end_s.string[0]; + if (!ends_on_space) { + destination->string[destination->used++] = f_fss_space_s.string[0]; + } + + destination->string[destination->used++] = f_fss_extended_list_open_s.string[0]; + + if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { + destination->string[destination->used++] = f_fss_extended_list_open_end_s.string[0]; + } } if (range->start > range->stop) { return F_none_stop; } - if (range->start >= content.used) { + if (range->start >= object.used) { return F_none_eos; } return F_none; } -#endif // _di_fl_fss_extended_list_content_write_ +#endif // _di_fl_fss_extended_list_object_write_ #ifdef __cplusplus } // extern "C" diff --git a/level_1/fl_fss/c/fss/extended_list.h b/level_1/fl_fss/c/fss/extended_list.h index 95682f7..af4ef2e 100644 --- a/level_1/fl_fss/c/fss/extended_list.h +++ b/level_1/fl_fss/c/fss/extended_list.h @@ -31,10 +31,12 @@ extern "C" { #endif /** - * Read an fss-0003 object. + * Read an fss-0003 content. * * This will record where delimit placeholders exist but will not apply the delimits. * + * This does not utilize recursion and has a max content depth of 1, see fss-0008 (Embedded List) for that purpose. + * * @param buffer * The buffer to read from. * @param state @@ -52,46 +54,121 @@ extern "C" { * The start location will represent where the read stopped on return. * A start location past the stop location or buffer used means that the entire range was processed. * @param found - * A location where a valid object was found. + * A set of all locations where a valid content was found. * @param delimits * A delimits array representing where delimits exist within the buffer. + * @param comments + * An array of ranges representing where comments are found within any valid content. + * This only stores comments found within valid content only. + * The comment range will include the trailing newline. * * @return - * F_fss_found_object on success and object was found (start location is at end of object). - * F_fss_found_object_not on success and no object was found (start location is after character designating this is not an object). - * F_none_eos on success after reaching the end of the buffer (a valid object is not yet confirmed). - * F_none_stop on success after reaching stopping point (a valid object is not yet confirmed). - * F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found). - * F_data_not_stop no data found after reaching stopping point (essentially only comments are found). + * F_fss_found_content on success and content was found (start location is at end of content). + * F_fss_found_content_not on success and no content was found (start location is after character designating this is not a content). + * F_none_eos on success after reaching the end of the buffer (a valid content is not yet confirmed). + * F_none_stop on success after reaching stopping point (a valid content is not yet confirmed). + * F_data_not_eos no content found after reaching the end of the buffer (essentially only comments are found). + * F_data_not_stop no content found after reaching stopping point (essentially only comments are found). * F_end_not_group_eos if EOS was reached before the a group termination was reached. * F_end_not_group_stop if stop point was reached before the a group termination was reached. * - * F_array_too_large (with error bit) if a buffer is too large. - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_complete_not_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. - * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * - * Errors (with error bit) from: f_utf_buffer_increment(). - * Errors (with error bit) from: f_fss_is_graph(). + * Errors (with error bit) from: f_array_lengths_increase(). + * Errors (with error bit) from: f_array_lengths_increase_by(). * 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_string_ranges_increase(). + * Errors (with error bit) from: f_utf_buffer_increment(). + * + * @see f_array_lengths_increase() + * @see f_array_lengths_increase_by() + * @see f_fss_is_space() + * @see f_fss_seek_to_eol() + * @see f_fss_skip_past_delimit() + * @see f_string_ranges_increase() + * @see f_utf_buffer_increment() + */ +#ifndef _di_fl_fss_extended_list_content_read_ + extern f_status_t fl_fss_extended_list_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_content_t * const found, f_fss_delimits_t * const delimits, f_fss_comments_t * const comments); +#endif // _di_fl_fss_extended_list_content_read_ + +/** + * Write an fss-0003 content from a given string. + * + * This will write the given string range as a valid content. + * Anything within this range will be escaped as necessary. + * + * The destination string may have NULLs. + * + * @param content + * The string to write as (does not stop at NULLS, they are ignored and not written). + * @param complete + * If f_fss_complete_none_e, then only the content is written. + * If f_fss_complete_next_e, then the content followed by any appropriate "next" character separating one content from the next, if applicable. + * If f_fss_complete_end_e, then the content followed by any appropriate "end" character designating the last content for some object, printing final newline, if applicable. + * If f_fss_complete_partial_e, this will write any appropriate open and close aspects of this content, except for the final newline. + * If f_fss_complete_full_e, this will write any appropriate open and close aspects of this content, including the final newline. + * @param prepend + * A string of whitespace to prepend at the start of each line. + * This should only be whitespace, anything else could produce invalid content. + * Set the pointer address to 0 to disable. + * @param ignore + * An optional list of ranges within the string to ignore. + * These ranges are only checked/ignored if there is a valid nested object open or a valid nested object close. + * Any valid nested object open or valid nested object close inside an ingore range will not be escaped. + * Set the pointer address to 0 to disable. + * @param state + * A state for providing flags and handling interrupts during long running operations. + * There is no print_error(). + * There is no functions structure. + * There is no data structure passed to these functions. + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. + * @param range + * The start/stop location within the content string to write as an content. + * @param destination + * The buffer where the content is written to. + * + * @return + * F_none on success. + * F_none_eos on success after reaching the end of the buffer. + * F_data_not_stop no data to write due start location being greater than stop location. + * F_data_not_eos no data to write due start location being greater than or equal to buffer size. + * F_none_stop on success after reaching stopping point. + * + * F_interrupt (with error bit) if stopping due to an interrupt. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_fss_is_graph(). + * 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_string_dynamic_append(). + * Errors (with error bit) from: f_string_dynamic_increase(). + * Errors (with error bit) from: f_string_dynamic_increase_by(). + * Errors (with error bit) from: f_utf_buffer_increment(). + * + * @see f_fss_is_graph() + * @see f_fss_skip_past_delimit() + * @see f_fss_skip_past_space() + * @see f_string_dynamic_append() + * @see f_string_dynamic_increase() + * @see f_string_dynamic_increase_by() + * @see f_utf_buffer_increment() */ -#ifndef _di_fl_fss_extended_list_object_read_ - extern f_status_t fl_fss_extended_list_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_delimits_t * const delimits); -#endif // _di_fl_fss_extended_list_object_read_ +#ifndef _di_fl_fss_extended_list_content_write_ + extern f_status_t fl_fss_extended_list_content_write(const f_string_static_t content, const uint8_t complete, const f_string_static_t * const prepend, const f_string_ranges_t * const ignore, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination); +#endif // _di_fl_fss_extended_list_content_write_ /** - * Read an fss-0003 content. + * Read an fss-0003 object. * * This will record where delimit placeholders exist but will not apply the delimits. * - * This does not utilize recursion and has a max content depth of 1, see fss-0008 (Embedded List) for that purpose. - * * @param buffer * The buffer to read from. * @param state @@ -109,41 +186,44 @@ extern "C" { * The start location will represent where the read stopped on return. * A start location past the stop location or buffer used means that the entire range was processed. * @param found - * A set of all locations where a valid content was found. + * A location where a valid object was found. * @param delimits * A delimits array representing where delimits exist within the buffer. - * @param comments - * An array of ranges representing where comments are found within any valid content. - * This only stores comments found within valid content only. - * The comment range will include the trailing newline. * * @return - * F_fss_found_content on success and content was found (start location is at end of content). - * F_fss_found_content_not on success and no content was found (start location is after character designating this is not a content). - * F_none_eos on success after reaching the end of the buffer (a valid content is not yet confirmed). - * F_none_stop on success after reaching stopping point (a valid content is not yet confirmed). - * F_data_not_eos no content found after reaching the end of the buffer (essentially only comments are found). - * F_data_not_stop no content found after reaching stopping point (essentially only comments are found). + * F_fss_found_object on success and object was found (start location is at end of object). + * F_fss_found_object_not on success and no object was found (start location is after character designating this is not an object). + * F_none_eos on success after reaching the end of the buffer (a valid object is not yet confirmed). + * F_none_stop on success after reaching stopping point (a valid object is not yet confirmed). + * F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found). + * F_data_not_stop no data found after reaching stopping point (essentially only comments are found). * F_end_not_group_eos if EOS was reached before the a group termination was reached. * F_end_not_group_stop if stop point was reached before the a group termination was reached. * - * F_array_too_large (with error bit) if a buffer is too large. - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_complete_not_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. - * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * - * Errors (with error bit) from: f_utf_buffer_increment(). + * Errors (with error bit) from: f_array_lengths_increase_by(). * Errors (with error bit) from: f_fss_is_graph(). * Errors (with error bit) from: f_fss_is_space(). + * Errors (with error bit) from: f_fss_is_zero_width(). + * 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_utf_buffer_increment(). + * + * @see f_array_lengths_increase_by() + * @see f_fss_is_graph() + * @see f_fss_is_space() + * @see f_fss_is_zero_width() + * @see f_fss_seek_to_eol() + * @see f_fss_skip_past_delimit() + * @see f_fss_skip_past_space() + * @see f_utf_buffer_increment() */ -#ifndef _di_fl_fss_extended_list_content_read_ - extern f_status_t fl_fss_extended_list_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_content_t * const found, f_fss_delimits_t * const delimits, f_fss_comments_t * const comments); -#endif // _di_fl_fss_extended_list_content_read_ +#ifndef _di_fl_fss_extended_list_object_read_ + extern f_status_t fl_fss_extended_list_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_object_t * const found, f_fss_delimits_t * const delimits); +#endif // _di_fl_fss_extended_list_object_read_ /** * Write an fss-0003 object from a given string. @@ -181,79 +261,30 @@ extern "C" { * F_none_eos on success after reaching the end of the buffer. * F_data_not_stop no data to write due start location being greater than stop location. * F_data_not_eos no data to write due start location being greater than or equal to buffer size. - * F_none_stop on success after reaching stopping point . + * F_none_stop on success after reaching stopping point. * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. * F_none_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. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * + * Errors (with error bit) from: f_fss_is_graph(). + * Errors (with error bit) from: f_fss_is_space(). + * Errors (with error bit) from: f_fss_skip_past_delimit(). + * Errors (with error bit) from: f_string_dynamic_increase(). + * Errors (with error bit) from: f_string_dynamic_increase_by(). * Errors (with error bit) from: f_utf_buffer_increment(). + * + * @see f_fss_is_graph() + * @see f_fss_is_space() + * @see f_fss_skip_past_delimit() + * @see f_string_dynamic_increase() + * @see f_string_dynamic_increase_by() + * @see f_utf_buffer_increment() */ #ifndef _di_fl_fss_extended_list_object_write_ extern f_status_t fl_fss_extended_list_object_write(const f_string_static_t object, const uint8_t complete, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination); #endif // _di_fl_fss_extended_list_object_write_ -/** - * Write an fss-0003 content from a given string. - * - * This will write the given string range as a valid content. - * Anything within this range will be escaped as necessary. - * - * The destination string may have NULLs. - * - * @param content - * The string to write as (does not stop at NULLS, they are ignored and not written). - * @param complete - * If f_fss_complete_none_e, then only the content is written. - * If f_fss_complete_next_e, then the content followed by any appropriate "next" character separating one content from the next, if applicable. - * If f_fss_complete_end_e, then the content followed by any appropriate "end" character designating the last content for some object, printing final newline, if applicable. - * If f_fss_complete_partial_e, this will write any appropriate open and close aspects of this content, except for the final newline. - * If f_fss_complete_full_e, this will write any appropriate open and close aspects of this content, including the final newline. - * @param prepend - * A string of whitespace to prepend at the start of each line. - * This should only be whitespace, anything else could produce invalid content. - * Set the pointer address to 0 to disable. - * @param ignore - * An optional list of ranges within the string to ignore. - * These ranges are only checked/ignored if there is a valid nested object open or a valid nested object close. - * Any valid nested object open or valid nested object close inside an ingore range will not be escaped. - * Set the pointer address to 0 to disable. - * @param state - * A state for providing flags and handling interrupts during long running operations. - * There is no print_error(). - * There is no functions structure. - * There is no data structure passed to these functions. - * - * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. - * Error bit designates an error but must be passed along with F_interrupt. - * All other statuses are ignored. - * @param range - * The start/stop location within the content string to write as an content. - * @param destination - * The buffer where the content is written to. - * - * @return - * F_none on success. - * F_none_eos on success after reaching the end of the buffer. - * F_data_not_stop no data to write due start location being greater than stop location. - * F_data_not_eos no data to write due start location being greater than or equal to buffer size. - * F_none_stop on success after reaching stopping point . - * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. - * - * Errors (with error bit) from: f_utf_buffer_increment(). - */ -#ifndef _di_fl_fss_extended_list_content_write_ - extern f_status_t fl_fss_extended_list_content_write(const f_string_static_t content, const uint8_t complete, const f_string_static_t * const prepend, const f_string_ranges_t * const ignore, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination); -#endif // _di_fl_fss_extended_list_content_write_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_1/fl_fss/c/private-fss.c b/level_1/fl_fss/c/private-fss.c index 61f2c12..1d87675 100644 --- a/level_1/fl_fss/c/private-fss.c +++ b/level_1/fl_fss/c/private-fss.c @@ -6,156 +6,6 @@ extern "C" { #endif -#if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_) - f_status_t private_fl_fss_basic_write_object_trim(const f_fss_quote_t quoted, const f_array_length_t used_start, f_state_t state, f_string_dynamic_t * const destination) { - - f_status_t status = F_none; - f_string_range_t destination_range = macro_f_string_range_t_initialize2(destination->used); - f_array_length_t i = 0; - - uint8_t width = 0; - const f_char_t quote_char = quoted == f_fss_quote_type_double_e ? f_string_ascii_quote_double_s.string[0] : f_string_ascii_quote_single_s.string[0]; - - // If there are any spaces, then this will be quoted so find the first non-placeholder character. - for (; destination_range.start < destination->used; ++destination_range.start) { - - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); - - if (F_status_set_fine(status) == F_interrupt) { - destination->used = used_start; - - return F_status_set_error(F_interrupt); - } - } - - if (destination->string[destination_range.start] != f_fss_delimit_placeholder_s.string[0]) break; - } // for - - if (destination->string[destination_range.start] == quote_char) { - const f_array_length_t front = destination_range.start; - - for (++destination_range.start; destination_range.start < destination->used; ++destination_range.start) { - - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); - - if (F_status_set_fine(status) == F_interrupt) { - destination->used = used_start; - - return F_status_set_error(F_interrupt); - } - } - - if (destination->string[destination_range.start] == f_fss_delimit_placeholder_s.string[0]) continue; - - status = f_fss_is_space(state, *destination, destination_range); - - if (F_status_is_error(status)) { - destination->used = used_start; - - return status; - } - - if (status == F_false) break; - - width = macro_f_utf_byte_width(destination->string[destination_range.start]); - - for (i = 0; i < width; ++i) { - destination->string[destination_range.start + i] = f_fss_delimit_placeholder_s.string[0]; - } // for - } // for - - // Find the last quote. - for (destination_range.start = destination->used - 1; destination_range.start > front; --destination_range.start) { - - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); - - if (F_status_set_fine(status) == F_interrupt) { - destination->used = used_start; - - return F_status_set_error(F_interrupt); - } - } - - if (destination->string[destination_range.start] == quote_char) { - --destination_range.start; - - break; - } - } // for - - const f_array_length_t rear = destination_range.start + 1; - - for (; destination_range.start > front; --destination_range.start) { - - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); - - if (F_status_set_fine(status) == F_interrupt) { - destination->used = used_start; - - return F_status_set_error(F_interrupt); - } - } - - if (destination->string[destination_range.start] == f_fss_delimit_placeholder_s.string[0]) continue; - - status = f_fss_is_space(state, *destination, destination_range); - - // When going backwards, getting incomplete UTF-8 sequences is not an error. - if (F_status_set_fine(status) == F_complete_not_utf) continue; - - if (F_status_is_error(status)) { - destination->used = used_start; - - return status; - } - - if (status == F_false) break; - - width = macro_f_utf_byte_width(destination->string[destination_range.start]); - - for (i = 0; i < width; ++i) { - destination->string[destination_range.start + i] = f_fss_delimit_placeholder_s.string[0]; - } // for - } // for - - // If there is no whitespace between the quotes, post-trimming, then remove the quotes. - for (destination_range.start = front; destination_range.start < rear; ++destination_range.start) { - - if (state.interrupt) { - status = state.interrupt((void *) &state, 0); - - if (F_status_set_fine(status) == F_interrupt) { - destination->used = used_start; - - return F_status_set_error(F_interrupt); - } - } - - status = f_fss_is_space(state, *destination, destination_range); - - if (F_status_is_error(status)) { - destination->used = used_start; - - return status; - } - - if (status == F_true) break; - } // for - - if (destination_range.start == rear) { - destination->string[front] = f_fss_delimit_placeholder_s.string[0]; - destination->string[rear] = f_fss_delimit_placeholder_s.string[0]; - } - } - - return F_none; - } -#endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_) - #if !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_list_content_write_) || !defined(_di_fl_fss_embedded_list_content_write_) f_status_t private_fl_fss_basic_list_write_add_until_end(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination) { @@ -408,7 +258,7 @@ extern "C" { // Only the first slash before a quoted needs to be escaped (or not) as once there is a slash before a quoted, this cannot ever be a quote object. // This simplifies the number of slashes needed. - macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); + status = f_array_lengths_increase(state.step_small, delimits); if (F_status_is_error(status)) return status; delimits->array[delimits->used++] = first_slash; @@ -569,7 +419,7 @@ extern "C" { range->start = first_slash; if (slash_count % 2 == 0) { - macro_f_fss_delimits_t_increase_by(status, (*delimits), slash_count / 2); + status = f_array_lengths_increase_by(slash_count / 2, delimits); if (F_status_is_error(status)) return status; while (slash_count > 0) { @@ -657,7 +507,7 @@ extern "C" { return F_fss_found_object; } else { - macro_f_fss_delimits_t_increase_by(status, (*delimits), (slash_count / 2) + 1); + status = f_array_lengths_increase_by((slash_count / 2) + 1, delimits); if (F_status_is_error(status)) return status; while (slash_count > 0) { @@ -1252,6 +1102,156 @@ extern "C" { } #endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) +#if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_) + f_status_t private_fl_fss_basic_write_object_trim(const f_fss_quote_t quoted, const f_array_length_t used_start, f_state_t state, f_string_dynamic_t * const destination) { + + f_status_t status = F_none; + f_string_range_t destination_range = macro_f_string_range_t_initialize2(destination->used); + f_array_length_t i = 0; + + uint8_t width = 0; + const f_char_t quote_char = quoted == f_fss_quote_type_double_e ? f_string_ascii_quote_double_s.string[0] : f_string_ascii_quote_single_s.string[0]; + + // If there are any spaces, then this will be quoted so find the first non-placeholder character. + for (; destination_range.start < destination->used; ++destination_range.start) { + + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + destination->used = used_start; + + return F_status_set_error(F_interrupt); + } + } + + if (destination->string[destination_range.start] != f_fss_delimit_placeholder_s.string[0]) break; + } // for + + if (destination->string[destination_range.start] == quote_char) { + const f_array_length_t front = destination_range.start; + + for (++destination_range.start; destination_range.start < destination->used; ++destination_range.start) { + + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + destination->used = used_start; + + return F_status_set_error(F_interrupt); + } + } + + if (destination->string[destination_range.start] == f_fss_delimit_placeholder_s.string[0]) continue; + + status = f_fss_is_space(state, *destination, destination_range); + + if (F_status_is_error(status)) { + destination->used = used_start; + + return status; + } + + if (status == F_false) break; + + width = macro_f_utf_byte_width(destination->string[destination_range.start]); + + for (i = 0; i < width; ++i) { + destination->string[destination_range.start + i] = f_fss_delimit_placeholder_s.string[0]; + } // for + } // for + + // Find the last quote. + for (destination_range.start = destination->used - 1; destination_range.start > front; --destination_range.start) { + + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + destination->used = used_start; + + return F_status_set_error(F_interrupt); + } + } + + if (destination->string[destination_range.start] == quote_char) { + --destination_range.start; + + break; + } + } // for + + const f_array_length_t rear = destination_range.start + 1; + + for (; destination_range.start > front; --destination_range.start) { + + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + destination->used = used_start; + + return F_status_set_error(F_interrupt); + } + } + + if (destination->string[destination_range.start] == f_fss_delimit_placeholder_s.string[0]) continue; + + status = f_fss_is_space(state, *destination, destination_range); + + // When going backwards, getting incomplete UTF-8 sequences is not an error. + if (F_status_set_fine(status) == F_complete_not_utf) continue; + + if (F_status_is_error(status)) { + destination->used = used_start; + + return status; + } + + if (status == F_false) break; + + width = macro_f_utf_byte_width(destination->string[destination_range.start]); + + for (i = 0; i < width; ++i) { + destination->string[destination_range.start + i] = f_fss_delimit_placeholder_s.string[0]; + } // for + } // for + + // If there is no whitespace between the quotes, post-trimming, then remove the quotes. + for (destination_range.start = front; destination_range.start < rear; ++destination_range.start) { + + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + destination->used = used_start; + + return F_status_set_error(F_interrupt); + } + } + + status = f_fss_is_space(state, *destination, destination_range); + + if (F_status_is_error(status)) { + destination->used = used_start; + + return status; + } + + if (status == F_true) break; + } // for + + if (destination_range.start == rear) { + destination->string[front] = f_fss_delimit_placeholder_s.string[0]; + destination->string[rear] = f_fss_delimit_placeholder_s.string[0]; + } + } + + return F_none; + } +#endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_) + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_1/fl_fss/c/private-fss.h b/level_1/fl_fss/c/private-fss.h index c66f0b1..c3c3008 100644 --- a/level_1/fl_fss/c/private-fss.h +++ b/level_1/fl_fss/c/private-fss.h @@ -16,40 +16,6 @@ extern "C" { #endif /** - * Trim a given object used by the basic and extended object write functions. - * - * @param quoted - * If 0, then double quotes are auto-inserted, when required. - * Otherwise, this is the type of quote to wrap the object in when writing. - * @param used_start - * The destination.used value before any operations were perfomed. - * @param state - * A state for providing flags and handling interrupts during long running operations. - * There is no print_error(). - * There is no functions structure. - * There is no data structure passed to these functions. - * - * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. - * Error bit designates an error but must be passed along with F_interrupt. - * All other statuses are ignored. - * @param destination - * The buffer where the object is written to. - * - * @return - * F_none on success. - * - * F_interrupt (with error bit) if stopping due to an interrupt. - * - * Errors (with error bit) from: f_fss_is_space(). - * - * @see fl_fss_basic_object_write() - * @see fl_fss_extended_object_write() - */ -#if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_) - extern f_status_t private_fl_fss_basic_write_object_trim(const f_fss_quote_t quoted, const f_array_length_t used_start, f_state_t state, f_string_dynamic_t * const destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_) - -/** * Add all bytes to destination until stop point, buffer end, or EOL. * * @param buffer @@ -75,10 +41,10 @@ extern "C" { * * Errors (with error bit) from: f_string_dynamic_increase(). * + * @see f_string_dynamic_increase() * @see fl_fss_basic_list_content_write() * @see fl_fss_embedded_list_content_write() * @see fl_fss_extended_list_content_write() - * @see f_string_dynamic_increase() */ #if !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_list_content_write_) || !defined(_di_fl_fss_embedded_list_content_write_) extern f_status_t private_fl_fss_basic_list_write_add_until_end(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination) F_attribute_visibility_internal_d; @@ -108,6 +74,7 @@ extern "C" { * * Errors (with error bit) from: f_fss_is_space(). * + * @see f_fss_is_space() * @see fl_fss_basic_list_object_write() * @see fl_fss_extended_list_object_write() */ @@ -161,22 +128,27 @@ extern "C" { * F_end_not_group_eos if EOS was reached before the a group termination was reached. * F_end_not_group_stop if stop point was reached before the a group termination was reached. * - * F_array_too_large (with error bit) if a buffer is too large. - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_complete_not_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. - * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. + * F_none_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. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * - * Errors (with error bit) from: f_utf_buffer_increment(). + * Errors (with error bit) from: f_array_lengths_increase(). + * Errors (with error bit) from: f_array_lengths_increase_by(). * Errors (with error bit) from: f_fss_is_graph(). * Errors (with error bit) from: f_fss_is_space(). * Errors (with error bit) from: f_fss_is_zero_width(). * 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_utf_buffer_increment(). * + * @see f_array_lengths_increase() + * @see f_array_lengths_increase_by() + * @see f_fss_is_graph() + * @see f_fss_is_space() + * @see f_fss_is_zero_width() + * @see f_fss_skip_past_delimit() + * @see f_fss_skip_past_space() + * @see f_utf_buffer_increment() * @see fl_fss_basic_object_read() * @see fl_fss_extended_object_read() * @see fl_fss_extended_content_read() @@ -224,16 +196,23 @@ extern "C" { * F_data_not_stop no data to write due start location being greater than stop location. * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. * F_none_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. - * F_string_too_large (with error bit) if appended string length is too large to store in the destination. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * + * Errors (with error bit) from: f_fss_is_space(). + * 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_string_dynamic_increase(). + * Errors (with error bit) from: f_string_dynamic_increase_by(). * Errors (with error bit) from: f_utf_buffer_increment(). * + * @see f_fss_is_space() + * @see f_fss_skip_past_delimit() + * @see f_fss_skip_past_space() + * @see f_string_dynamic_increase() + * @see f_string_dynamic_increase_by() + * @see f_utf_buffer_increment() * @see fl_fss_basic_object_write() * @see fl_fss_extended_object_write() * @see fl_fss_extended_content_write() @@ -242,6 +221,41 @@ extern "C" { extern f_status_t private_fl_fss_basic_write(const bool object_as, const f_string_static_t object, const f_fss_quote_t quoted, f_state_t state, f_string_range_t * const range, f_string_dynamic_t * const destination) F_attribute_visibility_internal_d; #endif // !defined(fl_fss_basic_object_write) || !defined(fl_fss_extended_object_write) || !defined(_di_fl_fss_extended_content_write_) +/** + * Trim a given object used by the basic and extended object write functions. + * + * @param quoted + * If 0, then double quotes are auto-inserted, when required. + * Otherwise, this is the type of quote to wrap the object in when writing. + * @param used_start + * The destination.used value before any operations were perfomed. + * @param state + * A state for providing flags and handling interrupts during long running operations. + * There is no print_error(). + * There is no functions structure. + * There is no data structure passed to these functions. + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. + * @param destination + * The buffer where the object is written to. + * + * @return + * F_none on success. + * + * F_interrupt (with error bit) if stopping due to an interrupt. + * + * Errors (with error bit) from: f_fss_is_space(). + * + * @see f_fss_is_space() + * @see fl_fss_basic_object_write() + * @see fl_fss_extended_object_write() + */ +#if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_) + extern f_status_t private_fl_fss_basic_write_object_trim(const f_fss_quote_t quoted, const f_array_length_t used_start, f_state_t state, f_string_dynamic_t * const destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_) + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_1/fl_print/c/private-print.c b/level_1/fl_print/c/private-print.c index 32332e3..b9bdf84 100644 --- a/level_1/fl_print/c/private-print.c +++ b/level_1/fl_print/c/private-print.c @@ -1237,7 +1237,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -1276,7 +1276,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -1319,7 +1319,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -1383,7 +1383,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -1749,7 +1749,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -1959,7 +1959,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -2012,7 +2012,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -2029,7 +2029,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -2052,7 +2052,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -2096,7 +2096,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -2290,7 +2290,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -2414,7 +2414,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; diff --git a/level_1/fl_string/c/private-string.c b/level_1/fl_string/c/private-string.c index f5a1ab6..065260e 100644 --- a/level_1/fl_string/c/private-string.c +++ b/level_1/fl_string/c/private-string.c @@ -141,7 +141,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -172,7 +172,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -215,7 +215,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -250,7 +250,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -356,7 +356,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -379,7 +379,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -410,7 +410,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -436,7 +436,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -503,7 +503,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -544,7 +544,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -558,7 +558,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; diff --git a/level_1/fl_string/c/private-string.h b/level_1/fl_string/c/private-string.h index e9aab0b..9bdbacc 100644 --- a/level_1/fl_string/c/private-string.h +++ b/level_1/fl_string/c/private-string.h @@ -109,7 +109,7 @@ extern "C" { * F_equal_to when both strings equal. * F_equal_to_not when both strings do not equal. * - * F_utf (with error bit) if a character is not valid UTF-8. + * F_utf_not (with error bit) if a character is not valid UTF-8. * * Errors (with error bit) from: f_utf_is_whitespace(). * @@ -144,7 +144,7 @@ extern "C" { * F_equal_to when both strings equal. * F_equal_to_not when both strings do not equal. * - * F_utf (with error bit) if a character is not valid UTF-8. + * F_utf_not (with error bit) if a character is not valid UTF-8. * * Errors (with error bit) from: f_utf_is_whitespace(). * @@ -173,9 +173,9 @@ extern "C" { * * @return * F_none on success. - * F_data_not on success but only whitespace found. + * F_data_not on success but only white space found. * - * F_utf (with error bit) if a character is not valid UTF-8. + * F_utf_not (with error bit) if a character is not valid UTF-8. * * Errors (with error bit) from: f_utf_is_whitespace(). * diff --git a/level_1/fl_string/c/string.h b/level_1/fl_string/c/string.h index e077327..a2df68c 100644 --- a/level_1/fl_string/c/string.h +++ b/level_1/fl_string/c/string.h @@ -867,7 +867,7 @@ extern "C" { * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 fragment. * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if character is an invalid UTF-8 character. + * F_utf_not (with error bit) if character is an invalid UTF-8 character. * * Errors (with error bit) from: f_utf_char_to_character(). * @@ -957,7 +957,7 @@ extern "C" { * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 fragment. * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if character is an invalid UTF-8 character. + * F_utf_not (with error bit) if character is an invalid UTF-8 character. * * Errors (with error bit) from: f_utf_char_to_character(). * @@ -1005,7 +1005,7 @@ extern "C" { * F_complete_not_utf (with error bit) if a character is an incomplete UTF-8 fragment. * F_maybe (with error bit) if a character could be a whitespace but width is not long enough. (This is only returned for an otherwise valid FLL Identifier.) * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if character is an invalid UTF-8 character. + * F_utf_not (with error bit) if character is an invalid UTF-8 character. * * Errors (with error bit) from: f_utf_is_whitespace(). * Errors (with error bit) from: f_utf_is_word(). @@ -1098,7 +1098,7 @@ extern "C" { * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 fragment. * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if character is an invalid UTF-8 character. + * F_utf_not (with error bit) if character is an invalid UTF-8 character. * * Errors (with error bit) from: f_utf_char_to_character(). * @@ -1186,7 +1186,7 @@ extern "C" { * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 fragment. * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if character is an invalid UTF-8 character. + * F_utf_not (with error bit) if character is an invalid UTF-8 character. * * Errors (with error bit) from: f_utf_char_to_character(). * diff --git a/level_1/fl_utf/c/private-utf.c b/level_1/fl_utf/c/private-utf.c index e2583ea..81a6bdd 100644 --- a/level_1/fl_utf/c/private-utf.c +++ b/level_1/fl_utf/c/private-utf.c @@ -186,7 +186,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -207,7 +207,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; @@ -221,7 +221,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_not); } return status; diff --git a/level_1/fl_utf/c/private-utf.h b/level_1/fl_utf/c/private-utf.h index 67069db..47b358a 100644 --- a/level_1/fl_utf/c/private-utf.h +++ b/level_1/fl_utf/c/private-utf.h @@ -71,6 +71,9 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * + * Errors (with error bit) from: f_utf_character_is_whitespace() + * + * @see f_utf_character_is_whitespace() * @see fl_utf_string_compare_trim() * @see fl_utf_string_dynamic_compare_trim() * @see fl_utf_string_dynamic_partial_compare_trim() @@ -95,11 +98,13 @@ extern "C" { * * @return * F_none on success. - * F_data_not on success but only whitespace found. + * F_data_not on success but only white space found. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * + * Errors (with error bit) from: f_utf_character_is_whitespace() + * + * @see f_utf_character_is_whitespace() * @see fl_utf_string_dynamic_rip() * @see fl_utf_string_rip() */ diff --git a/level_1/fl_utf/c/utf.c b/level_1/fl_utf/c/utf.c index adac0cd..cc1fd4b 100644 --- a/level_1/fl_utf/c/utf.c +++ b/level_1/fl_utf/c/utf.c @@ -59,13 +59,8 @@ extern "C" { if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - if (!source.used) { - return F_data_not_eos; - } - - if (range.start > range.stop) { - return F_data_not_stop; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; return f_utf_string_append(source.string + range.start, (range.stop - range.start) + 1, destination); } @@ -79,13 +74,8 @@ extern "C" { if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - if (!source.used) { - return F_data_not_eos; - } - - if (range.start > range.stop) { - return F_data_not_stop; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; return f_utf_string_append_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); } @@ -98,18 +88,13 @@ extern "C" { if (buffer.used <= range->start) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - if (!buffer.used) { - return F_data_not_eos; - } - - if (range->start > range->stop) { - return F_data_not_stop; - } + if (!buffer.used) return F_data_not; + if (range->start > range->stop) return F_data_not_stop; f_utf_char_t seek_to_character = seek_to_this << 24; if (macro_f_utf_char_t_width_is(buffer.string[range->start]) == 1) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_fragment); } while (buffer.string[range->start] != seek_to_character) { @@ -119,7 +104,7 @@ extern "C" { } if (macro_f_utf_char_t_width_is(buffer.string[range->start]) == 1) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_fragment); } if (range->start >= buffer.used) { @@ -142,18 +127,13 @@ extern "C" { if (buffer.used <= range->start) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - if (!buffer.used) { - return F_data_not_eos; - } - - if (range->start > range->stop) { - return F_data_not_stop; - } + if (!buffer.used) return F_data_not; + if (range->start > range->stop) return F_data_not_stop; f_status_t status = F_none; if (macro_f_utf_char_t_width_is(buffer.string[range->start]) == 1) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_fragment); } while (buffer.string[range->start] == placeholder || (status = f_utf_character_is_graph(buffer.string[range->start])) == F_false) { @@ -167,7 +147,7 @@ extern "C" { } if (macro_f_utf_char_t_width_is(buffer.string[range->start]) == 1) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_fragment); } if (range->start >= buffer.used) { @@ -194,13 +174,13 @@ extern "C" { if (buffer.used <= range->start) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - if (!buffer.used) return F_data_not_eos; + if (!buffer.used) return F_data_not; if (range->start > range->stop) return F_data_not_stop; f_status_t status = F_none; if (macro_f_utf_char_t_width_is(buffer.string[range->start]) == 1) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_fragment); } while (buffer.string[range->start] == placeholder || (status = f_utf_character_is_whitespace(buffer.string[range->start])) == F_false) { @@ -211,7 +191,7 @@ extern "C" { ++range->start; if (macro_f_utf_char_t_width_is(buffer.string[range->start]) == 1) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_fragment); } if (range->start >= buffer.used) return F_none_eos; @@ -231,18 +211,13 @@ extern "C" { if (buffer.used <= range->start) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - if (!buffer.used) { - return F_data_not_eos; - } - - if (range->start > range->stop) { - return F_data_not_stop; - } + if (!buffer.used) return F_data_not; + if (range->start > range->stop) return F_data_not_stop; f_utf_char_t seek_to_character = seek_to_this << 24; if (macro_f_utf_char_t_width_is(buffer.string[range->start]) == 1) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_fragment); } while (buffer.string[range->start] != seek_to_character) { @@ -250,7 +225,7 @@ extern "C" { ++range->start; if (macro_f_utf_char_t_width_is(buffer.string[range->start]) == 1) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_fragment); } if (range->start >= buffer.used) { @@ -272,9 +247,7 @@ extern "C" { if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - if (!length) { - return F_data_not_eos; - } + if (!length) return F_data_not; f_array_length_t begin = 0; f_array_length_t end = length - 1; @@ -299,9 +272,7 @@ extern "C" { if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - if (!length) { - return F_data_not_eos; - } + if (!length) return F_data_not; f_array_length_t begin = 0; f_array_length_t end = length - 1; @@ -335,7 +306,7 @@ extern "C" { for (; range->start <= range->stop; ++range->start) { if (macro_f_utf_char_t_width_is(string[range->start]) == 1) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_fragment); } if (string[range->start] == f_utf_char_t_eol_s) { @@ -364,7 +335,7 @@ extern "C" { f_status_t status = F_none; if (macro_f_utf_char_t_width_is(string[range->start]) == 1) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_fragment); } while (string[range->start] == placeholder || (status = f_utf_character_is_graph(string[range->start])) == F_false) { @@ -378,7 +349,7 @@ extern "C" { } if (macro_f_utf_char_t_width_is(string[range->start]) == 1) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_fragment); } if (range->start > range->stop) { @@ -407,7 +378,7 @@ extern "C" { f_status_t status = F_none; if (macro_f_utf_char_t_width_is(string[range->start]) == 1) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_fragment); } while (string[range->start] == placeholder || (status = f_utf_character_is_graph(string[range->start])) == F_true) { @@ -421,7 +392,7 @@ extern "C" { } if (macro_f_utf_char_t_width_is(string[range->start]) == 1) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_fragment); } if (range->start > range->stop) { @@ -450,7 +421,7 @@ extern "C" { const f_utf_char_t seek_to_character = seek_to_this << 24; if (macro_f_utf_char_t_width_is(string[0]) == 1) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_fragment); } while (range->start <= range->stop) { @@ -460,7 +431,7 @@ extern "C" { } if (macro_f_utf_char_t_width_is(string[range->start]) == 1) { - return F_status_set_error(F_utf); + return F_status_set_error(F_utf_fragment); } } // while diff --git a/level_1/fl_utf/c/utf.h b/level_1/fl_utf/c/utf.h index a218c6a..73e096c 100644 --- a/level_1/fl_utf/c/utf.h +++ b/level_1/fl_utf/c/utf.h @@ -105,7 +105,7 @@ extern "C" { * F_equal_to_not when both strings do not equal. * * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if a character in the string is an invalid UTF-8 character. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. */ #ifndef _di_fl_utf_string_dynamic_compare_ extern f_status_t fl_utf_string_dynamic_compare(const f_utf_string_static_t string1, const f_utf_string_static_t string2); @@ -128,7 +128,7 @@ extern "C" { * F_equal_to_not when both strings do not equal. * * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if a character in the string is an invalid UTF-8 character. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. * * Errors (with error bit) from: f_utf_character_is_whitespace(). * @@ -208,12 +208,14 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * F_data_not_stop if range.start > range.stop. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_utf_string_append(). + * + * @see f_utf_string_append() */ #ifndef _di_fl_utf_string_dynamic_rip_ extern f_status_t fl_utf_string_dynamic_rip(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination); @@ -236,11 +238,14 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * F_data_not_stop if range.start > range.stop. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_utf_string_append_nulless(). + * + * @see f_utf_string_append_nulless() */ #ifndef _di_fl_utf_string_dynamic_rip_nulless_ extern f_status_t fl_utf_string_dynamic_rip_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination); @@ -261,11 +266,11 @@ extern "C" { * F_none on success. * F_none_eol on success, but stopped at EOL. * F_none_eos on success, but stopped at end of buffer. - * F_data_not_eos if buffer length is 0. + * F_data_not if buffer length is 0. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if a character in the buffer is an invalid UTF-8 character. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. */ #ifndef _di_fl_utf_string_dynamic_seek_line_to_char_ extern f_status_t fl_utf_string_dynamic_seek_line_to_char(const f_utf_string_static_t buffer, f_string_range_t * const range, const f_char_t seek_to_this); @@ -285,11 +290,11 @@ extern "C" { * F_none on success. * F_none_eol on success, but stopped at EOL. * F_none_eos on success, but stopped at end of buffer. - * F_data_not_eos if buffer length is 0. + * F_data_not if buffer length is 0. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid - * F_utf (with error bit) if a character in the buffer is an invalid UTF-8 character. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. * * Errors (with error bit) from: f_utf_character_is_graph(). * @@ -314,11 +319,11 @@ extern "C" { * F_none_eol on success, but stopped at EOL. * F_none_eos on success, but stopped at end of buffer. * F_none_stop on success, but stopped stop location. - * F_data_not_eos if buffer length is 0. + * F_data_not if buffer length is 0. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if a character in the buffer is an invalid UTF-8 character. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. * * Errors (with error bit) from: f_utf_character_is_graph(). * @@ -343,11 +348,11 @@ extern "C" { * F_none on success. * F_none_eos on success, but stopped at end of buffer. * F_none_stop on success, but stopped stop location. - * F_data_not_eos if buffer length is 0. + * F_data_not if buffer length is 0. * F_data_not_stop if range.start > range.stop. * - * F_utf (with error bit) if a character in the buffer is an invalid UTF-8 character. * F_parameter (with error bit) if a parameter is invalid. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. */ #ifndef _di_fl_utf_string_dynamic_seek_to_char_ extern f_status_t fl_utf_string_dynamic_seek_to_char(const f_utf_string_static_t buffer, f_string_range_t * const range, const f_char_t seek_to_this); @@ -368,10 +373,10 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. * * Errors (with error bit) from: f_utf_character_is_whitespace(). * @@ -398,10 +403,10 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. * * Errors (with error bit) from: f_utf_character_is_whitespace(). * @@ -429,7 +434,7 @@ extern "C" { * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if a character in the buffer is an invalid UTF-8 character. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. */ #ifndef _di_fl_utf_string_seek_line_to_char_ extern f_status_t fl_utf_string_seek_line_to_char(const f_utf_string_t string, f_string_range_t * const range, const f_char_t seek_to_this); @@ -451,11 +456,8 @@ extern "C" { * F_none_eol on success, but stopped at EOL. * F_data_not_stop if range.start > range.stop. * - * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 fragment. - * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if a character in the string is an invalid UTF-8 character. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. * * Errors (with error bit) from: f_utf_character_is_graph(). * @@ -482,11 +484,8 @@ extern "C" { * F_none_stop on success, but stopped stop location. * F_data_not_stop if range.start > range.stop. * - * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 fragment. - * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if a character in the string is an invalid UTF-8 character. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. * * Errors (with error bit) from: f_utf_character_is_graph(). * @@ -511,10 +510,10 @@ extern "C" { * F_none on success. * F_none_eos on success, but stopped at end of buffer. * F_none_stop on success, but stopped stop location. - * * F_data_not_stop if range.start > range.stop. + * * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if a character in the buffer is an invalid UTF-8 character. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. */ #ifndef _di_fl_utf_string_seek_to_character_ extern f_status_t fl_utf_string_seek_to_char(const f_utf_string_t string, f_string_range_t * const range, const f_char_t seek_to_this); diff --git a/level_2/fll_error/c/private-error.c b/level_2/fll_error/c/private-error.c index 408213a..a8d7bc7 100644 --- a/level_2/fll_error/c/private-error.c +++ b/level_2/fll_error/c/private-error.c @@ -136,7 +136,7 @@ extern "C" { return F_false; } - if (status == F_utf) { + if (status == F_utf_not) { if (print.verbosity != f_console_verbosity_quiet_e) { flockfile(print.to.stream); @@ -152,27 +152,11 @@ extern "C" { return F_false; } - if (status == F_complete_not_utf) { - if (print.verbosity != f_console_verbosity_quiet_e) { - flockfile(print.to.stream); - - fl_print_format("%r%[%QInvalid UTF-8 character (truncated) found", print.to.stream, f_string_eol_s, print.context, print.prefix); - - private_fll_error_print_function(print, function); - - fl_print_format(".%]%r", print.to.stream, print.context, f_string_eol_s); - - funlockfile(print.to.stream); - } - - return F_false; - } - if (status == F_utf_fragment) { if (print.verbosity != f_console_verbosity_quiet_e) { flockfile(print.to.stream); - fl_print_format("%r%[%QInvalid UTF-8 character (fragment) found", print.to.stream, f_string_eol_s, print.context, print.prefix); + fl_print_format("%r%[%QUTF-8 character (fragment) found", print.to.stream, f_string_eol_s, print.context, print.prefix); private_fll_error_print_function(print, function); diff --git a/level_2/fll_fss/c/fss/basic.c b/level_2/fll_fss/c/fss/basic.c index c1b6cc7..5cd6150 100644 --- a/level_2/fll_fss/c/fss/basic.c +++ b/level_2/fll_fss/c/fss/basic.c @@ -153,8 +153,8 @@ extern "C" { } #endif // _di_fll_fss_basic_read_ -#ifndef _di_fll_fss_basic_write_string_ - f_status_t fll_fss_basic_write_string(const f_string_static_t object, const f_string_static_t content, const f_fss_quote_t quote, f_state_t state, f_string_dynamic_t * const destination) { +#ifndef _di_fll_fss_basic_write_ + f_status_t fll_fss_basic_write(const f_string_static_t object, const f_string_static_t content, const f_fss_quote_t quote, f_state_t state, f_string_dynamic_t * const destination) { #ifndef _di_level_2_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ @@ -186,7 +186,7 @@ extern "C" { return status; } -#endif // _di_fll_fss_basic_write_string_ +#endif // _di_fll_fss_basic_write_ #ifdef __cplusplus } // extern "C" diff --git a/level_2/fll_fss/c/fss/basic.h b/level_2/fll_fss/c/fss/basic.h index 17060ea..1be437f 100644 --- a/level_2/fll_fss/c/fss/basic.h +++ b/level_2/fll_fss/c/fss/basic.h @@ -66,16 +66,18 @@ extern "C" { * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * F_data_not_stop no data to write due start location being greater than stop location. * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. - * F_number_overflow (with error bit) if the maximimum buffer size is reached. + * F_number_overflow (with error bit) if the maximum buffer size is reached. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * + * Errors (with error bit) from: f_string_ranges_increase(). + * Errors (with error bit) from: f_string_rangess_increase(). + * Errors (with error bit) from: f_uint8s_increase(). * Errors (with error bit) from: fl_fss_basic_content_read(). * Errors (with error bit) from: fl_fss_basic_object_read(). * + * @see f_string_ranges_increase() + * @see f_string_rangess_increase() + * @see f_uint8s_increase() * @see fl_fss_basic_content_read() * @see fl_fss_basic_object_read() */ @@ -112,11 +114,7 @@ extern "C" { * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * F_data_not_stop no data to write due start location being greater than stop location. * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * * Errors (with error bit) from: f_string_dynamic_increase(). * Errors (with error bit) from: fl_fss_basic_content_write(). @@ -126,9 +124,9 @@ extern "C" { * @see fl_fss_basic_content_write() * @see fl_fss_basic_object_write() */ -#ifndef _di_fll_fss_basic_write_string_ - extern f_status_t fll_fss_basic_write_string(const f_string_static_t object, const f_string_static_t content, const f_fss_quote_t quote, f_state_t state, f_string_dynamic_t * const destination); -#endif // _di_fll_fss_basic_write_string_ +#ifndef _di_fll_fss_basic_write_ + extern f_status_t fll_fss_basic_write(const f_string_static_t object, const f_string_static_t content, const f_fss_quote_t quote, f_state_t state, f_string_dynamic_t * const destination); +#endif // _di_fll_fss_basic_write_ #ifdef __cplusplus } // extern "C" diff --git a/level_2/fll_fss/c/fss/basic_list.c b/level_2/fll_fss/c/fss/basic_list.c index 85aa983..9646a7d 100644 --- a/level_2/fll_fss/c/fss/basic_list.c +++ b/level_2/fll_fss/c/fss/basic_list.c @@ -130,8 +130,8 @@ extern "C" { } #endif // _di_fll_fss_basic_list_read_ -#ifndef _di_fll_fss_basic_list_write_string_ - f_status_t fll_fss_basic_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t * const content_prepend, f_state_t state, f_string_dynamic_t * const destination) { +#ifndef _di_fll_fss_basic_list_write_ + f_status_t fll_fss_basic_list_write(const f_string_static_t object, const f_string_static_t content, const f_string_static_t * const content_prepend, f_state_t state, f_string_dynamic_t * const destination) { #ifndef _di_level_2_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ @@ -160,7 +160,7 @@ extern "C" { return status; } -#endif // _di_fll_fss_basic_list_write_string_ +#endif // _di_fll_fss_basic_list_write_ #ifdef __cplusplus } // extern "C" diff --git a/level_2/fll_fss/c/fss/basic_list.h b/level_2/fll_fss/c/fss/basic_list.h index 84483a9..61c870b 100644 --- a/level_2/fll_fss/c/fss/basic_list.h +++ b/level_2/fll_fss/c/fss/basic_list.h @@ -65,16 +65,18 @@ extern "C" { * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * F_data_not_stop no data to write due start location being greater than stop location. * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. - * F_number_overflow (with error bit) if the maximimum buffer size is reached. + * F_number_overflow (with error bit) if the maximum buffer size is reached. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * + * Errors (with error bit) from: f_string_ranges_increase(). + * Errors (with error bit) from: f_string_rangess_increase(). + * Errors (with error bit) from: f_uint8s_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_string_ranges_increase() + * @see f_string_rangess_increase() + * @see f_uint8s_increase() * @see fl_fss_basic_list_content_read() * @see fl_fss_basic_list_object_read() */ @@ -109,23 +111,21 @@ extern "C" { * F_none_eos on success after reaching the end of the buffer. * F_none_stop on success after reaching stopping point. * F_data_not_eos no data to write due start location being greater than or equal to buffer size. - * F_data_not_stop no data to write due start location being greater than stop location. + * F_data_not_stop no data to write due start location being greater than stop location * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * + * Errors (with error bit) from: f_string_dynamic_increase(). * Errors (with error bit) from: fl_fss_basic_list_content_write(). * Errors (with error bit) from: fl_fss_basic_list_object_write(). * + * @see f_string_dynamic_increase() * @see fl_fss_basic_list_content_write() * @see fl_fss_basic_list_object_write() */ -#ifndef _di_fll_fss_basic_list_write_string_ - extern f_status_t fll_fss_basic_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, f_state_t state, f_string_dynamic_t * const destination); -#endif // _di_fll_fss_basic_list_write_string_ +#ifndef _di_fll_fss_basic_list_write_ + extern f_status_t fll_fss_basic_list_write(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, f_state_t state, f_string_dynamic_t * const destination); +#endif // _di_fll_fss_basic_list_write_ #ifdef __cplusplus } // extern "C" diff --git a/level_2/fll_fss/c/fss/embedded_list.c b/level_2/fll_fss/c/fss/embedded_list.c index 72b8d2c..968527c 100644 --- a/level_2/fll_fss/c/fss/embedded_list.c +++ b/level_2/fll_fss/c/fss/embedded_list.c @@ -125,8 +125,8 @@ extern "C" { } #endif // _di_fll_fss_embedded_list_read_ -#ifndef _di_fll_fss_embedded_list_write_string_ - f_status_t fll_fss_embedded_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_state_t state, f_string_dynamic_t * const destination) { +#ifndef _di_fll_fss_embedded_list_write_ + f_status_t fll_fss_embedded_list_write(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_state_t state, f_string_dynamic_t * const destination) { #ifndef _di_level_2_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ @@ -155,7 +155,7 @@ extern "C" { return status; } -#endif // _di_fll_fss_embedded_list_write_string_ +#endif // _di_fll_fss_embedded_list_write_ #ifdef __cplusplus } // extern "C" diff --git a/level_2/fll_fss/c/fss/embedded_list.h b/level_2/fll_fss/c/fss/embedded_list.h index e5a90c9..d3c8c98 100644 --- a/level_2/fll_fss/c/fss/embedded_list.h +++ b/level_2/fll_fss/c/fss/embedded_list.h @@ -64,21 +64,20 @@ extern "C" { * F_data_not_stop no data to write due start location being greater than stop location. * F_fss_found_object_content_not on success and object was found but no content was found (start location is at end of object). * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_complete_not_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. - * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. - * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. - * F_number_overflow (with error bit) if the maximimum buffer size is reached. + * F_number_overflow (with error bit) if the maximum buffer size is reached. * F_parameter (with error bit) if a parameter is invalid. - * F_end_not_eos (with error bit) if end of buffer is reached before a closing bracket is found (object was found). - * F_end_not_nest_eos (with error bit) if end of buffer is reached while inside a nested list before a closing bracket is found (object was found). - * F_end_not_nest_stop (with error bit) if stop location is reached while inside a nested list before a closing bracket is found (object was found). - * F_end_not_stop (with error bit) if stop location is reached before a closing bracket is found (object was found). - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * + * Errors (with error bit) from: f_string_ranges_increase(). + * Errors (with error bit) from: f_string_rangess_increase(). + * Errors (with error bit) from: f_uint8s_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_string_ranges_increase() + * @see f_string_rangess_increase() + * @see f_uint8s_increase() + * @see fl_fss_embedded_list_content_read() + * @see fl_fss_embedded_list_object_read() */ #ifndef _di_fll_fss_embedded_list_read_ extern f_status_t fll_fss_embedded_list_read(const f_string_static_t buffer, f_state_t state, f_string_range_t * const range, f_fss_nest_t * const nest, f_fss_delimits_t * const objects_delimits, f_fss_delimits_t * const contents_delimits, f_fss_comments_t * const comments); @@ -118,21 +117,19 @@ extern "C" { * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * F_data_not_stop no data to write due start location being greater than stop location. * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * + * Errors (with error bit) from: f_string_dynamic_increase(). * Errors (with error bit) from: fl_fss_embedded_list_content_write(). * Errors (with error bit) from: fl_fss_embedded_list_object_write(). * + * @see f_string_dynamic_increase() * @see fl_fss_embedded_list_content_write() * @see fl_fss_embedded_list_object_write() */ -#ifndef _di_fll_fss_embedded_list_write_string_ - extern f_status_t fll_fss_embedded_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_state_t state, f_string_dynamic_t * const destination); -#endif // _di_fll_fss_embedded_list_write_string_ +#ifndef _di_fll_fss_embedded_list_write_ + extern f_status_t fll_fss_embedded_list_write(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_state_t state, f_string_dynamic_t * const destination); +#endif // _di_fll_fss_embedded_list_write_ #ifdef __cplusplus } // extern "C" diff --git a/level_2/fll_fss/c/fss/extended.c b/level_2/fll_fss/c/fss/extended.c index 9c31462..b156c02 100644 --- a/level_2/fll_fss/c/fss/extended.c +++ b/level_2/fll_fss/c/fss/extended.c @@ -192,8 +192,8 @@ extern "C" { } #endif // _di_fll_fss_extended_read_ -#ifndef _di_fll_fss_extended_write_string_ - f_status_t fll_fss_extended_write_string(const f_string_static_t object, const f_string_statics_t contents, const f_fss_quote_t quote, f_state_t state, f_string_dynamic_t * const destination) { +#ifndef _di_fll_fss_extended_write_ + f_status_t fll_fss_extended_write(const f_string_static_t object, const f_string_statics_t contents, const f_fss_quote_t quote, f_state_t state, f_string_dynamic_t * const destination) { #ifndef _di_level_2_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ @@ -232,7 +232,7 @@ extern "C" { return status; } -#endif // _di_fll_fss_extended_write_string_ +#endif // _di_fll_fss_extended_write_ #ifdef __cplusplus } // extern "C" diff --git a/level_2/fll_fss/c/fss/extended.h b/level_2/fll_fss/c/fss/extended.h index 71a9572..0ff0535 100644 --- a/level_2/fll_fss/c/fss/extended.h +++ b/level_2/fll_fss/c/fss/extended.h @@ -62,22 +62,24 @@ extern "C" { * * @return * F_none on success. - * F_none_stop on success after reaching stopping point . + * F_none_stop on success after reaching stopping point. * F_none_eos on success after reaching the end of the buffer. * F_data_not_stop no data to write due start location being greater than stop location. * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * F_data_not_eol if there is no data to write and EOL was reached (@todo review related code and detemine what this is doing). * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. - * F_number_overflow (with error bit) if the maximimum buffer size is reached. + * F_number_overflow (with error bit) if the maximum buffer size is reached. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * + * Errors (with error bit) from: f_string_ranges_increase(). + * Errors (with error bit) from: f_string_rangess_increase(). + * Errors (with error bit) from: f_uint8s_increase(). * Errors (with error bit) from: fl_fss_extended_content_read(). * Errors (with error bit) from: fl_fss_extended_object_read(). * + * @see f_string_ranges_increase() + * @see f_string_rangess_increase() + * @see f_uint8s_increase() * @see fl_fss_extended_content_read() * @see fl_fss_extended_object_read() */ @@ -114,21 +116,19 @@ extern "C" { * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * F_data_not_stop no data to write due start location being greater than stop location. * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * + * Errors (with error bit) from: f_string_dynamic_increase(). * Errors (with error bit) from: fl_fss_extended_content_write(). * Errors (with error bit) from: fl_fss_extended_object_write(). * + * @see f_string_dynamic_increase() * @see fl_fss_extended_content_write() * @see fl_fss_extended_object_write() */ -#ifndef _di_fll_fss_extended_write_string_ - extern f_status_t fll_fss_extended_write_string(const f_string_static_t object, const f_string_statics_t contents, const f_fss_quote_t quote, f_state_t state, f_string_dynamic_t * const destination); -#endif // _di_fll_fss_extended_write_string_ +#ifndef _di_fll_fss_extended_write_ + extern f_status_t fll_fss_extended_write(const f_string_static_t object, const f_string_statics_t contents, const f_fss_quote_t quote, f_state_t state, f_string_dynamic_t * const destination); +#endif // _di_fll_fss_extended_write_ #ifdef __cplusplus } // extern "C" diff --git a/level_2/fll_fss/c/fss/extended_list.c b/level_2/fll_fss/c/fss/extended_list.c index 7330850..3c289b3 100644 --- a/level_2/fll_fss/c/fss/extended_list.c +++ b/level_2/fll_fss/c/fss/extended_list.c @@ -127,8 +127,8 @@ extern "C" { } #endif // _di_fll_fss_extended_list_read_ -#ifndef _di_fll_fss_extended_list_write_string_ - f_status_t fll_fss_extended_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_state_t state, f_string_dynamic_t * const destination) { +#ifndef _di_fll_fss_extended_list_write_ + f_status_t fll_fss_extended_list_write(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_state_t state, f_string_dynamic_t * const destination) { #ifndef _di_level_2_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ @@ -157,7 +157,7 @@ extern "C" { return status; } -#endif // _di_fll_fss_extended_list_write_string_ +#endif // _di_fll_fss_extended_list_write_ #ifdef __cplusplus } // extern "C" diff --git a/level_2/fll_fss/c/fss/extended_list.h b/level_2/fll_fss/c/fss/extended_list.h index 3d5aae7..cbb623c 100644 --- a/level_2/fll_fss/c/fss/extended_list.h +++ b/level_2/fll_fss/c/fss/extended_list.h @@ -68,22 +68,18 @@ extern "C" { * F_data_not_stop no data to write due start location being greater than stop location. * F_fss_found_object_content_not on success and object was found but no content was found (start location is at end of object). * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_complete_not_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. - * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. - * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. - * F_number_overflow (with error bit) if the maximimum buffer size is reached. + * F_number_overflow (with error bit) if the maximum buffer size is reached. * F_parameter (with error bit) if a parameter is invalid. - * F_end_not_eos (with error bit) if end of buffer is reached before a closing bracket is found (object was found). - * F_end_not_nest_eos (with error bit) if end of buffer is reached while inside a nested list before a closing bracket is found (object was found). - * F_end_not_nest_stop (with error bit) if stop location is reached while inside a nested list before a closing bracket is found (object was found). - * F_end_not_stop (with error bit) if stop location is reached before a closing bracket is found (object was found). - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * + * Errors (with error bit) from: f_string_ranges_increase(). + * Errors (with error bit) from: f_string_rangess_increase(). + * Errors (with error bit) from: f_uint8s_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_string_ranges_increase() + * @see f_string_rangess_increase() + * @see f_uint8s_increase() * @see fl_fss_extended_list_content_read() * @see fl_fss_extended_list_object_read() */ @@ -125,21 +121,19 @@ extern "C" { * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * F_data_not_stop no data to write due start location being greater than stop location. * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * + * Errors (with error bit) from: f_string_dynamic_increase(). * Errors (with error bit) from: fl_fss_extended_list_content_write(). * Errors (with error bit) from: fl_fss_extended_list_object_write(). * + * @see f_string_dynamic_increase() * @see fl_fss_extended_list_content_write() * @see fl_fss_extended_list_object_write() */ -#ifndef _di_fll_fss_extended_list_write_string_ - extern f_status_t fll_fss_extended_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_state_t state, f_string_dynamic_t * const destination); -#endif // _di_fll_fss_extended_list_write_string_ +#ifndef _di_fll_fss_extended_list_write_ + extern f_status_t fll_fss_extended_list_write(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_state_t state, f_string_dynamic_t * const destination); +#endif // _di_fll_fss_extended_list_write_ #ifdef __cplusplus } // extern "C" diff --git a/level_2/fll_fss/c/fss/payload.c b/level_2/fll_fss/c/fss/payload.c index d333a50..a9b2081 100644 --- a/level_2/fll_fss/c/fss/payload.c +++ b/level_2/fll_fss/c/fss/payload.c @@ -178,8 +178,8 @@ extern "C" { } #endif // _di_fll_fss_payload_read_ -#ifndef _di_fll_fss_payload_write_string_ - f_status_t fll_fss_payload_write_string(const f_string_static_t object, const f_string_static_t content, const bool trim, const f_string_static_t *content_prepend, f_state_t state, f_string_dynamic_t * const destination) { +#ifndef _di_fll_fss_payload_write_ + f_status_t fll_fss_payload_write(const f_string_static_t object, const f_string_static_t content, const bool trim, const f_string_static_t *content_prepend, f_state_t state, f_string_dynamic_t * const destination) { #ifndef _di_level_2_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ @@ -236,7 +236,7 @@ extern "C" { return status; } -#endif // _di_fll_fss_payload_write_string_ +#endif // _di_fll_fss_payload_write_ #ifdef __cplusplus } // extern "C" diff --git a/level_2/fll_fss/c/fss/payload.h b/level_2/fll_fss/c/fss/payload.h index 1d5ed35..d702c5d 100644 --- a/level_2/fll_fss/c/fss/payload.h +++ b/level_2/fll_fss/c/fss/payload.h @@ -70,21 +70,29 @@ extern "C" { * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * F_data_not_stop no data to write due start location being greater than stop location. * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. + * F_fss_found_object_content_not (with error bit) When payload Content is missing. * F_data_not_eos (with error bit) no data to write due start location being greater than or equal to buffer size, except that no "payload" is found. * F_data_not_stop (with error bit) no data to write due start location being greater than stop location, except that no "payload" is found. - * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. * F_none (with error bit) on success, except that no "payload" is found. * F_none_eos (with error bit) on success after reaching the end of the buffer, except that no "payload" is found. * F_none_stop (with error bit) on success after reaching stopping point, except that no "payload" is found. - * F_number_overflow (with error bit) if the maximimum buffer size is reached. + * F_number_overflow (with error bit) if the maximum buffer size is reached. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * * Errors (with error bit) from: fl_fss_basic_list_content_read(). * Errors (with error bit) from: fl_fss_basic_list_object_read(). * + * F_number_overflow (with error bit) if the maximum buffer size is reached. + * + * Errors (with error bit) from: f_string_ranges_increase(). + * Errors (with error bit) from: f_string_rangess_increase(). + * Errors (with error bit) from: f_uint8s_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_string_ranges_increase() + * @see f_string_rangess_increase() + * @see f_uint8s_increase() * @see fl_fss_basic_list_content_read() * @see fl_fss_basic_list_object_read() */ @@ -131,23 +139,19 @@ extern "C" { * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * F_data_not_stop no data to write due start location being greater than stop location. * - * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_interrupt (with error bit) if stopping due to an interrupt. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * - * Errors (with error bit) from: f_string_dynamic_increase_by(). + * Errors (with error bit) from: f_string_dynamic_increase(). * Errors (with error bit) from: fl_fss_basic_list_content_write(). * Errors (with error bit) from: fl_fss_basic_list_object_write(). * - * @see f_string_dynamic_increase_by() + * @see f_string_dynamic_increase() * @see fl_fss_basic_list_content_write() * @see fl_fss_basic_list_object_write() */ -#ifndef _di_fll_fss_payload_write_string_ - extern f_status_t fll_fss_payload_write_string(const f_string_static_t object, const f_string_static_t content, const bool trim, const f_string_static_t *content_prepend, f_state_t state, f_string_dynamic_t * const destination); -#endif // _di_fll_fss_payload_write_string_ +#ifndef _di_fll_fss_payload_write_ + extern f_status_t fll_fss_payload_write(const f_string_static_t object, const f_string_static_t content, const bool trim, const f_string_static_t *content_prepend, f_state_t state, f_string_dynamic_t * const destination); +#endif // _di_fll_fss_payload_write_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/control/c/private-control.c b/level_3/control/c/private-control.c index 36be8b1..4ac63d9 100644 --- a/level_3/control/c/private-control.c +++ b/level_3/control/c/private-control.c @@ -197,7 +197,7 @@ extern "C" { contents.used = 1; - status = fll_fss_extended_write_string(control_type_s, contents, 0, state, &data->cache.large); + status = fll_fss_extended_write(control_type_s, contents, 0, state, &data->cache.large); if (F_status_is_error(status)) return status; // Payload Header: action. @@ -205,24 +205,24 @@ extern "C" { contents_array[contents.used] = data->argv[main->parameters.remaining.array[contents.used]]; } // for - status = fll_fss_extended_write_string(control_action_s, contents, 0, state, &data->cache.large); + status = fll_fss_extended_write(control_action_s, contents, 0, state, &data->cache.large); if (F_status_is_error(status)) return status; // Payload Header: length. contents_array[0] = f_string_ascii_0_s; contents.used = 1; - status = fll_fss_extended_write_string(control_length_s, contents, 0, state, &data->cache.large); + status = fll_fss_extended_write(control_length_s, contents, 0, state, &data->cache.large); if (F_status_is_error(status)) return status; // Payload Packet: Header. - status = fll_fss_payload_write_string(f_fss_string_header_s, data->cache.large, F_false, 0, state, &data->cache.packet); + status = fll_fss_payload_write(f_fss_string_header_s, data->cache.large, F_false, 0, state, &data->cache.packet); if (F_status_is_error(status)) return status; // Payload Packet: Payload. data->cache.large.used = 0; - status = fll_fss_payload_write_string(f_fss_string_payload_s, data->cache.large, F_false, 0, state, &data->cache.packet); + status = fll_fss_payload_write(f_fss_string_payload_s, data->cache.large, F_false, 0, state, &data->cache.packet); if (F_status_is_error(status)) return status; // Construct Packet Size Block. diff --git a/level_3/control/c/private-control.h b/level_3/control/c/private-control.h index a3581c0..bf0ca0b 100644 --- a/level_3/control/c/private-control.h +++ b/level_3/control/c/private-control.h @@ -45,8 +45,8 @@ extern "C" { * Errors (with error bit) from: f_string_append(). * Errors (with error bit) from: f_string_dynamic_append(). * Errors (with error bit) from: f_string_dynamic_resize(). - * Errors (with error bit) from: fll_fss_extended_write_string(). - * Errors (with error bit) from: fll_fss_payload_write_string(). + * Errors (with error bit) from: fll_fss_extended_write(). + * Errors (with error bit) from: fll_fss_payload_write(). * * @see f_string_append() * @see f_string_dynamic_append() diff --git a/level_3/fss_payload_write/c/private-write.c b/level_3/fss_payload_write/c/private-write.c index 7feacac..964cc9b 100644 --- a/level_3/fss_payload_write/c/private-write.c +++ b/level_3/fss_payload_write/c/private-write.c @@ -95,7 +95,7 @@ extern "C" { prepend = &main->parameters.arguments.array[index]; } - status = fll_fss_payload_write_string(*object, *content, trim, prepend, state, buffer); + status = fll_fss_payload_write(*object, *content, trim, prepend, state, buffer); if (F_status_set_fine(status) == F_none_eol) { fss_payload_write_error_parameter_unsupported_eol_print(main); @@ -104,7 +104,7 @@ extern "C" { } if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fll_fss_payload_write_string", F_true); + fll_error_print(main->error, F_status_set_fine(status), "fll_fss_payload_write", F_true); return status; } diff --git a/level_3/utf8/c/private-print.c b/level_3/utf8/c/private-print.c index 30fc856..cec0a58 100644 --- a/level_3/utf8/c/private-print.c +++ b/level_3/utf8/c/private-print.c @@ -110,7 +110,7 @@ extern "C" { fl_print_format("%]", data->main->error.to.stream, data->main->context.set.notable); } - if (F_status_set_fine(status) == F_utf) { + if (F_status_set_fine(status) == F_utf_not) { fl_print_format("%[', not a valid UTF-8 character sequence.%]%r", data->main->error.to.stream, data->main->context.set.error, data->main->context.set.error, f_string_eol_s); } else if (F_status_set_fine(status) == F_complete_not_utf) { @@ -135,7 +135,7 @@ extern "C" { fl_print_format("%r%[%QFailed to encode Unicode codepoint '%]", data->main->error.to.stream, f_string_eol_s, data->main->context.set.error, data->main->error.prefix, data->main->context.set.error); fl_print_format("%[U+%_U%]", data->main->error.to.stream, data->main->context.set.notable, codepoint, data->main->context.set.notable); - if (F_status_set_fine(status) == F_utf) { + if (F_status_set_fine(status) == F_utf_not) { fl_print_format("%[', not a valid Unicode codepoint.%]%r", data->main->error.to.stream, data->main->context.set.error, data->main->context.set.error, f_string_eol_s); } else { diff --git a/level_3/utf8/c/private-utf8.c b/level_3/utf8/c/private-utf8.c index 3ac7858..3535e21 100644 --- a/level_3/utf8/c/private-utf8.c +++ b/level_3/utf8/c/private-utf8.c @@ -57,7 +57,7 @@ extern "C" { } } - if (status == F_utf) { + if (status == F_utf_not) { valid = F_false; } diff --git a/level_3/utf8/c/private-utf8_bytecode.c b/level_3/utf8/c/private-utf8_bytecode.c index e5d2576..419aef0 100644 --- a/level_3/utf8/c/private-utf8_bytecode.c +++ b/level_3/utf8/c/private-utf8_bytecode.c @@ -21,13 +21,13 @@ extern "C" { status = f_utf_unicode_to(character.string, character.used, &codepoint); } else { - status = F_status_set_error(F_utf); + status = F_status_set_error(F_utf_not); } if (F_status_is_error(status)) { status = F_status_set_fine(status); - if (status == F_failure || status == F_utf || status == F_complete_not_utf || status == F_utf_fragment || status == F_valid_not) { + if (status == F_failure || status == F_utf_not || status == F_complete_not_utf || status == F_utf_fragment || status == F_valid_not) { valid_not = F_true; utf8_print_character_invalid(data, character); @@ -53,7 +53,7 @@ extern "C" { } if (valid_not || F_status_is_error(status)) { - return F_utf; + return F_utf_not; } return F_none; @@ -118,7 +118,7 @@ extern "C" { } } - if (status == F_utf) { + if (status == F_utf_not) { valid = F_false; } @@ -147,7 +147,7 @@ extern "C" { } } - if (status == F_utf) { + if (status == F_utf_not) { valid = F_false; } } diff --git a/level_3/utf8/c/private-utf8_bytecode.h b/level_3/utf8/c/private-utf8_bytecode.h index 65ea852..1216844 100644 --- a/level_3/utf8/c/private-utf8_bytecode.h +++ b/level_3/utf8/c/private-utf8_bytecode.h @@ -25,9 +25,9 @@ extern "C" { * * @return * F_none on success. - * F_utf on invalid UTF-8 (which is still "success" when verifying). + * F_utf_not on invalid UTF-8 (which is still "success" when verifying). * - * F_utf (with error bit) if not verifying and + * F_utf_not (with error bit) if not verifying and * * Errors (with error bit) from: f_utf_unicode_to() */ diff --git a/level_3/utf8/c/private-utf8_codepoint.c b/level_3/utf8/c/private-utf8_codepoint.c index 316c4eb..689b718 100644 --- a/level_3/utf8/c/private-utf8_codepoint.c +++ b/level_3/utf8/c/private-utf8_codepoint.c @@ -38,7 +38,7 @@ extern "C" { if (F_status_is_error(status)) { status = F_status_set_fine(status); - if (status == F_failure || status == F_utf || status == F_complete_not_utf || status == F_utf_fragment || status == F_valid_not) { + if (status == F_failure || status == F_utf_not || status == F_complete_not_utf || status == F_utf_fragment || status == F_valid_not) { valid_not = F_true; utf8_print_character_invalid(data, character); @@ -86,7 +86,7 @@ extern "C" { data->text.used = 0; if (valid_not || F_status_is_error(status)) { - return F_utf; + return F_utf_not; } return status; @@ -251,7 +251,7 @@ extern "C" { } } - if (status == F_utf) { + if (status == F_utf_not) { valid = F_false; } @@ -280,7 +280,7 @@ extern "C" { } } - if (status == F_utf) { + if (status == F_utf_not) { valid = F_false; } } diff --git a/level_3/utf8/c/private-utf8_codepoint.h b/level_3/utf8/c/private-utf8_codepoint.h index bd34629..184b9fb 100644 --- a/level_3/utf8/c/private-utf8_codepoint.h +++ b/level_3/utf8/c/private-utf8_codepoint.h @@ -26,9 +26,9 @@ extern "C" { * * @return * F_none on success. - * F_utf on invalid UTF-8 (which is still "success" when verifying). + * F_utf_not on invalid UTF-8 (which is still "success" when verifying). * - * F_utf (with error bit) if not verifying and + * F_utf_not (with error bit) if not verifying and * * Errors (with error bit) from: f_utf_unicode_to() */