summaryrefslogtreecommitdiff
path: root/hv.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1998-01-07 19:12:27 +0000
committerGurusamy Sarathy <gsar@cpan.org>1998-01-07 19:12:27 +0000
commite7152ba2733b9227708ca768b222144415c13c66 (patch)
tree49a52a67b09ef9c1383e3f8a21982938b3c9d5c4 /hv.c
parentce1da67e6637b3b736abebfc7cd6991d91dbe03a (diff)
downloadperl-e7152ba2733b9227708ca768b222144415c13c66.tar.gz
[win32] tweak case-insensitive ENV implementation
p4raw-id: //depot/win32/perl@396
Diffstat (limited to 'hv.c')
-rw-r--r--hv.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/hv.c b/hv.c
index 21792bda55..add7a39f85 100644
--- a/hv.c
+++ b/hv.c
@@ -84,7 +84,6 @@ hv_fetch(HV *hv, char *key, U32 klen, I32 lval)
register XPVHV* xhv;
register U32 hash;
register HE *entry;
- char *origkey = key;
SV *sv;
if (!hv)
@@ -100,8 +99,15 @@ hv_fetch(HV *hv, char *key, U32 klen, I32 lval)
}
#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
}
@@ -137,13 +143,13 @@ hv_fetch(HV *hv, char *key, U32 klen, I32 lval)
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;
}
@@ -157,7 +163,6 @@ hv_fetch_ent(HV *hv, SV *keysv, I32 lval, register U32 hash)
register char *key;
STRLEN klen;
register HE *entry;
- SV *origkeysv = keysv;
SV *sv;
if (!hv)
@@ -181,10 +186,17 @@ hv_fetch_ent(HV *hv, SV *keysv, I32 lval, register U32 hash)
}
#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
}
@@ -223,13 +235,13 @@ hv_fetch_ent(HV *hv, SV *keysv, I32 lval, register U32 hash)
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;
}