Author: eadler
Date: Sat Jun  2 03:25:15 2018
New Revision: 334514
URL: https://svnweb.freebsd.org/changeset/base/334514

Log:
  top(1): Use standard boolean rather than homegrown alternative

Deleted:
  head/usr.bin/top/boolean.h
Modified:
  head/usr.bin/top/commands.c
  head/usr.bin/top/display.c
  head/usr.bin/top/machine.c
  head/usr.bin/top/screen.c
  head/usr.bin/top/top.1
  head/usr.bin/top/top.c

Modified: head/usr.bin/top/commands.c
==============================================================================
--- head/usr.bin/top/commands.c Sat Jun  2 02:06:48 2018        (r334513)
+++ head/usr.bin/top/commands.c Sat Jun  2 03:25:15 2018        (r334514)
@@ -22,6 +22,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <signal.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -30,7 +31,6 @@
 #include "commands.h"
 #include "sigdesc.h"           /* generated automatically */
 #include "top.h"
-#include "boolean.h"
 #include "machine.h"
 
 static int err_compar(const void *p1, const void *p2);
@@ -199,7 +199,7 @@ char *err_string(void)
 {
     struct errs *errp;
     int  cnt = 0;
-    int  first = Yes;
+    int  first = true;
     int  currerr = -1;
     int stringlen;             /* characters still available in "string" */
     static char string[STRMAX];
@@ -233,13 +233,13 @@ char *err_string(void)
                strcat(string, "; ");     /* we know there's more */
            }
            currerr = errp->errnum;
-           first = Yes;
+           first = true;
        }
        if ((stringlen = str_addarg(string, stringlen, errp->arg, first)) ==0)
        {
            return(err_listem);
        }
-       first = No;
+       first = false;
     }
 
     /* add final message */

Modified: head/usr.bin/top/display.c
==============================================================================
--- head/usr.bin/top/display.c  Sat Jun  2 02:06:48 2018        (r334513)
+++ head/usr.bin/top/display.c  Sat Jun  2 03:25:15 2018        (r334514)
@@ -33,6 +33,7 @@
 #include <curses.h>
 #include <ctype.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
 #include <strings.h>
@@ -44,7 +45,6 @@
 #include "layout.h"            /* defines for screen position layout */
 #include "display.h"
 #include "top.h"
-#include "boolean.h"
 #include "machine.h"           /* we should eliminate this!!! */
 #include "utils.h"
 
@@ -1147,7 +1147,7 @@ line_update(char *old, char *new, int start, int line)
     int diff;
     int newcol = start + 1;
     int lastcol = start;
-    char cursor_on_line = No;
+    char cursor_on_line = false;
     char *current;
 
     /* compare the two strings and only rewrite what has changed */
@@ -1172,7 +1172,7 @@ line_update(char *old, char *new, int start, int line)
        {
            Move_to(start, line);
        }
-       cursor_on_line = Yes;
+       cursor_on_line = true;
        putchar(ch);
        *old = ch;
        lastcol = 1;
@@ -1209,7 +1209,7 @@ line_update(char *old, char *new, int start, int line)
                {
                    /* use cursor addressing */
                    Move_to(newcol, line);
-                   cursor_on_line = Yes;
+                   cursor_on_line = true;
                }
                /* remember where the cursor is */
                lastcol = newcol + 1;

Modified: head/usr.bin/top/machine.c
==============================================================================
--- head/usr.bin/top/machine.c  Sat Jun  2 02:06:48 2018        (r334513)
+++ head/usr.bin/top/machine.c  Sat Jun  2 03:25:15 2018        (r334514)
@@ -35,6 +35,7 @@
 #include <paths.h>
 #include <pwd.h>
 #include <stdio.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
 #include <strings.h>
@@ -308,7 +309,7 @@ machine_init(struct statics *statics)
 {
        int i, j, empty, pagesize;
        uint64_t arc_size;
-       boolean_t carc_en;
+       bool carc_en;
        size_t size;
 
        size = sizeof(smpmode);

Modified: head/usr.bin/top/screen.c
==============================================================================
--- head/usr.bin/top/screen.c   Sat Jun  2 02:06:48 2018        (r334513)
+++ head/usr.bin/top/screen.c   Sat Jun  2 03:25:15 2018        (r334514)
@@ -30,7 +30,6 @@
 #include <curses.h>
 #include <termcap.h>
 #include "screen.h"
-#include "boolean.h"
 
 int  overstrike;
 int  screen_length;
@@ -54,7 +53,7 @@ static char *terminal_end;
 
 static struct termios old_settings;
 static struct termios new_settings;
-static char is_a_terminal = No;
+static char is_a_terminal = false;
 
 #define        STDIN   0
 #define        STDOUT  1
@@ -75,12 +74,12 @@ init_termcap(int interactive)
     if (!interactive)
     {
        /* pretend we have a dumb terminal */
-       smart_terminal = No;
+       smart_terminal = false;
        return;
     }
 
     /* assume we have a smart terminal until proven otherwise */
-    smart_terminal = Yes;
+    smart_terminal = true;
 
     /* get the terminal name */
     term_name = getenv("TERM");
@@ -89,7 +88,7 @@ init_termcap(int interactive)
     /* patch courtesy of Sam Horrocks at telegraph.ics.uci.edu */
     if (term_name == NULL)
     {
-       smart_terminal = No;
+       smart_terminal = false;
        return;
     }
 
@@ -107,14 +106,14 @@ init_termcap(int interactive)
        }
 
        /* pretend it's dumb and proceed */
-       smart_terminal = No;
+       smart_terminal = false;
        return;
     }
 
     /* "hardcopy" immediately indicates a very stupid terminal */
     if (tgetflag("hc"))
     {
-       smart_terminal = No;
+       smart_terminal = false;
        return;
     }
 
@@ -151,7 +150,7 @@ init_termcap(int interactive)
     if ((clear_screen  = tgetstr("cl", &bufptr)) == NULL ||
        (cursor_motion = tgetstr("cm", &bufptr)) == NULL)
     {
-       smart_terminal = No;
+       smart_terminal = false;
        return;
     }
 
@@ -178,7 +177,7 @@ init_termcap(int interactive)
     /* if stdout is not a terminal, pretend we are a dumb terminal */
     if (tcgetattr(STDOUT, &old_settings) == -1)
     {
-       smart_terminal = No;
+       smart_terminal = false;
     }
 }
 
@@ -203,7 +202,7 @@ init_screen(void)
        ch_kill  = old_settings.c_cc[VKILL];
 
        /* remember that it really is a terminal */
-       is_a_terminal = Yes;
+       is_a_terminal = true;
 
        /* send the termcap initialization string */
        putcap(terminal_init);
@@ -212,7 +211,7 @@ init_screen(void)
     if (!is_a_terminal)
     {
        /* not a terminal at all---consider it dumb */
-       smart_terminal = No;
+       smart_terminal = false;
     }
 }
 

Modified: head/usr.bin/top/top.1
==============================================================================
--- head/usr.bin/top/top.1      Sat Jun  2 02:06:48 2018        (r334513)
+++ head/usr.bin/top/top.1      Sat Jun  2 03:25:15 2018        (r334514)
@@ -145,7 +145,7 @@ numbers are displayed instead of the names.
 .TP
 .B \-v
 Write version number information to stderr then exit immediately.
-No other processing takes place when this option is used.  To see current
+false other processing takes place when this option is used.  To see current
 revision information while top is running, use the help command \*(lq?\*(rq.
 .TP
 .B \-w

Modified: head/usr.bin/top/top.c
==============================================================================
--- head/usr.bin/top/top.c      Sat Jun  2 02:06:48 2018        (r334513)
+++ head/usr.bin/top/top.c      Sat Jun  2 03:25:15 2018        (r334514)
@@ -31,7 +31,6 @@
 #include "display.h"           /* interface to display package */
 #include "screen.h"            /* interface to screen package */
 #include "top.h"
-#include "boolean.h"
 #include "machine.h"
 #include "utils.h"
 #include "username.h"
@@ -52,7 +51,7 @@ static char stdoutbuf[Buffersize];
 
 
 static int fmt_flags = 0;
-int pcpu_stats = No;
+int pcpu_stats = false;
 
 /* signal handling routines */
 static sigret_t leave(int);
@@ -140,7 +139,7 @@ handle_user(char *buf, size_t buflen)
     char *buf2 = buf;
 
     new_message(MT_standout, "Username to show (+ for all): ");
-    if (readline(buf, buflen, No) <= 0)
+    if (readline(buf, buflen, false) <= 0)
     {
        clear_message();
        return rc;
@@ -215,11 +214,11 @@ main(int argc, char *argv[])
     int  preset_argc = 0;
     char **av;
     int  ac;
-    char dostates = No;
-    char do_unames = Yes;
-    char interactive = Maybe;
+    bool dostates = false;
+    bool do_unames = true;
+    char interactive = 2;
     char warnings = 0;
-    char topn_specified = No;
+    char topn_specified = false;
     char ch;
     char *iptr;
     char no_command = 1;
@@ -282,16 +281,16 @@ main(int argc, char *argv[])
     }
 
     /* initialize some selection options */
-    ps.idle    = Yes;
+    ps.idle    = true;
     ps.self    = -1;
-    ps.system  = No;
+    ps.system  = false;
     reset_uids();
-    ps.thread  = No;
+    ps.thread  = false;
     ps.wcpu    = 1;
     ps.jid     = -1;
-    ps.jail    = No;
-    ps.swap    = No;
-    ps.kidle   = Yes;
+    ps.jail    = false;
+    ps.swap    = false;
+    ps.kidle   = true;
     ps.command = NULL;
 
     /* get preset options from the environment */
@@ -347,12 +346,12 @@ main(int argc, char *argv[])
                break;
 
              case 'i':                 /* go interactive regardless */
-               interactive = Yes;
+               interactive = 1;
                break;
 
              case 'n':                 /* batch, or non-interactive */
              case 'b':
-               interactive = No;
+               interactive = 0;
                break;
 
              case 'a':
@@ -476,7 +475,7 @@ main(int argc, char *argv[])
            }
             else
            {
-               topn_specified = Yes;
+               topn_specified = true;
            }
        }
 
@@ -563,7 +562,7 @@ main(int argc, char *argv[])
     display_header(topn > 0);
 
     /* determine interactive state */
-    if (interactive == Maybe)
+    if (interactive == 2)
     {
        interactive = smart_terminal;
     }
@@ -641,7 +640,7 @@ restart:
            {
                putchar('\n');
            }
-           dostates = Yes;
+           dostates = true;
        }
 
        /* display memory stats */
@@ -722,7 +721,7 @@ restart:
                }
            }
     
-           no_command = Yes;
+           no_command = true;
            if (!interactive)
            {
                sleep(delay);
@@ -734,7 +733,7 @@ restart:
            else while (no_command)
            {
                /* assume valid command unless told otherwise */
-               no_command = No;
+               no_command = false;
 
                /* set up arguments for select with timeout */
                FD_ZERO(&readfds);
@@ -814,7 +813,7 @@ restart:
                            new_message(MT_standout, " Command not understood");
                        }
                        putchar('\r');
-                       no_command = Yes;
+                       no_command = true;
                    }
                    else
                    {
@@ -825,7 +824,7 @@ restart:
                            new_message(MT_standout,
                            " Command cannot be handled by this terminal");
                            putchar('\r');
-                           no_command = Yes;
+                           no_command = true;
                        }
                        else switch(change)
                        {
@@ -864,7 +863,7 @@ restart:
                                    new_message(MT_standout,
                                        " Currently no errors to report.");
                                    putchar('\r');
-                                   no_command = Yes;
+                                   no_command = true;
                                }
                                else
                                {
@@ -881,7 +880,7 @@ restart:
                            case CMD_number2:
                                new_message(MT_standout,
                                    "Number of processes to show: ");
-                               newval = readline(tempbuf1, 8, Yes);
+                               newval = readline(tempbuf1, 8, true);
                                if (newval > -1)
                                {
                                    if (newval > max_topn)
@@ -895,12 +894,12 @@ restart:
                                    if (newval == 0)
                                    {
                                        /* inhibit the header */
-                                       display_header(No);
+                                       display_header(false);
                                    }
                                    else if (newval > topn && topn == 0)
                                    {
                                        /* redraw the header */
-                                       display_header(Yes);
+                                       display_header(true);
                                        d_header = i_header;
                                    }
                                    topn = newval;
@@ -909,7 +908,7 @@ restart:
            
                            case CMD_delay:     /* new seconds delay */
                                new_message(MT_standout, "Seconds to delay: ");
-                               if ((i = readline(tempbuf1, 8, Yes)) > -1)
+                               if ((i = readline(tempbuf1, 8, true)) > -1)
                                {
                                    if ((delay = i) == 0 && getuid() != 0)
                                    {
@@ -924,7 +923,7 @@ restart:
                                        "Displays to show (currently %s): ",
                                        displays == -1 ? "infinite" :
                                                         itoa(displays));
-                               if ((i = readline(tempbuf1, 10, Yes)) > 0)
+                               if ((i = readline(tempbuf1, 10, true)) > 0)
                                {
                                    displays = i;
                                }
@@ -937,13 +936,13 @@ restart:
     
                            case CMD_kill:      /* kill program */
                                new_message(0, "kill ");
-                               if (readline(tempbuf2, sizeof(tempbuf2), No) > 
0)
+                               if (readline(tempbuf2, sizeof(tempbuf2), false) 
> 0)
                                {
                                    if ((errmsg = kill_procs(tempbuf2)) != NULL)
                                    {
                                        new_message(MT_standout, "%s", errmsg);
                                        putchar('\r');
-                                       no_command = Yes;
+                                       no_command = true;
                                    }
                                }
                                else
@@ -954,13 +953,13 @@ restart:
            
                            case CMD_renice:    /* renice program */
                                new_message(0, "renice ");
-                               if (readline(tempbuf2, sizeof(tempbuf2), No) > 
0)
+                               if (readline(tempbuf2, sizeof(tempbuf2), false) 
> 0)
                                {
                                    if ((errmsg = renice_procs(tempbuf2)) != 
NULL)
                                    {
                                        new_message(MT_standout, "%s", errmsg);
                                        putchar('\r');
-                                       no_command = Yes;
+                                       no_command = true;
                                    }
                                }
                                else
@@ -988,7 +987,7 @@ restart:
 
                            case CMD_user:
                                if (handle_user(tempbuf2, sizeof(tempbuf2)))
-                                   no_command = Yes;
+                                   no_command = true;
                                break;
            
                            case CMD_thrtog:
@@ -1013,7 +1012,7 @@ restart:
                                if (++displaymode == DISP_MAX)
                                        displaymode = 0;
                                header_text = format_header(uname_field);
-                               display_header(Yes);
+                               display_header(true);
                                d_header = i_header;
                                reset_display();
                                break;
@@ -1026,13 +1025,13 @@ restart:
                            case CMD_order:
                                new_message(MT_standout,
                                    "Order to sort: ");
-                               if (readline(tempbuf2, sizeof(tempbuf2), No) > 
0)
+                               if (readline(tempbuf2, sizeof(tempbuf2), false) 
> 0)
                                {
                                  if ((i = string_index(tempbuf2, 
statics.order_names)) == -1)
                                        {
                                          new_message(MT_standout,
                                              " %s: unrecognized sorting 
order", tempbuf2);
-                                         no_command = Yes;
+                                         no_command = true;
                                    }
                                    else
                                    {
@@ -1058,7 +1057,7 @@ restart:
                            case CMD_jail:
                                new_message(MT_standout,
                                    "Jail to show (+ for all): ");
-                               if (readline(tempbuf2, sizeof(tempbuf2), No) > 
0)
+                               if (readline(tempbuf2, sizeof(tempbuf2), false) 
> 0)
                                {
                                    if (tempbuf2[0] == '+' &&
                                        tempbuf2[1] == '\0')
@@ -1069,7 +1068,7 @@ restart:
                                    {
                                        new_message(MT_standout,
                                            " %s: unknown jail", tempbuf2);
-                                       no_command = Yes;
+                                       no_command = true;
                                    }
                                    else
                                    {
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to