From 152eee20856e45567b50e0796f992569a491923b Mon Sep 17 00:00:00 2001 From: tg <tg@mirbsd.org> Date: Thu, 5 May 2016 21:33:46 +0000 Subject: [PATCH] handle combining characters at the end of the string correctly --- expr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/expr.c b/expr.c index cf08b50..f899952 100644 --- a/expr.c +++ b/expr.c @@ -23,7 +23,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.83 2016/03/01 18:29:38 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.84 2016/05/05 21:33:46 tg Exp $"); /* the order of these enums is constrained by the order of opinfo[] */ enum token { @@ -812,12 +812,16 @@ const char * utf_skipcols(const char *p, int cols) { int c = 0; + const char *q; while (c < cols) { if (!*p) return (p + cols - c); c += utf_widthadj(p, &p); } + if (UTFMODE) + while (utf_widthadj(p, &q) == 0) + p = q; return (p); }