fun: when writing this code I feared an off-by-one;

Steffen Daode Nurpmeso stumbled upon it and gave very detailed
instructions on how to reproduce it (thanks!); fix that

also only call x_bs0 if xcp < xep because *xep is undefined
This commit is contained in:
tg 2013-08-14 20:26:19 +00:00
parent bb0b409a9d
commit bf94b7e2ec
3 changed files with 9 additions and 9 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.628 2013/08/11 14:57:07 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.629 2013/08/14 20:26:15 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -31,7 +31,7 @@
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
expected-stdout:
@(#)MIRBSD KSH R48 2013/08/11
@(#)MIRBSD KSH R48 2013/08/14
description:
Check version of shell.
stdin:
@ -40,7 +40,7 @@ name: KSH_VERSION
category: shell:legacy-no
---
expected-stdout:
@(#)LEGACY KSH R48 2013/08/11
@(#)LEGACY KSH R48 2013/08/14
description:
Check version of legacy shell.
stdin:

8
edit.c
View File

@ -28,7 +28,7 @@
#ifndef MKSH_NO_CMDLINE_EDITING
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.269 2013/08/10 13:44:29 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.270 2013/08/14 20:26:17 tg Exp $");
/*
* in later versions we might use libtermcap for this, but since external
@ -2828,15 +2828,15 @@ x_adjust(void)
goto x_adjust_out;
}
/* fix up xbp to character begin first */
xbp = x_bs0(xcp, xbuf);
/* fix up xbp to just past a character end first */
xbp = xcp >= xep ? xep : x_bs0(xcp, xbuf);
/* walk backwards */
while (xbp > xbuf && col_left > 0) {
xbp = x_bs0(xbp - 1, xbuf);
col_left -= (n = x_size2(xbp, NULL));
}
/* check if we hit the prompt */
if (xbp == xbuf && xcp != xbuf && col_left > 0 && col_left < pwidth) {
if (xbp == xbuf && xcp != xbuf && col_left >= 0 && col_left < pwidth) {
/* so we did; force scrolling occurs */
xbp += utf_ptradj(xbp);
}

4
sh.h
View File

@ -164,9 +164,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.666 2013/08/11 14:57:10 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.667 2013/08/14 20:26:19 tg Exp $");
#endif
#define MKSH_VERSION "R48 2013/08/11"
#define MKSH_VERSION "R48 2013/08/14"
/* arithmetic types: C implementation */
#if !HAVE_CAN_INTTYPES