Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: Add g:: parameter expansion flag
On Thu, 12 May 2011 21:41:36 +0200
Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> On 12 May 2011 17:49, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> > Okay, how's this? I swapped the order so g happens first, and
> > changed the docs as discussed.
>
> 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: は
> 1
>
> Not exactly the intended result :).
>
> So I am pretty sure I want to use META_HREALLOC, is that correct? Ie
> if (!copied)
> val = dupstring(val), copied = 1;
> val = getkeystring(val, &len, getkeys, NULL);
> val = metafy(val, len, META_HREALLOC);
> (and same for the isarr case)
>
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.
--
Peter Stephenson <pws@xxxxxxx> 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, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
Messages sorted by:
Reverse Date,
Date,
Thread,
Author