Thu Aug 9 14:38:16 2018 UTC ()
Pull up following revision(s) (requested by simonb in ticket #1627):

	lib/libcurses/addbytes.c: revision 1.48

Avoid curx going beyond end of window when adding a wide character to the
last column.

OK @blymn.


(martin)
diff -r1.42 -r1.42.4.1 src/lib/libcurses/addbytes.c

cvs diff -r1.42 -r1.42.4.1 src/lib/libcurses/addbytes.c (expand / switch to unified diff)

--- src/lib/libcurses/addbytes.c 2013/11/10 03:14:16 1.42
+++ src/lib/libcurses/addbytes.c 2018/08/09 14:38:16 1.42.4.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: addbytes.c,v 1.42 2013/11/10 03:14:16 christos Exp $ */ 1/* $NetBSD: addbytes.c,v 1.42.4.1 2018/08/09 14:38:16 martin Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1987, 1993, 1994 4 * Copyright (c) 1987, 1993, 1994
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)addbytes.c 8.4 (Berkeley) 5/4/94"; 35static char sccsid[] = "@(#)addbytes.c 8.4 (Berkeley) 5/4/94";
36#else 36#else
37__RCSID("$NetBSD: addbytes.c,v 1.42 2013/11/10 03:14:16 christos Exp $"); 37__RCSID("$NetBSD: addbytes.c,v 1.42.4.1 2018/08/09 14:38:16 martin Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include <stdlib.h> 41#include <stdlib.h>
42#include <string.h> 42#include <string.h>
43#include "curses.h" 43#include "curses.h"
44#include "curses_private.h" 44#include "curses_private.h"
45#ifdef DEBUG 45#ifdef DEBUG
46#include <assert.h> 46#include <assert.h>
47#endif 47#endif
48 48
49#define SYNCH_IN {y = win->cury; x = win->curx;} 49#define SYNCH_IN {y = win->cury; x = win->curx;}
50#define SYNCH_OUT {win->cury = y; win->curx = x;} 50#define SYNCH_OUT {win->cury = y; win->curx = x;}
@@ -562,27 +562,27 @@ _cursesi_addwchar(WINDOW *win, __LINE ** @@ -562,27 +562,27 @@ _cursesi_addwchar(WINDOW *win, __LINE **
562 } 562 }
563 tp->ch = wch->vals[0]; 563 tp->ch = wch->vals[0];
564 tp->attr = lp->attr & WA_ATTRIBUTES; 564 tp->attr = lp->attr & WA_ATTRIBUTES;
565 /* Mark as "continuation" cell */ 565 /* Mark as "continuation" cell */
566 tp->attr |= __WCWIDTH; 566 tp->attr |= __WCWIDTH;
567 } 567 }
568 568
569 if (*x == win->maxx) { 569 if (*x == win->maxx) {
570 (*lnp)->flags |= __ISPASTEOL; 570 (*lnp)->flags |= __ISPASTEOL;
571 newx = win->maxx - 1 + win->ch_off; 571 newx = win->maxx - 1 + win->ch_off;
572 if (newx > *(*lnp)->lastchp) 572 if (newx > *(*lnp)->lastchp)
573 *(*lnp)->lastchp = newx; 573 *(*lnp)->lastchp = newx;
574 __touchline(win, *y, sx, (int) win->maxx - 1); 574 __touchline(win, *y, sx, (int) win->maxx - 1);
575 win->curx = sx; 575 *x = win->curx = sx;
576 } else { 576 } else {
577 win->curx = *x; 577 win->curx = *x;
578 578
579 /* clear the remining of the current characer */ 579 /* clear the remining of the current characer */
580 if (*x && *x < win->maxx) { 580 if (*x && *x < win->maxx) {
581 ex = sx + cw; 581 ex = sx + cw;
582 tp = &win->alines[*y]->line[ex]; 582 tp = &win->alines[*y]->line[ex];
583 while (ex < win->maxx && WCOL(*tp) < 0) { 583 while (ex < win->maxx && WCOL(*tp) < 0) {
584#ifdef DEBUG 584#ifdef DEBUG
585 __CTRACE(__CTRACE_INPUT, 585 __CTRACE(__CTRACE_INPUT,
586 "_cursesi_addwchar: clear " 586 "_cursesi_addwchar: clear "
587 "remaining of current char (%d,%d)nn", 587 "remaining of current char (%d,%d)nn",
588 *y, ex); 588 *y, ex);