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

Re: PATCH: parser (was: Re: PATCH: Improved _mailboxes)



Peter Stephenson wrote:

> This will probably be my last email for a while...
> 
> Sven Wischnowsky wrote:
> > Here is the first of the two. As I said, this mainly makes the parser
> > create wordcode directly, no more extra compilation phase.
> 
> I'm getting a core dump in zfinit from my .zshrc (after both patches, in
> fact).  It's in text.c.  Actually, there seem to be two bugs there.  One
> happens when a function is empty and you run `which' or equivalent:
> getpermtext() calls gettext2() without realising that the prog.len is zero,
> so it's only going to find garbage.  This must be because the code for
> end-of-text is not being added, or if it was removed it's not being tested
> enough.

Oops. There were only three places where I forgot to use par_save_list()
instead of par_list(). That's fixed now.

> I can't offhand see what's causing the second, but this seems to tickle it
> on my system (although I only tried this after masking out the previous one
> by putting an if (prog.len) before the call to gettext2()):
> 
>   chpwd() {
>     if [[ ${+ZFTP_USER} = 1 && -n $ZFTP_USER ]]; then
>       zftp_chpwd
>     else
>       [[ -t 1 && -t 2 ]] && header -P "%m:  %~";
>     fi
>   }
>   which chpwd
> 
> causes a crash with a backtrace as follows, although it's probably more
> useful to know that it seems to go wrong at the start of the second `[['.

The problem was that I forgot to tell text.c about simplified sublists.


Bye
 Sven

diff -ru ../z.old/Src/parse.c Src/parse.c
--- ../z.old/Src/parse.c	Thu Feb 24 10:46:25 2000
+++ Src/parse.c	Thu Feb 24 10:54:02 2000
@@ -1154,13 +1154,13 @@
 	    yylex();
 	if (tok == INBRACE && usebrace) {
 	    yylex();
-	    par_list(complex);
+	    par_save_list(complex);
 	    if (tok != OUTBRACE) {
 		cmdpop();
 		YYERRORV(oecused);
 	    }
 	} else {
-	    par_list(complex);
+	    par_save_list(complex);
 	    if (tok != FI) {
 		cmdpop();
 		YYERRORV(oecused);
@@ -1507,7 +1507,7 @@
 		int c = 0;
 
 		yylex();
-		par_list(&c);
+		par_save_list(&c);
 		if (tok != OUTBRACE) {
 		    cmdpop();
 		    lineno += oldlineno;
diff -ru ../z.old/Src/text.c Src/text.c
--- ../z.old/Src/text.c	Thu Feb 24 10:46:26 2000
+++ Src/text.c	Thu Feb 24 10:58:46 2000
@@ -269,7 +269,7 @@
 		    taddstr("! ");
 		if (WC_SUBLIST_FLAGS(code) & WC_SUBLIST_COPROC)
 		    taddstr("coproc ");
-		tpush(code, (WC_SUBLIST_TYPE(code) == WC_SUBLIST_END));
+		s = tpush(code, (WC_SUBLIST_TYPE(code) == WC_SUBLIST_END));
 	    } else {
 		if (!(stack = (WC_SUBLIST_TYPE(code) == WC_SUBLIST_END))) {
 		    taddstr((WC_SUBLIST_TYPE(code) == WC_SUBLIST_OR) ?
@@ -282,6 +282,8 @@
 			taddstr("coproc ");
 		}
 	    }
+	    if (!stack && (WC_SUBLIST_FLAGS(s->code) & WC_SUBLIST_SIMPLE))
+		state->pc++;
 	    break;
 	case WC_PIPE:
 	    if (!s) {

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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