diff --git a/expr.c b/expr.c index ec54df5..47eaa0e 100644 --- a/expr.c +++ b/expr.c @@ -22,7 +22,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.39 2009/11/28 14:28:00 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.40 2009/12/05 20:17:58 tg Exp $"); /* The order of these enums is constrained by the order of opinfo[] */ enum token { @@ -710,8 +710,11 @@ utf_skipcols(const char *p, int cols) { int c = 0; - while (c < cols) + while (c < cols) { + if (!*p) + return (p + cols - c); c += utf_widthadj(p, &p); + } return (p); } diff --git a/lex.c b/lex.c index 1dbd53a..5ac5e94 100644 --- a/lex.c +++ b/lex.c @@ -22,7 +22,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.102 2009/12/05 19:44:09 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.103 2009/12/05 20:17:59 tg Exp $"); /* * states while lexing word @@ -1326,7 +1326,7 @@ getsc_line(Source *s) /* Done here to ensure nothing odd happens when a timeout occurs */ XcheckN(s->xs, xp, LINE); - memset(xp, 0, LINE); + *xp = '\0'; s->start = s->str = xp; if (have_tty && ksh_tmout) {