These problems are exposed by the tests that I am writing.
The destination->used < length check cannot be performed because of the presence of NULL characters.
The nulless versions of the strings may be identical even if their sizes do not match.
The only case where this check should still happen is when destination.used is 0.
The comparison operator is using the wrong variable in some cases ('j' should be used with 'destination').
Replace uint8_t with f_char_t.
Minor updates to the documentation comments.
return F_data_not;
}
- if (destination->used < length) {
+ if (!destination->used) {
return private_f_string_append_nulless(source, length, destination);
}
continue;
}
- if (source[i] != destination->string[i]) {
+ if (source[i] != destination->string[j]) {
return private_f_string_prepend(source, length, destination);
}
return F_data_not;
}
- if (destination->used < length) {
+ if (!destination->used) {
return private_f_string_prepend_nulless(source, length, destination);
}
continue;
}
- if (source[i] != destination->string[i]) {
+ if (source[i] != destination->string[j]) {
return private_f_string_prepend_nulless(source, length, destination);
}
#endif // _di_f_string_seek_line_
#ifndef _di_f_string_seek_line_to_
- f_status_t f_string_seek_line_to(const f_string_t string, const uint8_t seek_to, f_string_range_t * const range) {
+ f_status_t f_string_seek_line_to(const f_string_t string, const f_char_t seek_to, f_string_range_t * const range) {
#ifndef _di_level_0_parameter_checking_
if (!range) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
#endif // _di_f_string_seek_line_to_
#ifndef _di_f_string_seek_to_
- f_status_t f_string_seek_to(const f_string_t string, const uint8_t seek_to, f_string_range_t * const range) {
+ f_status_t f_string_seek_to(const f_string_t string, const f_char_t seek_to, f_string_range_t * const range) {
#ifndef _di_level_0_parameter_checking_
if (!range) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
* @return
* F_none on success.
* F_none_eol on success, but stopped at EOL.
- * F_none_stop on success, but stopped stop location.
+ * F_none_stop on success, but stopped at the stop location.
* F_data_not_stop if range.start > range.stop.
*
* F_parameter (with error bit) if a parameter is invalid.
*/
#ifndef _di_f_string_seek_line_to_
- extern f_status_t f_string_seek_line_to(const f_string_t string, const uint8_t seek_to, f_string_range_t * const range);
+ extern f_status_t f_string_seek_line_to(const f_string_t string, const f_char_t seek_to, f_string_range_t * const range);
#endif // _di_f_string_seek_line_to_
/**
*
* @return
* F_none on success.
- * F_none_stop on success, but stopped stop location.
+ * F_none_stop on success, but stopped at the 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_parameter (with error bit) if a parameter is invalid.
*/
#ifndef _di_f_string_seek_to_
- extern f_status_t f_string_seek_to(const f_string_t string, const uint8_t seek_to, f_string_range_t * const range);
+ extern f_status_t f_string_seek_to(const f_string_t string, const f_char_t seek_to, f_string_range_t * const range);
#endif // _di_f_string_seek_to_
#ifdef __cplusplus
if (!source.used) return F_data_not;
- if (destination->used < source.used) {
+ if (!destination->used) {
return private_f_string_append_nulless(source.string, source.used, destination);
}
const f_array_length_t length = range.stop >= source.used ? source.used - range.start : (range.stop - range.start) + 1;
- if (destination->used < length) {
+ if (!destination->used) {
return private_f_string_append_nulless(source.string + range.start, length, destination);
}
continue;
}
- if (source.string[i + range.start] != destination->string[i]) {
+ if (source.string[i + range.start] != destination->string[j]) {
return private_f_string_prepend(source.string + range.start, length, destination);
}
const f_array_length_t length = range.stop >= source.used ? source.used - range.start : (range.stop - range.start) + 1;
- if (destination->used < length) {
+ if (!destination->used) {
return private_f_string_prepend_nulless(source.string + range.start, length, destination);
}
continue;
}
- if (source.string[i + range.start] != destination->string[i]) {
+ if (source.string[i + range.start] != destination->string[j]) {
return private_f_string_prepend_nulless(source.string + range.start, length, destination);
}
continue;
}
- if (source.string[i] != destination->string[i]) {
+ if (source.string[i] != destination->string[j]) {
return private_f_string_prepend(source.string, source.used, destination);
}
if (!source.used) return F_data_not;
- if (destination->used < source.used) {
+ if (!destination->used) {
return private_f_string_prepend_nulless(source.string, source.used, destination);
}
continue;
}
- if (source.string[i] != destination->string[i]) {
+ if (source.string[i] != destination->string[j]) {
return private_f_string_prepend_nulless(source.string, source.used, destination);
}