From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16717 invoked from network); 3 Apr 2008 21:01:56 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 3 Apr 2008 21:01:56 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 67674 invoked from network); 3 Apr 2008 21:01:49 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 3 Apr 2008 21:01:49 -0000 Received: (qmail 4470 invoked by alias); 3 Apr 2008 21:01:45 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24788 Received: (qmail 4454 invoked from network); 3 Apr 2008 21:01:44 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 3 Apr 2008 21:01:44 -0000 Received: from mtaout01-winn.ispmail.ntl.com (mtaout01-winn.ispmail.ntl.com [81.103.221.47]) by bifrost.dotsrc.org (Postfix) with ESMTP id 6580B82DC37A for ; Thu, 3 Apr 2008 23:01:40 +0200 (CEST) Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout01-winn.ispmail.ntl.com with ESMTP id <20080403210422.ICIP28015.mtaout01-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com> for ; Thu, 3 Apr 2008 22:04:22 +0100 Received: from pws-pc.ntlworld.com ([81.107.40.67]) by aamtaout02-winn.ispmail.ntl.com with ESMTP id <20080403210338.PCDU17393.aamtaout02-winn.ispmail.ntl.com@pws-pc.ntlworld.com> for ; Thu, 3 Apr 2008 22:03:38 +0100 Received: from pws-pc (pws-pc [127.0.0.1]) by pws-pc.ntlworld.com (8.14.2/8.14.2) with ESMTP id m33L1TSJ015700 for ; Thu, 3 Apr 2008 22:01:29 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: PATCH: ${(m)#...} X-Mailer: MH-E 8.0.3; nmh 1.2-20070115cvs; GNU Emacs 22.1.1 Date: Thu, 03 Apr 2008 22:01:29 +0100 Message-ID: <15699.1207256489@pws-pc> X-Virus-Scanned: ClamAV 0.91.2/6568/Thu Apr 3 18:12:56 2008 on bifrost X-Virus-Status: Clean I introduced the (m) flag to calculate the width of a multibyte character for the (l) and (r) padding flags. I'm not sure why I didn't introduce it for parameter lengths, too, but now I'm finding that useful. ${(m)#...} now returns the printable width of the string. Index: Doc/Zsh/expn.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/expn.yo,v retrieving revision 1.88 diff -u -r1.88 expn.yo --- Doc/Zsh/expn.yo 1 Feb 2008 19:59:48 -0000 1.88 +++ Doc/Zsh/expn.yo 3 Apr 2008 20:57:32 -0000 @@ -943,11 +943,13 @@ mechanism to be used for generating repetitions of control characters. ) item(tt(m))( -Only useful together with tt(l) and tt(r) when the tt(MULTIBYTE) option +Only useful together with one of the flags tt(l) or tt(r) or with the +tt(#) length operator when the tt(MULTIBYTE) option is in effect. Use the character width reported by the system in -calculating the how much of the string it occupies. Most printable -characters have a width of one unit, however certain Asian character sets -and certain special effects use wider characters. +calculating the how much of the string it occupies or the overall +length of the string. Most printable characters have a width of one +unit, however certain Asian character sets and certain special effects +use wider characters; combining characters have zero width. ) item(tt(r:)var(expr)tt(::)var(string1)tt(::)var(string2)tt(:))( As tt(l), but pad the words on the right and insert var(string2) Index: Src/subst.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/subst.c,v retrieving revision 1.83 diff -u -r1.83 subst.c --- Src/subst.c 27 Feb 2008 15:51:27 -0000 1.83 +++ Src/subst.c 3 Apr 2008 20:57:33 -0000 @@ -2589,7 +2589,8 @@ else if (getlen == 2) { if (*aval) for (len = -sl, ctr = aval; - len += sl + MB_METASTRLEN(*ctr), *++ctr;); + len += sl + MB_METASTRLEN2(*ctr, multi_width), + *++ctr;); } else for (ctr = aval; @@ -2597,7 +2598,7 @@ len += wordcount(*ctr, spsep, getlen > 3), ctr++); } else { if (getlen < 3) - len = MB_METASTRLEN(val); + len = MB_METASTRLEN2(val, multi_width); else len = wordcount(val, spsep, getlen > 3); } -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/