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

Re: Remaining zsh3.0-pre2 bugs



On Jul 7,  9:22pm, Bart Schaefer wrote:
} Subject: Re: Remaining zsh3.0-pre2 bugs
}
} On Jul 8,  2:48am, Zoltan Hidvegi wrote:
} } Subject: Re: Remaining zsh3.0-pre2 bugs
} }
} } And an other bug is that here documents do not appear in the history.
} } That's in fact a much more difficult bug.  The bug described above can be
} } fixed just by adding hwgetword to the list of saved variables in lexsave.
} 
} That doesn't fix the problem of the cursor ending up in the wrong place
} following the completion, though.

I'm now convinced that get_comp_string() is messing up the cursor position,
somewhere in this loop:

        /* While building the quoted form, we also clean up the command line. */
        offs = cs - wb;
        for (p = s, tt = qword, i = wb; *p; p++, tt++, i++)
            if (INULL(*p)) {
                if (i < cs)
                    offs--;
                if (p[1] || *p != Bnull) {
		    /* ... */
                } else {
                    ocs = cs;
                    *tt = '\0';
                    cs = we;
                    backdel(1);
                    if (ocs == we)
                        cs = we - 1;
                    else
                        cs = ocs;
                    we--;
                }
                chuck(p--);
            }

The specific clause

                    if (ocs == we)
                        cs = we - 1;

is hit twice during this completion:

	zsh% echo 'a
	> b'<TAB>

This in turn happens because qword (which came from s, which points to
clwords[clwpos]) points to "\230a;b\230x" rather than to "'a;b'x" and
because INULL('\230') is true.

So I rather suspect that has something to do with the bug, but I'm lost
at this point in terms of knowing what \230 represents, or how it got
into tokstr and thus ultimately into clwords[1], or whether INULL() is
supposed to be true at that point.

Anyway, cs decrements down to 8 because of the two \230 in qword; but
"echo 'a;b'" of course has 10 characters.  Back in docomplete(), this
section:

    /* If we added chline to the line buffer, reset the original contents. */
    if (ol) {
        strcpy((char *) line, ol);
        ll = strlen((char *) line);
        cs -= chl;
        wb -= chl;
        we -= chl;
        if (wb < 0 || we < 0) {
            unmetafy_line();
            return;
        }
    }

then decrements cs by chl (the length of "echo 'a;"), thus cs == 0 when
it should have remained cs == 2.

Hopefully that's enough for somebody more versed in the lexer to fix
get_comp_string() ...

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern

New male in /home/schaefer:
>N  2 Justin William Schaefer  Sat May 11 03:43  53/4040  "Happy Birthday"




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