3 * Copyright (c) 1991-2001, Larry Wall
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
11 * "'So that was the job I felt I had to do when I started,' thought Sam."
15 #define PERL_IN_DOOP_C
19 #if !defined(NSIG) || defined(M_UNIX) || defined(M_XENIX)
25 S_do_trans_simple(pTHX_ SV *sv)
32 I32 grows = PL_op->op_private & OPpTRANS_GROWS;
37 tbl = (short*)cPVOP->op_pv;
39 Perl_croak(aTHX_ "panic: do_trans_simple");
41 s = (U8*)SvPV(sv, len);
44 /* First, take care of non-UTF8 input strings, because they're easy */
47 if ((ch = tbl[*s]) >= 0) {
58 /* Allow for expansion: $_="a".chr(400); tr/a/\xFE/, FE needs encoding */
60 New(0, d, len*2+1, U8);
68 /* Need to check this, otherwise 128..255 won't match */
69 c = utf8_to_uv(s, send - s, &ulen, 0);
70 if (c < 0x100 && (ch = tbl[c]) >= 0) {
72 d = uv_to_utf8(d, ch);
75 else { /* No match -> copy */
82 sv_setpvn(sv, (char*)dstart, d - dstart);
87 SvCUR_set(sv, d - dstart);
95 S_do_trans_count(pTHX_ SV *sv)/* SPC - OK */
103 tbl = (short*)cPVOP->op_pv;
105 Perl_croak(aTHX_ "panic: do_trans_count");
107 s = (U8*)SvPV(sv, len);
119 c = utf8_to_uv(s, send - s, &ulen, 0);
120 if (c < 0x100 && tbl[c] >= 0)
129 S_do_trans_complex(pTHX_ SV *sv)/* SPC - NOT OK */
137 I32 grows = PL_op->op_private & OPpTRANS_GROWS;
142 tbl = (short*)cPVOP->op_pv;
144 Perl_croak(aTHX_ "panic: do_trans_complex");
146 s = (U8*)SvPV(sv, len);
152 if (PL_op->op_private & OPpTRANS_SQUASH) {
155 if ((ch = tbl[*s]) >= 0) {
158 if (p != d - 1 || *p != *d)
161 else if (ch == -1) /* -1 is unmapped character */
163 else if (ch == -2) /* -2 is delete character */
170 if ((ch = tbl[*s]) >= 0) {
174 else if (ch == -1) /* -1 is unmapped character */
176 else if (ch == -2) /* -2 is delete character */
181 SvCUR_set(sv, d - dstart);
185 New(0, d, len*2+1, U8);
190 if (PL_op->op_private & OPpTRANS_SQUASH) {
195 UV comp = utf8_to_uv_simple(s, &len);
197 if (comp > 0xff) { /* always unmapped */
201 else if ((ch = tbl[comp]) >= 0) {
204 d = uv_to_utf8(d, ch);
210 else if (ch == -1) { /* -1 is unmapped character */
214 else if (ch == -2) /* -2 is delete character */
223 UV comp = utf8_to_uv_simple(s, &len);
224 if (comp > 0xff) { /* always unmapped */
228 else if ((ch = tbl[comp]) >= 0) {
229 d = uv_to_utf8(d, ch);
232 else if (ch == -1) { /* -1 is unmapped character */
236 else if (ch == -2) /* -2 is delete character */
242 sv_setpvn(sv, (char*)dstart, d - dstart);
247 SvCUR_set(sv, d - dstart);
256 S_do_trans_simple_utf8(pTHX_ SV *sv)/* SPC - OK */
264 I32 grows = PL_op->op_private & OPpTRANS_GROWS;
267 SV* rv = (SV*)cSVOP->op_sv;
268 HV* hv = (HV*)SvRV(rv);
269 SV** svp = hv_fetch(hv, "NONE", 4, FALSE);
270 UV none = svp ? SvUV(*svp) : 0x7fffffff;
277 s = (U8*)SvPV(sv, len);
280 U8 *t = s, *e = s + len;
282 if ((hibit = UTF8_IS_CONTINUED(*t++)))
285 s = bytes_to_utf8(s, &len);
290 svp = hv_fetch(hv, "FINAL", 5, FALSE);
295 /* d needs to be bigger than s, in case e.g. upgrading is required */
296 New(0, d, len*3+UTF8_MAXLEN, U8);
306 if ((uv = swash_fetch(rv, s)) < none) {
309 d = uv_to_utf8(d, uv);
311 else if (uv == none) {
317 else if (uv == extra) {
321 d = uv_to_utf8(d, final);
327 STRLEN clen = d - dstart;
328 STRLEN nlen = dend - dstart + len + UTF8_MAXLEN;
330 Perl_croak(aTHX_ "panic: do_trans_complex_utf8");
331 Renew(dstart, nlen+UTF8_MAXLEN, U8);
333 dend = dstart + nlen;
336 if (grows || hibit) {
337 sv_setpvn(sv, (char*)dstart, d - dstart);
344 SvCUR_set(sv, d - dstart);
348 if (!isutf8 && !(PL_hints & HINT_UTF8))
349 sv_utf8_downgrade(sv, TRUE);
355 S_do_trans_count_utf8(pTHX_ SV *sv)/* SPC - OK */
362 SV* rv = (SV*)cSVOP->op_sv;
363 HV* hv = (HV*)SvRV(rv);
364 SV** svp = hv_fetch(hv, "NONE", 4, FALSE);
365 UV none = svp ? SvUV(*svp) : 0x7fffffff;
369 s = (U8*)SvPV(sv, len);
371 U8 *t = s, *e = s + len;
373 if ((hibit = !UTF8_IS_ASCII(*t++)))
376 start = s = bytes_to_utf8(s, &len);
381 if ((uv = swash_fetch(rv, s)) < none)
392 S_do_trans_complex_utf8(pTHX_ SV *sv) /* SPC - NOT OK */
398 I32 squash = PL_op->op_private & OPpTRANS_SQUASH;
399 I32 del = PL_op->op_private & OPpTRANS_DELETE;
400 I32 grows = PL_op->op_private & OPpTRANS_GROWS;
401 SV* rv = (SV*)cSVOP->op_sv;
402 HV* hv = (HV*)SvRV(rv);
403 SV** svp = hv_fetch(hv, "NONE", 4, FALSE);
404 UV none = svp ? SvUV(*svp) : 0x7fffffff;
413 s = (U8*)SvPV(sv, len);
416 U8 *t = s, *e = s + len;
418 if ((hibit = !UTF8_IS_ASCII(*t++)))
421 s = bytes_to_utf8(s, &len);
426 svp = hv_fetch(hv, "FINAL", 5, FALSE);
431 /* d needs to be bigger than s, in case e.g. upgrading is required */
432 New(0, d, len*3+UTF8_MAXLEN, U8);
444 uv = swash_fetch(rv, s);
447 STRLEN clen = d - dstart;
448 STRLEN nlen = dend - dstart + len + UTF8_MAXLEN;
450 Perl_croak(aTHX_ "panic: do_trans_complex_utf8");
451 Renew(dstart, nlen+UTF8_MAXLEN, U8);
453 dend = dstart + nlen;
458 d = uv_to_utf8(d, uv);
464 else if (uv == none) { /* "none" is unmapped character */
472 else if (uv == extra && !del) {
475 d = uv_to_utf8(d, final);
481 matches++; /* "none+1" is delete character */
487 uv = swash_fetch(rv, s);
489 STRLEN clen = d - dstart;
490 STRLEN nlen = dend - dstart + len + UTF8_MAXLEN;
492 Perl_croak(aTHX_ "panic: do_trans_complex_utf8");
493 Renew(dstart, nlen+UTF8_MAXLEN, U8);
495 dend = dstart + nlen;
499 d = uv_to_utf8(d, uv);
503 else if (uv == none) { /* "none" is unmapped character */
510 else if (uv == extra && !del) {
512 d = uv_to_utf8(d, final);
516 matches++; /* "none+1" is delete character */
520 if (grows || hibit) {
521 sv_setpvn(sv, (char*)dstart, d - dstart);
528 SvCUR_set(sv, d - dstart);
531 if (!isutf8 && !(PL_hints & HINT_UTF8))
532 sv_utf8_downgrade(sv, TRUE);
539 Perl_do_trans(pTHX_ SV *sv)
542 I32 hasutf = (PL_op->op_private &
543 (OPpTRANS_FROM_UTF|OPpTRANS_TO_UTF));
545 if (SvREADONLY(sv) && !(PL_op->op_private & OPpTRANS_IDENTICAL))
546 Perl_croak(aTHX_ PL_no_modify);
552 (void)SvPV_force(sv, len);
553 if (!(PL_op->op_private & OPpTRANS_IDENTICAL))
554 (void)SvPOK_only_UTF8(sv);
556 DEBUG_t( Perl_deb(aTHX_ "2.TBL\n"));
558 switch (PL_op->op_private & ~hasutf & 63) {
561 return do_trans_simple_utf8(sv);
563 return do_trans_simple(sv);
565 case OPpTRANS_IDENTICAL:
567 return do_trans_count_utf8(sv);
569 return do_trans_count(sv);
573 return do_trans_complex_utf8(sv);
575 return do_trans_complex(sv);
580 Perl_do_join(pTHX_ register SV *sv, SV *del, register SV **mark, register SV **sp)
583 register I32 items = sp - mark;
586 register char *delim = SvPV(del, delimlen);
590 len = (items > 0 ? (delimlen * (items - 1) ) : 0);
591 (void)SvUPGRADE(sv, SVt_PV);
592 if (SvLEN(sv) < len + items) { /* current length is way too short */
593 while (items-- > 0) {
594 if (*mark && !SvGAMAGIC(*mark) && SvOK(*mark)) {
600 SvGROW(sv, len + 1); /* so try to pre-extend */
616 for (; items > 0; items--,mark++) {
622 for (; items > 0; items--,mark++)
629 Perl_do_sprintf(pTHX_ SV *sv, I32 len, SV **sarg)
632 char *pat = SvPV(*sarg, patlen);
633 bool do_taint = FALSE;
635 sv_vsetpvfn(sv, pat, patlen, Null(va_list*), sarg + 1, len - 1, &do_taint);
641 /* currently converts input to bytes if possible, but doesn't sweat failure */
643 Perl_do_vecget(pTHX_ SV *sv, I32 offset, I32 size)
646 unsigned char *s = (unsigned char *) SvPV(sv, srclen);
651 if (size < 1 || (size & (size-1))) /* size < 1 or not a power of two */
652 Perl_croak(aTHX_ "Illegal number of bits in vec");
655 (void) Perl_sv_utf8_downgrade(aTHX_ sv, TRUE);
657 offset *= size; /* turn into bit offset */
658 len = (offset + size + 7) / 8; /* required number of bytes */
663 offset >>= 3; /* turn into byte offset */
665 if (offset >= srclen)
668 retnum = (UV) s[offset] << 8;
670 else if (size == 32) {
671 if (offset >= srclen)
673 else if (offset + 1 >= srclen)
675 ((UV) s[offset ] << 24);
676 else if (offset + 2 >= srclen)
678 ((UV) s[offset ] << 24) +
679 ((UV) s[offset + 1] << 16);
682 ((UV) s[offset ] << 24) +
683 ((UV) s[offset + 1] << 16) +
684 ( s[offset + 2] << 8);
687 else if (size == 64) {
688 if (ckWARN(WARN_PORTABLE))
689 Perl_warner(aTHX_ WARN_PORTABLE,
690 "Bit vector size > 32 non-portable");
691 if (offset >= srclen)
693 else if (offset + 1 >= srclen)
695 (UV) s[offset ] << 56;
696 else if (offset + 2 >= srclen)
698 ((UV) s[offset ] << 56) +
699 ((UV) s[offset + 1] << 48);
700 else if (offset + 3 >= srclen)
702 ((UV) s[offset ] << 56) +
703 ((UV) s[offset + 1] << 48) +
704 ((UV) s[offset + 2] << 40);
705 else if (offset + 4 >= srclen)
707 ((UV) s[offset ] << 56) +
708 ((UV) s[offset + 1] << 48) +
709 ((UV) s[offset + 2] << 40) +
710 ((UV) s[offset + 3] << 32);
711 else if (offset + 5 >= srclen)
713 ((UV) s[offset ] << 56) +
714 ((UV) s[offset + 1] << 48) +
715 ((UV) s[offset + 2] << 40) +
716 ((UV) s[offset + 3] << 32) +
717 ( s[offset + 4] << 24);
718 else if (offset + 6 >= srclen)
720 ((UV) s[offset ] << 56) +
721 ((UV) s[offset + 1] << 48) +
722 ((UV) s[offset + 2] << 40) +
723 ((UV) s[offset + 3] << 32) +
724 ((UV) s[offset + 4] << 24) +
725 ((UV) s[offset + 5] << 16);
728 ((UV) s[offset ] << 56) +
729 ((UV) s[offset + 1] << 48) +
730 ((UV) s[offset + 2] << 40) +
731 ((UV) s[offset + 3] << 32) +
732 ((UV) s[offset + 4] << 24) +
733 ((UV) s[offset + 5] << 16) +
734 ( s[offset + 6] << 8);
740 retnum = (s[offset >> 3] >> (offset & 7)) & ((1 << size) - 1);
742 offset >>= 3; /* turn into byte offset */
747 ((UV) s[offset] << 8) +
751 ((UV) s[offset ] << 24) +
752 ((UV) s[offset + 1] << 16) +
753 ( s[offset + 2] << 8) +
756 else if (size == 64) {
757 if (ckWARN(WARN_PORTABLE))
758 Perl_warner(aTHX_ WARN_PORTABLE,
759 "Bit vector size > 32 non-portable");
761 ((UV) s[offset ] << 56) +
762 ((UV) s[offset + 1] << 48) +
763 ((UV) s[offset + 2] << 40) +
764 ((UV) s[offset + 3] << 32) +
765 ((UV) s[offset + 4] << 24) +
766 ((UV) s[offset + 5] << 16) +
767 ( s[offset + 6] << 8) +
776 /* currently converts input to bytes if possible but doesn't sweat failures,
777 * although it does ensure that the string it clobbers is not marked as
778 * utf8-valid any more
781 Perl_do_vecset(pTHX_ SV *sv)
783 SV *targ = LvTARG(sv);
786 register unsigned char *s;
794 s = (unsigned char*)SvPV_force(targ, targlen);
796 /* This is handled by the SvPOK_only below...
797 if (!Perl_sv_utf8_downgrade(aTHX_ targ, TRUE))
800 (void) Perl_sv_utf8_downgrade(aTHX_ targ, TRUE);
803 (void)SvPOK_only(targ);
805 offset = LvTARGOFF(sv);
807 Perl_croak(aTHX_ "Assigning to negative offset in vec");
808 size = LvTARGLEN(sv);
809 if (size < 1 || (size & (size-1))) /* size < 1 or not a power of two */
810 Perl_croak(aTHX_ "Illegal number of bits in vec");
812 offset *= size; /* turn into bit offset */
813 len = (offset + size + 7) / 8; /* required number of bytes */
815 s = (unsigned char*)SvGROW(targ, len + 1);
816 (void)memzero((char *)(s + targlen), len - targlen + 1);
817 SvCUR_set(targ, len);
821 mask = (1 << size) - 1;
824 offset >>= 3; /* turn into byte offset */
825 s[offset] &= ~(mask << size);
826 s[offset] |= lval << size;
829 offset >>= 3; /* turn into byte offset */
831 s[offset ] = lval & 0xff;
832 else if (size == 16) {
833 s[offset ] = (lval >> 8) & 0xff;
834 s[offset+1] = lval & 0xff;
836 else if (size == 32) {
837 s[offset ] = (lval >> 24) & 0xff;
838 s[offset+1] = (lval >> 16) & 0xff;
839 s[offset+2] = (lval >> 8) & 0xff;
840 s[offset+3] = lval & 0xff;
843 else if (size == 64) {
844 if (ckWARN(WARN_PORTABLE))
845 Perl_warner(aTHX_ WARN_PORTABLE,
846 "Bit vector size > 32 non-portable");
847 s[offset ] = (lval >> 56) & 0xff;
848 s[offset+1] = (lval >> 48) & 0xff;
849 s[offset+2] = (lval >> 40) & 0xff;
850 s[offset+3] = (lval >> 32) & 0xff;
851 s[offset+4] = (lval >> 24) & 0xff;
852 s[offset+5] = (lval >> 16) & 0xff;
853 s[offset+6] = (lval >> 8) & 0xff;
854 s[offset+7] = lval & 0xff;
862 Perl_do_chop(pTHX_ register SV *astr, register SV *sv)
867 if (SvTYPE(sv) == SVt_PVAV) {
872 for (i = 0; i <= max; i++) {
873 sv = (SV*)av_fetch(av, i, FALSE);
874 if (sv && ((sv = *(SV**)sv), sv != &PL_sv_undef))
879 else if (SvTYPE(sv) == SVt_PVHV) {
882 (void)hv_iterinit(hv);
884 while ((entry = hv_iternext(hv)))
885 do_chop(astr,hv_iterval(hv,entry));
888 else if (SvREADONLY(sv))
889 Perl_croak(aTHX_ PL_no_modify);
891 if (len && !SvPOK(sv))
892 s = SvPV_force(sv, len);
895 char *send = s + len;
898 while (s > start && UTF8_IS_CONTINUATION(*s))
900 if (utf8_to_uv_simple((U8*)s, 0)) {
901 sv_setpvn(astr, s, send - s);
903 SvCUR_set(sv, s - start);
909 sv_setpvn(astr, "", 0);
913 sv_setpvn(astr, s, 1);
920 sv_setpvn(astr, "", 0);
925 Perl_do_chomp(pTHX_ register SV *sv)
936 if (SvTYPE(sv) == SVt_PVAV) {
941 for (i = 0; i <= max; i++) {
942 sv = (SV*)av_fetch(av, i, FALSE);
943 if (sv && ((sv = *(SV**)sv), sv != &PL_sv_undef))
944 count += do_chomp(sv);
948 else if (SvTYPE(sv) == SVt_PVHV) {
951 (void)hv_iterinit(hv);
953 while ((entry = hv_iternext(hv)))
954 count += do_chomp(hv_iterval(hv,entry));
957 else if (SvREADONLY(sv))
958 Perl_croak(aTHX_ PL_no_modify);
960 if (len && !SvPOKp(sv))
961 s = SvPV_force(sv, len);
968 while (len && s[-1] == '\n') {
976 char *rsptr = SvPV(PL_rs, rslen);
987 if (memNE(s, rsptr, rslen))
1002 Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right)
1018 bool left_utf = DO_UTF8(left);
1019 bool right_utf = DO_UTF8(right);
1022 if (left_utf && !right_utf)
1023 sv_utf8_upgrade(right);
1024 else if (!left_utf && right_utf)
1025 sv_utf8_upgrade(left);
1027 if (sv != left || (optype != OP_BIT_AND && !SvOK(sv) && !SvGMAGICAL(sv)))
1028 sv_setpvn(sv, "", 0); /* avoid undef warning on |= and ^= */
1029 lsave = lc = SvPV(left, leftlen);
1030 rsave = rc = SvPV(right, rightlen);
1031 len = leftlen < rightlen ? leftlen : rightlen;
1033 if ((left_utf || right_utf) && (sv == left || sv == right)) {
1034 needlen = optype == OP_BIT_AND ? len : leftlen + rightlen;
1035 Newz(801, dc, needlen + 1, char);
1037 else if (SvOK(sv) || SvTYPE(sv) > SVt_PVMG) {
1039 dc = SvPV_force(sv, n_a);
1040 if (SvCUR(sv) < len) {
1041 dc = SvGROW(sv, len + 1);
1042 (void)memzero(dc + SvCUR(sv), len - SvCUR(sv) + 1);
1044 if (optype != OP_BIT_AND && (left_utf || right_utf))
1045 dc = SvGROW(sv, leftlen + rightlen + 1);
1048 needlen = ((optype == OP_BIT_AND)
1049 ? len : (leftlen > rightlen ? leftlen : rightlen));
1050 Newz(801, dc, needlen + 1, char);
1051 (void)sv_usepvn(sv, dc, needlen);
1052 dc = SvPVX(sv); /* sv_usepvn() calls Renew() */
1055 (void)SvPOK_only(sv);
1056 if (left_utf || right_utf) {
1059 STRLEN lulen = leftlen;
1060 STRLEN rulen = rightlen;
1065 while (lulen && rulen) {
1066 luc = utf8_to_uv((U8*)lc, lulen, &ulen, UTF8_ALLOW_ANYUV);
1069 ruc = utf8_to_uv((U8*)rc, rulen, &ulen, UTF8_ALLOW_ANYUV);
1073 dc = (char*)uv_to_utf8((U8*)dc, duc);
1075 if (sv == left || sv == right)
1076 (void)sv_usepvn(sv, dcsave, needlen);
1077 SvCUR_set(sv, dc - dcsave);
1080 while (lulen && rulen) {
1081 luc = utf8_to_uv((U8*)lc, lulen, &ulen, UTF8_ALLOW_ANYUV);
1084 ruc = utf8_to_uv((U8*)rc, rulen, &ulen, UTF8_ALLOW_ANYUV);
1088 dc = (char*)uv_to_utf8((U8*)dc, duc);
1092 while (lulen && rulen) {
1093 luc = utf8_to_uv((U8*)lc, lulen, &ulen, UTF8_ALLOW_ANYUV);
1096 ruc = utf8_to_uv((U8*)rc, rulen, &ulen, UTF8_ALLOW_ANYUV);
1100 dc = (char*)uv_to_utf8((U8*)dc, duc);
1103 if (sv == left || sv == right)
1104 (void)sv_usepvn(sv, dcsave, needlen);
1105 SvCUR_set(sv, dc - dcsave);
1107 sv_catpvn(sv, rc, rulen);
1109 sv_catpvn(sv, lc, lulen);
1119 if (len >= sizeof(long)*4 &&
1120 !((long)dc % sizeof(long)) &&
1121 !((long)lc % sizeof(long)) &&
1122 !((long)rc % sizeof(long))) /* It's almost always aligned... */
1124 I32 remainder = len % (sizeof(long)*4);
1125 len /= (sizeof(long)*4);
1134 *dl++ = *ll++ & *rl++;
1135 *dl++ = *ll++ & *rl++;
1136 *dl++ = *ll++ & *rl++;
1137 *dl++ = *ll++ & *rl++;
1142 *dl++ = *ll++ ^ *rl++;
1143 *dl++ = *ll++ ^ *rl++;
1144 *dl++ = *ll++ ^ *rl++;
1145 *dl++ = *ll++ ^ *rl++;
1150 *dl++ = *ll++ | *rl++;
1151 *dl++ = *ll++ | *rl++;
1152 *dl++ = *ll++ | *rl++;
1153 *dl++ = *ll++ | *rl++;
1168 *dc++ = *lc++ & *rc++;
1172 *dc++ = *lc++ ^ *rc++;
1176 *dc++ = *lc++ | *rc++;
1180 sv_catpvn(sv, rsave + len, rightlen - len);
1181 else if (leftlen > len)
1182 sv_catpvn(sv, lsave + len, leftlen - len);
1200 I32 gimme = GIMME_V;
1201 I32 dokeys = (PL_op->op_type == OP_KEYS);
1202 I32 dovalues = (PL_op->op_type == OP_VALUES);
1203 I32 realhv = (SvTYPE(hv) == SVt_PVHV);
1205 if (PL_op->op_type == OP_RV2HV || PL_op->op_type == OP_PADHV)
1206 dokeys = dovalues = TRUE;
1209 if (PL_op->op_flags & OPf_MOD || LVRET) { /* lvalue */
1210 dTARGET; /* make sure to clear its target here */
1211 if (SvTYPE(TARG) == SVt_PVLV)
1212 LvTARG(TARG) = Nullsv;
1218 keys = realhv ? hv : avhv_keys((AV*)hv);
1219 (void)hv_iterinit(keys); /* always reset iterator regardless */
1221 if (gimme == G_VOID)
1224 if (gimme == G_SCALAR) {
1228 if (PL_op->op_flags & OPf_MOD || LVRET) { /* lvalue */
1229 if (SvTYPE(TARG) < SVt_PVLV) {
1230 sv_upgrade(TARG, SVt_PVLV);
1231 sv_magic(TARG, Nullsv, 'k', Nullch, 0);
1234 if (LvTARG(TARG) != (SV*)keys) {
1236 SvREFCNT_dec(LvTARG(TARG));
1237 LvTARG(TARG) = SvREFCNT_inc(keys);
1243 if (! SvTIED_mg((SV*)keys, 'P'))
1248 while (hv_iternext(keys)) i++;
1254 EXTEND(SP, HvKEYS(keys) * (dokeys + dovalues));
1256 PUTBACK; /* hv_iternext and hv_iterval might clobber stack_sp */
1257 while ((entry = hv_iternext(keys))) {
1260 XPUSHs(hv_iterkeysv(entry)); /* won't clobber stack_sp */
1264 hv_iterval(hv,entry) : avhv_iterval((AV*)hv,entry);
1265 DEBUG_H(Perl_sv_setpvf(aTHX_ tmpstr, "%lu%%%d=%lu",
1266 (unsigned long)HeHASH(entry),
1268 (unsigned long)(HeHASH(entry) & HvMAX(keys))));