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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
--- _install/install_ucb.c
+++ _install/install_ucb.c
@@ -267,7 +267,7 @@ cp(const char *src, const char *tgt, struct stat *dsp)
if (check(src, tgt, dsp, &sst) != OKAY)
return;
unlink(tgt);
- if ((dfd = creat(tgt, 0700)) < 0 || fchmod(dfd, 0700) < 0 ||
+ if ((dfd = creat(tgt, 0700)) < 0 || chmod(tgt, 0700) < 0 ||
fstat(dfd, &nst) < 0) {
fprintf(stderr, "%s: %s: %s\n", progname, src,
strerror(errno));
--- libcommon/Makefile.mk
+++ libcommon/Makefile.mk
@@ -15,7 +15,7 @@ CHECK: CHECK.c
headers: CHECK
one() { \
rm -f "$$1.h"; \
- if grep "$$1_h[ ]*=[ ]*[^0][ ]*;" CHECK >/dev/null; \
+ if true; \
then \
ln -s "_$$1.h" "$$1.h"; \
fi; \
--- libcommon/atoll.h
+++ libcommon/atoll.h
@@ -1,8 +1,10 @@
/* Sccsid @(#)atoll.h 1.4 (gritter) 7/18/04 */
#if defined (__hpux) || defined (_AIX) || \
- defined (__FreeBSD__) && (__FreeBSD__) < 5
+ (defined (__FreeBSD__) && (__FreeBSD__) < 5) || defined (__TINYC__)
+#ifndef __TINYC__
extern long long strtoll(const char *nptr, char **endptr, int base);
extern unsigned long long strtoull(const char *nptr, char **endptr, int base);
+#endif
extern long long atoll(const char *nptr);
#endif /* __hpux || _AIX || __FreeBSD__ < 5 */
--- libcommon/blank.h
+++ libcommon/blank.h
@@ -5,7 +5,7 @@
*/
/* Sccsid @(#)blank.h 1.3 (gritter) 5/1/04 */
-#ifndef __dietlibc__
+#if !defined(__dietlibc__) && !defined(__TINYC__)
#ifndef LIBCOMMON_BLANK_H
#define LIBCOMMON_BLANK_H 1
--- libcommon/getdir.c
+++ libcommon/getdir.c
@@ -52,7 +52,7 @@ extern int getdents(int, struct dirent *, size_t);
#undef d_ino
#endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __DragonFly__
|| __APPLE__ */
-#elif defined (__dietlibc__)
+#elif defined (__dietlibc__) || defined(__TINYC__)
#include <dirent.h>
#include <unistd.h>
#else /* !__GLIBC__, !__dietlibc__ */
--- libcommon/memalign.c
+++ libcommon/memalign.c
@@ -23,7 +23,7 @@
#if defined (__FreeBSD__) || defined (__dietlibc__) || defined (_AIX) || \
defined (__NetBSD__) || defined (__OpenBSD__) || \
- defined (__DragonFly__) || defined (__APPLE__)
+ defined (__DragonFly__) || defined (__APPLE__) || defined(__TINYC__)
/*
* FreeBSD malloc(3) promises to page-align the return of malloc() calls
* if size is at least a page. This serves for a poor man's memalign()
--- libcommon/memalign.h
+++ libcommon/memalign.h
@@ -26,7 +26,7 @@
#if defined (__FreeBSD__) || defined (__dietlibc__) || defined (_AIX) || \
defined (__NetBSD__) || defined (__OpenBSD__) || \
- defined (__DragonFly__) || defined (__APPLE__)
+ defined (__DragonFly__) || defined (__APPLE__) || defined(__TINYC__)
#include <stdlib.h>
extern void *memalign(size_t, size_t);
--- libcommon/pathconf.c
+++ libcommon/pathconf.c
@@ -21,7 +21,7 @@
*/
/* Sccsid @(#)pathconf.c 1.2 (gritter) 5/1/04 */
-#ifdef __dietlibc__
+#if defined(__dietlibc__) || defined(__TINYC__)
#include <unistd.h>
#include "pathconf.h"
--- libcommon/pathconf.h
+++ libcommon/pathconf.h
@@ -21,7 +21,7 @@
*/
/* Sccsid @(#)pathconf.h 1.2 (gritter) 5/1/04 */
-#ifdef __dietlibc__
+#if defined(__dietlibc__) || defined(__TINYC__)
#include <unistd.h>
extern long fpathconf(int, int);
--- libcommon/regexp.h
+++ libcommon/regexp.h
@@ -47,7 +47,7 @@
static const char regexp_h_sccsid[] REGEXP_H_USED =
"@(#)regexp.sl 1.56 (gritter) 5/29/05";
-#if !defined (REGEXP_H_USED_FROM_VI) && !defined (__dietlibc__)
+#if !defined (REGEXP_H_USED_FROM_VI) && !defined (__dietlibc__) && !defined (__TINYC__)
#define REGEXP_H_WCHARS
#endif
--- libcommon/sfile.c
+++ libcommon/sfile.c
@@ -21,7 +21,7 @@
*/
/* Sccsid @(#)sfile.c 1.9 (gritter) 6/7/04 */
-#ifdef __linux__
+#if defined(__linux__) && !defined(__TINYC__)
#undef _FILE_OFFSET_BITS
#include <sys/types.h>
--- libcommon/sighold.c
+++ libcommon/sighold.c
@@ -22,7 +22,7 @@
/* Sccsid @(#)sighold.c 1.7 (gritter) 1/22/06 */
#if defined (__FreeBSD__) || defined (__dietlibc__) || defined (__NetBSD__) || \
- defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__)
+ defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__) || defined (__TINYC__)
#include <signal.h>
#include "sigset.h"
--- libcommon/sigignore.c
+++ libcommon/sigignore.c
@@ -22,7 +22,7 @@
/* Sccsid @(#)sigignore.c 1.6 (gritter) 1/22/06 */
#if defined (__FreeBSD__) || defined (__dietlibc__) || defined (__NetBSD__) || \
- defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__)
+ defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__) || defined (__TINYC__)
#include <signal.h>
#include "sigset.h"
--- libcommon/sigpause.c
+++ libcommon/sigpause.c
@@ -22,7 +22,7 @@
/* Sccsid @(#)sigpause.c 1.6 (gritter) 1/22/06 */
#if defined (__FreeBSD__) || defined (__dietlibc__) || defined (__NetBSD__) || \
- defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__)
+ defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__) || defined (__TINYC__)
#include <signal.h>
#include "sigset.h"
--- libcommon/sigrelse.c
+++ libcommon/sigrelse.c
@@ -22,7 +22,7 @@
/* Sccsid @(#)sigrelse.c 1.8 (gritter) 1/22/06 */
#if defined (__FreeBSD__) || defined (__dietlibc__) || defined (__NetBSD__) || \
- defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__)
+ defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__) || defined (__TINYC__)
#include <signal.h>
#include "sigset.h"
--- libcommon/sigset.c
+++ libcommon/sigset.c
@@ -22,7 +22,7 @@
/* Sccsid @(#)sigset.c 1.7 (gritter) 1/22/06 */
#if defined (__FreeBSD__) || defined (__dietlibc__) || defined (__NetBSD__) || \
- defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__)
+ defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__) || defined (__TINYC__)
#include <signal.h>
#include "sigset.h"
@@ -46,10 +46,7 @@ void (*sigset(int sig, void (*func)(int)))(int)
if (sigaction(sig, func==SIG_HOLD?(struct sigaction *)0:&nact, &oact)
== -1)
return SIG_ERR;
- if (sigismember(&oset, sig))
- return SIG_HOLD;
- else
- return (oact.sa_handler);
+ return (oact.sa_handler);
}
#endif /* __FreeBSD__ || __dietlibc__ || __NetBSD__ || __OpenBSD__ ||
__DragonFly__ || __APPLE__ */
--- libcommon/sigset.h
+++ libcommon/sigset.h
@@ -22,7 +22,7 @@
/* Sccsid @(#)sigset.h 1.9 (gritter) 1/22/06 */
#if defined (__FreeBSD__) || defined (__dietlibc__) || defined (__NetBSD__) || \
- defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__)
+ defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__) || defined (__TINYC__)
#ifndef SIG_HOLD
#define SIG_HOLD ((void (*)(int))2)
--- libcommon/strtol.c
+++ libcommon/strtol.c
@@ -1,7 +1,7 @@
/* Sccsid @(#)strtol.c 1.6 (gritter) 7/18/04 */
#if defined (__hpux) || defined (_AIX) || \
- defined (__FreeBSD__) && (__FreeBSD__) < 5
+ (defined (__FreeBSD__) && (__FreeBSD__) < 5) || defined (__TINYC__)
#include <stdlib.h>
#include <ctype.h>
@@ -97,6 +97,7 @@ out: if (pp <= bptr) {
return v * sign;
}
+#ifndef __TINYC__
long long
strtoll(const char *nptr, char **endptr, int base)
{
@@ -108,6 +109,7 @@ strtoull(const char *nptr, char **endptr, int base)
{
return (unsigned long long)internal(nptr, endptr, base, 3);
}
+#endif
long long
atoll(const char *nptr)
--- nawk/awk.h
+++ nawk/awk.h
@@ -156,7 +156,6 @@ extern Cell *rlengthloc; /* RLENGTH */
#endif
#ifndef IN_MAKETAB
-#include <wchar.h>
/*
* Get next character from string s and store it in wc; n is set to
--- nawk/awk.lx.l
+++ nawk/awk.lx.l
@@ -71,7 +71,6 @@
#include "awk.h"
#include "y.tab.h"
-#include <pfmt.h>
#include <unistd.h>
static void awk_unputstr(const char *s);
--- nawk/run.c
+++ nawk/run.c
@@ -1467,14 +1467,6 @@ Cell *bltin(Node **a, int n)
case FRAND:
u = (Awkfloat) (rand() % 32767) / 32767.0;
break;
- case FSRAND:
- u = saved_srand; /* return previous seed */
- if (x->tval & REC) /* no argument provided */
- saved_srand = time(NULL);
- else
- saved_srand = getfval(x);
- srand((int) saved_srand);
- break;
case FTOUPPER:
case FTOLOWER:
p = getsval(x);
--- pgrep/pgrep.c
+++ pgrep/pgrep.c
@@ -214,7 +214,7 @@ chdir_to_proc(void)
fprintf(stderr, "%s: cannot open %s\n", progname, PROCDIR);
exit(3);
}
- if (fchdir(fd) < 0) {
+ if (chdir(PROCDIR) < 0) {
fprintf(stderr, "%s: cannot chdir to %s\n", progname, PROCDIR);
exit(3);
}
--- rm/rm.c
+++ rm/rm.c
@@ -242,7 +242,7 @@ rm(size_t pend, const char *base, const int olddir, int ssub, int level)
}
return;
}
- if (fchdir(df) < 0) {
+ if (chdir(base) < 0) {
if (rmfile(base, &st) < 0) {
fprintf(stderr,
"%s: cannot chdir to %s\n",
@@ -270,7 +270,7 @@ rm(size_t pend, const char *base, const int olddir, int ssub, int level)
progname, path);
errcnt |= 4;
}
- if (olddir >= 0 && fchdir(olddir) < 0) {
+ if (olddir >= 0) {
fprintf(stderr, "%s: cannot change backwards\n",
progname);
exit(1);
@@ -316,24 +316,6 @@ subproc(size_t pend, const char *base, int level)
int status;
while (waitpid(pid, &status, 0) != pid);
- if (status && WIFSIGNALED(status)) {
- /*
- * If the signal was sent due to a tty keypress,
- * we should be terminated automatically and
- * never reach this point. Otherwise, we terminate
- * with the same signal, but make sure that we do
- * not overwrite a possibly generated core file.
- * This results in nearly the usual behavior except
- * that the shell never prints a 'core dumped'
- * message.
- */
- struct rlimit rl;
-
- rl.rlim_cur = rl.rlim_max = 0;
- setrlimit(RLIMIT_CORE, &rl);
- raise(WTERMSIG(status));
- pause();
- }
return status ? WEXITSTATUS(status) : 0;
}
case -1:
|