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

PATCH: fix problem with globs inside (e) glob qualifier



On 19 Dec, I wrote:
> 
> I've just checked again and it does crash 4.0.2. It just takes a few
> runs, depending on the files in the current directory as it is doing
> globbing.
>   : *(e:'a=( * )':)
> seems to be sufficient. I suppose the filename generation code doesn't
> like being called recursively.

glob.c does contain code for saving and restoring it's state but it was
broken in a couple of places. First after saving pathbuf, the saved copy
was set to null. Then, in one place the values were not restored. There
may be other problems still there due to the save function not
reinitialising all the variables.

Oliver

Index: glob.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/glob.c,v
retrieving revision 1.28
diff -u -r1.28 glob.c
--- glob.c	5 Aug 2002 12:35:59 -0000	1.28
+++ glob.c	19 Feb 2003 18:09:55 -0000
@@ -181,9 +181,9 @@
     (N).gd_pathpos = pathpos; \
     (N).gd_pathbuf = pathbuf; \
     (N).gd_pathbufsz = 0; \
-    (N).gd_pathbuf = NULL; \
     (N).gd_glob_pre = glob_pre; \
     (N).gd_glob_suf = glob_suf; \
+    pathbuf = NULL; \
   } while (0)
 
 #define restore_globstate(N) \
@@ -234,7 +234,7 @@
 }
 
 /* stat the filename s appended to pathbuf.  l should be true for lstat,    *
- * false for stat.  If st is NULL, the file is only chechked for existance. *
+ * false for stat.  If st is NULL, the file is only checked for existance.  *
  * s == "" is treated as s == ".".  This is necessary since on most systems *
  * foo/ can be used to reference a non-directory foo.  Returns nonzero if   *
  * the file does not exists.                                                */
@@ -1580,6 +1580,7 @@
 	} else if (isset(NOMATCH)) {
 	    zerr("no matches found: %s", ostr, 0);
 	    free(matchbuf);
+	    restore_globstate(saved);
 	    return;
 	} else {
 	    /* treat as an ordinary string */

This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.



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