From: Kevin Day Date: Wed, 5 May 2021 05:00:40 +0000 (-0500) Subject: Bugfix: UTF-8 characters buffer is incorrectly returning an error. X-Git-Tag: 0.5.4~56 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=cfbb6ee6885b39ff96d9fc25784c746adf7b353c;p=fll Bugfix: UTF-8 characters buffer is incorrectly returning an error. 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. --- diff --git a/level_0/f_utf/c/utf.c b/level_0/f_utf/c/utf.c index 876c71b..a6e2d86 100644 --- a/level_0/f_utf/c/utf.c +++ b/level_0/f_utf/c/utf.c @@ -23,7 +23,7 @@ extern "C" { 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); } @@ -57,7 +57,7 @@ extern "C" { 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); } @@ -65,7 +65,7 @@ extern "C" { 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); }