register XPVHV* xhv;
register U32 hash;
register HE *entry;
- char *origkey = key;
SV *sv;
if (!hv)
}
#ifdef ENV_IS_CASELESS
else if (mg_find((SV*)hv,'E')) {
- sv = sv_2mortal(newSVpv(key,klen));
- key = strupr(SvPVX(sv));
+ U32 i;
+ for (i = 0; i < klen; ++i)
+ if (isLOWER(key[i])) {
+ char *nkey = strupr(SvPVX(sv_2mortal(newSVpv(key,klen))));
+ SV **ret = hv_fetch(hv, nkey, klen, 0);
+ if (!ret && lval)
+ ret = hv_store(hv, key, klen, NEWSV(61,0), 0);
+ return ret;
+ }
}
#endif
}
if ((gotenv = ENV_getenv(key)) != Nullch) {
sv = newSVpv(gotenv,strlen(gotenv));
SvTAINTED_on(sv);
- return hv_store(hv,origkey,klen,sv,hash);
+ return hv_store(hv,key,klen,sv,hash);
}
}
#endif
if (lval) { /* gonna assign to this, so it better be there */
sv = NEWSV(61,0);
- return hv_store(hv,origkey,klen,sv,hash);
+ return hv_store(hv,key,klen,sv,hash);
}
return 0;
}
register char *key;
STRLEN klen;
register HE *entry;
- SV *origkeysv = keysv;
SV *sv;
if (!hv)
}
#ifdef ENV_IS_CASELESS
else if (mg_find((SV*)hv,'E')) {
+ U32 i;
key = SvPV(keysv, klen);
- keysv = sv_2mortal(newSVpv(key,klen));
- (void)strupr(SvPVX(keysv));
- hash = 0;
+ for (i = 0; i < klen; ++i)
+ if (isLOWER(key[i])) {
+ SV *nkeysv = sv_2mortal(newSVpv(key,klen));
+ (void)strupr(SvPVX(nkeysv));
+ entry = hv_fetch_ent(hv, nkeysv, 0, 0);
+ if (!entry && lval)
+ entry = hv_store_ent(hv, keysv, NEWSV(61,0), hash);
+ return entry;
+ }
}
#endif
}
if ((gotenv = ENV_getenv(key)) != Nullch) {
sv = newSVpv(gotenv,strlen(gotenv));
SvTAINTED_on(sv);
- return hv_store_ent(hv,origkeysv,sv,hash);
+ return hv_store_ent(hv,keysv,sv,hash);
}
}
#endif
if (lval) { /* gonna assign to this, so it better be there */
sv = NEWSV(61,0);
- return hv_store_ent(hv,origkeysv,sv,hash);
+ return hv_store_ent(hv,keysv,sv,hash);
}
return 0;
}