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

ZLE history expansion bug fix



-----BEGIN PGP SIGNED MESSAGE-----

There is a bug in ZLE history expansion (2.6-beta9-test2):

% echo

% !{e <TAB>
[zsh hangs, eating up processor time]

The problem is that if a history reference is entered, using a { but not a
matching }, containing a valid history reference followed by a space, ZLE
enters an infinite loop.  I have not been able to determine why these specific
conditions are required to manifest this bug, nor whether any other set of
conditions will work.

My solution is to make all the ZLE code that calls the lexer treat LEXERR as a
terminating token, as well as ENDINPUT.  This solves the above bug.

 -zefram

      *** Src/zle_tricky.c.old	Thu May 25 03:37:30 1995
      --- Src/zle_tricky.c	Thu May 25 04:01:09 1995
      ***************
      *** 2831,2843 ****
        	noaliases = 1;
        	do {
        	    ctxtlex();
      ! 	    if (tok == ENDINPUT)
        		break;
        	    if (!first && tokstr && *tokstr)
        		addnode(foo, ztrdup(tokstr));
        	    first = 0;
      ! 	}
      ! 	while (tok != ENDINPUT);
        	noaliases = 0;
        	hflush();
        	strinend();
      --- 2831,2842 ----
        	noaliases = 1;
        	do {
        	    ctxtlex();
      ! 	    if (tok == ENDINPUT || tok == LEXERR)
        		break;
        	    if (!first && tokstr && *tokstr)
        		addnode(foo, ztrdup(tokstr));
        	    first = 0;
      ! 	} while (tok != ENDINPUT && tok != LEXERR);
        	noaliases = 0;
        	hflush();
        	strinend();
      ***************
      *** 3735,3742 ****
            noerrs = 1;
            do {
        	ctxtlex();
      !     }
      !     while (tok != ENDINPUT && zleparse);
            noerrs = ne;
            noaliases = 0;
            hflush();
      --- 3734,3740 ----
            noerrs = 1;
            do {
        	ctxtlex();
      !     } while (tok != ENDINPUT && tok != LEXERR && zleparse);
            noerrs = ne;
            noaliases = 0;
            hflush();
      ***************
      *** 3810,3816 ****
            do {
        	curlincmd = incmdpos;
        	ctxtlex();
      ! 	if (tok == ENDINPUT)
        	    break;
        	if (tok == STRING && curlincmd) {
        	    zsfree(s);
      --- 3808,3814 ----
            do {
        	curlincmd = incmdpos;
        	ctxtlex();
      ! 	if (tok == ENDINPUT || tok == LEXERR)
        	    break;
        	if (tok == STRING && curlincmd) {
        	    zsfree(s);
      ***************
      *** 3818,3825 ****
        	    cmdwb = ll - wordbeg;
        	    cmdwe = ll + 1 - inbufct;
        	}
      !     }
      !     while (tok != ENDINPUT && zleparse);
            hflush();
            popheap();
            strinend();
      --- 3816,3822 ----
        	    cmdwb = ll - wordbeg;
        	    cmdwe = ll + 1 - inbufct;
        	}
      !     } while (tok != ENDINPUT && tok != LEXERR && zleparse);
            hflush();
            popheap();
            strinend();

-----BEGIN PGP SIGNATURE-----
Version: 2.6.i

iQBVAgUBL8P06WWJ8JfKi+e9AQGDyAH+INB1B95UTrWeOhPW8nSUchVt9tmmImZ1
kyYZJxbk5Trm4w/HVYA0PK0au8ig1azw1tAZ/0lDWI0bwqQy1OSg6g==
=TKnv
-----END PGP SIGNATURE-----



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