summaryrefslogtreecommitdiff
blob: ac98999f3e883860d1e154a1ebc987e358d76dee (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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
diff --minimal -ruw csh/csh.c csh/csh.c
--- csh/csh.c	2003-05-28 21:32:36.000000000 +0100
+++ csh/csh.c	2003-05-28 21:31:51.000000000 +0100
@@ -102,9 +102,9 @@
 
 extern char **environ;
 
-static int readf(void *, char *, int);
-static fpos_t seekf(void *, fpos_t, int);
-static int writef(void *, const char *, int);
+static ssize_t readf(void *, char *, size_t);
+static int     seekf(void *, off_t, int);
+static ssize_t writef(void *, const char *, size_t);
 static int closef(void *);
 static int srccat(Char *, Char *);
 static int srcfile(char *, bool, bool);
@@ -124,6 +124,7 @@
     Char *cp;
     char *tcp, **tempv;
     const char *ecp;
+	cookie_io_functions_t cookie;
     sigset_t sigset;
     int f;
 
@@ -131,7 +132,7 @@
     cshout = stdout;
     csherr = stderr;
 
-    setprogname(argv[0]);
+    /* setprogname(argv[0]); */ 
     settimes();			/* Immed. estab. timing base */
 
     /*
@@ -215,14 +216,15 @@
      *	    Fortunately this is not needed under the current implementation
      *	    of stdio.
      */
-    (void)fclose(cshin);
-    (void)fclose(cshout);
-    (void)fclose(csherr);
-    if (!(cshin  = funopen((void *) &SHIN,  readf, writef, seekf, closef)))
+	cookie.read  = readf;
+	cookie.write = writef;
+	cookie.seek  = seekf;
+	cookie.close = closef;
+	if (!(cshin  = fopencookie((void *) &SHIN,  "r", cookie)))
 	exit(1);
-    if (!(cshout = funopen((void *) &SHOUT, readf, writef, seekf, closef)))
+	if (!(cshout = fopencookie((void *) &SHOUT, "w", cookie)))
 	exit(1);
-    if (!(csherr = funopen((void *) &SHERR, readf, writef, seekf, closef)))
+	if (!(csherr = fopencookie((void *) &SHERR, "w", cookie)))
 	exit(1);
     (void)setvbuf(cshin,  NULL, _IOLBF, 0);
     (void)setvbuf(cshout, NULL, _IOLBF, 0);
@@ -1241,21 +1243,21 @@
  */
 #define DESC(a) (*((int *) (a)) - (didfds && *((int *) a) >= FSHIN ? FSHIN : 0))
 
-static int
-readf(void *oreo, char *buf, int siz)
+static ssize_t
+readf(void *oreo, char *buf, size_t siz)
 {
     return read(DESC(oreo), buf, siz);
 }
 
 
-static int
-writef(void *oreo, const char *buf, int siz)
+static ssize_t
+writef(void *oreo, const char *buf, size_t siz)
 {
     return write(DESC(oreo), buf, siz);
 }
 
-static fpos_t
-seekf(void *oreo, fpos_t off, int whence)
+static int
+seekf(void *oreo, off_t off, int whence)
 {
     return lseek(DESC(oreo), off, whence);
 }
diff --minimal -ruw csh/dir.c csh/dir.c
--- csh/dir.c	2003-05-28 21:32:36.000000000 +0100
+++ csh/dir.c	2003-05-28 21:31:51.000000000 +0100
@@ -854,7 +854,7 @@
     if (p1 && *p1 == '/' &&
 	(Strncmp(p1, cp, cc) != 0 || (cp[cc] != '/' && cp[cc] != '\0'))) {
 	static ino_t home_ino;
-	static dev_t home_dev = NODEV;
+	static dev_t home_dev = -1;
 	static Char *home_ptr = NULL;
 	struct stat statbuf;
 
diff --minimal -ruw csh/extern.h /tmp/csh/extern.h
--- csh/extern.h	2003-05-28 21:32:36.000000000 +0100
+++ csh/extern.h	2003-05-28 21:31:51.000000000 +0100
@@ -39,6 +39,13 @@
 #define _EXTERN_H_
 
 #include <sys/cdefs.h>
+#include <stdio_ext.h>
+
+#define fpurge __fpurge
+
+size_t strlcpy(char *, const char *, size_t);
+
+extern const char *const sys_signame[];
 
 /*
  * csh.c
diff --minimal -ruw csh/func.c csh/func.c
--- csh/func.c	2003-05-28 21:32:36.000000000 +0100
+++ csh/func.c	2003-05-28 21:31:51.000000000 +0100
@@ -50,6 +50,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <errno.h>
 
 #if __STDC__
 # include <stdarg.h>
@@ -63,6 +64,7 @@
 
 extern char **environ;
 extern int progprintf(int, char **);
+extern int errno;
 
 static void islogin(void);
 static void reexecute(struct command *);
@@ -1428,8 +1430,8 @@
     int ret;
 
     ret = progprintf(blklen(v), c = short2blk(v));
-    (void)fflush(cshout);
-    (void)fflush(csherr);
+    (void)fflush(stdout);
+    (void)fflush(stderr);
 
     blkfree((Char **) c);
     if (ret)
diff --minimal -ruw csh/glob.c csh/glob.c
--- csh/glob.c	2003-05-28 21:32:36.000000000 +0100
+++ csh/glob.c	2003-05-28 21:31:51.000000000 +0100
@@ -402,7 +402,8 @@
 
     do {
 	ptr = short2qstr(*vl);
-	switch (glob(ptr, gflgs, 0, &globv)) {
+	switch (glob(ptr, nonomatch || glob_pattern_p(ptr, 1)
+		? gflgs : gflgs | GLOB_NOCHECK, 0, &globv)) {
 	case GLOB_ABORTED:
 	    setname(vis_str(*vl));
 	    stderror(ERR_NAME | ERR_GLOB);
@@ -410,17 +411,17 @@
 	case GLOB_NOSPACE:
 	    stderror(ERR_NOMEM);
 	    /* NOTREACHED */
+	case GLOB_NOMATCH:
+		magic = 1;
+		break;
 	default:
+		match |= globv.gl_flags & GLOB_MAGCHAR;
 	    break;
 	}
-	if (globv.gl_flags & GLOB_MAGCHAR) {
-	    match |= (globv.gl_matchc != 0);
-	    magic = 1;
-	}
 	gflgs |= GLOB_APPEND;
     }
     while (*++vl);
-    vl = (globv.gl_pathc == 0 || (magic && !match && !nonomatch)) ?
+	vl = (globv.gl_pathc == 0 || (magic && !match)) ?
 	NULL : blk2short(globv.gl_pathv);
     globfree(&globv);
     return (vl);
diff --minimal -ruw csh/pathnames.h csh/pathnames.h
--- csh/pathnames.h	2003-05-28 21:32:36.000000000 +0100
+++ csh/pathnames.h	2003-05-28 21:31:51.000000000 +0100
@@ -42,7 +42,7 @@
 #define	_PATH_DOTCSHRC		"/etc/csh.cshrc"
 #define	_PATH_DOTLOGIN		"/etc/csh.login"
 #define	_PATH_DOTLOGOUT		"/etc/csh.logout"
-#define	_PATH_LOGIN		"/usr/bin/login"
+#define	_PATH_LOGIN		"/bin/login"
 #define	_PATH_USRBIN		"/usr/bin"
 
 #endif /* !_PATHNAMES_H_ */
diff --minimal -ruw csh/proc.c csh/proc.c
--- csh/proc.c	2003-05-28 21:32:36.000000000 +0100
+++ csh/proc.c	2003-05-28 21:31:51.000000000 +0100
@@ -951,13 +951,21 @@
 		    stderror(ERR_NAME | ERR_BADSIG);
 		else if (signum == 0)
 		    (void)fputc('0', cshout); /* 0's symbolic name is '0' */
+		else if (!sys_signame[signum])
+			(void) fprintf(cshout, "%d", signum);
 		else
 		    (void)fprintf(cshout, "%s ", sys_signame[signum]);
 	    } else {
-		for (signum = 1; signum < NSIG; signum++) {
-		    (void)fprintf(cshout, "%s ", sys_signame[signum]);
-		    if (signum == NSIG / 2)
+			int cur = 0, len;
+			for (signum = 1; signum < NSIG; signum++)
+				if (sys_signame[signum]) {
+					len = strlen (sys_signame[signum]) + 1;
+					cur += len;
+					if (cur >= 80 - 1) {
 			(void)fputc('\n', cshout);
+						cur = len;
+					}
+					(void) fprintf(cshout, "%s ", sys_signame[signum]);
 	    	}
 	    }
 	    (void)fputc('\n', cshout);
@@ -979,9 +987,10 @@
 
 	    name = short2str(signame);
 	    for (signum = 1; signum < NSIG; signum++)
-		if (!strcasecmp(sys_signame[signum], name) ||
-		    (!strncasecmp("SIG", name, 3) &&	/* skip "SIG" prefix */
-		     !strcasecmp(sys_signame[signum], name + 3)))
+		if (sys_signame[signum] && \
+			(!strcasecmp(sys_signame[signum], name) ||
+				(strlen(name) > 3 && !strncasecmp("SIG", name, 3) &&
+					!strcasecmp(sys_signame[signum], name + 3))))
 		    break;
 
 	    if (signum == NSIG) {
diff --minimal -ruw csh/set.c csh/set.c
--- csh/set.c	2003-05-28 21:32:36.000000000 +0100
+++ csh/set.c	2003-05-28 21:31:51.000000000 +0100
@@ -633,7 +633,6 @@
     Setenv(STRPATH, exppath);
 }
 
-#ifndef lint
  /*
   * Lint thinks these have null effect
   */
@@ -650,19 +649,6 @@
 	((p)->v_right = t->v_left) ? (t->v_left->v_parent = (p)) : 0,\
 	(t->v_left = (p))->v_parent = t,\
 	(p) = t)
-#else
-struct varent *
-rleft(struct varent *p)
-{
-    return (p);
-}
-struct varent *
-rright(struct varent *p)
-{
-    return (p);
-}
-#endif				/* ! lint */
-
 
 /*
  * Rebalance a tree, starting at p and up.
@@ -674,10 +660,8 @@
 {
     struct varent *pp;
 
-#ifndef lint
     struct varent *t;	/* used by the rotate macros */
 
-#endif
     int ff;
 
     /*