zsh-workers
 help / color / mirror / code / Atom feed
* Re: Funny bug when autoloading with syntax error
@ 2000-02-04  9:34 Sven Wischnowsky
  0 siblings, 0 replies; 2+ messages in thread
From: Sven Wischnowsky @ 2000-02-04  9:34 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> Autoload the following function:
> 
> if (( 1 )): then   # note colon instead of semicolon
>   true
> fi
> 
> This loads silently, unlike trying it at the command line which gives a
> parse error near `fi', which is not unexpected.  `which fn' gives
> 
> fn () {
>         if (( 1 ))
>         then
>                 : then
>         fi
>         true
> }
> 
> This is, not to put too fine a point on it, wrong.

But of course the bug is that it doesn't complain about a parse error, 
right?

I hope that all syntactically correct strings end with a token of
ENDINPUT in parse_list().

The hunk in exec.c makes loadautofn() treat empty functions in the
same way as execautofn().

Bye
 Sven

diff -ru ../z.old/Src/exec.c Src/exec.c
--- ../z.old/Src/exec.c	Fri Feb  4 09:53:28 2000
+++ Src/exec.c	Fri Feb  4 10:29:34 2000
@@ -3097,6 +3097,8 @@
 	zerr("%s: function definition file not found", shf->nam, 0);
 	return 1;
     }
+    if (!prog)
+	prog = &dummy_eprog;
     PERMALLOC {
 	shf->funcdef = dupeprog(stripkshdef(prog, shf->nam));
     } LASTALLOC;
diff -ru ../z.old/Src/parse.c Src/parse.c
--- ../z.old/Src/parse.c	Fri Feb  4 09:53:32 2000
+++ Src/parse.c	Fri Feb  4 10:25:35 2000
@@ -357,7 +357,11 @@
     incmdpos = 1;
     yylex();
     ret = par_list();
-    if (tok == LEXERR) {
+#if 0
+    if (tok == LEXERR)
+#endif
+    if (tok != ENDINPUT)
+    {
 	yyerror(0);
 	return NULL;
     }

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Funny bug when autoloading with syntax error
@ 2000-02-03 18:30 Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2000-02-03 18:30 UTC (permalink / raw)
  To: Zsh hackers list

Autoload the following function:

if (( 1 )): then   # note colon instead of semicolon
  true
fi

This loads silently, unlike trying it at the command line which gives a
parse error near `fi', which is not unexpected.  `which fn' gives

fn () {
        if (( 1 ))
        then
                : then
        fi
        true
}

This is, not to put too fine a point on it, wrong.

-- 
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-02-04  9:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-02-04  9:34 Funny bug when autoloading with syntax error Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
2000-02-03 18:30 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).