zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: parsing inner function definition.
@ 2002-06-02 17:58 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2002-06-02 17:58 UTC (permalink / raw)
  To: Zsh hackers list

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@pwstephenson.fsnet.co.uk>
Work: pws@csr.com
Web: http://www.pwstephenson.fsnet.co.uk


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

only message in thread, other threads:[~2002-06-02 17:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-02 17:58 PATCH: parsing inner function definition 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).