Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Pre-3.0.8 consolidated PATCH



On Apr 22, 10:01am, Peter Stephenson wrote:
} Subject: Re: Potential 3.0.8 [was Re: broken parsing with $((`:`))]
}
} On Wed, 15 Apr 2015 09:23:00 -0700
} Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
} > I have the following un-pushed changes (some of which have been posted
} > in previous articles, some not):
} > 
} >  remove _message from _mkdir
} >  unquote history words when command line has a quote
} >  no files to add in compaudit
} >  compsys.yo tweak "will" -> "will be"
} >  local TZ in strftime
} >  quote/quotebreak remove useless cast
} >  doc vindex pid
} >  allow clobber of zero-sized files
} >  maybe-helpful change free() to zfree() in two places
} >  add backslash to alias expansion matching in _expand
} >  test for breadth-first glob with (Y1)
} 
} As far as I can see the only potentially controversial thing there is
} "allow clobber of zero-sized files", but I haven't looked back over the
} messages.

The following patch includes all of the above except that "clobber" one.
This is just to get an article number, I'll do separate commits for each
of the changes.


diff --git a/Completion/Base/Completer/_expand b/Completion/Base/Completer/_expand
index e52144c..3c76e13 100644
--- a/Completion/Base/Completer/_expand
+++ b/Completion/Base/Completer/_expand
@@ -87,7 +87,7 @@ if [[ "$force" = *s* ]] ||
 
   setopt aliases
   eval 'exp=( ${${(e)exp//\\[ 	
-]/ }//(#b)([ 	
+]/ }//(#b)([ 	\\
 ])/\\$match[1]} )' 2>/dev/null
   setopt NO_aliases
 else
diff --git a/Completion/Base/Completer/_history b/Completion/Base/Completer/_history
index 63878ac..cd69ca1 100644
--- a/Completion/Base/Completer/_history
+++ b/Completion/Base/Completer/_history
@@ -51,9 +51,14 @@ ISUFFIX=
 # We skip the first element of historywords so the current word doesn't
 # interfere with the completion
 
+local -a hslice
 while [[ $compstate[nmatches] -eq 0 && beg -lt max ]]; do
+  if [[ -n $compstate[quote] ]]
+  then hslice=( ${(Q)historywords[beg,beg+slice]} )
+  else hslice=( ${historywords[beg,beg+slice]} )
+  fi
   _wanted "$opt" history-words expl 'history word' \
-      compadd -Q -a 'historywords[beg,beg+slice]'
+      compadd -Q -a hslice
   (( beg+=slice ))
 done
 
diff --git a/Completion/Unix/Command/_mkdir b/Completion/Unix/Command/_mkdir
index b5f7519..58d6c74 100644
--- a/Completion/Unix/Command/_mkdir
+++ b/Completion/Unix/Command/_mkdir
@@ -61,7 +61,7 @@ case "$state" in
       [[ $variant == zsh && ${#${${words[2,-1]}:#-*}} -gt 0 ]]; then
       _wanted directories expl \
         'parent directory (alternatively specify name of directory)' \
-        _path_files -/ && ret=0 || _message 'name of directory'
+        _path_files -/ && ret=0
     fi
     ;;
 esac
diff --git a/Completion/compaudit b/Completion/compaudit
index 00125e4..fb0463c 100644
--- a/Completion/compaudit
+++ b/Completion/compaudit
@@ -71,6 +71,7 @@ if [[ -n $_compdir ]]; then
       _i_addfiles=(${_compdir}/*(/^M))
     fi
     for _i_line in {1..$#_i_addfiles}; do
+      (( $_i_line )) || break
       _i_file=${_i_addfiles[$_i_line]}
       [[ -d $_i_file && -z ${fpath[(r)$_i_file]} ]] ||
         _i_addfiles[$_i_line]=
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 45afe24..b699502 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -354,7 +354,7 @@ tt(all): no further completion is attempted; a string
 containing the substring tt(patterns): no pattern completion functions
 will be called; a string containing tt(default): the
 function for the `tt(-default-)' context will not be called, but
-functions defined for commands will
+functions defined for commands will be.
 )
 kindex(-math-, completion context)
 item(tt(-math-))(
diff --git a/Doc/Zsh/mod_system.yo b/Doc/Zsh/mod_system.yo
index d6b3765..7101e37 100644
--- a/Doc/Zsh/mod_system.yo
+++ b/Doc/Zsh/mod_system.yo
@@ -181,10 +181,12 @@ A readonly associative array.  The keys are:
 
 startitem()
 item(tt(pid))(
+vindex(pid, sysparams)
 Returns the process ID of the current process, even in subshells.  Compare
 tt($$), which returns the process ID of the main shell process.
 )
 item(tt(ppid))(
+vindex(ppid, sysparams)
 Returns the process ID of the parent of the current process, even in
 subshells.  Compare tt($PPID), which returns the process ID of the parent
 of the main shell process.
diff --git a/Src/Modules/datetime.c b/Src/Modules/datetime.c
index 00ebd2b..63a04dc 100644
--- a/Src/Modules/datetime.c
+++ b/Src/Modules/datetime.c
@@ -94,7 +94,7 @@ reverse_strftime(char *nam, char **argv, char *scalar, int quiet)
 }
 
 static int
-bin_strftime(char *nam, char **argv, Options ops, UNUSED(int func))
+output_strftime(char *nam, char **argv, Options ops, UNUSED(int func))
 {
     int bufsize, x;
     char *endptr = NULL, *scalar = NULL, *buffer;
@@ -145,6 +145,25 @@ bin_strftime(char *nam, char **argv, Options ops, UNUSED(int func))
     return 0;
 }
 
+static int
+bin_strftime(char *nam, char **argv, Options ops, int func)
+{
+    int result = 1;
+    char *tz = getsparam("TZ");
+
+    startparamscope();
+    if (tz && *tz) {
+	Param pm = createparam("TZ", PM_LOCAL|PM_SCALAR|PM_EXPORTED);
+	if (pm)
+	    pm->level = locallevel; /* because createparam() doesn't */
+	setsparam("TZ", ztrdup(tz));
+    }
+    result = output_strftime(nam, argv, ops, func);
+    endparamscope();
+
+    return result;
+}
+
 static zlong
 getcurrentsecs(UNUSED(Param pm))
 {
diff --git a/Src/compat.c b/Src/compat.c
index 09b3d6a..b3a8b06 100644
--- a/Src/compat.c
+++ b/Src/compat.c
@@ -443,7 +443,7 @@ zgetcwd(void)
 	ret = getcwd(cwdbuf, PATH_MAX);
 	if (ret)
 	    ret = dupstring(ret);
-	free(cwdbuf);
+	zfree(cwdbuf, PATH_MAX);
 #endif /* GETCWD_CALLS_MALLOC */
     }
 #endif /* HAVE_GETCWD */
diff --git a/Src/hist.c b/Src/hist.c
index 185d0a0..bd03c4f 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -2255,10 +2255,10 @@ getargs(Histent elist, int arg1, int arg2)
 }
 
 /**/
-int
+static int
 quote(char **tr)
 {
-    char *ptr, *rptr, **str = (char **)tr;
+    char *ptr, *rptr, **str = tr;
     int len = 3;
     int inquotes = 0;
 
@@ -2299,7 +2299,7 @@ quote(char **tr)
 static int
 quotebreak(char **tr)
 {
-    char *ptr, *rptr, **str = (char **)tr;
+    char *ptr, *rptr, **str = tr;
     int len = 3;
 
     for (ptr = *str; *ptr; ptr++, len++)
diff --git a/Src/init.c b/Src/init.c
index 3e41fb9..102276a 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -1409,7 +1409,7 @@ source(char *s)
 	retflag = 0;
     scriptname = old_scriptname;
     scriptfilename = old_scriptfilename;
-    free(cmdstack);
+    zfree(cmdstack, CMDSTACKSZ);
     cmdstack = ocs;
     cmdsp = ocsp;
 
diff --git a/Test/D02glob.ztst b/Test/D02glob.ztst
index 217ce7c..3e2095a 100644
--- a/Test/D02glob.ztst
+++ b/Test/D02glob.ztst
@@ -548,6 +548,7 @@
  (){ print "Negated:" $@:t } glob.tmp/dir*(Y1^Y)
  (){ print "Sorting:" $@:t } glob.tmp/dir*(Y4On)
  (){ [[ $#@ -eq 1 ]] && print Globs before last path component } glob.tmp/dir?/subdir(NY1)
+ (){ [[ $1 == glob.tmp/a ]] } glob.tmp/**/a(Y1) && print Breadth first
  (){ [[ $#@ -eq 0 ]] && print Respects qualifiers } glob.tmp/dir*(NY1.)
  (print -- *(Y)) 2>/dev/null || print "Argument required"
 0:short-circuit modifier
@@ -558,6 +559,7 @@
 >Negated: dir1 dir2 dir3 dir4
 >Sorting: dir4 dir3 dir2 dir1
 >Globs before last path component
+>Breadth first
 >Respects qualifiers
 >Argument required
 

-- 
Barton E. Schaefer



Messages sorted by: Reverse Date, Date, Thread, Author