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

Re: Bug: Wrong completion of $(( $(!cmd



Geoff Wing wrote:
> On Saturday 2007-01-06 23:48 +1100, Jörg Sommer output:
> :% echo 12
> :12
> :% echo $(( $(!echo<TAB>
> :% echo $($(( $(echo 12
> 
> and inungetc() just after gives me 11 lines of
> 	Warning: backing up wrong character.

The problem is somewhere here (in lex.c).  If dquote_parse() returns
non-zero it's an error indication, not a character, so the hungetc(c) is
definitely wrong in that case.  However, I don't understand the
intention behind error handling at this point.  I think we probably need
to return 1 earlier.


static int
cmd_or_math(int cs_type)
{
    int oldlen = len;
    int c;

    cmdpush(cs_type);
    c = dquote_parse(')', 0);
    cmdpop();
    *bptr = '\0';
    if (!c) {
	c = hgetc();
	if (c == ')')
	    return 1;
	hungetc(c);
	lexstop = 0;
	c = ')';
    }
    hungetc(c);
    lexstop = 0;
    while (len > oldlen) {
	len--;
	hungetc(itok(*--bptr) ? ztokens[*bptr - Pound] : *bptr);
    }
    hungetc('(');
    return 0;
}

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



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