Merge remote-tracking branch 'mksh/master'

This commit is contained in:
KO Myung-Hun
2016-05-06 17:12:52 +09:00
11 changed files with 256 additions and 137 deletions

19
expr.c
View File

@ -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.85 2016/05/05 22:56:13 tg Exp $");
/* the order of these enums is constrained by the order of opinfo[] */
enum token {
@ -809,15 +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);
}