From 5371f1874ae4a5d24a66f1f446078017eb971ef7 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Thu, 2 Sep 2021 16:35:18 +0200 Subject: [PATCH] [unicode] Fix issue with negative value of cells. Refs #126 Bug appeared in 0.13.5. --- src/intl/width.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/intl/width.c b/src/intl/width.c index e68adb1e..332cc835 100644 --- a/src/intl/width.c +++ b/src/intl/width.c @@ -129,9 +129,8 @@ static const struct RangeLut RANGE_LUT_LIST[] = { }; static const int RANGE_LUT_LIST_SIZE = 4; - -int -unicode_to_cell(unicode_val_T ucs4) +static int +unicode_to_cell_konsole(unicode_val_T ucs4) { const struct RangeLut *rl; @@ -158,3 +157,11 @@ unicode_to_cell(unicode_val_T ucs4) return RANGE_LUT_LIST[RANGE_LUT_LIST_SIZE - 1].width; } + +int +unicode_to_cell(unicode_val_T ucs4) +{ + int res = unicode_to_cell_konsole(ucs4); + + return res >= 0 ? res : 0; +}