From 218466583df6c415f15c6f543d4a1eed3532d297 Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Sun, 13 Sep 2015 23:47:32 -0700 Subject: [PATCH] Fix curses bug: garbled output in nl mode. Use nonl mode in sl, as more efficient. --- src/cmd/sl/sl.c | 1 + src/libcurses/cr_put.c | 13 +++++++------ src/libcurses/cr_tty.c | 3 +-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/cmd/sl/sl.c b/src/cmd/sl/sl.c index 7fdaeb1..37b6cbf 100644 --- a/src/cmd/sl/sl.c +++ b/src/cmd/sl/sl.c @@ -90,6 +90,7 @@ int main(int argc, char *argv[]) initscr(); signal(SIGINT, SIG_IGN); noecho(); + nonl(); leaveok(stdscr, TRUE); scrollok(stdscr, FALSE); diff --git a/src/libcurses/cr_put.c b/src/libcurses/cr_put.c index b733a5d..58bcd71 100644 --- a/src/libcurses/cr_put.c +++ b/src/libcurses/cr_put.c @@ -160,7 +160,7 @@ plod(cnt) * If we will later need a \n which will turn into a \r\n by * the system or the terminal, then don't bother to try to \r. */ - if ((NONL || !_pfast) && outline < destline) + if (!_pfast && outline < destline) goto dontcr; /* * If the terminal will do a \r\n and there isn't room for it, @@ -195,12 +195,13 @@ dontcr: outline++; if (NL) tputs(NL, 0, plodput); - else - plodput('\n'); + else { + plodput('\n'); + if (!_pfast) + outcol = 0; + } if (plodcnt < 0) goto out; - if (NONL || _pfast == 0) - outcol = 0; } if (BT) k = strlen(BT); @@ -271,7 +272,7 @@ dontcr: } else nondes: - if (ND) + if (ND) tputs(ND, 0, plodput); else plodput(' '); diff --git a/src/libcurses/cr_tty.c b/src/libcurses/cr_tty.c index cc506d3..92e84a0 100644 --- a/src/libcurses/cr_tty.c +++ b/src/libcurses/cr_tty.c @@ -52,6 +52,7 @@ gettmode() _res_flg = _tty.sg_flags; GT = ((_tty.sg_flags & XTABS) == 0); NONL = ((_tty.sg_flags & CRMOD) == 0); + _pfast = NONL; _tty.sg_flags &= ~XTABS; ioctl(_tty_ch, TIOCSETP, &_tty); # ifdef DEBUG @@ -59,8 +60,6 @@ gettmode() fprintf(outf, "GETTMODE: NONL = %s\n", NONL ? "TRUE" : "FALSE"); fprintf(outf, "GETTMODE: ospeed = %d\n", ospeed); # endif - /* Use nonl mode by default. */ - nonl(); } /*