zsh-workers
 help / color / mirror / code / Atom feed
From: Zefram <A.Main@dcs.warwick.ac.uk>
To: zsh-workers@math.gatech.edu (Z Shell workers mailing list)
Subject: ZLE history expansion bug fix
Date: Thu, 25 May 1995 04:11:44 +0100 (BST)	[thread overview]
Message-ID: <1843.199505250311@stone.dcs.warwick.ac.uk> (raw)

-----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-----


             reply	other threads:[~1995-05-25  5:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-05-25  3:11 Zefram [this message]
1995-05-29 19:49 ` Zoltan Hidvegi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1843.199505250311@stone.dcs.warwick.ac.uk \
    --to=a.main@dcs.warwick.ac.uk \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).