develooper Front page | perl.perl5.porters | Postings from May 2012

Re: [PATCH] perlapi.pod clarification patchlet: newSVpvn operateson buffers - not strings

Thread Previous | Thread Next
From:
Karl Williamson
Date:
May 23, 2012 20:30
Subject:
Re: [PATCH] perlapi.pod clarification patchlet: newSVpvn operateson buffers - not strings
Message ID:
4FBDAB47.3090603@khwilliamson.com
Could you send your patch as an attachment?

On 02/11/2012 09:40 AM, Shlomi Fish wrote:
> Hi all,
>
> this patchlet clarifies the documentation of newSVpvn to make it clear that it
> operates on a buffer (that may contain NUL characters and other binary data)
> rather than a C-terminated string.
>
> You can also find it here:
>
> https://github.com/shlomif/perl/tree/perlapi-pod-improvements
>
> Regards,
>
> 	Shlomi Fish
>
> diff --git a/sv.c b/sv.c
> index 471caba..c9eb0f1 100644
> --- a/sv.c
> +++ b/sv.c
> @@ -8355,22 +8355,24 @@ Perl_newSVpv(pTHX_ const char *const s, const STRLEN
> len) /*
>   =for apidoc newSVpvn
>
> -Creates a new SV and copies a string into it.  The reference count for the
> -SV is set to 1.  Note that if C<len>  is zero, Perl will create a zero length
> -string.  You are responsible for ensuring that the source string is at least
> -C<len>  bytes long.  If the C<s>  argument is NULL the new SV will be undefined.
> +Creates a new SV and copies a buffer into it, which may contain NUL characters
> +(C<\0>) and other binary data.  The reference count for the SV is set to 1.
> +Note that if C<len>  is zero, Perl will create a zero length (Perl) string.  You
> +are responsible for ensuring that the source buffer is at least
> +C<len>  bytes long.  If the C<buffer>  argument is NULL the new SV will be
> +undefined.
>
>   =cut
>   */
>
>   SV *
> -Perl_newSVpvn(pTHX_ const char *const s, const STRLEN len)
> +Perl_newSVpvn(pTHX_ const char *const buffer, const STRLEN len)
>   {
>       dVAR;
>       register SV *sv;
>
>       new_SV(sv);
> -    sv_setpvn(sv,s,len);
> +    sv_setpvn(sv,buffer,len);
>       return sv;
>   }
>
>


Thread Previous | Thread Next


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