summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2015-11-26 21:14:04 +0100
committerAxel Beckert <abe@deuxchevaux.org>2015-11-26 21:14:04 +0100
commitd62e937278a04b2cc8d4dde8be9562b9f10b068c (patch)
tree9ed62f2ee69f3231b0da25c69b420f3830f0fb3f
parente439a99f592f80729d28f5b2f6f3fbb012a3fd9d (diff)
parent78abc72f64b03d675922f9a958fdf5d6aa32ab67 (diff)
downloadzsh-d62e937278a04b2cc8d4dde8be9562b9f10b068c.tar.gz
zsh-d62e937278a04b2cc8d4dde8be9562b9f10b068c.zip
Merge tag '5.1.1-test-2' into debian
Second test version prior to 5.2 release.
-rw-r--r--ChangeLog66
-rw-r--r--Completion/Unix/Type/_groups4
-rw-r--r--Config/version.mk4
-rw-r--r--Functions/Prompts/prompt_adam1_setup3
-rw-r--r--Functions/Prompts/prompt_adam2_setup3
-rw-r--r--Functions/Prompts/prompt_bart_setup5
-rw-r--r--Functions/Prompts/prompt_clint_setup3
-rw-r--r--Functions/Prompts/prompt_oliver_setup2
-rw-r--r--Functions/Prompts/prompt_special_chars1
-rw-r--r--Functions/Prompts/promptinit2
-rw-r--r--Functions/VCS_Info/VCS_INFO_nvcsformats1
-rw-r--r--Src/Modules/param_private.c44
-rw-r--r--Src/Zle/zle_main.c3
-rw-r--r--Src/builtin.c1
-rw-r--r--Src/params.c36
-rw-r--r--Src/subst.c2
-rw-r--r--Src/utils.c15
-rw-r--r--Test/B01cd.ztst14
-rw-r--r--Test/B09hash.ztst71
-rw-r--r--Test/C02cond.ztst18
-rw-r--r--Test/D07multibyte.ztst2
-rw-r--r--Test/V01zmodload.ztst6
-rw-r--r--Test/V02zregexparse.ztst4
-rw-r--r--Test/V03mathfunc.ztst5
-rw-r--r--Test/V04features.ztst3
-rw-r--r--Test/V05styles.ztst4
-rw-r--r--Test/V09datetime.ztst22
-rw-r--r--Test/V10private.ztst10
-rw-r--r--Test/X02zlevi.ztst2
-rw-r--r--Test/Y01completion.ztst2
-rw-r--r--Test/Y02compmatch.ztst2
-rw-r--r--Test/Y03arguments.ztst2
-rw-r--r--Test/comptest2
-rwxr-xr-xTest/ztst.zsh2
34 files changed, 277 insertions, 89 deletions
diff --git a/ChangeLog b/ChangeLog
index 8dbd45686..0cd1900fc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,67 @@
+2015-11-25 Peter Stephenson <p.w.stephenson@ntlworld.com>
+
+ * unposted: Config/version.mk: 5.1.1-test-2
+
+2015-11-23 Barton E. Schaefer <schaefer@zsh.org>
+
+ * 37208: Src/params.c: check for restricted parameter before
+ changing from unset to set; return NULL from setnparam() on
+ failure to retrieve value (avoids null-pointer dereference);
+ add some expository comments
+
+ * 37208: Test/V10parameter.ztst: re-run the "typeset" tests with
+ the private module loaded
+
+ * 37208: Src/Modules/param_private.c: assignment in a nested scope
+ should not change private parameters in the outer scope from unset
+ to set; bug remains that the attempt does not generate a warning
+
+ * 37206: Src/subst.c: fix ${(t)param} for "typeset -H param"
+
+ * 37205: Test/B01cd.ztst: update documentary comment
+
+2015-11-23 Peter Stephenson <p.stephenson@samsung.com>
+
+ * 37203: Src/params.c: WARN_CREATE_GLOBAL test in wrong place
+ for associative array.
+
+2015-11-22 Barton E. Schaefer <schaefer@zsh.org>
+
+ * Matthew Martin: 37201: Completion/Unix/Type/_groups: change
+ quoting to handle group names with spaces
+
+2015-11-22 Barton E. Schaefer <schaefer@zsh.org>
+
+ * 37192: Functions/Prompts/prompt_adam1_setup,
+ Functions/Prompts/prompt_adam2_setup,
+ Functions/Prompts/prompt_bart_setup,
+ Functions/Prompts/prompt_clint_setup,
+ Functions/Prompts/prompt_oliver_setup,
+ Functions/Prompts/prompt_special_chars,
+ Functions/Prompts/promptinit: silence WARN_CREATE_GLOBAL
+
+2015-11-22 Peter Stephenson <p.w.stephenson@ntlworld.com>
+
+ * 37191: Src/utils.c: some locales prduce valid empty output for
+ strtfime escapes %p and %P.
+
+ * 37188: Test/B09hash.ztst: new test.
+
+ * 37187: Src/builtin.c: infinite loop in "hash -m".
+
+ * 37186: Functions/VCS_Info/VCS_INFO_nvcsformats,
+ Src/Zle/zle_main.c: a couple of WARN_CREATE_GLOBAL fixes.
+
+2015-11-21 Barton E. Schaefer <schaefer@zsh.org>
+
+ * 37181: Test/C02cond.ztst, Test/D07multibyte.ztst,
+ Test/V01zmodload.ztst, Test/V02zregexparse.ztst,
+ Test/V03mathfunc.ztst, Test/V04features.ztst, Test/V05styles.ztst,
+ Test/V09datetime.ztst, Test/V10private.ztst, Test/X02zlevi.ztst,
+ Test/Y01completion.ztst, Test/Y02compmatch.ztst,
+ Test/Y03arguments.ztst, Test/comptest, Test/ztst.zsh: consistent
+ use of zmodload and corresponding ZTST_unimplemented or ZTST_skip
+
2015-11-21 Peter Stephenson <p.w.stephenson@ntlworld.com>
* unposted: Config/version.mk, Etc/FAQ.yo, README: make
@@ -20,7 +84,7 @@
* 37168: Src/params.c: no WARN_CREATE_GLOBAL on special parameters.
- * 20974: Src/builtin.c, Test/D04parameter.ztst: fix bug
+ * users/20974: Src/builtin.c, Test/D04parameter.ztst: fix bug
when scalar value assigned to special array in typeset.
2015-11-20 Daniel Shahaf <d.s@daniel.shahaf.name>
diff --git a/Completion/Unix/Type/_groups b/Completion/Unix/Type/_groups
index a5624269e..c5e5aaf83 100644
--- a/Completion/Unix/Type/_groups
+++ b/Completion/Unix/Type/_groups
@@ -13,9 +13,9 @@ if ! zstyle -a ":completion:${curcontext}:" groups groups; then
: ${(A)_cache_groups:=${${(M)${(f)"$(_call_program groups dscacheutil -q group)"}:#name*}##*: }}
fi
elif (( ${+commands[getent]} )); then
- : ${(A)_cache_groups:=${${(s: :)$(_call_program groups getent group 2>/dev/null)}%%:*}}
+ : ${(A)_cache_groups:=${${(f)"$(_call_program groups getent group 2>/dev/null)"}%%:*}}
else
- : ${(A)_cache_groups:=${${${(s: :)$(</etc/group)}%%:*}:#+}}
+ : ${(A)_cache_groups:=${${${(f)"$(</etc/group)"}%%:*}:#+}}
if (( ${+commands[ypcat]} )) &&
tmp=$(_call_program groups ypcat group.byname 2>/dev/null); then
_cache_groups+=( ${${(f)tmp}%%:*} ) # If you use YP
diff --git a/Config/version.mk b/Config/version.mk
index ff259cd5b..8e28886ad 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-1
-VERSION_DATE='November 21, 2015'
+VERSION=5.1.1-test-2
+VERSION_DATE='November 25, 2015'
diff --git a/Functions/Prompts/prompt_adam1_setup b/Functions/Prompts/prompt_adam1_setup
index aca0e59f1..27a613ca1 100644
--- a/Functions/Prompts/prompt_adam1_setup
+++ b/Functions/Prompts/prompt_adam1_setup
@@ -18,6 +18,7 @@ EOF
}
prompt_adam1_setup () {
+ setopt localoptions nowarncreateglobal
prompt_adam1_color1=${1:-'blue'}
prompt_adam1_color2=${2:-'cyan'}
prompt_adam1_color3=${3:-'green'}
@@ -33,7 +34,7 @@ prompt_adam1_setup () {
}
prompt_adam1_precmd () {
- setopt noxtrace localoptions
+ setopt localoptions noxtrace nowarncreateglobal
local base_prompt_expanded_no_color base_prompt_etc
local prompt_length space_left
diff --git a/Functions/Prompts/prompt_adam2_setup b/Functions/Prompts/prompt_adam2_setup
index 14603b439..b9445116b 100644
--- a/Functions/Prompts/prompt_adam2_setup
+++ b/Functions/Prompts/prompt_adam2_setup
@@ -20,6 +20,7 @@ EOF
prompt_adam2_setup () {
# Some can't be local
+ setopt localoptions nowarncreateglobal
local prompt_gfx_tlc prompt_gfx_mlc prompt_gfx_blc
if [[ $1 == '8bit' ]]; then
@@ -73,7 +74,7 @@ prompt_adam2_setup () {
}
prompt_adam2_precmd() {
- setopt noxtrace localoptions extendedglob
+ setopt localoptions extendedglob noxtrace nowarncreateglobal
local prompt_line_1
prompt_adam2_choose_prompt
diff --git a/Functions/Prompts/prompt_bart_setup b/Functions/Prompts/prompt_bart_setup
index 22c0c0340..cb032de8a 100644
--- a/Functions/Prompts/prompt_bart_setup
+++ b/Functions/Prompts/prompt_bart_setup
@@ -70,8 +70,8 @@ prompt_bart_help () {
print -nP '\n%E'
}
-integer PSCOL=1
-typeset PSCMD=
+integer -g PSCOL=1
+typeset -g PSCMD=
prompt_bart_preexec () {
setopt localoptions noxtrace noshwordsplit noksharrays unset
@@ -106,7 +106,6 @@ prompt_bart_precmd () {
psvar[8]='' # No padding until we compute it
psvar[9]=()
- typeset -g PSCOL
# Reset the truncation widths for upcoming computations
((PSCOL == 1)) || { PSCOL=1 ; prompt_bart_ps1 }
if [[ -o promptcr ]]
diff --git a/Functions/Prompts/prompt_clint_setup b/Functions/Prompts/prompt_clint_setup
index 822d3908f..876d30408 100644
--- a/Functions/Prompts/prompt_clint_setup
+++ b/Functions/Prompts/prompt_clint_setup
@@ -38,12 +38,13 @@ prompt_clint_setup () {
[[ -n "$WINDOW" ]] && p_win="$pc['\(']%F{$pcc[4]}$WINDOW$pc['\)']"
p_userpwd="$pc['<']%F{$pcc[3]}%n@%m$p_win%F{$pcc[5]}:%F{$pcc[4]}%~$pc['>']"
- p_vcs="%(2v.%U%2v%u.)"
+ local p_vcs="%(2v.%U%2v%u.)"
p_shlvlhist="%fzsh%(2L./$SHLVL.) %B%h%b "
p_rc="%(?..[%?%1v] )"
p_end="%f%B%#%b "
+ typeset -ga zle_highlight
zle_highlight[(r)default:*]=default:$pcc[2]
prompt="$p_date$p_tty$p_plat$p_ver
diff --git a/Functions/Prompts/prompt_oliver_setup b/Functions/Prompts/prompt_oliver_setup
index 44d3f99ae..979411d4b 100644
--- a/Functions/Prompts/prompt_oliver_setup
+++ b/Functions/Prompts/prompt_oliver_setup
@@ -37,6 +37,8 @@ prompt_oliver_setup() {
PS1="$pcolr$user$host%~%"'$((COLUMNS-12))'"(l.$prompt_newline. )[%h%1(j.%%%j.)%0(?..:%?)]%# %b%f%k" RPS2='<%^'
PS2=''
+
+ typeset -ga zle_highlight
zle_highlight[(r)default:*]=default:$tcolr
}
diff --git a/Functions/Prompts/prompt_special_chars b/Functions/Prompts/prompt_special_chars
index a8da6c3e5..82a1f2d96 100644
--- a/Functions/Prompts/prompt_special_chars
+++ b/Functions/Prompts/prompt_special_chars
@@ -19,6 +19,7 @@ if [[ ${LC_ALL:-${LC_CTYPE:-$LANG}} = *(UTF-8|utf8)* ]]; then
schars[261]=$'\xe2\x96\x92'
schars[260]=$'\xe2\x96\x91'
else
+ local code
for code in 300 304 332 333 371 372 262 261 260; do
eval "schars[$code]=\$'\\$code'"
done
diff --git a/Functions/Prompts/promptinit b/Functions/Prompts/promptinit
index edf2d028b..587248997 100644
--- a/Functions/Prompts/promptinit
+++ b/Functions/Prompts/promptinit
@@ -160,7 +160,7 @@ Use prompt -h <theme> for help on specific themes.'
for hook in chpwd precmd preexec periodic zshaddhistory zshexit; do
add-zsh-hook -D "${hook}" "prompt_*_${hook}"
done
- set -A zle_highlight ${zle_highlight:#default:*}
+ typeset -ga zle_highlight=( ${zle_highlight:#default:*} )
(( ${#zle_highlight} )) || unset zle_highlight
prompt_$1_setup "$@[2,-1]" && prompt_theme=( "$@" )
diff --git a/Functions/VCS_Info/VCS_INFO_nvcsformats b/Functions/VCS_Info/VCS_INFO_nvcsformats
index 581aa5a97..203a86d23 100644
--- a/Functions/VCS_Info/VCS_INFO_nvcsformats
+++ b/Functions/VCS_Info/VCS_INFO_nvcsformats
@@ -4,6 +4,7 @@
setopt localoptions noksharrays NO_shwordsplit
local c v rr
+local -a msgs
if [[ $1 == '-preinit-' ]] ; then
c='default'
diff --git a/Src/Modules/param_private.c b/Src/Modules/param_private.c
index 7f9aa7921..7d1ba9c87 100644
--- a/Src/Modules/param_private.c
+++ b/Src/Modules/param_private.c
@@ -218,8 +218,10 @@ setfn_error(Param pm)
* The unsetfn family compare locallevel and restore the old GSU before
* calling the original unsetfn. This assures that if the old unsetfn
* wants to use its getfn or setfn, they're unconditionally present.
+ * The "explicit" flag indicates that "unset" was called, if zero the
+ * parameter is going out of scope (see params.c).
*
- */
+ */
/**/
static char *
@@ -248,13 +250,15 @@ pps_setfn(Param pm, char *x)
/**/
static void
-pps_unsetfn(Param pm, int x)
+pps_unsetfn(Param pm, int explicit)
{
struct gsu_closure *c = (struct gsu_closure *)(pm->gsu.s);
GsuScalar gsu = (GsuScalar)(c->g);
pm->gsu.s = gsu;
if (locallevel <= pm->level)
- gsu->unsetfn(pm, x);
+ gsu->unsetfn(pm, explicit);
+ if (explicit)
+ pm->gsu.s = (GsuScalar)c;
}
/**/
@@ -283,13 +287,15 @@ ppi_setfn(Param pm, zlong x)
/**/
static void
-ppi_unsetfn(Param pm, int x)
+ppi_unsetfn(Param pm, int explicit)
{
struct gsu_closure *c = (struct gsu_closure *)(pm->gsu.i);
GsuInteger gsu = (GsuInteger)(c->g);
pm->gsu.i = gsu;
if (locallevel <= pm->level)
- gsu->unsetfn(pm, x);
+ gsu->unsetfn(pm, explicit);
+ if (explicit)
+ pm->gsu.i = (GsuInteger)c;
}
/**/
@@ -318,13 +324,15 @@ ppf_setfn(Param pm, double x)
/**/
static void
-ppf_unsetfn(Param pm, int x)
+ppf_unsetfn(Param pm, int explicit)
{
struct gsu_closure *c = (struct gsu_closure *)(pm->gsu.f);
GsuFloat gsu = (GsuFloat)(c->g);
pm->gsu.f = gsu;
if (locallevel <= pm->level)
- gsu->unsetfn(pm, x);
+ gsu->unsetfn(pm, explicit);
+ if (explicit)
+ pm->gsu.f = (GsuFloat)c;
}
/**/
@@ -354,13 +362,15 @@ ppa_setfn(Param pm, char **x)
/**/
static void
-ppa_unsetfn(Param pm, int x)
+ppa_unsetfn(Param pm, int explicit)
{
struct gsu_closure *c = (struct gsu_closure *)(pm->gsu.a);
GsuArray gsu = (GsuArray)(c->g);
pm->gsu.a = gsu;
if (locallevel <= pm->level)
- gsu->unsetfn(pm, x);
+ gsu->unsetfn(pm, explicit);
+ if (explicit)
+ pm->gsu.a = (GsuArray)c;
}
static HashTable emptytable;
@@ -391,13 +401,15 @@ pph_setfn(Param pm, HashTable x)
/**/
static void
-pph_unsetfn(Param pm, int x)
+pph_unsetfn(Param pm, int explicit)
{
struct gsu_closure *c = (struct gsu_closure *)(pm->gsu.h);
GsuHash gsu = (GsuHash)(c->g);
pm->gsu.h = gsu;
if (locallevel <= pm->level)
- gsu->unsetfn(pm, x);
+ gsu->unsetfn(pm, explicit);
+ if (explicit)
+ pm->gsu.h = (GsuHash)c;
}
/*
@@ -425,9 +437,13 @@ scopeprivate(HashNode hn, int onoff)
pm->node.flags |= PM_NORESTORE;
else
pm->node.flags |= PM_UNSET;
- else if (!(pm->node.flags & PM_NORESTORE))
- pm->node.flags &= ~PM_UNSET;
- pm->node.flags &= ~PM_NORESTORE;
+ else {
+ if (pm->node.flags & PM_NORESTORE)
+ pm->node.flags |= PM_UNSET; /* createparam() may frob */
+ else
+ pm->node.flags &= ~PM_UNSET;
+ pm->node.flags &= ~PM_NORESTORE;
+ }
}
}
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 593d636cc..38427e8e3 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -2045,7 +2045,8 @@ setup_(UNUSED(Module m))
bpaste = zshcalloc(3*sizeof(char *));
bpaste[0] = ztrdup("\033[?2004h");
bpaste[1] = ztrdup("\033[?2004l");
- setaparam("zle_bracketed_paste", bpaste);
+ /* Intended to be global, no WARNCREATEGLOBAL check. */
+ assignaparam("zle_bracketed_paste", bpaste, 0);
return 0;
}
diff --git a/Src/builtin.c b/Src/builtin.c
index 01eb5b84c..cac4f42f9 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3712,6 +3712,7 @@ bin_hash(char *name, char **argv, Options ops, UNUSED(int func))
zwarnnam(name, "bad pattern : %s", *argv);
returnval = 1;
}
+ argv++;
continue;
}
if (!(asg = getasg(&argv, NULL))) {
diff --git a/Src/params.c b/Src/params.c
index b121bd6ad..4600284f0 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -880,6 +880,10 @@ createparam(char *name, int flags)
zerr("read-only variable: %s", name);
return NULL;
}
+ if ((oldpm->node.flags & PM_RESTRICTED) && isset(RESTRICTED)) {
+ zerr("%s: restricted", name);
+ return NULL;
+ }
if (!(oldpm->node.flags & PM_UNSET) || (oldpm->node.flags & PM_SPECIAL)) {
oldpm->node.flags &= ~PM_UNSET;
if ((oldpm->node.flags & PM_SPECIAL) && oldpm->ename) {
@@ -890,10 +894,6 @@ createparam(char *name, int flags)
}
return NULL;
}
- if ((oldpm->node.flags & PM_RESTRICTED) && isset(RESTRICTED)) {
- zerr("%s: restricted", name);
- return NULL;
- }
pm = oldpm;
pm->base = pm->width = 0;
@@ -2777,6 +2777,7 @@ assignsparam(char *s, char *val, int flags)
if (!v && !(v = getvalue(&vbuf, &t, 1))) {
unqueue_signals();
zsfree(val);
+ /* errflag |= ERRFLAG_ERROR; */
return NULL;
}
if (flags & ASSPM_WARN_CREATE)
@@ -2926,6 +2927,7 @@ assignaparam(char *s, char **val, int flags)
if (!(v = fetchvalue(&vbuf, &t, 1, SCANPM_ASSIGNING))) {
unqueue_signals();
freearray(val);
+ /* errflag |= ERRFLAG_ERROR; */
return NULL;
}
@@ -2970,6 +2972,7 @@ sethparam(char *s, char **val)
struct value vbuf;
Value v;
char *t = s;
+ int checkcreate = 0;
if (!isident(s)) {
zerr("not an identifier: %s", s);
@@ -2987,9 +2990,9 @@ sethparam(char *s, char **val)
return NULL;
queue_signals();
if (!(v = fetchvalue(&vbuf, &s, 1, SCANPM_ASSIGNING))) {
+ DPUTS(!v, "BUG: assigning to undeclared associative array");
createparam(t, PM_HASHED);
- if (isset(WARNCREATEGLOBAL) && locallevel > 0)
- check_warn_create(v->pm, "associative array");
+ checkcreate = isset(WARNCREATEGLOBAL) && locallevel > 0;
} else if (!(PM_TYPE(v->pm->node.flags) & PM_HASHED) &&
!(v->pm->node.flags & PM_SPECIAL)) {
unsetparam(t);
@@ -3000,8 +3003,11 @@ sethparam(char *s, char **val)
if (!v)
if (!(v = fetchvalue(&vbuf, &t, 1, SCANPM_ASSIGNING))) {
unqueue_signals();
+ /* errflag |= ERRFLAG_ERROR; */
return NULL;
}
+ if (checkcreate)
+ check_warn_create(v->pm, "associative array");
setarrvalue(v, val);
unqueue_signals();
return v->pm;
@@ -3059,8 +3065,11 @@ setnparam(char *s, mnumber val)
} else if (val.type & MN_INTEGER) {
pm->base = outputradix;
}
- v = getvalue(&vbuf, &t, 1);
- DPUTS(!v, "BUG: value not found for new parameter");
+ if (!(v = getvalue(&vbuf, &t, 1))) {
+ DPUTS(!v, "BUG: value not found for new parameter");
+ /* errflag |= ERRFLAG_ERROR; */
+ return NULL;
+ }
if (!was_unset && isset(WARNCREATEGLOBAL) && locallevel > 0)
check_warn_create(v->pm, "numeric");
}
@@ -3217,6 +3226,10 @@ unsetparam_pm(Param pm, int altflag, int exp)
*
* This could usefully be made type-specific, but then we need
* to be more careful when calling the unset method directly.
+ *
+ * The "exp"licit parameter should be nonzero for assignments and the
+ * unset command, and zero for implicit unset (e.g., end of scope).
+ * Currently this is used only by some modules.
*/
/**/
@@ -5103,8 +5116,11 @@ freeparamnode(HashNode hn)
{
Param pm = (Param) hn;
- /* Since the second flag to unsetfn isn't used, I don't *
- * know what its value should be. */
+ /* The second argument of unsetfn() is used by modules to
+ * differentiate "exp"licit unset from implicit unset, as when
+ * a parameter is going out of scope. It's not clear which
+ * of these applies here, but passing 1 has always worked.
+ */
if (delunset)
pm->gsu.s->unsetfn(pm, 1);
zsfree(pm->node.nam);
diff --git a/Src/subst.c b/Src/subst.c
index b7f8338c7..d9c9d24aa 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2454,7 +2454,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
val = dyncat(val, "-unique");
if (f & PM_HIDE)
val = dyncat(val, "-hide");
- if (f & PM_HIDE)
+ if (f & PM_HIDEVAL)
val = dyncat(val, "-hideval");
if (f & PM_SPECIAL)
val = dyncat(val, "-special");
diff --git a/Src/utils.c b/Src/utils.c
index 0afa8c908..464097034 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -3143,6 +3143,7 @@ strftimehandling:
* in the accounting in bufsize (but nowhere else).
*/
{
+ char origchar = fmt[-1];
int size = fmt - fmtstart;
char *tmp, *last;
tmp = zhalloc(size + 1);
@@ -3163,11 +3164,17 @@ strftimehandling:
*buf = '\1';
if (!strftime(buf, bufsize + 2, tmp, tm))
{
- if (*buf) {
- buf[0] = '\0';
- return -1;
+ /*
+ * Some locales don't have strings for
+ * AM/PM, so empty output is valid.
+ */
+ if (*buf || (origchar != 'p' && origchar != 'P')) {
+ if (*buf) {
+ buf[0] = '\0';
+ return -1;
+ }
+ return 0;
}
- return 0;
}
decr = strlen(buf);
buf += decr;
diff --git a/Test/B01cd.ztst b/Test/B01cd.ztst
index a5b3769f1..94447e717 100644
--- a/Test/B01cd.ztst
+++ b/Test/B01cd.ztst
@@ -57,13 +57,13 @@
# subsequent whitespace being significant; lines are not subject to any
# substitution unless the `q' flag (see below) is set.
#
-# The first line (only) of a '>' and '?' chunk may be preceded by a '*',
-# so the line starts '*>' or '*?'. This signifies that all lines in the
-# chunk (not just the one with the '*' in front) in the actual output
-# are pattern matched against the corresponding lines in the test
-# output. Each line following '>' or '?' must be a valid pattern, so
-# characters special to patterns such as parentheses must be quoted
-# with a backslash. The EXTENDED_GLOB option is used for all such patterns.
+# Each line of a '>' and '?' chunk may be preceded by a '*', so the line
+# starts '*>' or '*?'. This signifies that for any line with '*' in front
+# the actual output should be pattern matched against the corresponding
+# lines in the test output. Each line following '>' or '?' must be a
+# valid pattern, so characters special to patterns such as parentheses
+# must be quoted with a backslash. The EXTENDED_GLOB option is used for
+# all such patterns.
#
# Each chunk of indented code is to be evaluated in one go and is to
# be followed by a line starting (in the first column) with
diff --git a/Test/B09hash.ztst b/Test/B09hash.ztst
new file mode 100644
index 000000000..49f304838
--- /dev/null
+++ b/Test/B09hash.ztst
@@ -0,0 +1,71 @@
+# The hash builtin is most used for the command hash table, which is
+# populated automatically. This is therefore highly system specific,
+# so mostly we'll test with the directory hash table: the logic is
+# virtually identical but with the different table, and furthermore
+# the shell doesn't care whether the directory exists unless you refer
+# to it in a context that needs one.
+
+%prep
+ populate_hash() {
+ hash -d one=/first/directory
+ hash -d two=/directory/the/second
+ hash -d three=/noch/ein/verzeichnis
+ hash -d four=/bored/with/this/now
+ }
+
+%test
+
+ hash -d
+0:Directory hash initially empty
+
+ populate_hash
+ hash -d
+0:Populating directory hash and output with sort
+>four=/bored/with/this/now
+>one=/first/directory
+>three=/noch/ein/verzeichnis
+>two=/directory/the/second
+
+ hash -rd
+ hash -d
+0:Empty hash
+
+ populate_hash
+ hash -d
+0:Refill hash
+>four=/bored/with/this/now
+>one=/first/directory
+>three=/noch/ein/verzeichnis
+>two=/directory/the/second
+
+ hash -dL
+0:hash -L option
+>hash -d four=/bored/with/this/now
+>hash -d one=/first/directory
+>hash -d three=/noch/ein/verzeichnis
+>hash -d two=/directory/the/second
+
+ hash -dm 't*'
+0:hash -m option
+>three=/noch/ein/verzeichnis
+>two=/directory/the/second
+
+ hash -d five=/yet/more six=/here/we/go seven=/not/yet/eight
+ hash -d
+0:Multiple assignments
+>five=/yet/more
+>four=/bored/with/this/now
+>one=/first/directory
+>seven=/not/yet/eight
+>six=/here/we/go
+>three=/noch/ein/verzeichnis
+>two=/directory/the/second
+
+ hash -d one two three
+0:Multiple arguments with no assignment not in verbose mode
+
+ hash -vd one two three
+0:Multiple arguments with no assignment in verbose mode
+>one=/first/directory
+>two=/directory/the/second
+>three=/noch/ein/verzeichnis
diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst
index e9a596a22..40bbf424a 100644
--- a/Test/C02cond.ztst
+++ b/Test/C02cond.ztst
@@ -257,7 +257,7 @@ F:Failures in these cases do not indicate a problem in the shell.
>status = 1
# core dumps on failure
- if zmodload -i zsh/regex 2>/dev/null; then
+ if zmodload zsh/regex 2>/dev/null; then
echo >regex_test.sh 'if [[ $# = 1 ]]; then
if [[ $1 =~ /?[^/]+:[0-9]+:$ ]]; then
:
@@ -268,7 +268,8 @@ F:Failures in these cases do not indicate a problem in the shell.
fi
0:regex tests shouldn't crash
- (if zmodload -i zsh/regex 2>/dev/null; then
+ if zmodload zsh/regex 2>/dev/null; then
+ ( # subshell in case coredump test failed
string="this has stuff in it"
bad_regex=0
if [[ $string =~ "h([a-z]*) s([a-z]*) " ]]; then
@@ -295,23 +296,26 @@ F:Failures in these cases do not indicate a problem in the shell.
else
print -r "regex failed to match '$string'"
fi
+ )
else
# if it didn't load, tough, but not a test error
- print OK
- fi)
+ ZTST_skip="regexp library not found."
+ fi
0:MATCH, MBEGIN, MEND, match, mbegin, mend
>OK
- (if zmodload -i zsh/regex 2>/dev/null; then
+ if zmodload zsh/regex 2>/dev/null; then
+ ( # subshell because regex module may dump core, see above
if [[ a =~ a && b == b ]]; then
print OK
else
print "regex =~ inverted following test"
fi
+ )
else
# not a test error
- print OK
- fi)
+ ZTST_skip="regexp library not found."
+ fi
0:regex infix operator should not invert following conditions
>OK
diff --git a/Test/D07multibyte.ztst b/Test/D07multibyte.ztst
index dff2ec12f..f95c06d9a 100644
--- a/Test/D07multibyte.ztst
+++ b/Test/D07multibyte.ztst
@@ -500,7 +500,7 @@
# aren't quite double width, but the arithmetic is correct.
# It appears just to be an effect of the font.
- if zmodload -i zsh/regex 2>/dev/null; then
+ if zmodload zsh/regex 2>/dev/null; then
[[ $'\ua0' =~ '^.$' ]] && print OK
[[ $'\ua0' =~ $'^\ua0$' ]] && print OK
[[ $'\ua0'X =~ '^X$' ]] || print OK
diff --git a/Test/V01zmodload.ztst b/Test/V01zmodload.ztst
index 3580bacea..349ae9c89 100644
--- a/Test/V01zmodload.ztst
+++ b/Test/V01zmodload.ztst
@@ -52,7 +52,7 @@
>zmodload zsh/main
>zmodload zsh/parameter
-# You use to need zmodload -i to avoid an error.
+# You used to need zmodload -i to avoid an error.
# That has been deemed pointless, so now an attempt
# to load a loaded module should succeed.
zmodload zsh/main
@@ -64,7 +64,7 @@
for m in $mods
do
- zmodload -i $m || mods[(r)$m]=()
+ zmodload $m || mods[(r)$m]=()
done
0d:Test loading of all compiled modules
@@ -74,7 +74,7 @@
# Now check for proper failure conditions by trying some operations on
# a nonexistent module.
- zmodload -i bogus/notamodule
+ zmodload bogus/notamodule
1D:Check that loading a nonexistent module fails
zmodload -u bogus/notamodule
diff --git a/Test/V02zregexparse.ztst b/Test/V02zregexparse.ztst
index ddca3c903..b4cec424e 100644
--- a/Test/V02zregexparse.ztst
+++ b/Test/V02zregexparse.ztst
@@ -2,7 +2,9 @@
%prep
- zmodload zsh/zutil
+ if ! zmodload zsh/zutil 2>/dev/null; then
+ ZTST_unimplemented="can't load the zsh/zutil module for testing"
+ fi
%test
diff --git a/Test/V03mathfunc.ztst b/Test/V03mathfunc.ztst
index ab383db43..1edb7a279 100644
--- a/Test/V03mathfunc.ztst
+++ b/Test/V03mathfunc.ztst
@@ -1,9 +1,7 @@
# Tests for the module zsh/mathfunc
%prep
- if ( zmodload -i zsh/mathfunc ) >/dev/null 2>&1; then
- zmodload -i zsh/mathfunc
- else
+ if ! zmodload zsh/mathfunc 2>/dev/null; then
ZTST_unimplemented="The module zsh/mathfunc is not available."
fi
@@ -112,7 +110,6 @@ F:This test fails if your math library doesn't have erand48().
float -F f sum sumsq max max2 av sd
typeset -a randoms
randoms=('f = RANDOM' 'f = rand48()')
- zmodload -i zsh/mathfunc
for isource in 1 2; do
(( sum = sumsq = max = 0 ))
repeat $N; do
diff --git a/Test/V04features.ztst b/Test/V04features.ztst
index 2790456e2..6939053e1 100644
--- a/Test/V04features.ztst
+++ b/Test/V04features.ztst
@@ -7,7 +7,8 @@
# We use zsh/datetime because it has a list of features that is short
# but contains two types.
- if ! (zmodload zsh/datetime >/dev/null 2>/dev/null); then
+ # Subshell for prep test so we can load individual features later
+ if ! (zmodload zsh/datetime 2>/dev/null); then
ZTST_unimplemented="can't load the zsh/datetime module for testing"
fi
diff --git a/Test/V05styles.ztst b/Test/V05styles.ztst
index e932b5474..ca95b6348 100644
--- a/Test/V05styles.ztst
+++ b/Test/V05styles.ztst
@@ -2,9 +2,7 @@
# Test the use of styles, if the zsh/zutil module is available.
- if (zmodload zsh/zutil >/dev/null 2>/dev/null); then
- zmodload zsh/zutil
- else
+ if ! zmodload zsh/zutil 2>/dev/null; then
ZTST_unimplemented="can't load the zsh/zutil module for testing"
fi
diff --git a/Test/V09datetime.ztst b/Test/V09datetime.ztst
index 1e677cd69..63ff4ee23 100644
--- a/Test/V09datetime.ztst
+++ b/Test/V09datetime.ztst
@@ -1,18 +1,18 @@
%prep
- if ! (zmodload zsh/datetime >/dev/null 2>/dev/null); then
+ if zmodload zsh/datetime 2>/dev/null; then
+ setopt multibyte
+ unset LC_ALL
+ LC_TIME=C
+ TZ=UTC+0
+ # It's not clear this skip_extensions is correct, but the
+ # format in question is causing problems on Solaris.
+ # We'll revist this after the release.
+ [[ "$(strftime %^_10B 0)" = " JANUARY" ]] || skip_extensions=1
+ [[ "$(LC_TIME=ja_JP.UTF-8 strftime %OS 1)" = 一 ]] || skip_japanese=1
+ else
ZTST_unimplemented="can't load the zsh/datetime module for testing"
fi
- setopt multibyte
- zmodload zsh/datetime
- unset LC_ALL
- LC_TIME=C
- TZ=UTC+0
- # It's not clear this skip_extensions is correct, but the
- # format in question is causing problems on Solaris.
- # We'll revist this after the release.
- [[ "$(strftime %^_10B 0)" = " JANUARY" ]] || skip_extensions=1
- [[ "$(LC_TIME=ja_JP.UTF-8 strftime %OS 1)" = 一 ]] || skip_japanese=1
%test
diff --git a/Test/V10private.ztst b/Test/V10private.ztst
index 6c38e3974..f877455fd 100644
--- a/Test/V10private.ztst
+++ b/Test/V10private.ztst
@@ -2,16 +2,20 @@
%prep
- if ! (zmodload zsh/param/private >/dev/null 2>/dev/null); then
+ if ! zmodload zsh/param/private 2>/dev/null; then
ZTST_unimplemented="can't load the zsh/param/private module for testing"
fi
- zmodload zsh/param/private
%test
(zmodload -u zsh/param/private && zmodload zsh/param/private)
0:unload and reload the module without crashing
+ $ZTST_exe +Z -f $ZTST_srcdir/ztst.zsh $ZTST_srcdir/B02typeset.ztst
+0:typeset still works with zsh/param/private module loaded
+*>*
+*>*
+
typeset scalar_test=toplevel
() {
print $scalar_test
@@ -238,7 +242,7 @@ F:note "typeset" rather than "private" in output from outer
}
print Y ${(kv)hash_test} Z $array_test
}
- print ${(kv)hash_test}
+ print ${(kv)hash_test} ${(t)array_test}
0:privates are not visible in anonymous functions, part 3
>X top level
>Y in function Z in function
diff --git a/Test/X02zlevi.ztst b/Test/X02zlevi.ztst
index 14bc02ef8..ced70300f 100644
--- a/Test/X02zlevi.ztst
+++ b/Test/X02zlevi.ztst
@@ -3,7 +3,7 @@
%prep
if [[ $OSTYPE = cygwin ]]; then
ZTST_unimplemented="the zsh/zpty module does not work on Cygwin"
- elif ( zmodload -i zsh/zpty ) >/dev/null 2>&1; then
+ elif ( zmodload zsh/zpty 2>/dev/null ); then
. $ZTST_srcdir/comptest
comptestinit -v -z $ZTST_testdir/../Src/zsh
else
diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst
index 383e6529f..1568369c8 100644
--- a/Test/Y01completion.ztst
+++ b/Test/Y01completion.ztst
@@ -3,7 +3,7 @@
%prep
if [[ $OSTYPE = cygwin ]]; then
ZTST_unimplemented="the zsh/zpty module does not work on Cygwin"
- elif ( zmodload -i zsh/zpty ) >/dev/null 2>&1; then
+ elif ( zmodload zsh/zpty 2>/dev/null ); then
. $ZTST_srcdir/comptest
mkdir comp.tmp
cd comp.tmp
diff --git a/Test/Y02compmatch.ztst b/Test/Y02compmatch.ztst
index db734facc..e2f8e1a61 100644
--- a/Test/Y02compmatch.ztst
+++ b/Test/Y02compmatch.ztst
@@ -13,7 +13,7 @@
%prep
if [[ $OSTYPE = cygwin ]]; then
ZTST_unimplemented="the zsh/zpty module does not work on Cygwin"
- elif ( zmodload -i zsh/zpty ) >/dev/null 2>&1; then
+ elif ( zmodload zsh/zpty 2>/dev/null ); then
. $ZTST_srcdir/comptest
mkdir match.tmp
cd match.tmp
diff --git a/Test/Y03arguments.ztst b/Test/Y03arguments.ztst
index 0627104f5..0147c7d14 100644
--- a/Test/Y03arguments.ztst
+++ b/Test/Y03arguments.ztst
@@ -3,7 +3,7 @@
%prep
if [[ $OSTYPE = cygwin ]]; then
ZTST_unimplemented="the zsh/zpty module does not work on Cygwin"
- elif ( zmodload -i zsh/zpty ) >/dev/null 2>&1; then
+ elif ( zmodload zsh/zpty 2>/dev/null ); then
. $ZTST_srcdir/comptest
mkdir comp.tmp
cd comp.tmp
diff --git a/Test/comptest b/Test/comptest
index 20a3a5b1d..f10739abe 100644
--- a/Test/comptest
+++ b/Test/comptest
@@ -5,7 +5,7 @@ comptestinit () {
$ZTST_srcdir/../Completion
$ZTST_srcdir/../Completion/*/*~*/CVS(/) )
- zmodload -i zsh/zpty || return $?
+ zmodload zsh/zpty || return $?
comptest_zsh=${ZSH:-zsh}
comptest_keymap=e
diff --git a/Test/ztst.zsh b/Test/ztst.zsh
index ce89a83ce..cdd84b55d 100755
--- a/Test/ztst.zsh
+++ b/Test/ztst.zsh
@@ -41,7 +41,7 @@ export MODULE_PATH
# We need to be able to save and restore the options used in the test.
# We use the $options variable of the parameter module for this.
-zmodload -i zsh/parameter
+zmodload zsh/parameter
# Note that both the following are regular arrays, since we only use them
# in whole array assignments to/from $options.