summaryrefslogtreecommitdiff
path: root/misc/fep/patches/patch-ac
blob: f2e2a3307fe1d017fa1aee0d9b54ffb1d7ac15cf (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
$NetBSD: patch-ac,v 1.1 2000/02/07 03:18:10 christos Exp $

--- fep_com.c.orig	Wed May 29 01:31:09 1991
+++ fep_com.c	Sun Feb  6 21:47:53 2000
@@ -6,7 +6,17 @@
 #endif lint
 
 #include <stdio.h>
+#include <sys/ioctl.h>
+#ifdef TERMIOS
+#include <termios.h>
+#ifdef __linux__
+#ifndef _POSIX_VDISABLE
+#define _POSIX_VDISABLE '\0'
+#endif
+#endif
+#else
 #include <sgtty.h>
+#endif
 #include <ctype.h>
 #include <sys/param.h>
 #include <sys/file.h>
@@ -31,7 +41,7 @@
     char *comline, **more;
 {
     register FunctionTableEnt *ftp;
-    char linebuf[MAXCOMLEN], *line;
+    char linebuf[MAXCMDLEN], *line;
     char *search_string();
     int argc;
 
@@ -93,7 +103,7 @@
 
     while (*a && *b && *a == *b)
 	++a, ++b;
-    if ((*a == NULL || isspace (*a)) && (*b == NULL || isspace (*b)))
+    if ((*a == '\0' || isspace ((unsigned char)*a)) && (*b == '\0' || isspace ((unsigned char)*b)))
 	return 1;
     else
 	return 0;
@@ -295,7 +305,7 @@
 set (comline)
     char *comline;
 {
-    char line[MAXCOMLEN];
+    char line[MAXCMDLEN];
     char *cp, *index();
     char *argv[MAXARGS];
     int argc;
@@ -352,8 +362,13 @@
 
 extern	int Transparency;
 extern	int Through;
-extern	struct sgttyb slave_ttymode;
-extern	struct sgttyb master_ttymode;
+#ifdef TERMIOS
+#define ttystruct termios
+#elif defined(TIOCSETN)
+#define ttystruct sgttyb
+#endif
+struct	ttystruct master_ttymode;		/* master tty mode */
+struct	ttystruct slave_ttymode;		/* slave tty mode */
 extern	int master, slave;
 extern	char slave_tty[];
 
@@ -368,7 +383,11 @@
 {
     int r;
     int slave_fd;
+#ifdef TERMIOS
+    struct termios s;
+#else
     struct sgttyb s;
+#endif
 
     if (Through == OFF) {
 
@@ -378,15 +397,26 @@
 	    return;
 	}
 
+#ifdef TERMIOS
+	r = tcgetattr(slave_fd, &s);
+#else
 	r = ioctl (slave_fd, TIOCGETP, (char *) &s);
+#endif
 	if (r < 0) {
 	    perror (slave_tty);
 	    (void) close (slave_fd);
 	    return;
 	}
 
+#ifdef TERMIOS
+	s.c_lflag &= ~(ICANON);
+	s.c_cc[VMIN] = 1;
+	s.c_cc[VTIME] = 0;
+	r = tcsetattr(0, TCSANOW, &s);
+#else
 	s.sg_flags |= CBREAK;
 	r = ioctl (0, TIOCSETN, (char *) & s);
+#endif
 	if (r < 0) {
 	    perror (slave_tty);
 	    (void) close (slave_fd);
@@ -394,7 +424,11 @@
 	(void) close (slave_fd);
     }
     else
+#ifdef TERMIOS
+	r = tcsetattr(0, TCSANOW, & master_ttymode);
+#else
 	r = ioctl (0, TIOCSETN, (char *) & master_ttymode);
+#endif
 
     if (r < 0) {
 	printf ("Can't change pty mode.\n");
@@ -410,7 +444,11 @@
 fix_transparency()
 {
     int r;
+#ifdef TERMIOS
+    struct termios s;
+#else
     struct sgttyb s;
+#endif
 
     if (Through)
 	return;
@@ -418,11 +456,17 @@
     if (slave < 0)
 	return;
 
+#ifdef TERMIOS
+    r = tcgetattr(slave, &s);
+    s.c_iflag |= ICRNL;
+    s.c_oflag |= ONLCR;
+#else
     r = ioctl (slave, TIOCGETP, (char *) &s);
     /*
      * slave CRMOD is off, but master should be.
      */
     s.sg_flags |= CRMOD;
+#endif
     if (r < 0) {
 	perror (slave_tty);
 	return;
@@ -432,9 +476,19 @@
      * If find slave tty mode is cbreak or raw, fix tty mode of stdout to
      * same mode as slave and set Transparency ON.
      */
-    if (s.sg_flags & (CBREAK|RAW)) {
+
+#ifdef TERMIOS
+    if ((s.c_lflag & ICANON) == 0)
+#else
+    if (s.sg_flags & (CBREAK|RAW))
+#endif
+    {
 	if (Transparency == OFF) {
+#ifdef TERMIOS
+	    r = tcsetattr(0, TCSANOW, & s);
+#else
 	    r = ioctl (0, TIOCSETN, (char *) & s);
+#endif
 	    if (r < 0) {
 		perror ("stdout");
 		return;
@@ -445,7 +499,11 @@
     }
     else {
 	if (Transparency == ON) {
-	    r = ioctl (0, TIOCSETN, (char *) &master_ttymode);
+#ifdef TERMIOS
+	    r = tcsetattr(0, TCSANOW, & master_ttymode);
+#else
+	    r = ioctl (0, TIOCSETN, (char *) & master_ttymode);
+#endif
 	    if (r < 0) {
 		perror ("stdout");
 		return;
@@ -738,9 +796,9 @@
 fep_pwd (line)
     char *line;
 {
-    char cwd[MAXPATHLEN], *getwd();
+    char cwd[MAXPATHLEN];
 
-    (void) getwd (cwd);
+    (void) getcwd (cwd, sizeof(cwd));
     printf ("%s\n", cwd);
 }
 
@@ -755,7 +813,7 @@
     argc = mkargv (comline, argv, MAXARGS);
     
     argp = &argv[1];
-    if (*argp && strcmp (*argp, "-n") == NULL) {
+    if (*argp && strcmp (*argp, "-n") == 0) {
 	putnewline = 0;
 	++argp;
     }
@@ -791,7 +849,7 @@
     int argc;
     int i;
     char **argp;
-    char *buf[256];
+    char buf[256];
 
     argc = mkargv (comline, argv, MAXARGS);