The previous commit: "Bugfix: UTF-8 characters are not being fully printed" exposed that for UTF-8 characters (width 2 or greater), an error is always returned.
When the width properly fits in the requested range, return the appropriate success code instead of an error.
width = macro_f_utf_byte_width(buffer.string[range->start - 1]);
if (width > range->start) {
- if (width > 1) {
+ if (width > 1 && width > range->start + 1) {
return F_status_set_error(F_complete_not_utf_eos);
}
width = macro_f_utf_byte_width(buffer.string[range->start]);
if (range->start + width > range->stop) {
- if (width > 1) {
+ if (width > 1 && range->start + width > range->stop + 1) {
return F_status_set_error(F_complete_not_utf_stop);
}
return F_none_stop;
}
else if (range->start + width >= buffer.used) {
- if (width > 1) {
+ if (width > 1 && range->start + width >= buffer.used + 1) {
return F_status_set_error(F_complete_not_utf_eos);
}