}
#else
if (SvREADONLY(sv)) {
- if (SvFAKE(sv) && !isGV_with_GP(sv)) {
+ if (SvIsCOW(sv)) {
const char * const pvx = SvPVX_const(sv);
const STRLEN len = SvCUR(sv);
SvFAKE_off(sv);
#endif /* __GNU__ */
#define SvIsCOW(sv) ((SvFLAGS(sv) & (SVf_FAKE | SVf_READONLY)) == \
- (SVf_FAKE | SVf_READONLY) && !isGV_with_GP(sv))
+ (SVf_FAKE | SVf_READONLY) && !isGV_with_GP(sv) \
+ && SvTYPE(sv) != SVt_REGEXP)
#define SvIsCOW_shared_hash(sv) (SvIsCOW(sv) && SvLEN(sv) == 0)
#define SvSHARED_HEK_FROM_PV(pvx) \
chdir 't' if -d 't';
@INC = '../lib';
require './test.pl';
- plan( tests => 10 );
+ plan( tests => 13 );
}
for my $arg ('', 'q[]', qw( 1 undef )) {
$x = 42;
is $x, 42, 'Internals::SvREADONLY can turn off readonliness on globs';
+# Same thing with regexps
+$x = ${qr//};
+Internals::SvREADONLY $x, 1;
+ok Internals::SvREADONLY($x),
+ 'read-only regexps are read-only acc. to Internals::';
+eval { $x = [] };
+like $@, qr/Modification of a read-only value attempted at/,
+ 'read-only regexps';
+Internals::SvREADONLY($x,0);
+$x = 42;
+is $x, 42, 'Internals::SvREADONLY can turn off readonliness on regexps';
+
$h{a} = __PACKAGE__;
Internals::SvREADONLY $h{a}, 1;
eval { $h{a} = 3 };