From af7eba0c848d12629d41be991467d35a902a9e66 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Thu, 13 Nov 2003 16:45:36 +0000 Subject: merge back changes from 4.1 --- ChangeLog | 24 ++++++++++++++++++++++++ Src/Modules/parameter.c | 2 ++ Src/Zle/zle_main.c | 3 ++- Src/builtin.c | 6 ++++-- Src/exec.c | 2 +- Src/hist.c | 2 ++ Src/input.c | 14 ++++++++++++++ Src/params.c | 10 ++++++---- 8 files changed, 55 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 65d042be2..3569b26ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -72,6 +72,11 @@ * 18944: Completion/Unix/Command/_ruby: update ruby completion for version 1.8.0 and add descriptions for -T matches +2003-08-11 Peter Stephenson + + * 18941: Src/hist.c, Src/input.c: Alias text could end up in + history after a parsing error during alias expansion. + 2003-08-05 Peter Stephenson * 18926: Src/Zle/complist.c: fix (without knowing how) insertion @@ -152,6 +157,11 @@ * 18877: Etc/completion-style-guide: add a few more points +2003-07-22 Peter Stephenson + + * 18880: Src/Modules/parameter.c: Don't return unset variables + in whole array value for $parameters. + 2003-07-21 Doug Kearns * 18872: Completion/Unix/Command/_java: update javac completion for @@ -228,6 +238,10 @@ spaces) was flakey. The same problem probably exists for completing modified files, but the code is indecipherable. + * 18769: Src/exec.c: parse error in autoloading file causes + return value zero and empty function definition. Presumed + to be error introduced with wordcode. + 2003-07-02 Oliver Kiddle * 18520, 13691 (Mario Lang), 13701 (Sven): @@ -295,6 +309,11 @@ * 18600: Src/pattern.c: bug matching against [[:xdigit:]]. +2003-05-19 Peter Stephenson + + * 18548: Src/Zle/zle_main.c: memory leak when vared'ing arrays + spotted by valgrind (18543). + 2003-05-14 Peter Stephenson * Jonathan Paisley : 18513: @@ -408,6 +427,11 @@ Completion/Cygwin/Command/_pscp, Completion/Cygwin/Command/_putclip: cygwin completion functions. +2003-04-04 Peter Stephenson + + * 18435: Src/builtin.c, Src/params.c: spotted by Oliver: unsetting + a readonly variable returned status 0. + 2003-03-28 Wayne Davison * 18402: Src/builtin.c: Prevent "print -m" from crashing (it now diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c index e023ca9fe..5b897a7dc 100644 --- a/Src/Modules/parameter.c +++ b/Src/Modules/parameter.c @@ -181,6 +181,8 @@ scanpmparameters(HashTable ht, ScanFunc func, int flags) for (i = 0; i < realparamtab->hsize; i++) for (hn = realparamtab->nodes[i]; hn; hn = hn->next) { + if (((Param)hn)->flags & PM_UNSET) + continue; pm.nam = hn->nam; if (func != scancountparams && ((flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) || diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index cb1854e9b..b7c7767b7 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -949,9 +949,10 @@ bin_vared(char *name, char **args, char *ops, int func) /* * Use spacesplit with fourth argument 1: identify quoted separators, - * unquote but don't split. + * and unquote. This duplicates the string, so we still need to free. */ a = spacesplit(t, 1, 0, 1); + zsfree(t); if (PM_TYPE(pm->flags) == PM_ARRAY) setaparam(args[0], a); else diff --git a/Src/builtin.c b/Src/builtin.c index bfb2f85b8..be5d124b6 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -2399,8 +2399,10 @@ bin_unset(char *name, char **argv, char *ops, int func) zerrnam(name, "%s: invalid element for unset", s, 0); returnval = 1; } - } else - unsetparam_pm(pm, 0, 1); + } else { + if (unsetparam_pm(pm, 0, 1)) + returnval = 1; + } if (ss) *ss = '['; } diff --git a/Src/exec.c b/Src/exec.c index 77b657c18..7a457696a 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3272,7 +3272,7 @@ loadautofn(Shfunc shf, int fksh, int autol) return NULL; } if (!prog) - prog = &dummy_eprog; + return NULL; if (ksh == 2 || (ksh == 1 && isset(KSHAUTOLOAD))) { if (autol) { prog->flags |= EF_RUN; diff --git a/Src/hist.c b/Src/hist.c index e40007049..4a01ff652 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -290,6 +290,8 @@ safeinungetc(int c) void herrflush(void) { + inpopalias(); + while (!lexstop && inbufct && !strin) hwaddc(ingetc()); } diff --git a/Src/input.c b/Src/input.c index 525a3202a..bf31c09cf 100644 --- a/Src/input.c +++ b/Src/input.c @@ -540,3 +540,17 @@ inpop(void) inpoptop(); } while (remcont); } + +/* + * Expunge any aliases from the input stack; they shouldn't appear + * in the history and need to be flushed explicitly when we encounter + * an error. + */ + +/**/ +void +inpopalias(void) +{ + while (inbufflags & INP_ALIAS) + inpoptop(); +} diff --git a/Src/params.c b/Src/params.c index aa80bcc78..e2a9f61f7 100644 --- a/Src/params.c +++ b/Src/params.c @@ -2089,18 +2089,18 @@ unsetparam(char *s) /* Unset a parameter */ /**/ -mod_export void +mod_export int unsetparam_pm(Param pm, int altflag, int exp) { Param oldpm, altpm; if ((pm->flags & PM_READONLY) && pm->level <= locallevel) { zerr("read-only variable: %s", pm->nam, 0); - return; + return 1; } if ((pm->flags & PM_RESTRICTED) && isset(RESTRICTED)) { zerr("%s: restricted", pm->nam, 0); - return; + return 1; } pm->unsetfn(pm, exp); if ((pm->flags & PM_EXPORTED) && pm->env) { @@ -2142,7 +2142,7 @@ unsetparam_pm(Param pm, int altflag, int exp) */ if ((pm->level && locallevel >= pm->level) || (pm->flags & (PM_SPECIAL|PM_REMOVABLE)) == PM_SPECIAL) - return; + return 0; /* remove parameter node from table */ paramtab->removenode(paramtab, pm->nam); @@ -2167,6 +2167,8 @@ unsetparam_pm(Param pm, int altflag, int exp) } paramtab->freenode((HashNode) pm); /* free parameter node */ + + return 0; } /* Standard function to unset a parameter. This is mostly delegated to * -- cgit 1.4.1