summaryrefslogtreecommitdiff
path: root/doop.c
diff options
context:
space:
mode:
authorPerl 5 Porters <perl5-porters@africa.nicoh.com>1996-06-18 08:52:39 +0000
committerCharles Bailey <bailey@genetics.upenn.edu>1996-06-18 08:52:39 +0000
commit8c2cee6fb5e11729e07e05b4e1c329fc91f18a19 (patch)
tree4b962cb0ab4f3d219c119c1981032dbf7cdd05df /doop.c
parent517844ec99ebe2d880df96289d21cffbf8a8b217 (diff)
downloadperl-8c2cee6fb5e11729e07e05b4e1c329fc91f18a19.tar.gz
perl 5.003_01: doop.c
Fix length test so chomp won't clip strings shorter than $/ Incorporate shared hash key support
Diffstat (limited to 'doop.c')
-rw-r--r--doop.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/doop.c b/doop.c
index c906db70d1..85146bf6f6 100644
--- a/doop.c
+++ b/doop.c
@@ -494,7 +494,7 @@ register SV *sv;
++count;
}
else {
- if (len < rslen)
+ if (len < rslen - 1)
goto nope;
len -= rslen - 1;
s -= rslen - 1;
@@ -622,9 +622,7 @@ dARGS
{
dSP;
HV *hv = (HV*)POPs;
- I32 i;
register HE *entry;
- char *tmps;
SV *tmpstr;
I32 dokeys = (op->op_type == OP_KEYS);
I32 dovalues = (op->op_type == OP_VALUES);
@@ -638,6 +636,7 @@ dARGS
(void)hv_iterinit(hv); /* always reset iterator regardless */
if (GIMME != G_ARRAY) {
+ I32 i;
dTARGET;
if (!SvRMAGICAL(hv) || !mg_find((SV*)hv,'P'))
@@ -659,21 +658,17 @@ dARGS
PUTBACK; /* hv_iternext and hv_iterval might clobber stack_sp */
while (entry = hv_iternext(hv)) {
SPAGAIN;
- if (dokeys) {
- tmps = hv_iterkey(entry,&i); /* won't clobber stack_sp */
- if (!i)
- tmps = "";
- XPUSHs(sv_2mortal(newSVpv(tmps,i)));
- }
+ if (dokeys)
+ XPUSHs(hv_iterkeysv(entry)); /* won't clobber stack_sp */
if (dovalues) {
tmpstr = NEWSV(45,0);
PUTBACK;
sv_setsv(tmpstr,hv_iterval(hv,entry));
SPAGAIN;
DEBUG_H( {
- sprintf(buf,"%d%%%d=%d\n",entry->hent_hash,
- HvMAX(hv)+1,entry->hent_hash & HvMAX(hv));
- sv_setpv(tmpstr,buf);
+ sprintf(buf,"%d%%%d=%d\n", HeHASH(entry),
+ HvMAX(hv)+1, HeHASH(entry) & HvMAX(hv));
+ sv_setpv(tmpstr,buf);
} )
XPUSHs(sv_2mortal(tmpstr));
}