Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 9cf936f

Browse files
author
Reini Urban
committed
SvREADONLY_off: allow calls as argument
on cperl. no multiple evaluation, at least without PERL_GCC_BRACE_GROUPS_FORBIDDEN
1 parent b94c72c commit 9cf936f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

sv.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,21 @@ C<sv_force_normal> does nothing.
11891189
#else
11901190
# define SvREADONLY_on(sv) (SvFLAGS(sv) |= SVf_READONLY)
11911191
# ifdef USE_CPERL
1192-
# /* double evaluation! */
1192+
# if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
1193+
# /* can avoid double evaluation */
1194+
# define SvREADONLY_off(sv) \
1195+
({ SV *const _sv = MUTABLE_SV(sv); \
1196+
if ((SV*)(_sv) == &PL_sv_placeholder \
1197+
|| (SV*)(_sv) == &PL_sv_undef \
1198+
|| (SV*)(_sv) == &PL_sv_yes \
1199+
|| (SV*)(_sv) == &PL_sv_no \
1200+
|| (SV*)(_sv) == (SV*)&PL_padname_const \
1201+
|| (SV*)(_sv) == (SV*)&PL_defstash) \
1202+
croak_no_modify(); \
1203+
else \
1204+
SvFLAGS(_sv) &= ~SVf_READONLY; \
1205+
})
1206+
# else
11931207
# define SvREADONLY_off(sv) \
11941208
if ((SV*)(sv) == &PL_sv_placeholder \
11951209
|| (SV*)(sv) == &PL_sv_undef \
@@ -1200,6 +1214,7 @@ C<sv_force_normal> does nothing.
12001214
croak_no_modify(); \
12011215
else \
12021216
(SvFLAGS(sv) &= ~SVf_READONLY)
1217+
# endif
12031218
# else
12041219
# define SvREADONLY_off(sv) (SvFLAGS(sv) &= ~SVf_READONLY)
12051220
# endif

0 commit comments

Comments
 (0)