svn commit: r332948 - stable/11/contrib/top
Kurt Lidl
lidl at FreeBSD.org
Tue Apr 24 17:37:31 UTC 2018
Author: lidl
Date: Tue Apr 24 17:37:29 2018
New Revision: 332948
URL: https://svnweb.freebsd.org/changeset/base/332948
Log:
MFC r332671: top: fix warnings from clang/gcc
Add includes for <curses.h> and <termcap.h> where necessary, and
rename a few internal functions to have a "top_" prefix to avoid
clashes with standard names from curses.h/termcap.h headers.
Top now compiles without warnings on both gcc and clang.
Modified:
stable/11/contrib/top/display.c
stable/11/contrib/top/screen.c
stable/11/contrib/top/screen.h
stable/11/contrib/top/top.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/contrib/top/display.c
==============================================================================
--- stable/11/contrib/top/display.c Tue Apr 24 17:35:13 2018 (r332947)
+++ stable/11/contrib/top/display.c Tue Apr 24 17:37:29 2018 (r332948)
@@ -32,7 +32,9 @@
#include <sys/time.h>
+#include <curses.h>
#include <ctype.h>
+#include <termcap.h>
#include <time.h>
#include <unistd.h>
@@ -255,7 +257,7 @@ double *avenrun;
register int i;
/* i_loadave also clears the screen, since it is first */
- clear();
+ top_clear();
/* mpid == -1 implies this system doesn't have an _mpid */
if (mpid != -1)
@@ -796,7 +798,7 @@ i_message()
}
if (next_msg[0] != '\0')
{
- standout(next_msg);
+ top_standout(next_msg);
msglen = strlen(next_msg);
next_msg[0] = '\0';
}
@@ -1076,7 +1078,7 @@ caddr_t a1, a2, a3;
i = strlen(next_msg);
if ((type & MT_delayed) == 0)
{
- type & MT_standout ? standout(next_msg) :
+ type & MT_standout ? top_standout(next_msg) :
fputs(next_msg, stdout);
(void) clear_eol(msglen - i);
msglen = i;
@@ -1088,7 +1090,7 @@ caddr_t a1, a2, a3;
{
if ((type & MT_delayed) == 0)
{
- type & MT_standout ? standout(next_msg) : fputs(next_msg, stdout);
+ type & MT_standout ? top_standout(next_msg) : fputs(next_msg, stdout);
msglen = strlen(next_msg);
next_msg[0] = '\0';
}
Modified: stable/11/contrib/top/screen.c
==============================================================================
--- stable/11/contrib/top/screen.c Tue Apr 24 17:35:13 2018 (r332947)
+++ stable/11/contrib/top/screen.c Tue Apr 24 17:37:29 2018 (r332948)
@@ -45,6 +45,8 @@
# endif
# endif
#endif
+#include <curses.h>
+#include <termcap.h>
#include "screen.h"
#include "boolean.h"
@@ -432,10 +434,7 @@ get_screensize()
}
void
-standout(msg)
-
-char *msg;
-
+top_standout(char *msg)
{
if (smart_terminal)
{
@@ -450,8 +449,7 @@ char *msg;
}
void
-clear()
-
+top_clear()
{
if (smart_terminal)
{
@@ -460,10 +458,7 @@ clear()
}
int
-clear_eol(len)
-
-int len;
-
+clear_eol(int len)
{
if (smart_terminal && !overstrike && len > 0)
{
@@ -496,12 +491,8 @@ go_home()
/* This has to be defined as a subroutine for tputs (instead of a macro) */
-void
-putstdout(ch)
-
-char ch;
-
+int
+putstdout(int ch)
{
- putchar(ch);
+ return putchar(ch);
}
-
Modified: stable/11/contrib/top/screen.h
==============================================================================
--- stable/11/contrib/top/screen.h Tue Apr 24 17:35:13 2018 (r332947)
+++ stable/11/contrib/top/screen.h Tue Apr 24 17:37:29 2018 (r332948)
@@ -28,10 +28,10 @@ extern int screen_length;
extern int screen_width;
/* a function that puts a single character on stdout */
-void putstdout(char ch);
+int putstdout(int ch);
int clear_eol(int len);
-void standout(char *msg);
-void clear(void);
+void top_standout(char *msg);
+void top_clear(void);
void go_home(void);
void reinit_screen(void);
void get_screensize(void);
Modified: stable/11/contrib/top/top.c
==============================================================================
--- stable/11/contrib/top/top.c Tue Apr 24 17:35:13 2018 (r332947)
+++ stable/11/contrib/top/top.c Tue Apr 24 17:37:29 2018 (r332948)
@@ -39,6 +39,7 @@ char *copyright =
#include <sys/time.h>
#include <ctype.h>
+#include <curses.h>
#include <errno.h>
#include <jail.h>
#include <setjmp.h>
@@ -79,7 +80,7 @@ int pcpu_stats = No;
sigret_t leave();
sigret_t tstop();
#ifdef SIGWINCH
-sigret_t winch();
+sigret_t top_winch(int);
#endif
volatile sig_atomic_t leaveflag;
@@ -681,7 +682,7 @@ char *argv[];
(void) signal(SIGQUIT, leave);
(void) signal(SIGTSTP, tstop);
#ifdef SIGWINCH
- (void) signal(SIGWINCH, winch);
+ (void) signal(SIGWINCH, top_winch);
#endif
#ifdef SIGRELSE
sigrelse(SIGINT);
@@ -896,7 +897,7 @@ restart:
max_topn = display_resize();
/* reset the signal handler */
- (void) signal(SIGWINCH, winch);
+ (void) signal(SIGWINCH, top_winch);
reset_display();
winchflag = 0;
@@ -970,9 +971,9 @@ restart:
case CMD_help1: /* help */
case CMD_help2:
reset_display();
- clear();
+ top_clear();
show_help();
- standout("Hit any key to continue: ");
+ top_standout("Hit any key to continue: ");
fflush(stdout);
(void) read(0, &ch, 1);
break;
@@ -988,9 +989,9 @@ restart:
else
{
reset_display();
- clear();
+ top_clear();
show_errors();
- standout("Hit any key to continue: ");
+ top_standout("Hit any key to continue: ");
fflush(stdout);
(void) read(0, &ch, 1);
}
@@ -1299,10 +1300,7 @@ int i;
}
#ifdef SIGWINCH
-sigret_t winch(i) /* SIGWINCH handler */
-
-int i;
-
+sigret_t top_winch(int i) /* SIGWINCH handler */
{
winchflag = 1;
}
More information about the svn-src-stable-11
mailing list