Skip to content

Commit 16cabc7

Browse files
committed
perlapi: Clarify gv_init
1 parent bda38bb commit 16cabc7

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

gv.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ Perl_cvstash_set(pTHX_ CV *cv, HV *stash)
331331
}
332332

333333
/*
334-
335334
=for apidoc gv_init
336335
=for apidoc_item gv_init_pv
337336
=for apidoc_item gv_init_pvn
@@ -343,21 +342,27 @@ overwriting it as happens with typeglobs created by C<SvSetSV>. Converting
343342
any scalar that is C<SvOK()> may produce unpredictable results and is reserved
344343
for perl's internal use.
345344
345+
They differ only in how the name is specified, and C<gv_init> lacks a C<flags>
346+
parameter, but has a boolean C<multi> parameter instead.
347+
346348
C<gv> is the scalar to be converted.
347349
348-
C<stash> is the parent stash/package, if any.
350+
C<stash> is the parent stash/package, if any; or NULL if none.
351+
352+
In C<gv_init> and C<gv_init_pvn>, C<name> points to the first byte of the
353+
string specifying the name, and an additional parameter, C<len>, specifies its
354+
length in bytes. Hence, C<name> may contain embedded-NUL characters.
349355
350-
In C<gv_init> and C<gv_init_pvn>, C<name> and C<len> give the name. The name
351-
must be unqualified; that is, it must not include the package name. If C<gv>
352-
is a stash element, it is the caller's responsibility to ensure that the name
353-
passed to this function matches the name of the element. If it does not match,
354-
perl's internal bookkeeping will get out of sync. C<name> may contain embedded
355-
NUL characters.
356+
The name must be unqualified; that is, it must not include the package name.
357+
If C<gv> is a stash element, it is the caller's responsibility to ensure that
358+
the name passed to this function matches the name of the element. If it does
359+
not match, perl's internal bookkeeping will get out of sync.
356360
357361
C<gv_init_pv> is identical to C<gv_init_pvn>, but takes a NUL-terminated string
358362
for the name instead of separate char * and length parameters.
359363
360-
In C<gv_init_sv>, the name is given by C<sv>.
364+
In C<gv_init_sv>, C<*name> is an SV, and the name is the PV extracted from
365+
that using C<L</SvPV>>.
361366
362367
All but C<gv_init> take a C<flags> parameter. Set C<flags> to include
363368
C<SVf_UTF8> if C<name> is a UTF-8 string. In C<gv_init_sv>, if C<SvUTF8(sv)>

0 commit comments

Comments
 (0)