From d90e97e16a7f9343fbec9d9b33da45806b2a4e89 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 3 Nov 2003 11:33:46 +0000 Subject: 19216: Save and restore pipestatus. Remove debugging output --- ChangeLog | 11 +++++++++++ Src/exec.c | 20 ++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 015b66553..4af1d7f70 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,20 @@ +2003-11-03 Peter Stephenson + + * 19216: Src/exec.c: save and restore $pipestatus on functions + when noreturnval flag is set. Remove unnecessary debugging output. + 2003-11-02 Felix Rosencrantz * unposted: Src/.cvsignore, Src/Builtins/.cvsignore, Src/Modules/.cvsignore, Src/Zle/.cvsignore: add *.dll for cygwin builds and fix typo. +2003-10-29 Peter Stephenson + + * c.f. 19209: Src/...: Globally replace zcalloc with zshcalloc + to avoid clash with zcalloc from zlib; this is linked in on + some systems (certainly Debian) for some database lookups. + 2003-10-27 Peter Stephenson * zsh-users/6727: from Lloyd Zusman: Completion/Unix/Command/_w3m, diff --git a/Src/exec.c b/Src/exec.c index 0b6948c6e..5b17371bb 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3064,8 +3064,6 @@ getproc(char *cmd) if (!out) { addproc(pid, NULL, 1); - fprintf(stderr, "Proc %d added\n", pid); - fflush(stderr); } return pnam; } @@ -3448,7 +3446,8 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval) * was executed. */ { char **tab, **x, *oargv0; - int oldzoptind, oldlastval, oldoptcind; + int oldzoptind, oldlastval, oldoptcind, oldnumpipestats; + int *oldpipestats = NULL; char saveopts[OPT_SIZE], *oldscriptname = scriptname, *fname = dupstring(name); int obreaks; struct funcstack fstack; @@ -3463,6 +3462,16 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval) if (trapreturn < 0) trapreturn--; oldlastval = lastval; + oldnumpipestats = numpipestats; + if (noreturnval) { + /* + * Easiest to use the heap here since we're bracketed + * immediately by a pushheap/popheap pair. + */ + size_t bytes = sizeof(int)*numpipestats; + oldpipestats = (int *)zhalloc(bytes); + memcpy(oldpipestats, pipestats, bytes); + } starttrapscope(); @@ -3568,8 +3577,11 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval) if (trapreturn < -1) trapreturn++; - if (noreturnval) + if (noreturnval) { lastval = oldlastval; + numpipestats = oldnumpipestats; + memcpy(pipestats, oldpipestats, sizeof(int)*numpipestats); + } popheap(); if (exit_pending) { -- cgit 1.4.1