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

Re: PATCH: displaying wide characters



Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> Looks like an off-by-one error somewhere.
> 
> *** /tmp/zsh.ztst.out.4543      Thu Oct 20 08:00:11 2005
> --- /tmp/zsh.ztst.tout.4543     Thu Oct 20 08:00:11 2005
> ***************
> *** 1,2 ****
> ! start ...d at 10 Not truncated ...
> ! start truncat... Not truncated ...
> --- 1,2 ----
> ! start ...d at 10 Not truncated ..
> ! start truncat... Not truncated ..
> Test ../../zsh-4.0/Test/D01prompt.ztst failed: output differs from expected as
> shown above for:
>   print -P 'start %10<...<truncated at 10%<< Not truncated%3< ...<Not shown'
>   print -P 'start %10>...>truncated at 10%>> Not truncated%3> ...>Not shown'
> Was testing: prompt truncation

It looks like it, but it isn't.  I didn't change the old code here, and
this feature is in 4.2.  I was going by the manual:

     %<string<
     %>string>
     %[xstring]
...
          If the string is longer than the  specified  truncation
          length,  it  will  appear in full, completely replacing
          the truncated string.

which is unambiguous, so I presume there is a bug in the old code.  Even
more confusingly, it does the following (in both 4.2 and the non-multibyte
code):

% print -P '%10<0123456789<truncated at 10'
0123456789
% print -P '%10>0123456789abcde>truncated at 10'
0123456789
% print -P '%10<0123456789abcdef<truncated at 10'
truncated at 100

May be I should rewrite the code in the other branch to be more like the
code I just added.  Unless anyone wants to argue the manual is wrong?  (The
last output is certainly a bug.)  I suspect it's too minor to worry much
about and I should just fix the old code.  The only time I can think of
where this is significant is if you have a string with a variable
truncation length or truncation indicator so can't guarantee in advance
this won't happen, which must be fairly unlikely.

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


This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com



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