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) {
12 memout.nextc = memout.buf;
17 redirect(cmd->ncmd.redirect, mode);
19 if (cmdentry.u.index != EXECCMD)
21 if (flags == EV_BACKCMD) {
25 backcmd->buf = memout.buf;
27 + backcmd->nleft = memout.bufsize;
29 backcmd->nleft = memout.nextc - memout.buf;
36 trputs("normal command: "); trargs(argv);
37 diff -u ash-0.4.0/eval.c.orig ash-0.4.0-/eval.c.orig
38 --- ash-0.4.0/eval.c.orig Tue Apr 24 00:53:12 2001
39 +++ ash-0.4.0-/eval.c.orig Tue Apr 24 00:13:57 2001
42 mode = (cmdentry.u.index == EXECCMD)? 0 : REDIR_PUSH;
43 if (flags == EV_BACKCMD) {
48 memout.nextc = memout.buf;
53 redirect(cmd->ncmd.redirect, mode);
55 if (cmdentry.u.index != EXECCMD)
57 if (flags == EV_BACKCMD) {
61 backcmd->buf = memout.buf;
63 + backcmd->nleft = memout.bufsize;
65 backcmd->nleft = memout.nextc - memout.buf;
72 trputs("normal command: "); trargs(argv);
73 Common subdirectories: ash-0.4.0/funcs and ash-0.4.0-/funcs
74 diff -u ash-0.4.0/output.c ash-0.4.0-/output.c
75 --- ash-0.4.0/output.c Fri Jan 12 17:50:39 2001
76 +++ ash-0.4.0-/output.c Tue Apr 24 00:43:44 2001
82 +#undef CEOF /* get rid of the redefine warning */
89 #define OUTPUT_ERR 01 /* error occurred on output */
93 +struct output output = {NULL, NULL, 0, NULL, 0, 1, 0};
94 +struct output errout = {NULL, NULL, 0, NULL, 0, 2, 0};
95 +struct output memout = {NULL, NULL, 0, NULL, 0, MEM_OUT, 0};
97 struct output output = {NULL, 0, NULL, OUTBUFSIZ, 1, 0};
98 struct output errout = {NULL, 0, NULL, 100, 2, 0};
99 struct output memout = {NULL, 0, NULL, 0, MEM_OUT, 0};
101 struct output *out1 = &output;
102 struct output *out2 = &errout;
118 + if (memout.stream != NULL)
121 if (memout.buf != NULL) {
124 @@ -124,33 +144,22 @@
149 + fputs(p, file->stream);
171 @@ -192,11 +202,11 @@
181 if (dest->buf == NULL || dest->nextc == dest->buf || dest->fd < 0)
183 if (xwrite(dest->fd, dest->buf, dest->nextc - dest->buf) < 0)
185 dest->nextc = dest->buf;
186 dest->nleft = dest->bufsize;
199 dprintf(const char *fmt, ...)
213 struct output strout;
223 + vsnprintf(outbuf, length, fmt, ap);
225 strout.nextc = outbuf;
226 strout.nleft = length;
227 strout.fd = BLOCK_OUT;
230 if (strout.flags & OUTPUT_ERR)
231 outbuf[length - 1] = '\0';
237 * Formatted output. This routine handles a subset of the printf formats:
238 * - Formats supported: d, u, o, p, X, s, and c.
241 #endif /* !HAVE_VASPRINTF */
250 xwrite(fd, buf, nbytes)
264 * Version of ioctl that retries after a signal is caught.
265 * XXX unused function
267 while ((i = ioctl(fd, request, arg)) == -1 && errno == EINTR);
274 +void initstreams() {
275 + output.stream = stdout;
276 + errout.stream = stderr;
282 + memout.stream = open_memstream(&memout.buf, &memout.bufsize);
289 + fclose(memout.stream);
290 + memout.stream = NULL;
294 diff -u ash-0.4.0/output.h ash-0.4.0-/output.h
295 --- ash-0.4.0/output.h Sat Jan 31 19:28:11 1998
296 +++ ash-0.4.0-/output.h Tue Apr 24 00:13:57 2001
319 extern struct output *out1;
320 extern struct output *out2;
322 -void open_mem __P((char *, int, struct output *));
323 -void out1str __P((const char *));
324 -void out2str __P((const char *));
325 void outstr __P((const char *, struct output *));
327 void emptyoutbuf __P((struct output *));
329 void flushall __P((void));
331 void flushout __P((struct output *));
333 void freestdout __P((void));
334 void outfmt __P((struct output *, const char *, ...))
335 __attribute__((__format__(__printf__,2,3)));
336 void out1fmt __P((const char *, ...))
337 __attribute__((__format__(__printf__,1,2)));
339 void dprintf __P((const char *, ...))
340 __attribute__((__format__(__printf__,1,2)));
342 void fmtstr __P((char *, size_t, const char *, ...))
343 __attribute__((__format__(__printf__,3,4)));
345 void doformat __P((struct output *, const char *, va_list));
346 -int xwrite __P((int, char *, int));
347 -int xioctl __P((int, unsigned long, char *));
349 +int xwrite __P((int, const char *, int));
351 +void initstreams __P((void));
352 +void openmemout __P((void));
353 +void closememout __P((void));
355 +#define outc(c, o) putc(c, (o)->stream)
356 +#define flushout(o) fflush((o)->stream)
357 +#define doformat(d, f, a) vfprintf((d)->stream, f, a)
359 #define outc(c, file) (--(file)->nleft < 0? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c)))
360 -#define out1c(c) outc(c, out1);
361 -#define out2c(c) outc(c, out2);
363 +#define out1c(c) outc(c, out1)
364 +#define out2c(c) outc(c, out2)
365 +#define out1str(s) outstr(s, out1)
366 +#define out2str(s) outstr(s, out2)