From 43fcc5d2e6d10f3d06dbf2aa8a09d23e17c8106c Mon Sep 17 00:00:00 2001 From: Chip Salzenberg Date: Tue, 17 Dec 1996 10:23:42 +1200 Subject: [PATCH] Support SvREADONLY on arrays --- av.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/av.c b/av.c index cad6eaeac4..554f2619a9 100644 --- a/av.c +++ b/av.c @@ -179,10 +179,13 @@ SV *val; if (!av) return 0; + if (!val) + val = &sv_undef; if (SvRMAGICAL(av)) { if (mg_find((SV*)av,'P')) { - mg_copy((SV*)av, val, 0, key); + if (val != &sv_undef) + mg_copy((SV*)av, val, 0, key); return 0; } } @@ -192,9 +195,8 @@ SV *val; if (key < 0) return 0; } - if (!val) - val = &sv_undef; - + if (SvREADONLY(av) && key >= AvFILL(av)) + croak(no_modify); if (key > AvMAX(av)) av_extend(av,key); if (AvREIFY(av)) @@ -362,6 +364,8 @@ register AV *av; if (!av || AvFILL(av) < 0) return &sv_undef; + if (SvREADONLY(av)) + croak(no_modify); retval = AvARRAY(av)[AvFILL(av)]; AvARRAY(av)[AvFILL(av)--] = &sv_undef; if (SvSMAGICAL(av)) @@ -379,6 +383,8 @@ register I32 num; if (!av || num <= 0) return; + if (SvREADONLY(av)) + croak(no_modify); if (!AvREAL(av)) { if (AvREIFY(av)) av_reify(av); @@ -422,6 +428,8 @@ register AV *av; if (!av || AvFILL(av) < 0) return &sv_undef; + if (SvREADONLY(av)) + croak(no_modify); retval = *AvARRAY(av); if (AvREAL(av)) *AvARRAY(av) = &sv_undef; -- 2.34.1