PP(pp_chop)
{
- dSP; dMARK; dTARGET;
- while (SP > MARK)
- do_chop(TARG, POPs);
+ dSP; dMARK; dTARGET; dORIGMARK;
+ while (MARK < SP)
+ do_chop(TARG, *++MARK);
+ SP = ORIGMARK;
PUSHTARG;
RETURN;
}
UV result;
register UV buv;
bool buvok = SvUOK(TOPs);
-
+
if (buvok)
buv = SvUVX(TOPs);
else {
send = tmps + len;
while (tmps < send) {
- UV c = utf8_to_uv(tmps, send-tmps, &l, UTF8_ALLOW_ANYUV);
+ UV c = utf8n_to_uvchr(tmps, send-tmps, &l, UTF8_ALLOW_ANYUV);
tmps += UTF8SKIP(tmps);
targlen += UNISKIP(~c);
nchar++;
if (nwide) {
Newz(0, result, targlen + 1, U8);
while (tmps < send) {
- UV c = utf8_to_uv(tmps, send-tmps, &l, UTF8_ALLOW_ANYUV);
+ UV c = utf8n_to_uvchr(tmps, send-tmps, &l, UTF8_ALLOW_ANYUV);
tmps += UTF8SKIP(tmps);
- result = uv_to_utf8(result, ~c);
+ result = uvchr_to_utf8(result, ~c);
}
*result = '\0';
result -= targlen;
else {
Newz(0, result, nchar + 1, U8);
while (tmps < send) {
- U8 c = (U8)utf8_to_uv(tmps, 0, &l, UTF8_ALLOW_ANY);
+ U8 c = (U8)utf8n_to_uvchr(tmps, 0, &l, UTF8_ALLOW_ANY);
tmps += UTF8SKIP(tmps);
*result++ = ~c;
}
STRLEN len;
U8 *s = (U8*)SvPVx(argsv, len);
- XPUSHu(DO_UTF8(argsv) ? utf8_to_uv_simple(s, 0) : (*s & 0xff));
+ XPUSHu(DO_UTF8(argsv) ? utf8_to_uvchr(s, 0) : (*s & 0xff));
RETURN;
}
if (value > 255 && !IN_BYTE) {
SvGROW(TARG, UNISKIP(value)+1);
- tmps = (char*)uv_to_utf8((U8*)SvPVX(TARG), value);
+ tmps = (char*)uvchr_to_utf8((U8*)SvPVX(TARG), value);
SvCUR_set(TARG, tmps - SvPVX(TARG));
*tmps = '\0';
(void)SvPOK_only(TARG);
STRLEN ulen;
U8 tmpbuf[UTF8_MAXLEN+1];
U8 *tend;
- UV uv = utf8_to_uv(s, slen, &ulen, 0);
+ UV uv;
if (PL_op->op_private & OPpLOCALE) {
TAINT;
SvTAINTED_on(sv);
- uv = toTITLE_LC_uni(uv);
+ uv = toTITLE_LC_uvchr(utf8n_to_uvchr(s, slen, &ulen, 0));
}
else
uv = toTITLE_utf8(s);
- tend = uv_to_utf8(tmpbuf, uv);
+ tend = uvchr_to_utf8(tmpbuf, uv);
if (!SvPADTMP(sv) || tend - tmpbuf != ulen || SvREADONLY(sv)) {
dTARGET;
STRLEN ulen;
U8 tmpbuf[UTF8_MAXLEN+1];
U8 *tend;
- UV uv = utf8_to_uv(s, slen, &ulen, 0);
+ UV uv;
if (PL_op->op_private & OPpLOCALE) {
TAINT;
SvTAINTED_on(sv);
- uv = toLOWER_LC_uni(uv);
+ uv = toLOWER_LC_uvchr(utf8n_to_uvchr(s, slen, &ulen, 0));
}
else
uv = toLOWER_utf8(s);
- tend = uv_to_utf8(tmpbuf, uv);
+ tend = uvchr_to_utf8(tmpbuf, uv);
if (!SvPADTMP(sv) || tend - tmpbuf != ulen || SvREADONLY(sv)) {
dTARGET;
TAINT;
SvTAINTED_on(TARG);
while (s < send) {
- d = uv_to_utf8(d, toUPPER_LC_uni( utf8_to_uv(s, len, &ulen, 0)));
+ d = uvchr_to_utf8(d, toUPPER_LC_uvchr( utf8n_to_uvchr(s, len, &ulen, 0)));
s += ulen;
}
}
else {
while (s < send) {
- d = uv_to_utf8(d, toUPPER_utf8( s ));
+ d = uvchr_to_utf8(d, toUPPER_utf8( s ));
s += UTF8SKIP(s);
}
}
TAINT;
SvTAINTED_on(TARG);
while (s < send) {
- d = uv_to_utf8(d, toLOWER_LC_uni( utf8_to_uv(s, len, &ulen, 0)));
+ d = uvchr_to_utf8(d, toLOWER_LC_uvchr( utf8n_to_uvchr(s, len, &ulen, 0)));
s += ulen;
}
}
else {
while (s < send) {
- d = uv_to_utf8(d, toLOWER_utf8(s));
+ d = uvchr_to_utf8(d, toLOWER_utf8(s));
s += UTF8SKIP(s);
}
}
continue;
}
else {
- if (!utf8_to_uv_simple(s, 0))
+ if (!utf8_to_uvchr(s, 0))
break;
up = (char*)s;
s += UTF8SKIP(s);
STRLEN llen;
STRLEN rlen;
register char *pat = SvPV(left, llen);
+#if 0
+ /* Packed side is assumed to be octets - so force downgrade if it
+ has been UTF-8 encoded by accident
+ */
+ register char *s = SvPVbyte(right, rlen);
+#else
register char *s = SvPV(right, rlen);
+#endif
char *strend = s + rlen;
char *strbeg = s;
register char *patend = pat + llen;
U16 aushort;
unsigned int auint;
U32 aulong;
- UV auv;
#ifdef HAS_QUAD
Uquad_t auquad;
#endif
if (len > strend - s)
len = strend - s;
if (checksum) {
- if (DO_UTF8(right)) {
- while (len > 0) {
- STRLEN l;
- auv = utf8_to_uv((U8*)s, strend - s,
- &l, UTF8_ALLOW_ANYUV);
- culong += auv;
- s += l;
- len -= l;
- }
- }
- else {
- uchar_checksum:
- while (len-- > 0) {
- auint = *s++ & 0xFF;
- culong += auint;
- }
+ uchar_checksum:
+ while (len-- > 0) {
+ auint = *s++ & 255;
+ culong += auint;
}
}
else {
EXTEND(SP, len);
EXTEND_MORTAL(len);
- if (DO_UTF8(right)) {
- while (len > 0) {
- STRLEN l;
- auv = utf8_to_uv((U8*)s, strend - s,
- &l, UTF8_ALLOW_ANYUV);
- sv = NEWSV(37, 0);
- sv_setuv(sv, auv);
- PUSHs(sv_2mortal(sv));
- s += l;
- len -= l;
- }
- }
- else {
- while (len-- > 0) {
- auint = *s++ & 0xFF;
- sv = NEWSV(37, 0);
- sv_setuv(sv, auint);
- PUSHs(sv_2mortal(sv));
- }
+ while (len-- > 0) {
+ auint = *s++ & 255;
+ sv = NEWSV(37, 0);
+ sv_setiv(sv, (IV)auint);
+ PUSHs(sv_2mortal(sv));
}
}
break;
if (checksum) {
while (len-- > 0 && s < strend) {
STRLEN alen;
- auint = utf8_to_uv((U8*)s, strend - s, &alen, 0);
+ auint = utf8n_to_uvchr((U8*)s, strend - s, &alen, 0);
along = alen;
s += along;
if (checksum > 32)
EXTEND_MORTAL(len);
while (len-- > 0 && s < strend) {
STRLEN alen;
- auint = utf8_to_uv((U8*)s, strend - s, &alen, 0);
+ auint = utf8n_to_uvchr((U8*)s, strend - s, &alen, 0);
along = alen;
s += along;
sv = NEWSV(37, 0);
unsigned int auint;
I32 along;
U32 aulong;
- UV auv;
#ifdef HAS_QUAD
Quad_t aquad;
Uquad_t auquad;
#ifdef PERL_NATINT_PACK
int natint; /* native integer */
#endif
- bool has_utf8;
items = SP - MARK;
MARK++;
items = saveitems;
}
break;
+ case 'C':
case 'c':
while (len-- > 0) {
fromstr = NEXTFROM;
sv_catpvn(cat, &achar, sizeof(char));
}
break;
- case 'C':
- has_utf8 = SvUTF8(cat);
- while (len-- > 0) {
- fromstr = NEXTFROM;
- auv = SvUV(fromstr);
- if (!has_utf8 && auv > 0xFF && !IN_BYTE) {
- has_utf8 = TRUE;
- if (SvCUR(cat))
- sv_utf8_upgrade(cat);
- else
- SvUTF8_on(cat); /* There will be UTF8. */
- }
- if (has_utf8) {
- SvGROW(cat, SvCUR(cat) + UNISKIP(auv) + 1);
- SvCUR_set(cat, (char*)uv_to_utf8((U8*)SvEND(cat),auv)
- - SvPVX(cat));
- }
- else {
- achar = auv;
- sv_catpvn(cat, &achar, sizeof(char));
- }
- }
- *SvEND(cat) = '\0';
- break;
case 'U':
- has_utf8 = SvUTF8(cat);
while (len-- > 0) {
fromstr = NEXTFROM;
- auv = SvUV(fromstr);
- if (!has_utf8 && auv > 0x80) {
- has_utf8 = TRUE;
- sv_utf8_upgrade(cat);
- }
- SvGROW(cat, SvCUR(cat) + UNISKIP(auv) + 1);
- SvCUR_set(cat, (char*)uv_to_utf8((U8*)SvEND(cat),auv)
+ auint = SvUV(fromstr);
+ SvGROW(cat, SvCUR(cat) + UTF8_MAXLEN + 1);
+ SvCUR_set(cat, (char*)uvchr_to_utf8((U8*)SvEND(cat),auint)
- SvPVX(cat));
}
*SvEND(cat) = '\0';