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

Re: bug in 3.0.0?



> The problem is with "else { ... }".  3.0 wants a "fi" at the end of the
> if/elif/else chain, even when using the { ... } form -- but only when
> it ends with "else { ... }".
> 
> This seems to fix it.

That breaks

if ... ; then ... ; else { ... } ; ... fi

The patch below is a slighly modified version of Bart's patch.

Zoltan


*** Src/parse.c	1996/08/14 16:48:19	2.25
--- Src/parse.c	1996/08/22 21:07:43
***************
*** 605,611 ****
      unsigned char nc;
      LinkList ifsl, thensl;
      LinkNode no;
!     int ni = 0, nt = 0;
      List l, *ll;
  
      ifsl = newlinklist();
--- 605,611 ----
      unsigned char nc;
      LinkList ifsl, thensl;
      LinkNode no;
!     int ni = 0, nt = 0, usebrace = 0;
      List l, *ll;
  
      ifsl = newlinklist();
***************
*** 634,639 ****
--- 634,640 ----
  	xtok = FI;
  	nc = cmdstack[cmdsp - 1] == CS_IF ? CS_IFTHEN : CS_ELIFTHEN;
  	if (tok == THEN) {
+ 	    usebrace = 0;
  	    cmdpop();
  	    cmdpush(nc);
  	    yylex();
***************
*** 643,648 ****
--- 644,650 ----
  	    cmdpop();
  	} else {
  	    if (tok == INBRACE) {
+ 		usebrace = 1;
  		cmdpop();
  		cmdpush(nc);
  		yylex();
***************
*** 676,685 ****
  	cmdpush(CS_ELSE);
  	while (tok == SEPER)
  	    yylex();
! 	l = par_list();
! 	if (tok != FI) {
! 	    cmdpop();
! 	    YYERRORV;
  	}
  	addlinknode(thensl, l);
  	nt++;
--- 678,696 ----
  	cmdpush(CS_ELSE);
  	while (tok == SEPER)
  	    yylex();
! 	if (tok == INBRACE && usebrace) {
! 	    yylex();
! 	    l = par_list();
! 	    if (tok != OUTBRACE) {
! 		cmdpop();
! 		YYERRORV;
! 	    }
! 	} else {
! 	    l = par_list();
! 	    if (tok != FI) {
! 		cmdpop();
! 		YYERRORV;
! 	    }
  	}
  	addlinknode(thensl, l);
  	nt++;



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