Clean up a bug I introduced into caseless ENV hv_delete
Nicholas Clark [Sun, 14 Dec 2003 15:32:32 +0000 (15:32 +0000)]
(should be the proper fix for 21870 and 21872's band aid)

p4raw-id: //depot/perl@21904

hv.c

diff --git a/hv.c b/hv.c
index 78b1f9d..7115332 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -902,25 +902,20 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
                    }           
                    return Nullsv;              /* element cannot be deleted */
                }
-           }
 #ifdef ENV_IS_CASELESS
-           if (mg_find((SV*)hv, PERL_MAGIC_env)) {
-               /* XXX This code isn't UTF8 clean.  */
-               keysv = sv_2mortal(newSVpvn(key,klen));
-               key = strupr(SvPVX(keysv));
-
-#if 0
-               /* keysave not in scope - don't understand - NI-S */
-                if (k_flags & HVhek_FREEKEY) {
-                    Safefree(keysave);
+               else if (mg_find((SV*)hv, PERL_MAGIC_env)) {
+                   /* XXX This code isn't UTF8 clean.  */
+                   keysv = sv_2mortal(newSVpvn(key,klen));
+                   if (k_flags & HVhek_FREEKEY) {
+                       Safefree(key);
+                   }
+                   key = strupr(SvPVX(keysv));
+                   is_utf8 = 0;
+                   k_flags = 0;
+                   hash = 0;
                }
 #endif
-
-               is_utf8 = 0;
-               k_flags = 0;
-               hash = 0;
            }
-#endif
        }
     }
     xhv = (XPVHV*)SvANY(hv);