If a terminals capability is deemed insufficient for top, the
variable is_a_terminal is switched to 0 in the init_screen
function, as is the variable smart_terminal. This diff makes
this logical relationship more explicit in the relevant code.
There is no functional change.

ok/comments?

-lum

Index: screen.c
===================================================================
RCS file: /cvs/src/usr.bin/top/screen.c,v
retrieving revision 1.20
diff -u -p -r1.20 screen.c
--- screen.c    5 Feb 2010 10:21:10 -0000       1.20
+++ screen.c    27 Aug 2011 13:47:54 -0000
@@ -157,27 +157,26 @@ init_screen(void)
                /* send the termcap initialization string */
                putcap(terminal_init);
 #endif
-       }
-       if (!is_a_terminal) {
+               if (smart_terminal)
+                       initscr();
+       } else
                /* not a terminal at all---consider it dumb */
                smart_terminal = No;
-       }
 
-       if (smart_terminal)
-               initscr();
 }
 
 void
 end_screen(void)
 {
-       if (smart_terminal) {
-               move(screen_length-1, 0);
-               clrtoeol();
-               refresh();
-               endwin();
-       }
-       if (is_a_terminal)
+       if (is_a_terminal) {
+               if (smart_terminal) {
+                       move(screen_length-1, 0);
+                       clrtoeol();
+                       refresh();
+                       endwin();
+               }
                (void) tcsetattr(STDOUT_FILENO, TCSADRAIN, &old_settings);
+       }
 }
 
 void
@@ -185,12 +184,13 @@ reinit_screen(void)
 {
 #if 0
        /* install our settings if it is a terminal */
-       if (is_a_terminal)
+       if (is_a_terminal) {
                (void) tcsetattr(STDOUT_FILENO, TCSADRAIN, &new_settings);
 
-       /* send init string */
-       if (smart_terminal)
-               putcap(terminal_init);
+               /* send init string */
+               if (smart_terminal)
+                       putcap(terminal_init);
+       }
 #endif
 }

Reply via email to