develooper Front page | perl.perl5.porters | Postings from September 2006

Re: NULL and sv_setpv vs. newSVpv

Thread Previous
From:
Rafael Garcia-Suarez
Date:
September 11, 2006 01:42
Subject:
Re: NULL and sv_setpv vs. newSVpv
Message ID:
b77c1dce0609110142l15dbd8f2v5d09c681358a32eb@mail.gmail.com
On 11/09/06, Yitzchak Scott-Thoennes <sthoenna@efn.org> wrote:
> There's a subtle difference there, in that newSVpv doesn't allow a null
> pv when length is 0, while sv_setpv does (doing a SvOK_off in that case.)
> And of course pwent->pw_comment is NULL for cygwin.  I could just fix that,
> like:
>
> --- perl-current/pp_sys.c       2006-08-21 03:18:50.000000000 -0700
> +++ perl/pp_sys.c       2006-09-10 16:23:41.843750000 -0700
> @@ -5202,7 +5202,7 @@
>         PUSHs(sv_2mortal(newSVpv(pwent->pw_class, 0)));
>  #   else
>  #       ifdef PWCOMMENT
> -       PUSHs(sv_2mortal(newSVpv(pwent->pw_comment, 0)));
> +       PUSHs(sv_2mortal(newSVpv(pwent->pw_comment ? pwent->pw_comment : "", 0)));
>  #      else
>         /* I think that you can never get this compiled, but just in case.  */
>         PUSHs(sv_mortalcopy(&PL_sv_no));
>
>
> but that patch made a similar change in a lot of other cases.
> Would it be better to do something like:
>
> --- perl-current/sv.c   2006-09-05 03:44:58.000000000 -0700
> +++ perl/sv.c   2006-09-10 20:25:52.656250000 -0700
> @@ -6933,7 +6933,7 @@ Perl_newSVpv(pTHX_ const char *s, STRLEN
>      register SV *sv;
>
>      new_SV(sv);
> -    sv_setpvn(sv,s,len ? len : strlen(s));
> +    sv_setpvn(sv,s,len || s == NULL ? len : strlen(s));
>      return sv;

I just applied this last patch as change #28813 to bleadperl.

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About