Down with C++ reserved names
[p5sagit/p5-mst-13.2.git] / av.c
diff --git a/av.c b/av.c
index 3eaeea8..150398e 100644 (file)
--- a/av.c
+++ b/av.c
@@ -1,7 +1,7 @@
 /*    av.c
  *
  *    Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- *    2000, 2001, 2002, 2003, by Larry Wall and others
+ *    2000, 2001, 2002, 2003, 2004, 2005 by Larry Wall and others
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -193,7 +193,7 @@ Perl_av_fetch(pTHX_ register AV *av, I32 key, I32 lval)
        return 0;
 
     if (SvRMAGICAL(av)) {
-        MAGIC *tied_magic = mg_find((SV*)av, PERL_MAGIC_tied);
+        const MAGIC * const tied_magic = mg_find((SV*)av, PERL_MAGIC_tied);
         if (tied_magic || mg_find((SV*)av, PERL_MAGIC_regdata)) {
             U32 adjust_index = 1;
 
@@ -281,7 +281,7 @@ Perl_av_store(pTHX_ register AV *av, I32 key, SV *val)
        val = &PL_sv_undef;
 
     if (SvRMAGICAL(av)) {
-        MAGIC *tied_magic = mg_find((SV*)av, PERL_MAGIC_tied);
+        const MAGIC * const tied_magic = mg_find((SV*)av, PERL_MAGIC_tied);
         if (tied_magic) {
             /* Handle negative array indices 20020222 MJD */
             if (key < 0) {
@@ -380,13 +380,13 @@ AV *
 Perl_av_make(pTHX_ register I32 size, register SV **strp)
 {
     register AV *av;
-    register I32 i;
-    register SV** ary;
 
     av = (AV*)NEWSV(8,0);
     sv_upgrade((SV *) av,SVt_PVAV);
     AvFLAGS(av) = AVf_REAL;
     if (size) {                /* `defined' was returning undef for size==0 anyway. */
+        register SV** ary;
+        register I32 i;
        New(4,ary,size,SV*);
        AvALLOC(av) = ary;
        SvPVX(av) = (char*)ary;
@@ -438,7 +438,6 @@ void
 Perl_av_clear(pTHX_ register AV *av)
 {
     register I32 key;
-    SV** ary;
 
 #ifdef DEBUGGING
     if (SvREFCNT(av) == 0 && ckWARN_d(WARN_DEBUGGING)) {
@@ -460,7 +459,7 @@ Perl_av_clear(pTHX_ register AV *av)
        return;
 
     if (AvREAL(av)) {
-       ary = AvARRAY(av);
+        SV** ary = AvARRAY(av);
        key = AvFILLp(av) + 1;
        while (key) {
            SV * sv = ary[--key];
@@ -723,7 +722,7 @@ empty.
 */
 
 I32
-Perl_av_len(pTHX_ register AV *av)
+Perl_av_len(pTHX_ const register AV *av)
 {
     return AvFILL(av);
 }
@@ -803,10 +802,10 @@ Perl_av_delete(pTHX_ AV *av, I32 key, I32 flags)
        Perl_croak(aTHX_ PL_no_modify);
 
     if (SvRMAGICAL(av)) {
-        MAGIC *tied_magic = mg_find((SV*)av, PERL_MAGIC_tied);
-        SV **svp;
+        const MAGIC * const tied_magic = mg_find((SV*)av, PERL_MAGIC_tied);
         if ((tied_magic || mg_find((SV*)av, PERL_MAGIC_regdata))) {
             /* Handle negative array indices 20020222 MJD */
+            SV **svp;
             if (key < 0) {
                 unsigned adjust_index = 1;
                 if (tied_magic) {
@@ -864,6 +863,8 @@ Perl_av_delete(pTHX_ AV *av, I32 key, I32 flags)
        SvREFCNT_dec(sv);
        sv = Nullsv;
     }
+    else if (AvREAL(av))
+       sv = sv_2mortal(sv);
     return sv;
 }
 
@@ -885,7 +886,7 @@ Perl_av_exists(pTHX_ AV *av, I32 key)
 
 
     if (SvRMAGICAL(av)) {
-        MAGIC *tied_magic = mg_find((SV*)av, PERL_MAGIC_tied);
+        const MAGIC * const tied_magic = mg_find((SV*)av, PERL_MAGIC_tied);
         if (tied_magic || mg_find((SV*)av, PERL_MAGIC_regdata)) {
             SV *sv = sv_newmortal();
             MAGIC *mg;