NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lib/57592: curses: aspell clears screen if no correction found



The following reply was made to PR lib/57592; it has been noted by GNATS.

From: RVP <rvp%SDF.ORG@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: Rin Okuyama <rokuyama.rk%gmail.com@localhost>
Subject: Re: lib/57592: curses: aspell clears screen if no correction found
Date: Sun, 10 Sep 2023 22:48:29 +0000 (UTC)

 On Sun, 10 Sep 2023, Rin Okuyama wrote:
 
 > aspell linked against libcurses.so.9.1 outputs additional ``^[[H'' and
 > ``^[[2J'' that cause screen clear.
 >
 
 Yes, it's the 2nd (unpaired) rmcup which clears the screen (ncurses+Rxvt only).
 
 > However, this is not a regression for our curses [...]
 >
 
 My analysis is that aspell will only clear the screen like this, if
 a) TERM=rxvt
 b) curses is ncurses.
 
 I made some notes (and also a patch) a couple of days ago. I've added this
 as-is below. Okuyama-san, can you check this please?
 
 
 --- NOTES: Aspell + ncurses + TERM=rxvt clearing the screen ---
 To trigger this issue you must:
 
 1. Call endwin() twice.
     (See: aspell-0.60.8/prog/check_funs.cpp:begin_check())
 
 2. Have a curses with non-idempotent endwin() (like ncurses; BSD curses
     is not affected by this).
 
 3. Have a termcap/terminfo entry where the `te'/`rmcup' capability has an
     Erase in Display (ED) string `\E[2J' in it (like for rxvt).
 
 This should reproduce the issue more simply:
 
 ```
 $ (export TERM=rxvt; tput smcup; tput rmcup; tput rmcup)
 ```
 
 The second `rmcup' will clear the current screen instead of the alt. screen.
 Fix:
 
 ```
 diff -urN aspell-0.60.8.orig/prog/check_funs.cpp aspell-0.60.8/prog/check_funs.cpp
 --- aspell-0.60.8.orig/prog/check_funs.cpp	2019-10-08 00:15:21.000000000 +0000
 +++ aspell-0.60.8/prog/check_funs.cpp	2023-09-07 07:31:11.452543000 +0000
 @@ -110,6 +110,9 @@
   #endif
 
   static void cleanup (void) {
 +  static int done = 0;
 +  if (done)
 +    return;    /* do cleanup only once (for ncurses; see NetBSD PR #57592) */
   #if   HAVE_LIBCURSES
     if (use_curses) {
       endwin();
 @@ -120,6 +123,7 @@
       tcsetattr (STDIN_FILENO, TCSANOW, &saved_attributes);
   #endif
     }
 +  done = 1;
   }
 
   #if   HAVE_LIBCURSES
 ```
 
 --- END of NOTES ---
 
 -RVP
 


Home | Main Index | Thread Index | Old Index