OP *arg;
{
register short *tbl;
- register char *s;
- register I32 matches = 0;
+ register U8 *s;
+ register U8 *send;
+ register U8 *d;
register I32 ch;
- register char *send;
- register char *d;
+ register I32 matches = 0;
register I32 squash = op->op_private & OPpTRANS_SQUASH;
STRLEN len;
if (SvREADONLY(sv))
croak(no_modify);
- tbl = (short*) cPVOP->op_pv;
- s = SvPV(sv, len);
+ tbl = (short*)cPVOP->op_pv;
+ s = (U8*)SvPV(sv, len);
if (!len)
return 0;
if (!SvPOKp(sv))
- s = SvPV_force(sv, len);
+ s = (U8*)SvPV_force(sv, len);
(void)SvPOK_only(sv);
send = s + len;
if (!tbl || !s)
DEBUG_t( deb("2.TBL\n"));
if (!op->op_private) {
while (s < send) {
- if ((ch = tbl[*s & 0377]) >= 0) {
+ if ((ch = tbl[*s]) >= 0) {
matches++;
*s = ch;
}
else {
d = s;
while (s < send) {
- if ((ch = tbl[*s & 0377]) >= 0) {
+ if ((ch = tbl[*s]) >= 0) {
*d = ch;
if (matches++ && squash) {
if (d[-1] == *d)
}
matches += send - d; /* account for disappeared chars */
*d = '\0';
- SvCUR_set(sv, d - SvPVX(sv));
+ SvCUR_set(sv, d - (U8*)SvPVX(sv));
}
SvSETMAGIC(sv);
return matches;
do_chomp(sv)
register SV *sv;
{
- register I32 count = 0;
+ register I32 count;
STRLEN len;
char *s;
-
+
+ if (RsSNARF(rs))
+ return 0;
+ count = 0;
if (SvTYPE(sv) == SVt_PVAV) {
register I32 i;
I32 max;
s = SvPV_force(sv, len);
if (s && len) {
s += --len;
- if (rspara) {
+ if (RsPARA(rs)) {
if (*s != '\n')
goto nope;
++count;
++count;
}
}
- else if (rslen == 1) {
- if (*s != rschar)
- goto nope;
- ++count;
- }
else {
- if (len < rslen - 1)
- goto nope;
- len -= rslen - 1;
- s -= rslen - 1;
- if (bcmp(s, rs, rslen))
- goto nope;
- count += rslen;
+ STRLEN rslen;
+ char *rsptr = SvPV(rs, rslen);
+ if (rslen == 1) {
+ if (*s != *rsptr)
+ goto nope;
+ ++count;
+ }
+ else {
+ if (len < rslen - 1)
+ goto nope;
+ len -= rslen - 1;
+ s -= rslen - 1;
+ if (bcmp(s, rsptr, rslen))
+ goto nope;
+ count += rslen;
+ }
}
-
*s = '\0';
SvCUR_set(sv, len);
SvNIOK_off(sv);
{
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);
(void)hv_iterinit(hv); /* always reset iterator regardless */
if (GIMME != G_ARRAY) {
+ I32 i;
dTARGET;
if (!SvRMAGICAL(hv) || !mg_find((SV*)hv,'P'))
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));
}