zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: shell function context for substitution
@ 2008-09-29 15:11 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2008-09-29 15:11 UTC (permalink / raw)
  To: Zsh hackers list

Minor fix for ~[...]: it doesn't set a shell function context.  The only
consequence I'm aware of that would be visible is an error message when
debugging is turned on when it autoloads zsh_directory_name because it
tries to turn the code into text and can't because it hasn't yet been
loaded.

The cleanest fix is to make this a new context.  I don't think the
specific contexts are used anywhere, just the fact that there is on.

Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.202
diff -u -r1.202 utils.c
--- Src/utils.c	27 Sep 2008 23:15:10 -0000	1.202
+++ Src/utils.c	29 Sep 2008 15:08:51 -0000
@@ -2935,14 +2935,23 @@
 char **
 subst_string_by_func(Shfunc func, char *arg1, char *orig)
 {
+    int osc = sfcontext;
     LinkList l = newlinklist();
+    char **ret;
+
     addlinknode(l, func->node.nam);
     if (arg1)
 	addlinknode(l, arg1);
     addlinknode(l, orig);
+    sfcontext = SFC_SUBST;
+
     if (doshfunc(func, l, 1))
-	return NULL;
-    return getaparam("reply");
+	ret = NULL;
+    else
+	ret = getaparam("reply");
+
+    sfcontext = osc;
+    return ret;
 }
 
 /**/
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.146
diff -u -r1.146 zsh.h
--- Src/zsh.h	11 Sep 2008 12:49:20 -0000	1.146
+++ Src/zsh.h	29 Sep 2008 15:08:52 -0000
@@ -1076,6 +1076,7 @@
 #define SFC_WIDGET   4		/* user defined widget */
 #define SFC_COMPLETE 5		/* called from completion code */
 #define SFC_CWIDGET  6		/* new style completion widget */
+#define SFC_SUBST    7          /* used to perform substitution task */
 
 /* tp in funcstack */
 

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-09-29 15:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-29 15:11 PATCH: shell function context for substitution Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).