From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27016 invoked by alias); 13 May 2011 08:54:49 -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: 29257 Received: (qmail 27525 invoked from network); 13 May 2011 08:54:46 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Fri, 13 May 2011 09:54:34 +0100 From: Peter Stephenson To: Subject: Re: PATCH: Add g:: parameter expansion flag Message-ID: <20110513095434.24e81474@pwslap01u.europe.root.pri> In-Reply-To: References: <110512070408.ZM29757@torch.brasslantern.com> <1305215346-27247-1-git-send-email-mikachu@gmail.com> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.103.11.49] X-Scanned-By: MailControl A_10_80_00 (www.mailcontrol.com) on 10.68.0.130 On Thu, 12 May 2011 21:41:36 +0200 Mikael Magnusson wrote: > On 12 May 2011 17:49, Mikael Magnusson wrote: > > Okay, how's this? I swapped the order so g happens first, and > > changed the docs as discussed. >=20 > Just as I was thinking about committing it, I found a bug. I have to > metafy the result of getkeystring(). > % print -Rn ${(g:o:):-'\201\227\343\201\257'}|wc -c > zsh: command not found: =E3=81=AF > 1 >=20 > Not exactly the intended result :). >=20 > So I am pretty sure I want to use META_HREALLOC, is that correct? Ie > if (!copied) > val =3D dupstring(val), copied =3D 1; > val =3D getkeystring(val, &len, getkeys, NULL); > val =3D metafy(val, len, META_HREALLOC); > (and same for the isarr case) >=20 That would do, as it's what untok_and_escape() does, although META_HEAPDUP would probably be OK at this point. Reallocating what's on the heap is a slightly strange thing to do, since the point of the heap is to provide quick storage without the need to micromanage it; it tends to be done when there's a long string on the heap that it would be inefficient to keep duplicating, which isn't the case here. If the original heap chunk is surrounded by other allocations it has to duplicate anyway, since the heap doesn't let you reuse memory (until the whole heap is popped); you can't tell just be looking at the call whether this will be the case. --=20 Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, = UK Member of the CSR plc group of companies. CSR plc registered in England and= Wales, registered number 4187346, registered office Churchill House, Cambr= idge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom