From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24510 invoked by alias); 29 Sep 2016 14:13:10 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 39500 Received: (qmail 10028 invoked from network); 29 Sep 2016 14:13:10 -0000 X-Qmail-Scanner-Diagnostics: from out2-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.26):SA:0(0.0/5.0):. Processed in 0.4776 secs); 29 Sep 2016 14:13:10 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=/rkzCLTNzjZO6v41gIQss4dCm+4=; b=VvndVN 8Z06aNpXnfCam/qst9NpypwXPjR2tN4f19F/CBIJUYldME/Y07wrp/pA4pIy2F9u MsKsTgw5T/AcVjtv0xHWoKmA1vlZr43RDNVBR6Y5h6xijrTxGbFw3qRFqaj+8FHW L1I+tdHBaDwKwo6hNE7lRUEtCFawQ5V7MosiI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=/rkzCLTNzjZO6v41gIQss4dCm+4=; b=FMLgP R3cyCnal53FuuctYDP217ZUoBQksrNB3znC1cdrw2Seb4tIOsl0PjSRBX1V08O6n xiNXBZwnB7Q+KUz8INmn7wijJNhWEdsmo5JSj3C51oEhSISWpx/FZ8u01hMhWsEH krtUqJc5z23F4/bVLEc4CDCQshoxz+Y1gRBxKw= X-Sasl-enc: pxNfirnmKCY/1iRCYbK1QcGVHQJKVneRqIBVpof0OF0w 1475158380 Date: Thu, 29 Sep 2016 14:11:39 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: Re: [PATCH] _describe and literal \n Message-ID: <20160929141139.GA5059@fujitsu.shahaf.local2> References: <20160723180430.GA22451@tarsus.local2> <160723130059.ZM19333@torch.brasslantern.com> <20160723212345.GA2982@tarsus.local2> <5530.1469316428@hydra.kiddle.eu> <20160724213046.GB27932@tarsus.local2> <92023.1475008338@hydra.kiddle.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <92023.1475008338@hydra.kiddle.eu> User-Agent: Mutt/1.5.23 (2014-03-12) Oliver Kiddle wrote on Tue, Sep 27, 2016 at 22:32:18 +0200: > On 24 Jul, Daniel Shahaf wrote: > > (let me know if I should push the patch I'd posted) > > I don't think anyone ever gave an answer to this. I don't see any > problem with pushing the patch. While I'm not keen on _describe > putting \n etc in the descriptions that's not a new thing and with > the patch it is certainly more consistent. Thanks for the poke. I looked again and I think I found the underlying problem. compadd prints the description using nice*() functions, but _describe does its width computations using the raw string length; hence compadd prints a longer string than _describe computed. I think that overflowed the terminal width due to the "spaces-only" fake match that _describe adds. Using 'nice' widths in compdescribe fixes the case from 38928, but not the one from 38925. I think that one simply needs a s/zputs/nicezputs/ somewhere in the "not part of a group" codepath. Thanks again for the ping. Daniel diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c index 27b78cd..6ac880c 100644 --- a/Src/Zle/computil.c +++ b/Src/Zle/computil.c @@ -199,11 +199,11 @@ cd_calc(void) set->count++; if ((l = strlen(str->str)) > cd_state.pre) cd_state.pre = l; - if ((l = MB_METASTRWIDTH(str->str)) > cd_state.premaxw) + if ((l = ZMB_nicewidth(str->str)) > cd_state.premaxw) cd_state.premaxw = l; if (str->desc) { set->desc++; - if ((l = strlen(str->desc)) > cd_state.suf) + if ((l = strlen(str->desc)) > cd_state.suf) /* ### strlen() assumes no \n */ cd_state.suf = l; } } @@ -490,7 +490,7 @@ cd_init(char *nam, char *hide, char *mlen, char *sep, setp = &(cd_state.sets); cd_state.sep = ztrdup(sep); cd_state.slen = strlen(sep); - cd_state.swidth = MB_METASTRWIDTH(sep); + cd_state.swidth = ZMB_nicewidth(sep); cd_state.sets = NULL; cd_state.showd = disp; cd_state.maxg = cd_state.groups = cd_state.descs = 0; @@ -526,7 +526,8 @@ cd_init(char *nam, char *hide, char *mlen, char *sep, str->other = NULL; str->set = set; - for (tmp = *ap; *tmp && *tmp != ':'; tmp++) + /* Advance tmp to the first unescaped colon. */ + for (tmp = *ap; *tmp && *tmp != ':'; tmp++) if (*tmp == '\\' && tmp[1]) tmp++; @@ -537,7 +538,7 @@ cd_init(char *nam, char *hide, char *mlen, char *sep, *tmp = '\0'; str->str = str->match = ztrdup(rembslash(*ap)); str->len = strlen(str->str); - str->width = MB_METASTRWIDTH(str->str); + str->width = ZMB_nicewidth(str->str); str->sortstr = NULL; } if (str) @@ -692,16 +693,16 @@ cd_get(char **params) * end of screen as safety margin */ d = str->desc; - w = MB_METASTRWIDTH(d); + w = ZMB_nicewidth(d); if (w <= remw) strcpy(p, d); else { pp = p; while (remw > 0 && *d) { - l = MB_METACHARLEN(d); + l = MB_METACHARLEN(d); /* ### should use a _nice variant? */ memcpy(pp, d, l); pp[l] = '\0'; - w = MB_METASTRWIDTH(pp); + w = ZMB_nicewidth(pp); if (w > remw) { *pp = '\0'; break; @@ -792,17 +793,17 @@ cd_get(char **params) cd_state.swidth - CM_SPACE; p = pp = dbuf + cd_state.slen; d = str->desc; - w = MB_METASTRWIDTH(d); + w = ZMB_nicewidth(d); if (w <= remw) { strcpy(p, d); remw -= w; pp += strlen(d); } else while (remw > 0 && *d) { - l = MB_METACHARLEN(d); + l = MB_METACHARLEN(d); /* ### should use a _nice variant? */ memcpy(pp, d, l); pp[l] = '\0'; - w = MB_METASTRWIDTH(pp); + w = ZMB_nicewidth(pp); if (w > remw) { *pp = '\0'; break;