122 lines
2.7 KiB
Text
122 lines
2.7 KiB
Text
$NetBSD: patch-ag,v 1.6 2014/09/23 22:40:27 jperkin Exp $
|
|
|
|
- needs term.h for termcap
|
|
- get terminal size from termcap only if LINES and COLUMNS aren't set
|
|
in the environment
|
|
- return values from non-void functions
|
|
(arguably these should be made void but it causes complications)
|
|
- don't use implicit int
|
|
- add missing conditionals around conditionally-used declaration
|
|
- remove unused variables
|
|
- use correct type signature for signal handler
|
|
- use time_t for calling time()
|
|
|
|
--- src/unix.c.orig 1995-11-18 16:36:58.000000000 +0000
|
|
+++ src/unix.c
|
|
@@ -123,6 +123,9 @@ int scnothing()
|
|
#include <curses.h> /* Curses screen output */
|
|
#undef WINDOW /* Oh no! */
|
|
#endif /* CURSES */
|
|
+#ifndef __sun
|
|
+#include <termcap.h>
|
|
+#endif
|
|
|
|
/** Completion include files **/
|
|
/** Directory accessing: Try and figure this out... if you can! **/
|
|
@@ -816,9 +819,19 @@ int scopen()
|
|
exit(1);
|
|
}
|
|
|
|
- /* Get size from termcap */
|
|
- term.t_nrow = tgetnum("li") - 1;
|
|
- term.t_ncol = tgetnum("co");
|
|
+ /*
|
|
+ * If LINES and/or COLUMNS are set in the environment then use those
|
|
+ * values, otherwise get them from termcap.
|
|
+ */
|
|
+ if ((cp = getenv("LINES")) == NULL || sscanf(cp, "%hd",
|
|
+ &term.t_nrow) != 1)
|
|
+ term.t_nrow = tgetnum("li");
|
|
+ term.t_nrow -= 1;
|
|
+
|
|
+ if ((cp = getenv("COLUMNS")) == NULL || sscanf(cp, "%hd",
|
|
+ &term.t_ncol) != 1)
|
|
+ term.t_ncol = tgetnum("co");
|
|
+
|
|
if (term.t_nrow < 3 || term.t_ncol < 3) {
|
|
puts("Screen size is too small!");
|
|
exit(1);
|
|
@@ -956,6 +969,7 @@ int sckopen()
|
|
dis_ufk();
|
|
#endif
|
|
#endif
|
|
+ return 0;
|
|
}
|
|
|
|
/* close keyboard -hm */
|
|
@@ -968,6 +982,7 @@ int sckclose()
|
|
dis_sfk();
|
|
#endif
|
|
#endif
|
|
+ return 0;
|
|
}
|
|
|
|
/** Move cursor **/
|
|
@@ -1063,7 +1078,7 @@ int state; /* New state */
|
|
}
|
|
|
|
/** Beep **/
|
|
-scbeep()
|
|
+int scbeep()
|
|
{
|
|
#if TERMCAP || TERMIOS
|
|
#if !NOISY
|
|
@@ -1085,7 +1100,9 @@ scbeep()
|
|
}
|
|
|
|
#if COLOR
|
|
+#if USG || AUX
|
|
static char cmap[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
|
|
+#endif
|
|
|
|
/** Set foreground color **/
|
|
int scfcol(color)
|
|
@@ -1230,11 +1247,9 @@ int bktoshell(f, n)
|
|
/** Get time of day **/
|
|
char * timeset()
|
|
{
|
|
- long int buf; /* Should be time_t */
|
|
+ time_t buf;
|
|
char * sp, * cp;
|
|
|
|
- char * ctime();
|
|
-
|
|
/* Get system time */
|
|
time(&buf);
|
|
|
|
@@ -1553,7 +1568,6 @@ char *fspec; /* Filename specificatio
|
|
/** Get next filename from pattern **/
|
|
char *getnfile()
|
|
{
|
|
- int index;
|
|
struct DIRENTRY * dp;
|
|
struct stat fstat;
|
|
|
|
@@ -1706,15 +1720,15 @@ char *name; /* name of directory to dele
|
|
/*
|
|
* Window size changes handled via signals.
|
|
*/
|
|
-void winch_changed()
|
|
+void winch_changed(int sig)
|
|
{
|
|
+ (void)sig;
|
|
signal(SIGWINCH,winch_changed);
|
|
winch_flag = 1;
|
|
}
|
|
|
|
void winch_new_size()
|
|
{
|
|
- EWINDOW *wp;
|
|
struct winsize win;
|
|
|
|
winch_flag=0;
|