Skip to content

Commit

Permalink
Fix PR lib/55931
Browse files Browse the repository at this point in the history
Only reset outcol if we actually emit a \n as cursor_down may not may
not put the cursor at the start of the next line.
  • Loading branch information
blymn authored and blymn committed Jun 27, 2021
1 parent 2fca1a1 commit d08b415
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/libcurses/cr_put.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: cr_put.c,v 1.34 2019/05/20 22:17:41 blymn Exp $ */
/* $NetBSD: cr_put.c,v 1.35 2021/06/27 23:57:08 blymn Exp $ */

/*
* Copyright (c) 1981, 1993, 1994
Expand Down Expand Up @@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)cr_put.c 8.3 (Berkeley) 5/4/94";
#else
__RCSID("$NetBSD: cr_put.c,v 1.34 2019/05/20 22:17:41 blymn Exp $");
__RCSID("$NetBSD: cr_put.c,v 1.35 2021/06/27 23:57:08 blymn Exp $");
#endif
#endif /* not lint */

Expand Down Expand Up @@ -93,6 +93,8 @@ fgoto(int in_refresh)

#ifdef DEBUG
__CTRACE(__CTRACE_OUTPUT, "fgoto: in_refresh=%d\n", in_refresh);
__CTRACE(__CTRACE_OUTPUT, "fgoto: outcol=%d, outline=%d, destcol=%d, destline=%d\n",
outcol, outline, destcol, destline);
#endif /* DEBUG */
if (destcol >= COLS) {
destline += destcol / COLS;
Expand Down Expand Up @@ -214,6 +216,8 @@ plod(int cnt, int in_refresh)
#ifdef DEBUG
__CTRACE(__CTRACE_OUTPUT, "plod: cnt=%d, in_refresh=%d\n",
cnt, in_refresh);
__CTRACE(__CTRACE_OUTPUT, "plod: plodding from col %d, row %d to col %d, row %d\n",
outcol, outline, destcol, destline);
#endif /* DEBUG */
plodcnt = plodflg = cnt;
soutcol = outcol;
Expand Down Expand Up @@ -331,6 +335,7 @@ plod(int cnt, int in_refresh)
plodput('\n');
outline++;
}

outcol = 0;
}
dontcr:while (outline < destline) {
Expand All @@ -341,7 +346,14 @@ dontcr:while (outline < destline) {
plodput('\n');
if (plodcnt < 0)
goto out;
if (__NONL || __pfast == 0)
/*
* If the terminal does a CR with NL or we are in
* a mode where a \n will result in an implicit \r
* then adjust the outcol to match iff we actually
* emitted said \n.
*/
if ((__NONL || __pfast == 0) &&
(!cursor_down || (*cursor_down == '\n')))
outcol = 0;
}
#ifdef notdef
Expand Down

0 comments on commit d08b415

Please sign in to comment.