fix utf_widthadj/utf_skipcols handling for the remaining cases I can spot
This commit is contained in:
15
expr.c
15
expr.c
@ -23,7 +23,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.84 2016/05/05 21:33:46 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.85 2016/05/05 22:56:13 tg Exp $");
|
||||
|
||||
/* the order of these enums is constrained by the order of opinfo[] */
|
||||
enum token {
|
||||
@ -809,19 +809,26 @@ utf_mbswidth(const char *s)
|
||||
}
|
||||
|
||||
const char *
|
||||
utf_skipcols(const char *p, int cols)
|
||||
utf_skipcols(const char *p, int cols, int *colp)
|
||||
{
|
||||
int c = 0;
|
||||
const char *q;
|
||||
|
||||
while (c < cols) {
|
||||
if (!*p)
|
||||
return (p + cols - c);
|
||||
if (!*p) {
|
||||
/* end of input; special handling for edit.c */
|
||||
if (!colp)
|
||||
return (p + cols - c);
|
||||
*colp = c;
|
||||
return (p);
|
||||
}
|
||||
c += utf_widthadj(p, &p);
|
||||
}
|
||||
if (UTFMODE)
|
||||
while (utf_widthadj(p, &q) == 0)
|
||||
p = q;
|
||||
if (colp)
|
||||
*colp = c;
|
||||
return (p);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user