/* doop.c
*
* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
* 2000, 2001, 2002, 2004, by Larry Wall and others
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
*
*/
/*
* "'So that was the job I felt I had to do when I started,' thought Sam."
*/
#include "EXTERN.h"
#define PERL_IN_DOOP_C
#include "perl.h"
#ifndef PERL_MICRO
#include <signal.h>
#endif
{
U8 *s;
U8 *d;
short *tbl;
if (!tbl)
/* First, take care of non-UTF-8 input strings, because they're easy */
while (s < send) {
matches++;
}
else
s++;
}
SvSETMAGIC(sv);
return matches;
}
/* Allow for expansion: $_="a".chr(400); tr/a/\xFE/, FE needs encoding */
if (grows)
else
d = s;
dstart = d;
while (s < send) {
UV c;
/* Need to check this, otherwise 128..255 won't match */
matches++;
d = uvchr_to_utf8(d, ch);
s += ulen;
}
else { /* No match -> copy */
d += ulen;
s += ulen;
}
}
if (grows) {
}
else {
*d = '\0';
}
SvSETMAGIC(sv);
return matches;
}
{
U8 *s;
short *tbl;
if (!tbl)
while (s < send) {
if (tbl[*s++] >= 0)
matches++;
}
else
while (s < send) {
UV c;
if (c < 0x100) {
if (tbl[c] >= 0)
matches++;
} else if (complement)
matches++;
s += ulen;
}
return matches;
}
{
U8 *s;
U8 *d;
short *tbl;
if (!tbl)
if (!isutf8) {
dstart = d = s;
while (s < send) {
matches++;
if (p != d - 1 || *p != *d)
p = d++;
}
*d++ = *s;
matches++;
s++;
}
}
else {
while (s < send) {
matches++;
}
*d++ = *s;
matches++;
s++;
}
}
*d = '\0';
}
else { /* isutf8 */
if (grows)
else
d = s;
dstart = d;
if (complement && !del)
#ifdef MACOS_TRADITIONAL
#endif
while (s < send) {
if (comp > 0xff) {
if (!complement) {
d += len;
}
else {
matches++;
if (!del) {
d = uvchr_to_utf8(d, ch);
}
s += len;
continue;
}
}
}
matches++;
d = uvchr_to_utf8(d, ch);
}
s += len;
continue;
}
d += len;
}
matches++;
s += len;
pch = 0xfeedface;
}
}
else {
while (s < send) {
if (comp > 0xff) {
if (!complement) {
d += len;
}
else {
matches++;
if (!del) {
else
}
}
}
d = uvchr_to_utf8(d, ch);
matches++;
}
d += len;
}
matches++;
s += len;
}
}
if (grows) {
}
else {
*d = '\0';
}
}
SvSETMAGIC(sv);
return matches;
}
{
U8 *s;
U8 *d;
if (!isutf8) {
while (t < e) {
break;
}
if (hibit)
s = bytes_to_utf8(s, &len);
}
start = s;
if (svp)
if (grows) {
/* d needs to be bigger than s, in case e.g. upgrading is required */
dstart = d;
}
else {
dstart = d = s;
}
while (s < send) {
s += UTF8SKIP(s);
matches++;
d = uvuni_to_utf8(d, uv);
}
int i = UTF8SKIP(s);
d += i;
s += i;
}
int i = UTF8SKIP(s);
s += i;
matches++;
d = uvuni_to_utf8(d, final);
}
else
s += UTF8SKIP(s);
if (d > dend) {
if (!grows)
}
}
}
else {
*d = '\0';
}
SvSETMAGIC(sv);
return matches;
}
{
U8 *s;
while (t < e) {
break;
}
if (hibit)
}
while (s < send) {
matches++;
s += UTF8SKIP(s);
}
if (hibit)
return matches;
}
{
U8 *s;
U8 *d;
if (!isutf8) {
while (t < e) {
break;
}
if (hibit)
s = bytes_to_utf8(s, &len);
}
start = s;
if (svp) {
}
if (grows) {
/* d needs to be bigger than s, in case e.g. upgrading is required */
dstart = d;
}
else {
dstart = d = s;
}
if (squash) {
while (s < send) {
if (d > dend) {
if (!grows)
}
matches++;
s += UTF8SKIP(s);
d = uvuni_to_utf8(d, uv);
}
continue;
}
int i = UTF8SKIP(s);
d += i;
s += i;
puv = 0xfeedface;
continue;
}
matches++;
if (havefinal) {
s += UTF8SKIP(s);
d = uvuni_to_utf8(d, final);
}
}
else {
d += len;
}
s += len;
}
continue;
}
matches++; /* "none+1" is delete character */
s += UTF8SKIP(s);
}
}
else {
while (s < send) {
if (d > dend) {
if (!grows)
}
matches++;
s += UTF8SKIP(s);
d = uvuni_to_utf8(d, uv);
continue;
}
int i = UTF8SKIP(s);
d += i;
s += i;
continue;
}
matches++;
s += UTF8SKIP(s);
d = uvuni_to_utf8(d, final);
continue;
}
matches++; /* "none+1" is delete character */
s += UTF8SKIP(s);
}
}
}
else {
*d = '\0';
}
SvSETMAGIC(sv);
return matches;
}
{
if (SvREADONLY(sv)) {
}
if (!len)
return 0;
(void)SvPOK_only_UTF8(sv);
}
case 0:
if (hasutf)
return do_trans_simple_utf8(sv);
else
return do_trans_simple(sv);
case OPpTRANS_IDENTICAL:
if (hasutf)
return do_trans_count_utf8(sv);
else
return do_trans_count(sv);
default:
if (hasutf)
return do_trans_complex_utf8(sv);
else
return do_trans_complex(sv);
}
}
void
{
/* SvCUR assumes it's SvPOK() and woe betide you if it's not. */
mark++;
while (items-- > 0) {
}
mark++;
}
++mark;
}
/* sv_setpv retains old UTF8ness [perl #24846] */
SvUTF8_off(sv);
if (items-- > 0) {
if (*mark)
mark++;
}
if (delimlen) {
}
}
else {
}
SvSETMAGIC(sv);
}
void
{
SvUTF8_off(sv);
SvSETMAGIC(sv);
if (do_taint)
}
/* currently converts input to bytes if possible, but doesn't sweat failure */
{
if (offset < 0)
return retnum;
if (size <= 8)
retnum = 0;
else {
if (size == 16) {
retnum = 0;
else
}
else if (size == 32) {
retnum = 0;
retnum =
retnum =
else
retnum =
}
#ifdef UV_IS_QUAD
else if (size == 64) {
if (ckWARN(WARN_PORTABLE))
"Bit vector size > 32 non-portable");
retnum = 0;
retnum =
retnum =
retnum =
retnum =
retnum =
retnum =
else
retnum =
}
#endif
}
}
else if (size < 8)
else {
if (size == 8)
else if (size == 16)
retnum =
s[offset + 1];
else if (size == 32)
retnum =
s[offset + 3];
#ifdef UV_IS_QUAD
else if (size == 64) {
if (ckWARN(WARN_PORTABLE))
"Bit vector size > 32 non-portable");
retnum =
s[offset + 7];
}
#endif
}
return retnum;
}
/* currently converts input to bytes if possible but doesn't sweat failures,
* although it does ensure that the string it clobbers is not marked as
* utf8-valid any more
*/
void
{
register unsigned char *s;
if (!targ)
return;
/* This is handled by the SvPOK_only below...
if (!Perl_sv_utf8_downgrade(aTHX_ targ, TRUE))
SvUTF8_off(targ);
*/
}
(void)SvPOK_only(targ);
if (offset < 0)
}
if (size < 8) {
}
else {
if (size == 8)
else if (size == 16) {
}
else if (size == 32) {
}
#ifdef UV_IS_QUAD
else if (size == 64) {
if (ckWARN(WARN_PORTABLE))
"Bit vector size > 32 non-portable");
}
#endif
}
}
void
{
char *s;
register I32 i;
for (i = 0; i <= max; i++) {
}
return;
}
(void)hv_iterinit(hv);
/*SUPPRESS 560*/
return;
}
else if (SvREADONLY(sv)) {
/* SV is copy-on-write */
sv_force_normal_flags(sv, 0);
}
if (SvREADONLY(sv))
}
if (s && len) {
char *start = s;
s = send - 1;
while (s > start && UTF8_IS_CONTINUATION(*s))
s--;
if (utf8_to_uvchr((U8*)s, 0)) {
*s = '\0';
SvNIOK_off(sv);
}
}
else
}
else if (s && len) {
s += --len;
*s = '\0';
SvUTF8_off(sv);
SvNIOK_off(sv);
}
else
SvSETMAGIC(sv);
}
{
char *s;
return 0;
return 0;
count = 0;
register I32 i;
for (i = 0; i <= max; i++) {
}
return count;
}
(void)hv_iterinit(hv);
/*SUPPRESS 560*/
return count;
}
else if (SvREADONLY(sv)) {
/* SV is copy-on-write */
sv_force_normal_flags(sv, 0);
}
if (SvREADONLY(sv))
}
if (PL_encoding) {
/* XXX, here sv is utf8-ized as a side-effect!
If encoding.pm is used properly, almost string-generating
operations, including literal strings, chr(), input data, etc.
should have been utf8-ized already, right?
*/
}
}
if (s && len) {
s += --len;
if (*s != '\n')
goto nope;
++count;
--len;
--s;
++count;
}
}
else {
? sv_len_utf8(PL_rs)
: rslen;
/* Assumption is that rs is shorter than the scalar. */
/* RS is utf8, scalar is 8 bit. */
if (is_utf8) {
/* Cannot downgrade, therefore cannot possibly match
*/
temp_buffer = NULL;
goto nope;
}
rsptr = temp_buffer;
}
else if (PL_encoding) {
/* RS is 8 bit, encoding.pm is used.
* Do not recode PL_rs as a side-effect. */
}
else {
/* RS is 8 bit, scalar is utf8. */
rsptr = temp_buffer;
}
}
if (rslen == 1) {
if (*s != *rsptr)
goto nope;
++count;
}
else {
goto nope;
s -= rslen - 1;
goto nope;
count += rs_charlen;
}
}
SvNIOK_off(sv);
SvSETMAGIC(sv);
}
nope:
if (svrecode)
return count;
}
void
{
#ifdef LIBERAL
register long *dl;
register long *ll;
register long *rl;
#endif
register char *dc;
register char *lc;
register char *rc;
char *lsave;
char *rsave;
}
}
}
else {
}
(void)SvPOK_only(sv);
switch (optype) {
case OP_BIT_AND:
}
break;
case OP_BIT_XOR:
}
goto mop_up_utf;
case OP_BIT_OR:
}
if (rulen)
else if (lulen)
else
break;
}
goto finish;
}
else
#ifdef LIBERAL
if (len >= sizeof(long)*4 &&
!((long)dc % sizeof(long)) &&
!((long)lc % sizeof(long)) &&
!((long)rc % sizeof(long))) /* It's almost always aligned... */
{
len /= (sizeof(long)*4);
switch (optype) {
case OP_BIT_AND:
while (len--) {
}
break;
case OP_BIT_XOR:
while (len--) {
}
break;
case OP_BIT_OR:
while (len--) {
}
}
}
#endif
{
switch (optype) {
case OP_BIT_AND:
while (len--)
break;
case OP_BIT_XOR:
while (len--)
goto mop_up;
case OP_BIT_OR:
while (len--)
else
break;
}
}
}
OP *
{
dSP;
if (!hv) {
dTARGET; /* make sure to clear its target here */
}
}
IV i;
}
}
}
else {
i = 0;
/*SUPPRESS 560*/
while (hv_iternext(keys)) i++;
}
PUSHi( i );
}
PUTBACK; /* hv_iternext and hv_iterval might clobber stack_sp */
if (dokeys) {
}
if (dovalues) {
}
}
return NORMAL;
}