diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2007-11-11 15:00:06 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2007-11-11 15:00:06 +0800 |
commit | 44a94779a85f2a87cd0d552c1d272b8c05b85630 (patch) | |
tree | 77bd58bff5b3cdb3d8ad44455befb6f536750bd1 | |
parent | [PARSER] Removed noexpand/length check on eofmark (diff) | |
download | dash-44a94779a85f2a87cd0d552c1d272b8c05b85630.tar.gz dash-44a94779a85f2a87cd0d552c1d272b8c05b85630.zip |
[EXPAND] Removed herefd hack
The herefd hack goes back more than a decade. it limits the amount of memory we have to allocate when expanding here-documents by writing the result out from time to time. However, it's no longer safe because the stack is used to place intermediate results too and there we certainly don't want to write them out should we be short on memory. In any case, with today's computers we can afford to keep the entire result in memory and write them out at the end.
Diffstat (limited to '')
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/eval.c | 6 | ||||
-rw-r--r-- | src/expand.c | 4 | ||||
-rw-r--r-- | src/memalloc.c | 5 | ||||
-rw-r--r-- | src/memalloc.h | 1 |
5 files changed, 1 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog index ad98810..39940b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2007-11-11 Herbert Xu <herbert@gondor.apana.org.au> * Removed noexpand/length check on eofmark. + * Removed herefd hack. 2007-10-20 Herbert Xu <herbert@gondor.apana.org.au> diff --git a/src/eval.c b/src/eval.c index 17b558d..a8feaa0 100644 --- a/src/eval.c +++ b/src/eval.c @@ -577,8 +577,6 @@ evalpipe(union node *n, int flags) void evalbackcmd(union node *n, struct backcmd *result) { - int saveherefd; - result->fd = -1; result->buf = NULL; result->nleft = 0; @@ -587,9 +585,6 @@ evalbackcmd(union node *n, struct backcmd *result) goto out; } - saveherefd = herefd; - herefd = -1; - #ifdef notyet /* * For now we disable executing builtins in the same @@ -636,7 +631,6 @@ evalbackcmd(union node *n, struct backcmd *result) result->fd = pip[0]; result->jp = jp; } - herefd = saveherefd; out: TRACE(("evalbackcmd done: fd=%d buf=0x%x nleft=%d jp=0x%x\n", result->fd, result->buf, result->nleft, result->jp)); diff --git a/src/expand.c b/src/expand.c index c489446..ee699e8 100644 --- a/src/expand.c +++ b/src/expand.c @@ -184,7 +184,6 @@ static inline const char *getpwhome(const char *name) void expandhere(union node *arg, int fd) { - herefd = fd; expandarg(arg, (struct arglist *)NULL, EXP_QUOTED); xwrite(fd, stackblock(), expdest - (char *)stackblock()); } @@ -663,18 +662,15 @@ subevalvar(char *p, char *str, int strloc, int subtype, int startloc, int varfla int quotes = flag & QUOTES_ESC; char *startp; char *loc; - int saveherefd = herefd; struct nodelist *saveargbackq = argbackq; int amount; char *rmesc, *rmescend; int zero; char *(*scan)(char *, char *, char *, char *, int , int); - herefd = -1; argstr(p, EXP_TILDE | (subtype != VSASSIGN && subtype != VSQUESTION ? (flag & EXP_QUOTED ? EXP_QPAT : EXP_CASE) : 0)); STPUTC('\0', expdest); - herefd = saveherefd; argbackq = saveargbackq; startp = stackblock() + startloc; diff --git a/src/memalloc.c b/src/memalloc.c index 8d3e2ed..e75e609 100644 --- a/src/memalloc.c +++ b/src/memalloc.c @@ -109,7 +109,6 @@ struct stack_block *stackp = &stackbase; char *stacknxt = stackbase.space; size_t stacknleft = MINSIZE; char *sstrend = stackbase.space + MINSIZE; -int herefd = -1; pointer stalloc(size_t nbytes) @@ -264,10 +263,6 @@ void * growstackstr(void) { size_t len = stackblocksize(); - if (herefd >= 0 && len >= 1024) { - xwrite(herefd, stackblock(), len); - return stackblock(); - } growstackblock(); return stackblock() + len; } diff --git a/src/memalloc.h b/src/memalloc.h index ad6015d..4b5be46 100644 --- a/src/memalloc.h +++ b/src/memalloc.h @@ -46,7 +46,6 @@ struct stackmark { extern char *stacknxt; extern size_t stacknleft; extern char *sstrend; -extern int herefd; pointer ckmalloc(size_t); pointer ckrealloc(pointer, size_t); |