1 diff -u ash-0.4.0/eval.c ash-0.4.0-/eval.c
2 --- ash-0.4.0/eval.c Tue Apr 24 00:53:12 2001
3 +++ ash-0.4.0-/eval.c Tue Apr 24 00:13:57 2001
6 mode = (cmdentry.u.index == EXECCMD)? 0 : REDIR_PUSH;
7 if (flags == EV_BACKCMD) {
8 +#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
12 memout.nextc = memout.buf;
17 redirect(cmd->ncmd.redirect, mode);
19 if (cmdentry.u.index != EXECCMD)
21 if (flags == EV_BACKCMD) {
22 +#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
25 backcmd->buf = memout.buf;
26 +#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
27 + backcmd->nleft = memout.bufsize;
29 backcmd->nleft = memout.nextc - memout.buf;
36 trputs("normal command: "); trargs(argv);
37 Common subdirectories: ash-0.4.0/funcs and ash-0.4.0-/funcs
38 diff -u ash-0.4.0/output.c ash-0.4.0-/output.c
39 --- ash-0.4.0/output.c Fri Jan 12 17:50:39 2001
40 +++ ash-0.4.0-/output.c Tue Apr 24 00:43:44 2001
45 +#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
46 +#undef CEOF /* get rid of the redefine warning */
53 #define OUTPUT_ERR 01 /* error occurred on output */
56 +#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
57 +struct output output = {NULL, NULL, 0, NULL, 0, 1, 0};
58 +struct output errout = {NULL, NULL, 0, NULL, 0, 2, 0};
59 +struct output memout = {NULL, NULL, 0, NULL, 0, MEM_OUT, 0};
61 struct output output = {NULL, 0, NULL, OUTBUFSIZ, 1, 0};
62 struct output errout = {NULL, 0, NULL, 100, 2, 0};
63 struct output memout = {NULL, 0, NULL, 0, MEM_OUT, 0};
65 struct output *out1 = &output;
66 struct output *out2 = &errout;
73 +#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
81 +#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
82 + if (memout.stream != NULL)
85 if (memout.buf != NULL) {
112 +#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
113 + fputs(p, file->stream);
123 +#if !defined(_GNU_SOURCE) || defined(__UCLIBC__)
135 @@ -192,11 +202,11 @@
139 +#if !defined(_GNU_SOURCE) || defined(__UCLIBC__)
145 if (dest->buf == NULL || dest->nextc == dest->buf || dest->fd < 0)
147 if (xwrite(dest->fd, dest->buf, dest->nextc - dest->buf) < 0)
149 dest->nextc = dest->buf;
150 dest->nleft = dest->bufsize;
160 +#if !defined(__GLIBC__) && !defined(__UCLIBC__)
163 dprintf(const char *fmt, ...)
176 +#if !defined(_GNU_SOURCE) || defined(__UCLIBC__)
177 struct output strout;
186 +#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
187 + vsnprintf(outbuf, length, fmt, ap);
189 strout.nextc = outbuf;
190 strout.nleft = length;
191 strout.fd = BLOCK_OUT;
194 if (strout.flags & OUTPUT_ERR)
195 outbuf[length - 1] = '\0';
199 +#if !defined(_GNU_SOURCE) || defined(__UCLIBC__)
201 * Formatted output. This routine handles a subset of the printf formats:
202 * - Formats supported: d, u, o, p, X, s, and c.
205 #endif /* !HAVE_VASPRINTF */
214 xwrite(fd, buf, nbytes)
228 * Version of ioctl that retries after a signal is caught.
229 * XXX unused function
231 while ((i = ioctl(fd, request, arg)) == -1 && errno == EINTR);
237 +#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
238 +void initstreams() {
239 + output.stream = stdout;
240 + errout.stream = stderr;
246 + memout.stream = open_memstream(&memout.buf, &memout.bufsize);
253 + fclose(memout.stream);
254 + memout.stream = NULL;
258 diff -u ash-0.4.0/output.h ash-0.4.0-/output.h
259 --- ash-0.4.0/output.h Sat Jan 31 19:28:11 1998
260 +++ ash-0.4.0-/output.h Tue Apr 24 00:13:57 2001
265 +#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
270 +#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
283 extern struct output *out1;
284 extern struct output *out2;
286 -void open_mem __P((char *, int, struct output *));
287 -void out1str __P((const char *));
288 -void out2str __P((const char *));
289 void outstr __P((const char *, struct output *));
291 void emptyoutbuf __P((struct output *));
293 void flushall __P((void));
295 void flushout __P((struct output *));
297 void freestdout __P((void));
298 void outfmt __P((struct output *, const char *, ...))
299 __attribute__((__format__(__printf__,2,3)));
300 void out1fmt __P((const char *, ...))
301 __attribute__((__format__(__printf__,1,2)));
302 +#if !defined(__GLIBC__) && !defined(__UCLIBC__)
303 void dprintf __P((const char *, ...))
304 __attribute__((__format__(__printf__,1,2)));
306 void fmtstr __P((char *, size_t, const char *, ...))
307 __attribute__((__format__(__printf__,3,4)));
309 void doformat __P((struct output *, const char *, va_list));
310 -int xwrite __P((int, char *, int));
311 -int xioctl __P((int, unsigned long, char *));
313 +int xwrite __P((int, const char *, int));
314 +#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
315 +void initstreams __P((void));
316 +void openmemout __P((void));
317 +void closememout __P((void));
319 +#define outc(c, o) putc(c, (o)->stream)
320 +#define flushout(o) fflush((o)->stream)
321 +#define doformat(d, f, a) vfprintf((d)->stream, f, a)
323 #define outc(c, file) (--(file)->nleft < 0? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c)))
324 -#define out1c(c) outc(c, out1);
325 -#define out2c(c) outc(c, out2);
327 +#define out1c(c) outc(c, out1)
328 +#define out2c(c) outc(c, out2)
329 +#define out1str(s) outstr(s, out1)
330 +#define out2str(s) outstr(s, out2)