summaryrefslogtreecommitdiff
path: root/x11/hanterm/patches/patch-ae
blob: dd8b5edc6d32e9cfea0e805e572a8a7eacbc2319 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
$NetBSD: patch-ae,v 1.5 2014/09/22 11:56:39 joerg Exp $

- avoid union wait
- force termios on all modern systems
- declare void functions void
- avoid implicit int
- don't declare own errno
- fix os conditionals (apparently with respect to VMS)
- call execl() and execlp() correctly
- don't synthesize vsprintf with fake arguments
- use ctype.h functions correctly

--- main.c.orig	2002-01-09 00:41:11.000000000 +0000
+++ main.c
@@ -63,15 +63,7 @@ SOFTWARE.
 #include <X11/Xaw/SimpleMenu.h>
 #include <pwd.h>
 #include <ctype.h>
-#ifdef linux
-#ifdef	__GLIBC__
-#if	__GLIBC_MINOR__<1
-#include <termbits.h>
-#else
 #include <termios.h>
-#endif	/* __GLIBC_MINOR__ */
-#endif	/* __GLIBC__ */
-#endif
 
 #ifdef DGUX /* dkim@surecom.com */
 /* DGUX is SVR4 but its SYSV side of TTY has bugs in it */
@@ -239,8 +231,18 @@ static Bool IsPts = False;
 #ifdef SVR4
 #define USE_POSIX_WAIT
 #endif
+#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \
+    defined(__DragonFly__) || defined(__linux__)
+#ifndef USE_POSIX_WAIT
+#define USE_POSIX_WAIT
+#endif
+#ifndef USE_TERMIOS
+#define USE_TERMIOS
+#endif
+#endif
 
 #include <stdio.h>
+#include <stdarg.h>
 #include <errno.h>
 #include <setjmp.h>
 
@@ -391,6 +393,9 @@ extern char *ptsname();
 extern char *strindex ();
 extern void HandlePopupMenu();
 
+static void get_terminal (void);
+static void resize(TScreen *screen, char *TermName, char *oldtc, char *newtc);
+
 int switchfb[] = {0, 2, 1, 3};
 
 static SIGNAL_T reapchild ();
@@ -583,6 +588,8 @@ static int tslot;
 #endif	/* USE_SYSV_UTMP */
 static jmp_buf env;
 
+static void spawn (void);
+
 char *ProgramName;
 Boolean sunFunctionKeys;
 
@@ -805,9 +812,9 @@ static char *message[] = {
 "will be started.  Options that start with a plus sign (+) restore the default.",
 NULL};
 
-#ifndef USE_TERMIOS
-static remove_termcap_entry ();
-#endif
+/*#ifndef USE_TERMIOS*/
+static void remove_termcap_entry (char *, const char *);
+/*#endif*/
 
 static int abbrev (tst, cmp)
   char *tst, *cmp;
@@ -816,7 +823,7 @@ static int abbrev (tst, cmp)
     return ((len >= 2) && (!strncmp(tst, cmp, len)));
 }
 
-static Syntax (badOption)
+static void Syntax (badOption)
     char *badOption;
 {
     struct _options *opt;
@@ -842,13 +849,13 @@ static Syntax (badOption)
     exit (1);
 }
 
-static Version ()
+static void Version ()
 {
     printf("%s %s %s %s\n", HANTERM_PRODUCT, HANTERM_VERSION,
 	    HANTERM_RELEASE, HANTERM_RELEASEDATE);
     exit (0);
 }
-static Help ()
+static void Help ()
 {
     struct _options *opt;
     char **cpp;
@@ -960,6 +967,7 @@ XtActionsRec actionProcs[] = {
 
 Atom wm_delete_window;
 
+int
 main (argc, argv)
 int argc;
 char **argv;
@@ -1527,7 +1535,8 @@ char **argv;
 	if (ioctl (pty, FIONBIO, (char *)&mode) == -1) SysError (ERROR_FIONBIO);
 #endif	/* USE_SYSV_TERMIO */
 	
-#if defined(linux)||defined(SVR4)||(defined(hpux)&&OSMAJORVERSION>=10)
+
+#ifndef VMS
 	pty_mask = pty;
 	X_mask = Xsocket;
 	FD_ZERO(&Select_mask);
@@ -1566,6 +1575,7 @@ char *name;
  * has problems, we can re-enter this function and get another one.
  */
 
+int
 get_pty (pty)
     int *pty;
 {
@@ -1730,6 +1740,7 @@ int pty_search(pty)
     return 1;
 }
 
+static void
 get_terminal ()
 /* 
  * sets up X and initializes the terminal structure except for term.buf.fildes.
@@ -1854,7 +1865,7 @@ void first_map_occurred ()
 #endif /* USE_HANDSHAKE else !USE_HANDSHAKE */
 
 
-spawn ()
+static void spawn (void)
 /* 
  *  Inits pty and tty and forks a login process.
  *  Does not close fd Xsocket.
@@ -2983,10 +2994,10 @@ spawn ()
 
 #ifdef USE_LOGIN_DASH_P
 		if (term->misc.login_shell && pw && added_utmp_entry)
-		  execl (bin_login, "login", "-p", "-f", pw->pw_name, 0);
+		  execl (bin_login, "login", "-p", "-f", pw->pw_name, (void *)NULL);
 #endif
 		execlp (ptr, (term->misc.login_shell ? shname_minus : shname),
-			0);
+			(void *)NULL);
 
 		/* Exec failed. */
 		fprintf (stderr, "%s: Could not exec %s!\n", xterm_name, ptr);
@@ -3235,10 +3246,8 @@ Exit(n)
 }
 
 /* ARGSUSED */
-resize(screen, TermName, oldtc, newtc)
-TScreen *screen;
-char *TermName;
-register char *oldtc, *newtc;
+static void
+resize(TScreen *screen, char *TermName, char *oldtc, char *newtc)
 {
 #ifndef USE_SYSV_ENVVARS
 	register char *ptr1, *ptr2;
@@ -3329,18 +3338,20 @@ static SIGNAL_T reapchild (n)
 }
 
 /* VARARGS1 */
-consolepr(fmt,x0,x1,x2,x3,x4,x5,x6,x7,x8,x9)
-char *fmt;
+void
+consolepr(const char *fmt, ...)
 {
-	extern int errno;
 	extern char *SysErrorMsg();
 	int oerrno;
 	int f;
  	char buf[ BUFSIZ ];
+	va_list ap;
 
 	oerrno = errno;
  	strcpy(buf, "hanterm: ");
- 	sprintf(buf+strlen(buf), fmt, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9);
+	va_start(ap, fmt);
+ 	vsnprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), fmt, ap);
+	va_end(ap);
  	strcat(buf, ": ");
  	strcat(buf, SysErrorMsg (oerrno));
  	strcat(buf, "\n");	
@@ -3356,10 +3367,8 @@ char *fmt;
 }
 
 
-#ifndef USE_TERMIOS
-static remove_termcap_entry (buf, str)
-    char *buf;
-    char *str;
+/*#ifndef USE_TERMIOS*/
+static void remove_termcap_entry (char *buf, const char *str)
 {
     register char *strinbuf;
 
@@ -3377,7 +3386,7 @@ static remove_termcap_entry (buf, str)
     }
     return;
 }
-#endif
+/*#endif*/
 
 /*
  * parse_tty_modes accepts lines of the following form:
@@ -3396,7 +3405,8 @@ static int parse_tty_modes (s, modelist)
     int count = 0;
 
     while (1) {
-	while (*s && isascii(*s) && isspace(*s)) s++;
+	while (*s && isascii((unsigned char)*s) && isspace((unsigned char)*s))
+	    s++;
 	if (!*s) return count;
 
 	for (mp = modelist; mp->name; mp++) {