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.
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.
}
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;
* 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);
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);
}
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;
}
// 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) {
* 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.
* 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.
* 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);
}
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).
*
* 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()
* 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()
* 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()
* 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()
* 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()
* 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()
* 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()
* 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()
* 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()
* 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()
* 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()
* 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()
* 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()
* 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()
* 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()
* 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()
* 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()
* 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()
* 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()
* 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()
* 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()
* 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()
* 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()
* 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;
* 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()
* 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()
* 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()
* 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()
*
* 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()
#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);
#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.
#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_
#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) {
}
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
}
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
}
else {
if (width_max < 4) {
- return F_status_set_error(F_utf);
+ return F_status_set_error(F_utf_not);
}
// U+10000 -> U+10FFFF
*
* 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);
* 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()
*/
* 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);
*
* 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);
*
* 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);
*
* 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()
*/
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;
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;
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;
* 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().
*/
* 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().
*/
* 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().
*/
* 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()
*/
* 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()
*/
* 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()
*/
* 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);
* 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);
* 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()
*/
* 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);
* 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);
* 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);
* 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()
*/
* 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);
* 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()
*/
* 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()
*/
* 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);
* 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);
* 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);
* 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);
* 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);
* 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);
* 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);
*
* 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);
* 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()
*/
* 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);
* 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);
*
* 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);
* 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()
*/
* 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()
*/
* 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()
*/
* 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);
* 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()
*/
* 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()
*/
* 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()
*/
* 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);
* 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()
*/
* 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()
*/
* 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);
* 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);
* 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()
*/
* 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);
* 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()
* 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()
*/
* 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()
*/
* 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);
* 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);
* 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);
* 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);
* 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);
* 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);
* 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()
* 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()
* 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()
*/
* 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);
* 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()
*/
*
* 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);
* 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()
*/
* 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()
*/
* 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()
*/
* 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);
* 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()
* 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().
*/
* 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);
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_
}
#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_
}
#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
#endif
/**
- * Read an fss-0000 object.
+ * Read an fss-0000 content.
*
* This will record where delimit placeholders exist but will not apply the delimits.
*
* 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).
* 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.
*
* 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).
* 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.
* 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
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);
}
}
+ 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;
}
}
- 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) {
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) {
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
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);
}
}
- 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;
}
}
- 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) {
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) {
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
-
break;
}
}
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;
}
}
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) {
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);
}
#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
#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.
*
* 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).
* 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.
*
* 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).
* 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.
* 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
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);
}
}
+ 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])) {
}
}
- 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) {
}
}
- 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;
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;
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) {
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;
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;
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);
}
}
- 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);
}
}
- 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) {
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);
}
}
- 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"
#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
* 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).
* 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
* 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).
* 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.
* 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
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_
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)) {
}
#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_
}
#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
#endif
/**
- * Read an fss-0001 object.
+ * Read an fss-0001 content.
*
* This will record where delimit placeholders exist but will not apply the delimits.
*
* 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).
* 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.
*
* 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).
* 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.
* 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
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);
}
}
+ 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);
}
}
- 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) {
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) {
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);
}
}
- 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);
}
}
- 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);
}
}
- 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) {
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);
}
}
- 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
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"
#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
* 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
* 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.
* 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
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) {
// 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;
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) {
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) {
}
#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
#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
*
* 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;
*
* 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()
*/
* 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()
* 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()
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
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
* 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().
*
* 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().
*
*
* @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().
*
* 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().
*
* 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().
*
* 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().
* 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().
*
* 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().
*
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;
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;
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;
*
* 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()
*
* @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()
*/
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);
}
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);
}
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) {
}
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) {
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) {
}
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) {
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) {
++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;
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) {
++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) {
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;
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;
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) {
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) {
}
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) {
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) {
}
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) {
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) {
}
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
* 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);
* 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().
*
*
* @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);
*
* @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);
* 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);
* 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().
*
* 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().
*
* 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);
*
* @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().
*
*
* @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().
*
* 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);
* 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().
*
* 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().
*
* 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);
return F_false;
}
- if (status == F_utf) {
+ if (status == F_utf_not) {
if (print.verbosity != f_console_verbosity_quiet_e) {
flockfile(print.to.stream);
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);
}
#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_
return status;
}
-#endif // _di_fll_fss_basic_write_string_
+#endif // _di_fll_fss_basic_write_
#ifdef __cplusplus
} // 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()
*/
* 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().
* @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"
}
#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_
return status;
}
-#endif // _di_fll_fss_basic_list_write_string_
+#endif // _di_fll_fss_basic_list_write_
#ifdef __cplusplus
} // 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()
*/
* 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"
}
#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_
return status;
}
-#endif // _di_fll_fss_embedded_list_write_string_
+#endif // _di_fll_fss_embedded_list_write_
#ifdef __cplusplus
} // 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);
* 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"
}
#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_
return status;
}
-#endif // _di_fll_fss_extended_write_string_
+#endif // _di_fll_fss_extended_write_
#ifdef __cplusplus
} // 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()
*/
* 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"
}
#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_
return status;
}
-#endif // _di_fll_fss_extended_list_write_string_
+#endif // _di_fll_fss_extended_list_write_
#ifdef __cplusplus
} // 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()
*/
* 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"
}
#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_
return status;
}
-#endif // _di_fll_fss_payload_write_string_
+#endif // _di_fll_fss_payload_write_
#ifdef __cplusplus
} // 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()
*/
* 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"
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.
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.
* 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()
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);
}
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;
}
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) {
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 {
}
}
- if (status == F_utf) {
+ if (status == F_utf_not) {
valid = F_false;
}
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);
}
if (valid_not || F_status_is_error(status)) {
- return F_utf;
+ return F_utf_not;
}
return F_none;
}
}
- if (status == F_utf) {
+ if (status == F_utf_not) {
valid = F_false;
}
}
}
- if (status == F_utf) {
+ if (status == F_utf_not) {
valid = F_false;
}
}
*
* @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()
*/
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);
data->text.used = 0;
if (valid_not || F_status_is_error(status)) {
- return F_utf;
+ return F_utf_not;
}
return status;
}
}
- if (status == F_utf) {
+ if (status == F_utf_not) {
valid = F_false;
}
}
}
- if (status == F_utf) {
+ if (status == F_utf_not) {
valid = F_false;
}
}
*
* @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()
*/