summaryrefslogtreecommitdiffstats
path: root/source/ap/ash/patches/ash-memout.patch
diff options
context:
space:
mode:
author Patrick J Volkerding <volkerdi@slackware.com>2009-08-26 10:00:38 -0500
committer Eric Hameleers <alien@slackware.com>2018-05-31 22:41:17 +0200
commit5a12e7c134274dba706667107d10d231517d3e05 (patch)
tree55718d5acb710fde798d9f38d0bbaf594ed4b296 /source/ap/ash/patches/ash-memout.patch
downloadcurrent-5a12e7c134274dba706667107d10d231517d3e05.tar.gz
current-5a12e7c134274dba706667107d10d231517d3e05.tar.xz
Slackware 13.0slackware-13.0
Wed Aug 26 10:00:38 CDT 2009 Slackware 13.0 x86_64 is released as stable! Thanks to everyone who helped make this release possible -- see the RELEASE_NOTES for the credits. The ISOs are off to the replicator. This time it will be a 6 CD-ROM 32-bit set and a dual-sided 32-bit/64-bit x86/x86_64 DVD. We're taking pre-orders now at store.slackware.com. Please consider picking up a copy to help support the project. Once again, thanks to the entire Slackware community for all the help testing and fixing things and offering suggestions during this development cycle. As always, have fun and enjoy! -P.
Diffstat (limited to 'source/ap/ash/patches/ash-memout.patch')
-rw-r--r--source/ap/ash/patches/ash-memout.patch333
1 files changed, 333 insertions, 0 deletions
diff --git a/source/ap/ash/patches/ash-memout.patch b/source/ap/ash/patches/ash-memout.patch
new file mode 100644
index 000000000..1bfedadaa
--- /dev/null
+++ b/source/ap/ash/patches/ash-memout.patch
@@ -0,0 +1,333 @@
+diff -u ash-0.4.0/eval.c ash-0.4.0-/eval.c
+--- ash-0.4.0/eval.c Tue Apr 24 00:53:12 2001
++++ ash-0.4.0-/eval.c Tue Apr 24 00:13:57 2001
+@@ -879,9 +879,13 @@
+ #endif
+ mode = (cmdentry.u.index == EXECCMD)? 0 : REDIR_PUSH;
+ if (flags == EV_BACKCMD) {
++#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
++ openmemout();
++#else
+ memout.nleft = 0;
+ memout.nextc = memout.buf;
+ memout.bufsize = 64;
++#endif
+ mode |= REDIR_BACKQ;
+ }
+ redirect(cmd->ncmd.redirect, mode);
+@@ -928,10 +932,18 @@
+ if (cmdentry.u.index != EXECCMD)
+ popredir();
+ if (flags == EV_BACKCMD) {
++#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
++ closememout();
++#endif
+ backcmd->buf = memout.buf;
++#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
++ backcmd->nleft = memout.bufsize;
++#else
+ backcmd->nleft = memout.nextc - memout.buf;
++#endif
+ memout.buf = NULL;
+ }
++ cmdenviron = NULL;
+ } else {
+ #ifdef DEBUG
+ trputs("normal command: "); trargs(argv);
+Common subdirectories: ash-0.4.0/funcs and ash-0.4.0-/funcs
+diff -u ash-0.4.0/output.c ash-0.4.0-/output.c
+--- ash-0.4.0/output.c Fri Jan 12 17:50:39 2001
++++ ash-0.4.0-/output.c Tue Apr 24 00:43:44 2001
+@@ -65,6 +65,10 @@
+ #include <errno.h>
+ #include <unistd.h>
+ #include <stdlib.h>
++#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
++#undef CEOF /* get rid of the redefine warning */
++#include <fcntl.h>
++#endif
+
+ #include "shell.h"
+ #include "syntax.h"
+@@ -79,9 +83,15 @@
+ #define OUTPUT_ERR 01 /* error occurred on output */
+
+
++#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
++struct output output = {NULL, NULL, 0, NULL, 0, 1, 0};
++struct output errout = {NULL, NULL, 0, NULL, 0, 2, 0};
++struct output memout = {NULL, NULL, 0, NULL, 0, MEM_OUT, 0};
++#else
+ struct output output = {NULL, 0, NULL, OUTBUFSIZ, 1, 0};
+ struct output errout = {NULL, 0, NULL, 100, 2, 0};
+ struct output memout = {NULL, 0, NULL, 0, MEM_OUT, 0};
++#endif
+ struct output *out1 = &output;
+ struct output *out2 = &errout;
+
+@@ -92,9 +102,19 @@
+ INCLUDE "output.h"
+ INCLUDE "memalloc.h"
+
++INIT {
++#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
++ initstreams();
++#endif
++}
++
+ RESET {
+ out1 = &output;
+ out2 = &errout;
++#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
++ if (memout.stream != NULL)
++ closememout();
++#endif
+ if (memout.buf != NULL) {
+ ckfree(memout.buf);
+ memout.buf = NULL;
+@@ -124,33 +144,22 @@
+
+
+ void
+-out1str(p)
+- const char *p;
+- {
+- outstr(p, out1);
+-}
+-
+-
+-void
+-out2str(p)
+- const char *p;
+- {
+- outstr(p, out2);
+-}
+-
+-
+-void
+ outstr(p, file)
+ const char *p;
+ struct output *file;
+ {
++#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
++ fputs(p, file->stream);
++#else
+ while (*p)
+ outc(*p++, file);
++#endif
+ if (file == out2)
+ flushout(file);
+ }
+
+
++#if !defined(_GNU_SOURCE) || defined(__UCLIBC__)
+ char out_junk[16];
+
+
+@@ -183,6 +192,7 @@
+ }
+ dest->nleft--;
+ }
++#endif
+
+
+ void
+@@ -192,11 +202,11 @@
+ }
+
+
++#if !defined(_GNU_SOURCE) || defined(__UCLIBC__)
+ void
+ flushout(dest)
+ struct output *dest;
+ {
+-
+ if (dest->buf == NULL || dest->nextc == dest->buf || dest->fd < 0)
+ return;
+ if (xwrite(dest->fd, dest->buf, dest->nextc - dest->buf) < 0)
+@@ -204,6 +214,7 @@
+ dest->nextc = dest->buf;
+ dest->nleft = dest->bufsize;
+ }
++#endif
+
+
+ void
+@@ -264,6 +275,7 @@
+ va_end(ap);
+ }
+
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
+ void
+ #ifdef __STDC__
+ dprintf(const char *fmt, ...)
+@@ -285,6 +297,7 @@
+ va_end(ap);
+ flushout(out2);
+ }
++#endif
+
+ void
+ #ifdef __STDC__
+@@ -295,7 +308,9 @@
+ #endif
+ {
+ va_list ap;
++#if !defined(_GNU_SOURCE) || defined(__UCLIBC__)
+ struct output strout;
++#endif
+ #ifndef __STDC__
+ char *outbuf;
+ size_t length;
+@@ -308,6 +323,9 @@
+ #else
+ va_start(ap, fmt);
+ #endif
++#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
++ vsnprintf(outbuf, length, fmt, ap);
++#else
+ strout.nextc = outbuf;
+ strout.nleft = length;
+ strout.fd = BLOCK_OUT;
+@@ -316,8 +334,10 @@
+ outc('\0', &strout);
+ if (strout.flags & OUTPUT_ERR)
+ outbuf[length - 1] = '\0';
++#endif
+ }
+
++#if !defined(_GNU_SOURCE) || defined(__UCLIBC__)
+ /*
+ * Formatted output. This routine handles a subset of the printf formats:
+ * - Formats supported: d, u, o, p, X, s, and c.
+@@ -534,7 +554,7 @@
+ }
+ #endif /* !HAVE_VASPRINTF */
+ }
+-
++#endif
+
+
+ /*
+@@ -544,7 +564,7 @@
+ int
+ xwrite(fd, buf, nbytes)
+ int fd;
+- char *buf;
++ const char *buf;
+ int nbytes;
+ {
+ int ntry;
+@@ -570,6 +590,8 @@
+ }
+
+
++
++#ifdef notdef
+ /*
+ * Version of ioctl that retries after a signal is caught.
+ * XXX unused function
+@@ -586,3 +608,27 @@
+ while ((i = ioctl(fd, request, arg)) == -1 && errno == EINTR);
+ return i;
+ }
++#endif
++
++
++#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
++void initstreams() {
++ output.stream = stdout;
++ errout.stream = stderr;
++}
++
++
++void
++openmemout() {
++ memout.stream = open_memstream(&memout.buf, &memout.bufsize);
++}
++
++
++void
++closememout() {
++ INTOFF;
++ fclose(memout.stream);
++ memout.stream = NULL;
++ INTON;
++}
++#endif
+diff -u ash-0.4.0/output.h ash-0.4.0-/output.h
+--- ash-0.4.0/output.h Sat Jan 31 19:28:11 1998
++++ ash-0.4.0-/output.h Tue Apr 24 00:13:57 2001
+@@ -45,13 +45,19 @@
+ #else
+ #include <varargs.h>
+ #endif
++#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
++#include <stdio.h>
++#endif
+
+ struct output {
++#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
++ FILE *stream;
++#endif
+ char *nextc;
+ int nleft;
+ char *buf;
+ int bufsize;
+- short fd;
++ int fd;
+ short flags;
+ };
+
+@@ -61,29 +67,44 @@
+ extern struct output *out1;
+ extern struct output *out2;
+
+-void open_mem __P((char *, int, struct output *));
+-void out1str __P((const char *));
+-void out2str __P((const char *));
+ void outstr __P((const char *, struct output *));
++#ifndef _GNU_SOURCE
+ void emptyoutbuf __P((struct output *));
++#endif
+ void flushall __P((void));
++#ifndef _GNU_SOURCE
+ void flushout __P((struct output *));
++#endif
+ void freestdout __P((void));
+ void outfmt __P((struct output *, const char *, ...))
+ __attribute__((__format__(__printf__,2,3)));
+ void out1fmt __P((const char *, ...))
+ __attribute__((__format__(__printf__,1,2)));
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
+ void dprintf __P((const char *, ...))
+ __attribute__((__format__(__printf__,1,2)));
++#endif
+ void fmtstr __P((char *, size_t, const char *, ...))
+ __attribute__((__format__(__printf__,3,4)));
++#ifndef _GNU_SOURCE
+ void doformat __P((struct output *, const char *, va_list));
+-int xwrite __P((int, char *, int));
+-int xioctl __P((int, unsigned long, char *));
++#endif
++int xwrite __P((int, const char *, int));
++#if defined(_GNU_SOURCE) && !defined(__UCLIBC__)
++void initstreams __P((void));
++void openmemout __P((void));
++void closememout __P((void));
+
++#define outc(c, o) putc(c, (o)->stream)
++#define flushout(o) fflush((o)->stream)
++#define doformat(d, f, a) vfprintf((d)->stream, f, a)
++#else
+ #define outc(c, file) (--(file)->nleft < 0? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c)))
+-#define out1c(c) outc(c, out1);
+-#define out2c(c) outc(c, out2);
++#endif
++#define out1c(c) outc(c, out1)
++#define out2c(c) outc(c, out2)
++#define out1str(s) outstr(s, out1)
++#define out2str(s) outstr(s, out2)
+
+ #define OUTPUT_INCL
+ #endif