There's a bug in this patch! This line:
> + if (name_cursor == ':') {
needs to be:
> + if (*name_cursor == ':') {
Also, the next line:
> + tmpbuf = name;
gives a build warning:
gv.c:1058: warning: assignment discards qualifiers from pointer target type
On Fri, Oct 8, 2010 at 10:40, Nicholas Clark <[email protected]> wrote:
> In perl.git, the branch blead has been updated
>
> <http://perl5.git.perl.org/perl.git/commitdiff/e771aaa95f65a9c44af94b9391ba49f4fcbfda43?hp=4c43faf178da84900d2d5ff3de31d38bf7fab5d3>
>
> - Log -----------------------------------------------------------------
> commit e771aaa95f65a9c44af94b9391ba49f4fcbfda43
> Author: Nicholas Clark <[email protected]>
> Date: Fri Oct 8 15:39:24 2010 +0100
>
> Perl_gv_fetchpvn_flags() can avoid copying when the package separator is ::
> -----------------------------------------------------------------------
>
> Summary of changes:
> gv.c | 17 +++++++++--------
> 1 files changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/gv.c b/gv.c
> index db9617f..9e93937 100644
> --- a/gv.c
> +++ b/gv.c
> @@ -1052,16 +1052,17 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg,
> STRLEN full_len, I32 flags,
>
> len = name_cursor - name;
> if (len > 0) {
> - char smallbuf[128];
> char *tmpbuf;
>
> - if (len + 2 <= (I32)sizeof (smallbuf))
> - tmpbuf = smallbuf;
> - else
> + if (name_cursor == ':') {
> + tmpbuf = name;
> + len += 2;
> + } else {
> Newx(tmpbuf, len+2, char);
> - Copy(name, tmpbuf, len, char);
> - tmpbuf[len++] = ':';
> - tmpbuf[len++] = ':';
> + Copy(name, tmpbuf, len, char);
> + tmpbuf[len++] = ':';
> + tmpbuf[len++] = ':';
> + }
> gvp = (GV**)hv_fetch(stash,tmpbuf,len,add);
> gv = gvp ? *gvp : NULL;
> if (gv && gv != (const GV *)&PL_sv_undef) {
> @@ -1070,7 +1071,7 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN
> full_len, I32 flags,
> else
> GvMULTI_on(gv);
> }
> - if (tmpbuf != smallbuf)
> + if (tmpbuf != name)
> Safefree(tmpbuf);
> if (!gv || gv == (const GV *)&PL_sv_undef)
> return NULL;
>
> --
> Perl5 Master Repository
>