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

PATCH: parsing inner function definition.



I've been hacking Eprog to provide reference counts, which should allow
code chunks to be freed immediately they stop being used instead of at
the outermost command level.  This seems to be going OK so far, but I'd
better check it a bit more before letting it loose on the world.

Meanwhile, a typo revealed this nasty bug in parsing which has been
there a long time (and hence this will go on the 4.0 line, too).

% outer() { inner(); }
%

Whoops, that should have been a parse error.  Now run outer, then inner,
and you will see a segmentation violation or something equally nasty.
The easiest fix I can see in this case is the following, but it may well
be there is more to it.

By the way, this bug showed up by way of attempting to parse the
non-standard form `fn() print code goes directly here;' which I doubt if
anyone ever uses.  Hence another attempt to fix it would be to allow
this form and insert a dummy Eprog at this point.  But I don't like that
as much.

Note that, owing to numerous excuses for not working (e.g. the Queen's
Golden Jubilee, the world cup, ...) I will be fairly unresponsive until
Wednesday.

Index: Src/parse.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/parse.c,v
retrieving revision 1.33
diff -u -r1.33 parse.c
--- Src/parse.c	7 Mar 2002 16:20:04 -0000	1.33
+++ Src/parse.c	2 Jun 2002 17:44:08 -0000
@@ -1590,6 +1590,8 @@
 		pl = ecadd(WCB_PIPE(WC_PIPE_END, 0));
 
 		par_cmd(&c);
+		if (!c)
+		    YYERROR(oecused);
 
 		set_sublist_code(sl, WC_SUBLIST_END, 0, ecused - 1 - sl, c);
 		set_list_code(ll, (Z_SYNC | Z_END), c);

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>
Work: pws@xxxxxxx
Web: http://www.pwstephenson.fsnet.co.uk



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