register XPVHV* xhv;
register U32 hash;
register HE *entry;
+ char *origkey = key;
SV *sv;
if (!hv)
Sv = sv;
return &Sv;
}
+#ifdef ENV_IS_CASELESS
+ else if (mg_find((SV*)hv,'E')) {
+ sv = sv_2mortal(newSVpv(key,klen));
+ key = strupr(SvPVX(sv));
+ }
+#endif
}
xhv = (XPVHV*)SvANY(hv);
if ((gotenv = ENV_getenv(key)) != Nullch) {
sv = newSVpv(gotenv,strlen(gotenv));
SvTAINTED_on(sv);
- return hv_store(hv,key,klen,sv,hash);
+ return hv_store(hv,origkey,klen,sv,hash);
}
}
#endif
if (lval) { /* gonna assign to this, so it better be there */
sv = NEWSV(61,0);
- return hv_store(hv,key,klen,sv,hash);
+ return hv_store(hv,origkey,klen,sv,hash);
}
return 0;
}
register char *key;
STRLEN klen;
register HE *entry;
+ SV *origkeysv = keysv;
SV *sv;
if (!hv)
return 0;
- if (SvRMAGICAL(hv) && mg_find((SV*)hv,'P')) {
- static HE mh;
+ if (SvRMAGICAL(hv)) {
+ if (mg_find((SV*)hv,'P')) {
+ static HE mh;
- sv = sv_newmortal();
- keysv = sv_2mortal(newSVsv(keysv));
- mg_copy((SV*)hv, sv, (char*)keysv, HEf_SVKEY);
- if (!HeKEY_hek(&mh)) {
- char *k;
- New(54, k, HEK_BASESIZE + sizeof(SV*), char);
- HeKEY_hek(&mh) = (HEK*)k;
+ sv = sv_newmortal();
+ keysv = sv_2mortal(newSVsv(keysv));
+ mg_copy((SV*)hv, sv, (char*)keysv, HEf_SVKEY);
+ if (!HeKEY_hek(&mh)) {
+ char *k;
+ New(54, k, HEK_BASESIZE + sizeof(SV*), char);
+ HeKEY_hek(&mh) = (HEK*)k;
+ }
+ HeSVKEY_set(&mh, keysv);
+ HeVAL(&mh) = sv;
+ return &mh;
+ }
+#ifdef ENV_IS_CASELESS
+ else if (mg_find((SV*)hv,'E')) {
+ key = SvPV(keysv, klen);
+ keysv = sv_2mortal(newSVpv(key,klen));
+ (void)strupr(SvPVX(keysv));
+ hash = 0;
}
- HeSVKEY_set(&mh, keysv);
- HeVAL(&mh) = sv;
- return &mh;
+#endif
}
xhv = (XPVHV*)SvANY(hv);
if ((gotenv = ENV_getenv(key)) != Nullch) {
sv = newSVpv(gotenv,strlen(gotenv));
SvTAINTED_on(sv);
- return hv_store_ent(hv,keysv,sv,hash);
+ return hv_store_ent(hv,origkeysv,sv,hash);
}
}
#endif
if (lval) { /* gonna assign to this, so it better be there */
sv = NEWSV(61,0);
- return hv_store_ent(hv,keysv,sv,hash);
+ return hv_store_ent(hv,origkeysv,sv,hash);
}
return 0;
}
mg_copy((SV*)hv, val, key, klen);
if (!xhv->xhv_array && !needs_store)
return 0;
+#ifdef ENV_IS_CASELESS
+ else if (mg_find((SV*)hv,'E')) {
+ SV *sv = sv_2mortal(newSVpv(key,klen));
+ key = strupr(SvPVX(sv));
+ hash = 0;
+ }
+#endif
}
}
if (!hash)
TAINT_IF(save_taint);
if (!xhv->xhv_array && !needs_store)
return Nullhe;
- }
+#ifdef ENV_IS_CASELESS
+ else if (mg_find((SV*)hv,'E')) {
+ key = SvPV(keysv, klen);
+ keysv = sv_2mortal(newSVpv(key,klen));
+ (void)strupr(SvPVX(keysv));
+ hash = 0;
+ }
+#endif
+ }
}
key = SvPV(keysv, klen);
-
+
if (!hash)
PERL_HASH(hash, key, klen);
if (mg_find(sv, 's')) {
return Nullsv; /* %SIG elements cannot be deleted */
}
- if (mg_find(sv, 'p')) {
+ else if (mg_find(sv, 'p')) {
sv_unmagic(sv, 'p'); /* No longer an element */
return sv;
}
+#ifdef ENV_IS_CASELESS
+ else if (mg_find((SV*)hv,'E')) {
+ sv = sv_2mortal(newSVpv(key,klen));
+ key = strupr(SvPVX(sv));
+ }
+#endif
}
xhv = (XPVHV*)SvANY(hv);
if (!xhv->xhv_array)
sv_unmagic(sv, 'p'); /* No longer an element */
return sv;
}
+#ifdef ENV_IS_CASELESS
+ else if (mg_find((SV*)hv,'E')) {
+ key = SvPV(keysv, klen);
+ keysv = sv_2mortal(newSVpv(key,klen));
+ (void)strupr(SvPVX(keysv));
+ hash = 0;
+ }
+#endif
}
xhv = (XPVHV*)SvANY(hv);
if (!xhv->xhv_array)
magic_existspack(sv, mg_find(sv, 'p'));
return SvTRUE(sv);
}
+#ifdef ENV_IS_CASELESS
+ else if (mg_find((SV*)hv,'E')) {
+ sv = sv_2mortal(newSVpv(key,klen));
+ key = strupr(SvPVX(sv));
+ }
+#endif
}
xhv = (XPVHV*)SvANY(hv);
magic_existspack(sv, mg_find(sv, 'p'));
return SvTRUE(sv);
}
+#ifdef ENV_IS_CASELESS
+ else if (mg_find((SV*)hv,'E')) {
+ key = SvPV(keysv, klen);
+ keysv = sv_2mortal(newSVpv(key,klen));
+ (void)strupr(SvPVX(keysv));
+ hash = 0;
+ }
+#endif
}
xhv = (XPVHV*)SvANY(hv);
$Is_Dos = $^O eq 'dos';
$PERL = ($Is_MSWin32 ? '.\perl' : './perl');
-print "1..30\n";
+print "1..34\n";
eval '$ENV{"FOO"} = "hi there";'; # check that ENV is inited inside eval
if ($Is_MSWin32) { ok 1, `cmd /x /c set FOO` eq "FOO=hi there\n"; }
close FOO; # just mention it, squelch used-only-once
if ($Is_MSWin32 || $Is_Dos) {
- ok 3,1;
- ok 4,1;
+ ok "3 # skipped",1;
+ ok "4 # skipped",1;
}
else {
# the next tests are embedded inside system simply because sh spits out
ok 28, $^T > 850000000, $^T;
if ($Is_VMS || $Is_Dos) {
- ok 29, 1;
- ok 30, 1;
+ ok "29 # skipped", 1;
+ ok "30 # skipped", 1;
}
else {
$PATH = $ENV{PATH};
: (`echo \$NoNeSuCh` eq "foo\n") );
}
+# test case-insignificance of %ENV (these tests must be enabled only
+# when perl is compiled with -DENV_IS_CASELESS)
+if ($Is_MSWin32) {
+ %ENV = ();
+ $ENV{'Foo'} = 'bar';
+ $ENV{'fOo'} = 'baz';
+ ok 31, (scalar(keys(%ENV)) == 1);
+ ok 32, exists($ENV{'FOo'});
+ ok 33, (delete($ENV{'foO'}) eq 'baz');
+ ok 34, (scalar(keys(%ENV)) == 0);
+}
+else {
+ ok "31 # skipped",1;
+ ok "32 # skipped",1;
+ ok "33 # skipped",1;
+ ok "34 # skipped",1;
+}