summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--Completion/compinstall2
-rw-r--r--Src/params.c2
-rw-r--r--Test/D06subscript.ztst8
4 files changed, 17 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 59d29622c..d7cf980e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-03-18  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 24717, 24718, 24719: Completion/compinstall, Src/params.c,
+	Test/D06subscript.ztst: a 0 subscript is neither valid nor
+	equivalent to 1 any longer, so the (i) subscript flag on an empty
+	array needs to yield 1 as it probably always should have.
+
 2008-03-15  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* unposted: Completion/Unix/Command/.distfiles,
@@ -1012,7 +1019,7 @@
 2007-10-26  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* unposted: Src/curses.c: zcurses input oops.
-	
+
 	* 24024: configure.ac, Doc/Zsh/mod_curses.yo,
 	Src/Modules/curses.c, Src/Modules/curses_keys.awk:  add "zcurses
 	input" for single character raw input without echoing.  Test for
@@ -6234,7 +6241,7 @@
 	* 21316 (modified): Completion/Unix/Command/_less,
 	Completion/Unix/Type/_ctags_tags: new completion for ctags tags; update
 	less -t completion to use it
-	
+
 	* 21320: Completion/Unix/Command/_screen: complete -D and -R with the
 	appropriate session types; fix incorrect completion of -c and -dmS
 	options
diff --git a/Completion/compinstall b/Completion/compinstall
index d4562d739..4fc615958 100644
--- a/Completion/compinstall
+++ b/Completion/compinstall
@@ -1438,7 +1438,7 @@ number of completions.  Please enter:
 	 done
 	 amenu=(${=menu})
 	 elt=${amenu[(i)*select*]}
-	 [[ $elt -gt $#amenu ]] && elt=
+	 [[ $elt -eq 0 || $elt -gt $#amenu ]] && elt=
 	 case $select in
 	   <->) if [[ -n $elt ]]; then
 		  amenu[$elt]="select=$select"
diff --git a/Src/params.c b/Src/params.c
index f7534472c..d7135c438 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -1317,7 +1317,7 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w,
 	    } else
 		ta = getarrvalue(v);
 	    if (!ta || !*ta)
-		return 0;
+		return !down;
 	    len = arrlen(ta);
 	    if (beg < 0)
 		beg += len;
diff --git a/Test/D06subscript.ztst b/Test/D06subscript.ztst
index 6c9f477cc..4cb814977 100644
--- a/Test/D06subscript.ztst
+++ b/Test/D06subscript.ztst
@@ -178,11 +178,15 @@
 >lower
 >upper
 
-  typeset -a empty_array
-  echo X${${l##*}[-1]}X
+  typeset -ga empty
+  echo X${${empty##*}[-1]}X
 0:Negative index applied to substition result from empty array
 >XX
 
+  print $empty[(i)] $empty[(I)]
+0:(i) returns 1 for empty array, (I) returns 0.
+>1 0
+
   array=(one two three four)
   print X$array[0]X
 0:Element zero is empty if KSH_ZERO_SUBSCRIPT is off.