diff options
-rw-r--r-- | ChangeLog | 40 | ||||
-rw-r--r-- | Completion/Base/Utility/_regex_words | 8 | ||||
-rw-r--r-- | Completion/Unix/Command/_curl | 7 | ||||
-rw-r--r-- | Completion/Unix/Type/_urls | 2 | ||||
-rw-r--r-- | Config/version.mk | 4 | ||||
-rw-r--r-- | Functions/Misc/zcalc | 4 | ||||
-rw-r--r-- | Functions/Prompts/prompt_walters_setup | 6 | ||||
-rw-r--r-- | Src/Modules/param_private.c | 59 | ||||
-rw-r--r-- | Test/B02typeset.ztst | 4 | ||||
-rw-r--r-- | Test/V10private.ztst | 40 |
10 files changed, 145 insertions, 29 deletions
@@ -1,5 +1,45 @@ +2015-11-29 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * unposted; Config/version.mk: 5.1.1-test-3. + +2015-11-28 Daniel Shahaf <d.s@daniel.shahaf.name> + + * unposted (after 37243): Test/B02typeset.ztst: Explain the + breadcrumb by adding a comment. + +2015-11-27 Barton E. Schaefer <schaefer@zsh.org> + + * unposted: Test/V10private.ztst: %cleanup block is not called when + %prep sets ZTST_unimplemented, so avoid leaving a mess + + * 37243: Test/B02typeset.ztst, Test/V10private.ztst: too many + problems with inserting a line into B02, instead add a placeholder + and substitute for it. + +2015-11-27 Peter Stephenson <p.stephenson@samsung.com> + + * unposted: Functions/Misc/zcalc: ZCALCPROMPT created globally. + +2015-11-27 Daniel Shahaf <d.s@daniel.shahaf.name> + + * 37214: Functions/Prompts/prompt_walters_setup: 'prompt + walters': Don't export PS1 + + * 37163: Completion/Unix/Command/_curl, + Completion/Unix/Type/_urls: Remove curl completion + + * 37215: Completion/Base/Utility/_regex_words: _regex_words: + Don't add mismatched parentheses + 2015-11-26 Barton E. Schaefer <schaefer@zsh.org> + * 37229: Src/Modules/param_private.c, Test/V10private.ztst: non- + local assignment to a parameter name whose outermost declaration + is private, is an error rather than a silent no-op. Fix %prep + from 37225 for Solaris. + + * unposted (cf. 37226): Test/B02typeset.ztst: export == typeset -xg + * 37225: Test/V10private.ztst: fix test from 37208 * 37224: Test/B02typeset.ztst: delete obsolete comment diff --git a/Completion/Base/Utility/_regex_words b/Completion/Base/Utility/_regex_words index 77ba197a4..62c2491bb 100644 --- a/Completion/Base/Utility/_regex_words +++ b/Completion/Base/Utility/_regex_words @@ -20,7 +20,13 @@ local tag=$1 local desc=$2 shift 2 -reply=(\() +if (( $# )); then + reply=(\() +else + # ### Is this likely to happen in callers? Should we warn? + reply=() + return +fi integer i local -a wds diff --git a/Completion/Unix/Command/_curl b/Completion/Unix/Command/_curl new file mode 100644 index 000000000..72e2e5b53 --- /dev/null +++ b/Completion/Unix/Command/_curl @@ -0,0 +1,7 @@ +#compdef curl + +# As of 7.43.0, curl upstream provides its own _curl definition. This +# definition is provided as a fallback, and should be installed later +# in $fpath than the curl-provided definition of _curl. + +_urls "$@" diff --git a/Completion/Unix/Type/_urls b/Completion/Unix/Type/_urls index 6f23803ed..e81eaac05 100644 --- a/Completion/Unix/Type/_urls +++ b/Completion/Unix/Type/_urls @@ -1,4 +1,4 @@ -#compdef curl -value-,WWW_HOME,-default- -P -value-,(ftp|http(|s))_proxy,-default- +#compdef -value-,WWW_HOME,-default- -P -value-,(ftp|http(|s))_proxy,-default- # Configuration styles used: # diff --git a/Config/version.mk b/Config/version.mk index 8e28886ad..6205a6f77 100644 --- a/Config/version.mk +++ b/Config/version.mk @@ -27,5 +27,5 @@ # This must also serve as a shell script, so do not add spaces around the # `=' signs. -VERSION=5.1.1-test-2 -VERSION_DATE='November 25, 2015' +VERSION=5.1.1-test-3 +VERSION_DATE='November 29, 2015' diff --git a/Functions/Misc/zcalc b/Functions/Misc/zcalc index 17700e48b..857007a94 100644 --- a/Functions/Misc/zcalc +++ b/Functions/Misc/zcalc @@ -114,7 +114,9 @@ forms=( '%2$g' '%.*g' '%.*f' '%.*E' '') zmodload -i zsh/mathfunc 2>/dev/null autoload -Uz zmathfuncdef -: ${ZCALCPROMPT="%1v> "} +if (( ! ${+ZCALCPROMPT} )); then + typeset -g ZCALCPROMPT="%1v> " +fi # Supply some constants. float PI E diff --git a/Functions/Prompts/prompt_walters_setup b/Functions/Prompts/prompt_walters_setup index b2b0b8430..7948254d8 100644 --- a/Functions/Prompts/prompt_walters_setup +++ b/Functions/Prompts/prompt_walters_setup @@ -14,10 +14,10 @@ EOF prompt_walters_setup () { if [[ "$TERM" != "dumb" ]]; then - export PROMPT='%B%(?..[%?] )%b%n@%U%m%u> ' - export RPROMPT="%F{${1:-green}}%~%f" + PROMPT='%B%(?..[%?] )%b%n@%U%m%u> ' + RPROMPT="%F{${1:-green}}%~%f" else - export PROMPT="%(?..[%?] )%n@%m:%~> " + PROMPT="%(?..[%?] )%n@%m:%~> " fi prompt_opts=(cr percent) diff --git a/Src/Modules/param_private.c b/Src/Modules/param_private.c index 7d1ba9c87..e13813c3d 100644 --- a/Src/Modules/param_private.c +++ b/Src/Modules/param_private.c @@ -170,11 +170,15 @@ static int bin_private(char *nam, char **args, LinkList assigns, Options ops, int func) { int from_typeset = 1; + int ofake = fakelevel; /* paranoia in case of recursive call */ makeprivate_error = 0; - if (!OPT_ISSET(ops, 'P')) - return bin_typeset(nam, args, assigns, ops, func); - else if (OPT_ISSET(ops, 'T')) { + if (!OPT_ISSET(ops, 'P')) { + fakelevel = 0; + from_typeset = bin_typeset(nam, args, assigns, ops, func); + fakelevel = ofake; + return from_typeset; + } else if (OPT_ISSET(ops, 'T')) { zwarn("bad option: -T"); return 1; } @@ -193,7 +197,7 @@ bin_private(char *nam, char **args, LinkList assigns, Options ops, int func) from_typeset = bin_typeset("private", args, assigns, ops, func); scanhashtable(paramtab, 0, 0, 0, makeprivate, 0); endparamscope(); - fakelevel = 0; + fakelevel = ofake; unqueue_signals(); return makeprivate_error | from_typeset; @@ -419,12 +423,21 @@ pph_unsetfn(Param pm, int explicit) * at this locallevel. Any that we find are marked PM_UNSET. If they are * already unset, they are also marked as PM_NORESTORE. * - * On exit from the scope, we find the same parameters again and remove + * The same game is played with PM_READONLY and PM_RESTRICTED, so private + * parameters are always read-only at deeper locallevel. This is possible + * because there is no builtin-command interface to set PM_RESTRICTED, so + * only parameters "known to the shell" can otherwise be restricted. + * + * On exit from the scope, we find the same parameters again and reset * the PM_UNSET and PM_NORESTORE flags as appropriate. We're guaraneed * by makeprivate() that PM_NORESTORE won't conflict with anything here. + * Similarly, PM_READONLY and PM_RESTRICTED are also reset. * */ +#define PM_WAS_UNSET PM_NORESTORE +#define PM_WAS_RONLY PM_RESTRICTED + static void scopeprivate(HashNode hn, int onoff) { @@ -432,17 +445,25 @@ scopeprivate(HashNode hn, int onoff) if (pm->level == locallevel) { if (!is_private(pm)) return; - if (onoff == PM_UNSET) + if (onoff == PM_UNSET) { if (pm->node.flags & PM_UNSET) - pm->node.flags |= PM_NORESTORE; + pm->node.flags |= PM_WAS_UNSET; else pm->node.flags |= PM_UNSET; - else { - if (pm->node.flags & PM_NORESTORE) + if (pm->node.flags & PM_READONLY) + pm->node.flags |= PM_WAS_RONLY; + else + pm->node.flags |= PM_READONLY; + } else { + if (pm->node.flags & PM_WAS_UNSET) pm->node.flags |= PM_UNSET; /* createparam() may frob */ else pm->node.flags &= ~PM_UNSET; - pm->node.flags &= ~PM_NORESTORE; + if (pm->node.flags & PM_WAS_RONLY) + pm->node.flags |= PM_READONLY; /* paranoia / symmetry */ + else + pm->node.flags &= ~PM_READONLY; + pm->node.flags &= ~(PM_WAS_UNSET|PM_WAS_RONLY); } } } @@ -478,8 +499,24 @@ getprivatenode(HashTable ht, const char *nam) HashNode hn = getparamnode(ht, nam); Param pm = (Param) hn; - while (!fakelevel && pm && locallevel > pm->level && is_private(pm)) + while (!fakelevel && pm && locallevel > pm->level && is_private(pm)) { + if (!(pm->node.flags & PM_UNSET)) { + /* + * private parameters are always marked PM_UNSET before we + * increment locallevel, so the only way we get here is + * when createparam() wants a new parameter that is not at + * the current locallevel and it has therefore cleared the + * PM_UNSET flag. + */ + DPUTS(pm->old, "BUG: PM_UNSET cleared in wrong scope"); + setfn_error(pm); + /* + * TODO: instead of throwing an error here, create a global + * parameter, insert as pm->old, handle WARN_CREATE_GLOBAL. + */ + } pm = pm->old; + } return (HashNode)pm; } diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst index 0aa16d2e3..fc8b3e46e 100644 --- a/Test/B02typeset.ztst +++ b/Test/B02typeset.ztst @@ -4,7 +4,7 @@ # Equivalences: # declare typeset -# export typeset -x +# export typeset -xg # float typeset -E # functions typeset -f # integer typeset -i @@ -21,6 +21,8 @@ # Assorted illegal flag combinations %prep + ## Do not remove the next line, it's used by V10private.ztst + # test_zsh_param_private mkdir typeset.tmp && cd typeset.tmp diff --git a/Test/V10private.ztst b/Test/V10private.ztst index d5bee5e88..513a3c43d 100644 --- a/Test/V10private.ztst +++ b/Test/V10private.ztst @@ -4,13 +4,12 @@ if ! zmodload zsh/param/private 2>/dev/null; then ZTST_unimplemented="can't load the zsh/param/private module for testing" + else + # Do not use .tmp here, ztst.zsh will remove it too soon (see %cleanup) + mkdir private.TMP + sed -e 's,# test_zsh_param_private,zmodload zsh/param/private,' < $ZTST_srcdir/B02typeset.ztst > private.TMP/B02 fi - # Do not use .tmp here, ztst.zsh will remove it too soon (see %cleanup) - mkdir private.TMP - sed '/^%prep/a \ - zmodload zsh/param/private' < $ZTST_srcdir/B02typeset.ztst > private.TMP/B02 - %test (zmodload -u zsh/param/private && zmodload zsh/param/private) @@ -243,15 +242,38 @@ F:note "typeset" rather than "private" in output from outer () { print X ${(kv)hash_test} hash_test=(even deeper) - array_test+=(${(kv)hash_test}) + { + array_test+=(${(kv)hash_test}) + } always { + print ${array_test-array_test not set} ${(t)array_test} + } } print Y ${(kv)hash_test} Z $array_test } print ${(kv)hash_test} ${(t)array_test} -0:privates are not visible in anonymous functions, part 3 +1:privates are not visible in anonymous functions, part 3 +>X top level +>array_test not set +?(anon):4: array_test: attempt to assign private in nested scope +F:future revision will create a global with this assignment + + typeset -a array_test + typeset -A hash_test=(top level) + () { + local -Pa array_test=(in function) + local -PA hash_test=($array_test) + () { + print X ${(kv)hash_test} + hash_test=(even deeper) + array_test+=(${(kv)hash_test}) + } + print Y ${(kv)hash_test} Z $array_test + } + print ${(kv)hash_test} $array_test +0:privates are not visible in anonymous functions, part 4 >X top level >Y in function Z in function ->even deeper +>even deeper even deeper typeset -A hash_test=(top level) () { @@ -263,7 +285,7 @@ F:note "typeset" rather than "private" in output from outer print Y ${(kv)hash_test} } print ${(t)hash_test} ${(kv)hash_test} -0:privates are not visible in anonymous functions, part 4 +0:privates are not visible in anonymous functions, part 5 >X top level >Y in function > |