From bbaa186ec6d7857e5cc0da80b89bef6bbc2a2f5f Mon Sep 17 00:00:00 2001 From: tg Date: Sun, 22 Feb 2009 19:02:27 +0000 Subject: [PATCH] optimise utf_widthadj --- edit.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/edit.c b/edit.c index 2cc5344..2c157bd 100644 --- a/edit.c +++ b/edit.c @@ -5,7 +5,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.151 2009/02/22 18:57:19 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.152 2009/02/22 19:02:27 tg Exp $"); /* tty driver characters we are interested in */ typedef struct { @@ -721,13 +721,13 @@ utf_widthadj(const char *src, const char **dst) if (!UTFMODE || (len = utf_mbtowc(&wc, src)) == (size_t)-1 || wc == 0) len = width = 1; - else - width = utf_wcwidth(wc); + else if ((width = utf_wcwidth(wc)) < 0) + /* XXX use 2 for x_zotc3 here? */ + width = 1; if (dst) *dst = src + len; - /* XXX (width == -1 ? 2 : width) for x_zotc3 but appar. noth. else */ - return (width == -1 ? 1 : width); + return (width); } int