Skip to content

Commit

Permalink
Expose a public SAVESTRLEN() macro
Browse files Browse the repository at this point in the history
This seems to have been forgotten in the public API, perhaps because it
was added later.

Fixes #19165
  • Loading branch information
leonerd committed Oct 5, 2021
1 parent a764175 commit 58541fd
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 32 deletions.
20 changes: 10 additions & 10 deletions pad.c
Expand Up @@ -204,11 +204,11 @@ Perl_pad_new(pTHX_ int flags)
SAVECOMPPAD();
if (! (flags & padnew_CLONE)) {
SAVESPTR(PL_comppad_name);
save_strlen((STRLEN *)&PL_padix);
save_strlen((STRLEN *)&PL_constpadix);
save_strlen((STRLEN *)&PL_comppad_name_fill);
save_strlen((STRLEN *)&PL_min_intro_pending);
save_strlen((STRLEN *)&PL_max_intro_pending);
SAVESTRLEN(PL_padix);
SAVESTRLEN(PL_constpadix);
SAVESTRLEN(PL_comppad_name_fill);
SAVESTRLEN(PL_min_intro_pending);
SAVESTRLEN(PL_max_intro_pending);
SAVEBOOL(PL_cv_has_eval);
if (flags & padnew_SAVESUB) {
SAVEBOOL(PL_pad_reset_pending);
Expand Down Expand Up @@ -1402,17 +1402,17 @@ void
Perl_pad_block_start(pTHX_ int full)
{
ASSERT_CURPAD_ACTIVE("pad_block_start");
save_strlen((STRLEN *)&PL_comppad_name_floor);
SAVESTRLEN(PL_comppad_name_floor);
PL_comppad_name_floor = PadnamelistMAX(PL_comppad_name);
if (full)
PL_comppad_name_fill = PL_comppad_name_floor;
if (PL_comppad_name_floor < 0)
PL_comppad_name_floor = 0;
save_strlen((STRLEN *)&PL_min_intro_pending);
save_strlen((STRLEN *)&PL_max_intro_pending);
SAVESTRLEN(PL_min_intro_pending);
SAVESTRLEN(PL_max_intro_pending);
PL_min_intro_pending = 0;
save_strlen((STRLEN *)&PL_comppad_name_fill);
save_strlen((STRLEN *)&PL_padix_floor);
SAVESTRLEN(PL_comppad_name_fill);
SAVESTRLEN(PL_padix_floor);
/* PL_padix_floor is what PL_padix is reset to at the start of each
statement, by pad_reset(). We set it when entering a new scope
to keep things like this working:
Expand Down
3 changes: 3 additions & 0 deletions pod/perlguts.pod
Expand Up @@ -1732,6 +1732,8 @@ Inside such a I<pseudo-block> the following service is available:

=item C<SAVEBOOL(int i)>

=item C<SAVESTRLEN(STRLEN i)>

These macros arrange things to restore the value of integer variable
C<i> at the end of the enclosing I<pseudo-block>.

Expand All @@ -1743,6 +1745,7 @@ C<i> at the end of the enclosing I<pseudo-block>.
=for apidoc Amh||SAVEI8|I8 i
=for apidoc Amh||SAVEI16|I16 i
=for apidoc Amh||SAVEBOOL|bool i
=for apidoc Amh||SAVESTRLEN|STRLEN i

=item C<SAVESPTR(s)>

Expand Down
46 changes: 24 additions & 22 deletions scope.h
Expand Up @@ -226,28 +226,30 @@ scope has the given name. C<name> must be a literal string.
if (PL_savestack_ix > old) leave_scope(old); \
} STMT_END

#define SAVEI8(i) save_I8((I8*)&(i))
#define SAVEI16(i) save_I16((I16*)&(i))
#define SAVEI32(i) save_I32((I32*)&(i))
#define SAVEINT(i) save_int((int*)&(i))
#define SAVEIV(i) save_iv((IV*)&(i))
#define SAVELONG(l) save_long((long*)&(l))
#define SAVEBOOL(b) save_bool(&(b))
#define SAVESPTR(s) save_sptr((SV**)&(s))
#define SAVEPPTR(s) save_pptr((char**)&(s))
#define SAVEVPTR(s) save_vptr((void*)&(s))
#define SAVEPADSVANDMORTALIZE(s) save_padsv_and_mortalize(s)
#define SAVEFREESV(s) save_freesv(MUTABLE_SV(s))
#define SAVEFREEPADNAME(s) save_pushptr((void *)(s), SAVEt_FREEPADNAME)
#define SAVEMORTALIZESV(s) save_mortalizesv(MUTABLE_SV(s))
#define SAVEFREEOP(o) save_freeop((OP*)(o))
#define SAVEFREEPV(p) save_freepv((char*)(p))
#define SAVECLEARSV(sv) save_clearsv((SV**)&(sv))
#define SAVEGENERICSV(s) save_generic_svref((SV**)&(s))
#define SAVEGENERICPV(s) save_generic_pvref((char**)&(s))
#define SAVESHAREDPV(s) save_shared_pvref((char**)&(s))
#define SAVESETSVFLAGS(sv,mask,val) save_set_svflags(sv,mask,val)
#define SAVEFREECOPHH(h) save_pushptr((void *)(h), SAVEt_FREECOPHH)
#define SAVEI8(i) save_I8((I8*)&(i))
#define SAVEI16(i) save_I16((I16*)&(i))
#define SAVEI32(i) save_I32((I32*)&(i))
#define SAVEINT(i) save_int((int*)&(i))
#define SAVEIV(i) save_iv((IV*)&(i))
#define SAVELONG(l) save_long((long*)&(l))
#define SAVESTRLEN(l) Perl_save_strlen(aTHX_ (STRLEN*)&(l))
#define SAVEBOOL(b) save_bool(&(b))
#define SAVESPTR(s) save_sptr((SV**)&(s))
#define SAVEPPTR(s) save_pptr((char**)&(s))
#define SAVEVPTR(s) save_vptr((void*)&(s))
#define SAVEPADSVANDMORTALIZE(s) save_padsv_and_mortalize(s)
#define SAVEFREESV(s) save_freesv(MUTABLE_SV(s))
#define SAVEFREEPADNAME(s) save_pushptr((void *)(s), SAVEt_FREEPADNAME)
#define SAVEMORTALIZESV(s) save_mortalizesv(MUTABLE_SV(s))
#define SAVEFREEOP(o) save_freeop((OP*)(o))
#define SAVEFREEPV(p) save_freepv((char*)(p))
#define SAVECLEARSV(sv) save_clearsv((SV**)&(sv))
#define SAVEGENERICSV(s) save_generic_svref((SV**)&(s))
#define SAVEGENERICPV(s) save_generic_pvref((char**)&(s))
#define SAVESHAREDPV(s) save_shared_pvref((char**)&(s))
#define SAVESETSVFLAGS(sv,mask,val) save_set_svflags(sv,mask,val)
#define SAVEFREECOPHH(h) save_pushptr((void *)(h), SAVEt_FREECOPHH)

#define SAVEDELETE(h,k,l) \
save_delete(MUTABLE_HV(h), (char*)(k), (I32)(l))
#define SAVEHDELETE(h,s) \
Expand Down

0 comments on commit 58541fd

Please sign in to comment.