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

Re: Vi command mode and end-of-line; ZWC('\n') ?



On Sat, 22 Aug 2015 18:19:11 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> That thread about end-of-line not working as a "bindkey -a" widget annoys
> me for some reason.  I started looking through zle_move.c and discovered
> that in a few places we compare
> 
> 	zleline[zlecs] == ZWC('\n')
> 
> but in more places we simply do
> 
> 	zleline[pos] == '\n'
> 	zleline[zlecs - 1] != '\n'
> 
> There's even one comment about the latter
> 
> 	/* works OK with combining chars since '\n' must be on its own */
> 
> So which is it?  Should we be using ZWC() or not?

ZWC is basically a glorified standards-compliant cast --- '\n' is a char
while zleline takes wchar_t.  So the sole effect is to ensure we assign
a wide character. So ideally we should be using it everywhere for
consistency; however, I can't think of a practical effect for a 7-bit
ASCII character on a modern system.

pws



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