pp_ctl.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/* pp_ctl.c
*
* Copyright (c) 1991-2001, Larry Wall
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
*
*/
/*
* Now far ahead the Road has gone,
* And I must follow, if I can,
* Pursuing it with eager feet,
* Until it joins some larger way
* Where many paths and errands meet.
* And whither then? I cannot say.
*/
#include "EXTERN.h"
#define PERL_IN_PP_CTL_C
#include "perl.h"
#ifndef WORD_ALIGN
#define WORD_ALIGN sizeof(U16)
#endif
#ifdef PERL_OBJECT
#else
#define sv_cmp_static Perl_sv_cmp
#endif
{
dSP;
if (cxix < 0)
case G_ARRAY:
case G_SCALAR:
default:
}
}
{
return NORMAL;
}
{
restore in regcomp, where marked with XXXX. */
PL_reginterp_cnt = 0;
return NORMAL;
}
{
dSP;
register char *t;
}
if (mg) {
}
else {
/* Check against the last compiled regexp. */
{
if (pm->op_pmregexp) {
}
PL_reginterp_cnt = 0; /* XXXX Be extra paranoid - needed
}
}
#ifndef INCOMPLETE_TAINTS
if (PL_tainting) {
if (PL_tainted)
else
}
#endif
/* XXX runtime compiled output needs to move to the pad */
#if !defined(USE_ITHREADS) && !defined(USE_THREADS)
/* XXX can't change the optree at runtime either */
#endif
}
}
{
dSP;
/* Are we done */
{
bool isutf8;
(void)SvPOK_only(targ);
if (isutf8)
}
}
m = s;
s = orig;
s = orig + (m - s);
}
{ /* Update the pos() information. */
I32 i;
}
i = m - orig;
sv_pos_b2u(sv, &i);
}
}
void
{
U32 i;
if (!p)
else
*rsp = (void*)p;
}
}
}
void
{
U32 i;
if (RX_MATCH_COPIED(rx))
RX_MATCH_COPIED_set(rx, *p);
*p++ = 0;
}
}
void
{
if (p) {
Safefree(p);
}
}
{
register char *t;
register char *f;
register char *s;
register char *send;
char *item;
char *chophere;
char *linemark;
bool gotsome;
bool item_is_utf = FALSE;
if (SvREADONLY(tmpForm)) {
}
else
}
t += len;
/* need to jump to the next word */
for (;;) {
DEBUG_f( {
char *name = "???";
arg = -1;
switch (*fpc) {
}
if (arg >= 0)
else
} )
switch (*fpc++) {
case FF_LINEMARK:
linemark = t;
lines++;
break;
case FF_LITERAL:
while (arg--)
*t++ = *f++;
break;
case FF_SKIP:
f += *fpc++;
break;
case FF_FETCH:
f += arg;
else {
if (ckWARN(WARN_SYNTAX))
}
break;
case FF_CHECKNL:
}
else
while (s < send) {
if (*s & ~31)
else if (*s == '\n')
break;
s++;
}
item_is_utf = TRUE;
break;
}
}
item_is_utf = FALSE;
while (s < send) {
if (*s & ~31)
else if (*s == '\n')
break;
s++;
}
break;
case FF_CHECKCHOP:
while (s < send) {
if (*s == '\r') {
break;
}
if (*s++ & ~31)
}
}
else {
if (isSPACE(*s)) {
if (chopspace)
chophere = s;
if (*s == '\r')
break;
}
else {
if (*s & ~31)
if (strchr(PL_chopset, *s))
chophere = s + 1;
}
s++;
}
}
item_is_utf = TRUE;
break;
}
}
item_is_utf = FALSE;
while (s < send) {
if (*s == '\r') {
break;
}
if (*s++ & ~31)
}
}
else {
if (isSPACE(*s)) {
if (chopspace)
chophere = s;
if (*s == '\r')
break;
}
else {
if (*s & ~31)
if (strchr(PL_chopset, *s))
chophere = s + 1;
}
s++;
}
}
break;
case FF_SPACE:
if (arg) {
while (arg-- > 0)
*t++ = ' ';
}
break;
case FF_HALFSPACE:
if (arg) {
arg /= 2;
while (arg-- > 0)
*t++ = ' ';
}
break;
case FF_ITEM:
s = item;
if (item_is_utf) {
while (arg--) {
if (UTF8_IS_CONTINUED(*s)) {
switch (UTF8SKIP(s)) {
case 7: *t++ = *s++;
case 6: *t++ = *s++;
case 5: *t++ = *s++;
case 4: *t++ = *s++;
case 3: *t++ = *s++;
case 2: *t++ = *s++;
case 1: *t++ = *s++;
}
}
else {
if ( !((*t++ = *s++) & ~31) )
t[-1] = ' ';
}
}
break;
}
while (arg--) {
#ifdef EBCDIC
int ch = *t++ = *s++;
#else
if ( !((*t++ = *s++) & ~31) )
#endif
t[-1] = ' ';
}
break;
case FF_CHOP:
s = chophere;
if (chopspace) {
while (*s && isSPACE(*s))
s++;
}
break;
case FF_LINEGLOB:
if (itemsize) {
while (s < send) {
if (*s++ == '\n') {
if (s == send)
itemsize--;
else
lines++;
}
}
}
break;
case FF_DECIMAL:
/* If the field is marked with ^ and the value is undefined,
blank it out. */
while (arg--)
*t++ = ' ';
break;
}
/* Formats aren't yet marked for locales, so assume "yes". */
{
#if defined(USE_LONG_DOUBLE)
if (arg & 256) {
} else {
}
#else
if (arg & 256) {
sprintf(t, "%#*.*f",
} else {
sprintf(t, "%*.0f",
}
#endif
}
t += fieldsize;
break;
case FF_NEWLINE:
f++;
while (t-- > linemark && *t == ' ') ;
t++;
*t++ = '\n';
break;
case FF_BLANK:
if (gotsome) {
if (arg) { /* repeat until fields exhausted? */
*t = '\0';
if (lines == 200) {
}
}
}
else {
t = linemark;
lines--;
}
break;
case FF_MORE:
s = chophere;
if (chopspace) {
s++;
}
if (s < send) {
if (arg) {
while (arg-- > 0)
*t++ = ' ';
}
s = t - 3;
s--;
}
*s++ = '.';
*s++ = '.';
*s++ = '.';
}
break;
case FF_END:
*t = '\0';
}
}
}
{
dSP;
(void)POPMARK;
}
pp_pushmark(); /* push dst */
pp_pushmark(); /* push src */
ENTER; /* enter outer scope */
/* SAVE_DEFSV does *not* suffice here for USE_THREADS */
ENTER; /* enter inner scope */
pp_pushmark(); /* push top */
}
{
}
{
dSP;
/* first, move source pointer to the next item in the source list */
++PL_markstack_ptr[-1];
/* if there are new items, push them into the destination list */
if (items) {
/* might need to make room back there first */
/* XXX this implementation is very pessimal because the stack
* is repeatedly extended for every set of items. Is possible
* to do this without any stack extension or copying at all
* by maintaining a separate list over which the map iterates
* (like foreach does). --gsar */
/* everything in the stack after the destination list moves
* towards the end the stack by the amount of room needed */
/* items to shift up (accounting for the moved source pointer) */
/* This optimization is by Ben Tilly and it does
* things differently from what Sarathy (gsar)
* is describing. The downside of this optimization is
* that leaves "holes" (uninitialized and hopefully unused areas)
* to the Perl stack, but on the other hand this
* shouldn't be a problem. If Sarathy's idea gets
* implemented, this optimization should become
* irrelevant. --jhi */
*PL_markstack_ptr += shift;
while (count--)
}
/* copy the new items down to the destination list */
while (items--)
}
LEAVE; /* exit inner scope */
/* All done yet? */
(void)POPMARK; /* pop top */
LEAVE; /* exit outer scope */
(void)POPMARK; /* pop src */
(void)POPMARK; /* pop dst */
}
}
else {
ENTER; /* enter inner scope */
/* set $_ to the new source item */
}
}
{
I32 overloading = 0;
}
}
else {
}
}
is_xsub = 1;
}
else if (gv) {
}
else {
}
}
if (is_xsub)
else {
}
}
}
else {
PL_sortcop = Nullop;
}
/*SUPPRESS 560*/
SvTEMP_off(*up);
overloading = 1;
else
}
up++;
}
}
if (PL_sortcop) {
if (max > 1) {
SAVEOP();
}
#ifdef USE_THREADS
#endif
}
}
/* This is mostly copied from pp_entersub */
#ifndef USE_THREADS
#endif /* USE_THREADS */
}
PL_stack_sp = newsp;
}
}
else {
if (max > 1) {
? ( overloading
while (p < q) {
*p++ = *q;
*q-- = tmp;
}
}
}
}
return nextop;
}
/* Range stuff. */
{
return NORMAL;
else
return NORMAL;
}
{
dSP;
}
else {
int flip;
} else {
}
if (flip) {
}
else {
SP--;
}
}
}
}
{
dSP;
register I32 i, j;
if (SvGMAGICAL(left))
if (SvGMAGICAL(right))
{
if (max >= i) {
j = max - i + 1;
EXTEND_MORTAL(j);
}
else
j = 0;
while (j--) {
}
}
else {
break;
}
}
}
else {
? (GvIO(PL_last_in_gv)
}
}
}
/* Control. */
{
register I32 i;
register PERL_CONTEXT *cx;
for (i = cxstack_ix; i >= 0; i--) {
case CXt_SUBST:
if (ckWARN(WARN_EXITING))
break;
case CXt_SUB:
if (ckWARN(WARN_EXITING))
break;
case CXt_FORMAT:
if (ckWARN(WARN_EXITING))
break;
case CXt_EVAL:
if (ckWARN(WARN_EXITING))
break;
case CXt_NULL:
if (ckWARN(WARN_EXITING))
return -1;
case CXt_LOOP:
continue;
}
return i;
}
}
return i;
}
{
}
{
if (cxix < 0)
return G_VOID;
case G_VOID:
return G_VOID;
case G_SCALAR:
return G_SCALAR;
case G_ARRAY:
return G_ARRAY;
default:
/* NOTREACHED */
return 0;
}
}
{
else
return 0;
}
{
}
{
I32 i;
register PERL_CONTEXT *cx;
for (i = startingblock; i >= 0; i--) {
default:
continue;
case CXt_EVAL:
case CXt_SUB:
case CXt_FORMAT:
return i;
}
}
return i;
}
{
I32 i;
register PERL_CONTEXT *cx;
for (i = startingblock; i >= 0; i--) {
default:
continue;
case CXt_EVAL:
return i;
}
}
return i;
}
{
I32 i;
register PERL_CONTEXT *cx;
for (i = startingblock; i >= 0; i--) {
case CXt_SUBST:
if (ckWARN(WARN_EXITING))
break;
case CXt_SUB:
if (ckWARN(WARN_EXITING))
break;
case CXt_FORMAT:
if (ckWARN(WARN_EXITING))
break;
case CXt_EVAL:
if (ckWARN(WARN_EXITING))
break;
case CXt_NULL:
if (ckWARN(WARN_EXITING))
return -1;
case CXt_LOOP:
return i;
}
}
return i;
}
void
{
register PERL_CONTEXT *cx;
while (cxstack_ix > cxix) {
/* Note: we don't need to restore the base context info till the end. */
case CXt_SUBST:
continue; /* not break */
case CXt_SUB:
break;
case CXt_EVAL:
break;
case CXt_LOOP:
break;
case CXt_NULL:
break;
case CXt_FORMAT:
break;
}
cxstack_ix--;
}
}
void
{
if (PL_in_eval)
else if (PL_errors)
else
}
OP *
{
if (PL_in_eval) {
register PERL_CONTEXT *cx;
if (message) {
if (PL_in_eval & EVAL_KEEPERR) {
static char prefix[] = "\t(in cleanup) ";
char *e = Nullch;
e = Nullch;
}
if (!e) {
}
}
}
else
}
else
&& PL_curstackinfo->si_prev)
{
dounwind(-1);
}
if (cxix >= 0) {
if (cxix < cxstack_ix)
my_exit(1);
}
*++newsp = &PL_sv_undef;
PL_stack_sp = newsp;
/* LEAVE could clobber PL_curcop (see save_re_context())
* XXX it might be better to find a way to avoid messing with
* PL_curcop in save_re_context() instead, but this is a more
* minimal fix --GSAR */
if (optype == OP_REQUIRE) {
}
return pop_return();
}
}
if (!message)
{
#ifdef USE_SFIO
/* SFIO can really mess with your errno */
int e = errno;
#endif
(void)PerlIO_flush(serr);
#ifdef USE_SFIO
errno = e;
#endif
}
/* NOTREACHED */
return 0;
}
{
else
}
{
dSP;
else
}
{
dSP;
else
}
{
dSP;
register PERL_CONTEXT *cx;
char *stashname;
if (MAXARG)
for (;;) {
/* we may be in a higher stacklevel, so dig down deeper */
}
if (cxix < 0) {
}
count++;
if (!count--)
break;
}
/* We expect that ccstack[dbcxix] is CXt_SUB, anyway, the
field below is defined for any cx. */
}
if (!stashname)
PUSHs(&PL_sv_undef);
else {
}
}
if (!stashname)
PUSHs(&PL_sv_undef);
else
if (!MAXARG)
/* So is ccstack[dbcxix]. */
}
else {
}
PUSHs(&PL_sv_undef);
else
/* eval STRING */
}
/* require */
}
/* eval BLOCK (try blocks have old_namesv == 0) */
else {
PUSHs(&PL_sv_undef);
PUSHs(&PL_sv_undef);
}
}
else {
PUSHs(&PL_sv_undef);
PUSHs(&PL_sv_undef);
}
{
if (!PL_dbargs) {
SVt_PVAV)));
}
}
/* XXX only hints propagated via op_private are currently
* visible (others are not easily accessible, since they
* use the global PL_hints) */
{
if (old_warnings == pWARN_NONE ||
else if (old_warnings == pWARN_ALL ||
else
}
}
{
dSP;
char *tmps;
if (MAXARG < 1)
tmps = "";
else
}
{
return NORMAL;
}
{
TAINT_NOT; /* Each statement is presumed innocent */
{
dSP;
register PERL_CONTEXT *cx;
if (!cv)
return NORMAL;
PL_debug = 0;
hasargs = 0;
(void)SvREFCNT_inc(cv);
}
else
return NORMAL;
}
{
return NORMAL;
}
{
register PERL_CONTEXT *cx;
#ifdef USE_ITHREADS
void *iterdata;
#endif
#ifdef USE_THREADS
SAVEGENERICSV(*svp);
}
else
#endif /* USE_THREADS */
#ifndef USE_ITHREADS
#else
cxtype |= CXp_PADVAR;
#endif
}
else {
SAVEGENERICSV(*svp);
#ifdef USE_ITHREADS
#endif
}
#ifdef USE_ITHREADS
#else
#endif
{
}
else
}
}
else {
}
}
{
dSP;
register PERL_CONTEXT *cx;
}
{
dSP;
register PERL_CONTEXT *cx;
; /* do nothing */
else
*++newsp = &PL_sv_undef;
}
else {
TAINT_NOT; /* Each item is independent */
}
}
return NORMAL;
}
{
register PERL_CONTEXT *cx;
bool clear_errsv = FALSE;
if (cxstack_ix == PL_sortcxix
{
if (cxstack_ix > PL_sortcxix)
return 0;
}
}
if (cxix < 0)
if (cxix < cxstack_ix)
case CXt_SUB:
break;
case CXt_EVAL:
if (!(PL_in_eval & EVAL_KEEPERR))
clear_errsv = TRUE;
if (CxTRYBLOCK(cx))
break;
lex_end();
if (optype == OP_REQUIRE &&
{
/* Unassume the success we assumed earlier. */
}
break;
case CXt_FORMAT:
break;
default:
}
if (popsub2) {
sv_2mortal(*newsp);
}
else {
}
}
else
}
else
}
else
*++newsp = &PL_sv_undef;
}
TAINT_NOT; /* Each item is independent */
}
}
PL_stack_sp = newsp;
/* Stack values are safe: */
if (popsub2) {
}
else
if (clear_errsv)
return pop_return();
}
{
dSP;
register PERL_CONTEXT *cx;
if (cxix < 0)
}
else {
if (cxix < 0)
}
if (cxix < cxstack_ix)
case CXt_LOOP:
break;
case CXt_SUB:
nextop = pop_return();
break;
case CXt_EVAL:
nextop = pop_return();
break;
case CXt_FORMAT:
nextop = pop_return();
break;
default:
}
else
*++newsp = &PL_sv_undef;
}
TAINT_NOT; /* Each item is independent */
}
}
/* Stack values are safe: */
switch (pop2) {
case CXt_LOOP:
break;
case CXt_SUB:
break;
}
return nextop;
}
{
register PERL_CONTEXT *cx;
if (cxix < 0)
}
else {
if (cxix < 0)
}
if (cxix < cxstack_ix)
/* clear off anything above the scope we're re-entering, but
* save the rest until after a possible continue block */
if (PL_scopestack_ix < inner)
}
{
register PERL_CONTEXT *cx;
if (cxix < 0)
}
else {
if (cxix < 0)
}
if (cxix < cxstack_ix)
}
{
static char too_deep[] = "Target of goto is too deeply nested";
o->op_type == OP_LEAVELOOP ||
o->op_type == OP_LEAVETRY)
{
}
*ops = 0;
/* First try all the kids at this level, since that's likeliest. */
return kid;
}
if (kid == PL_lastgotoprobe)
continue;
return o;
}
}
*ops = 0;
return 0;
}
{
return pp_goto();
/*NOTREACHED*/
}
{
dSP;
register PERL_CONTEXT *cx;
#define GOTO_DEPTH 64
char *label;
static char must_have_label[] = "goto must have label";
label = 0;
/* This egregious kludge implements goto &subroutine */
register PERL_CONTEXT *cx;
if (gv) {
/* autoloaded stub? */
goto retry;
goto retry;
tmpstr = sv_newmortal();
}
}
/* First do some returnish stuff. */
if (cxix < 0)
if (cxix < cxstack_ix)
mark = PL_stack_sp;
/* put @_ back onto stack */
PL_stack_sp++;
PL_stack_sp += items;
#ifndef USE_THREADS
#endif /* USE_THREADS */
/* abandon @_ if it got reified */
}
}
#ifdef USE_THREADS
#else
#endif
PL_stack_sp++;
PL_stack_sp += items;
}
/* Now do some callish stuff. */
#ifdef PERL_XSUB_OLDSTYLE
if (CvOLDSTYLE(cv)) {
SP--;
}
items);
}
else
#endif /* PERL_XSUB_OLDSTYLE */
{
PL_stack_sp--; /* There is no cv arg. */
/* Push a mark for the start of arglist */
/* Pop the current context like a decent sub should */
/* Do _not_ use PUTBACK, keep the XSUB's return stack! */
}
return pop_return();
}
else {
}
(void)SvREFCNT_inc(cv);
else { /* save temporaries on recursion? */
|| *name == '&')
{
/* outer lexical or anon code */
}
else { /* our own lexical */
if (*name == '@')
else if (*name == '%')
else
SvPADMY_on(sv);
}
}
}
else {
}
}
}
}
}
#ifdef USE_THREADS
if (items) {
/* Mark is at the end of the stack. */
PUTBACK ;
}
}
#endif /* USE_THREADS */
#ifndef USE_THREADS
#endif /* USE_THREADS */
{
#ifndef USE_THREADS
#endif /* USE_THREADS */
++mark;
}
}
}
while (items--) {
if (*mark)
SvTEMP_off(*mark);
mark++;
}
}
if (PERLDB_SUB) { /* Checking curstash breaks DProf. */
/*
* We do not care about using sv to call CV;
* it's for informational purposes only.
*/
if (PERLDB_SUB_NN) {
} else {
}
if ( PERLDB_GOTO
PUSHMARK( PL_stack_sp );
PL_stack_sp--;
}
}
}
}
else {
}
}
if (! do_dump)
}
else
/* find label */
PL_lastgotoprobe = 0;
*enterops = 0;
case CXt_EVAL:
break;
case CXt_LOOP:
break;
case CXt_SUBST:
continue;
case CXt_BLOCK:
if (ix)
else
break;
case CXt_SUB:
break;
}
/* FALL THROUGH */
case CXt_FORMAT:
case CXt_NULL:
default:
if (ix)
break;
}
if (gotoprobe) {
if (retop)
break;
}
}
if (!retop)
/* pop unwanted frames */
if (ix < cxstack_ix) {
if (ix < 0)
ix = 0;
}
/* push wanted frames */
/* Eventually we may want to stack the needed arguments
* for each op. For now, we punt on the hard ones. */
}
}
}
if (do_dump) {
#ifdef VMS
#endif
PL_do_undump = TRUE;
my_unexec();
PL_restartop = 0; /* hmm, must be GNU unexec().. */
}
}
{
dSP;
if (MAXARG < 1)
anum = 0;
else {
#ifdef VMS
anum = 0;
#endif
}
PUSHs(&PL_sv_undef);
}
#ifdef NOTYET
{
dSP;
if (value < 0.0) {
--match; /* was fractional--truncate other way */
}
if (match < 0)
match = 0;
}
{
dSP;
if (PL_multiline)
else {
if (match < 0)
match = 0;
}
}
#endif
/* Eval. */
STATIC void
{
register char *t;
while (s && s < send) {
t = strchr(s, '\n');
if (t)
t++;
else
t = send;
s = t;
}
}
#ifdef PERL_FLEXIBLE_EXCEPTIONS
STATIC void *
{
return docatch_body();
}
#endif
STATIC void *
{
return NULL;
}
{
int ret;
#ifdef DEBUGGING
#endif
PL_op = o;
#ifdef PERL_FLEXIBLE_EXCEPTIONS
#else
#endif
switch (ret) {
case 0:
#ifndef PERL_FLEXIBLE_EXCEPTIONS
docatch_body();
#endif
break;
case 3:
PL_restartop = 0;
goto redo_body;
}
/* FALL THROUGH */
default:
/* NOTREACHED */
}
return Nullop;
}
OP *
/* sv Text to convert to OP tree. */
/* startop op_free() this to undo. */
/* code Short string id of the caller. */
{
dSP; /* Make POPBLOCK work. */
char *safestr;
/* switch to eval mode */
if (PL_curcop == &PL_compiling) {
}
code, (unsigned long)++PL_evalseq,
}
else
/* XXX For C<eval "...">s within BEGIN {} blocks, this ends up
deleting the eval's FILEGV from the stash before gv_check() runs
(i.e. before run-time proper). To work around the coredump that
ensues, we always turn GvMULTI_on for any globals that were
introduced within evals. See force_ident(). GSAR 96-10-12 */
SAVEHINTS();
#ifdef OP_IN_REGISTER
#else
#endif
PL_hints = 0;
lex_end();
if (PL_curcop == &PL_compiling)
#ifdef OP_IN_REGISTER
#endif
return rop;
}
/* With USE_THREADS, eval_owner must be held on entry to doeval */
{
dSP;
I32 i;
: EVAL_INEVAL);
/* set up a scratch pad */
for (i = cxstack_ix - 1; i >= 0; i--) {
break;
break;
}
}
#ifdef USE_THREADS
#endif /* USE_THREADS */
PL_comppad = newAV();
PL_comppad_name = newAV();
PL_comppad_name_fill = 0;
PL_min_intro_pending = 0;
PL_padix = 0;
#ifdef USE_THREADS
#endif /* USE_THREADS */
comppadlist = newAV();
if (!saveop ||
{
}
/* make sure we compile in the right package */
}
PL_beginav = newAV();
/* try to compile it */
PL_error_count = 0;
PL_curcop->cop_arybase = 0;
else
if (PL_eval_root) {
}
if (!startop) {
pop_return();
}
lex_end();
if (optype == OP_REQUIRE) {
}
else if (startop) {
}
#ifdef USE_THREADS
PL_eval_owner = 0;
#endif /* USE_THREADS */
}
CopLINE_set(&PL_compiling, 0);
if (startop) {
*startop = PL_eval_root;
} else
else
/* Register with debugger: */
if (cv) {
dSP;
}
}
/* compiled okay, so do it */
#ifdef USE_THREADS
PL_eval_owner = 0;
#endif /* USE_THREADS */
}
{
}
else {
{
}
else {
}
}
}
else {
}
return fp;
}
{
dSP;
register PERL_CONTEXT *cx;
char *name;
char *tryname;
int filter_has_file = 0;
GV *filter_child_proc = 0;
SV *filter_state = 0;
SV *filter_sub = 0;
if (s < end) {
s += len;
if (s < end) {
s += len;
if (s < end)
}
}
if (PERL_REVISION < rev
|| (PERL_REVISION == rev
&& (PERL_VERSION < ver
|| (PERL_VERSION == ver
&& PERL_SUBVERSION < sver))))
{
}
}
{
/* help out with the "use 5.6" confusion */
"this is only v%d.%d.%d, stopped"
}
else {
"this is only v%d.%d.%d, stopped",
}
}
}
}
TAINT_PROPER("require");
*svp != &PL_sv_undef)
/* prepare to compile file */
#ifdef MACOS_TRADITIONAL
{
/* We consider paths of the form :a:b ambiguous and interpret them first
as global then as local
*/
goto trylocal;
}
else
trylocal: {
#else
{
}
else {
#endif
I32 i;
#ifdef VMS
char *unixname;
#endif
{
int count;
}
tryrsfp = 0;
if (sv_isobject(loader))
else
if (count > 0) {
int i = 0;
}
if (io) {
/* reading from a child process doesn't
nest -- when returning from reading
the inner module, the outer one is
unreadable (closed?) I've tried to
save the gv to manage the lifespan of
the pipe, but this didn't help. XXX */
(void)SvREFCNT_inc(filter_child_proc);
}
else {
}
}
}
if (i < count) {
}
}
filter_sub = arg;
(void)SvREFCNT_inc(filter_sub);
if (i < count) {
filter_state = SP[i];
(void)SvREFCNT_inc(filter_state);
}
if (tryrsfp == 0) {
}
}
}
if (tryrsfp) {
break;
}
filter_has_file = 0;
if (filter_child_proc) {
filter_child_proc = 0;
}
if (filter_state) {
filter_state = 0;
}
if (filter_sub) {
filter_sub = 0;
}
}
else {
#ifdef MACOS_TRADITIONAL
char buf[256];
#else
#ifdef VMS
char *unixdir;
continue;
#else
#endif
#endif
TAINT_PROPER("require");
#ifdef MACOS_TRADITIONAL
{
/* Convert slashes in the name part, but not the directory part, to colons */
char * colon;
*colon++ = ':';
}
#endif
if (tryrsfp) {
tryname += 2;
break;
}
}
}
}
}
if (!tryrsfp) {
if (namesv) { /* did we lookup @INC? */
I32 i;
}
}
}
}
else
/* Assume success here to prevent recursive requirement. */
SAVEHINTS();
PL_hints = 0;
if (PL_dowarn & G_WARN_ALL_ON)
else if (PL_dowarn & G_WARN_ALL_OFF)
else
if (filter_sub || filter_child_proc) {
}
/* switch to eval mode */
CopLINE_set(&PL_compiling, 0);
#ifdef USE_THREADS
while (PL_eval_owner)
PL_eval_owner = thr;
#endif /* USE_THREADS */
}
{
return pp_require();
}
{
dSP;
register PERL_CONTEXT *cx;
char *safestr;
TAINT_PROPER("eval");
/* switch to eval mode */
(unsigned long)++PL_evalseq,
}
else
/* XXX For C<eval "...">s within BEGIN {} blocks, this ends up
deleting the eval's FILEGV from the stash before gv_check() runs
(i.e. before run-time proper). To work around the coredump that
ensues, we always turn GvMULTI_on for any globals that were
introduced within evals. See force_ident(). GSAR 96-10-12 */
SAVEHINTS();
else {
}
/* prepare to compile string */
#ifdef USE_THREADS
while (PL_eval_owner)
PL_eval_owner = thr;
#endif /* USE_THREADS */
}
}
{
dSP;
register PERL_CONTEXT *cx;
retop = pop_return();
else
}
else {
*MARK = &PL_sv_undef;
}
}
else {
/* in case LEAVE wipes old return values */
TAINT_NOT; /* Each item is independent */
}
}
}
#ifdef DEBUGGING
#endif
lex_end();
if (optype == OP_REQUIRE &&
{
/* Unassume the success we assumed earlier. */
/* die_where() did LEAVE, or we won't be here */
}
else {
if (!(save_flags & OPf_SPECIAL))
}
}
{
dSP;
register PERL_CONTEXT *cx;
}
{
dSP;
register PERL_CONTEXT *cx;
pop_return();
else
}
else {
*MARK = &PL_sv_undef;
}
}
else {
/* in case LEAVE wipes old return values */
TAINT_NOT; /* Each item is independent */
}
}
}
}
STATIC void
{
register char *base;
register I32 skipspaces = 0;
bool noblank;
bool repeat;
bool ischop;
if (len == 0)
if (s < send) {
*fpc++ = FF_LINEMARK;
base = s;
}
while (s <= send) {
switch (*s++) {
default:
skipspaces = 0;
continue;
case '~':
if (*s == '~') {
*s = ' ';
}
s[-1] = ' ';
/* FALL THROUGH */
case ' ': case '\t':
skipspaces++;
continue;
case '\n': case 0:
skipspaces++;
arg -= skipspaces;
if (arg) {
if (postspace)
*fpc++ = FF_LITERAL;
}
if (s <= send)
skipspaces--;
if (skipspaces) {
*fpc++ = skipspaces;
}
skipspaces = 0;
if (s <= send)
*fpc++ = FF_NEWLINE;
if (noblank) {
if (repeat)
else
arg = 0;
}
if (s < send) {
*fpc++ = FF_LINEMARK;
base = s;
}
else
s++;
continue;
case '@':
case '^':
if (postspace) {
}
if (arg) {
*fpc++ = FF_LITERAL;
}
base = s - 1;
if (*s == '*') {
s++;
*fpc++ = 0;
*fpc++ = FF_LINEGLOB;
}
else if (*s == '#' || (*s == '.' && s[1] == '#')) {
base = s - 1;
while (*s == '#')
s++;
if (*s == '.') {
char *f;
s++;
f = s;
while (*s == '#')
s++;
arg |= 256 + (s - f);
}
*fpc++ = FF_DECIMAL;
}
else {
if (*s == '>') {
while (*++s == '>') ;
}
else if (*s == '|') {
while (*++s == '|') ;
}
else {
if (*s == '<')
while (*++s == '<') ;
}
if (*s == '.' && s[1] == '.' && s[2] == '.') {
s += 3;
}
if (prespace)
if (ismore)
if (ischop)
}
base = s;
skipspaces = 0;
continue;
}
}
{ /* need to jump to the next word */
int z;
}
}
/*
* The rest of this file was derived from source code contributed
* by Tom Horsley.
*
* NOTE: this code was derived from Tom Horsley's qsort replacement
* and should not be confused with the original code.
*/
/* Copyright (C) Tom Horsley, 1997. All rights reserved.
Permission granted to distribute under the same terms as perl which are
(briefly):
it under the terms of either:
a) the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any
later version, or
b) the "Artistic License" which comes with this Kit.
Details on the perl license can be found in the perl source code which
may be located via the www.perl.com web page.
This is the most wonderfulest possible qsort I can come up with (and
still be mostly portable) My (limited) tests indicate it consistently
does about 20% fewer calls to compare than does the qsort in the Visual
C++ library, other vendors may vary.
Some of the ideas in here can be found in "Algorithms" by Sedgewick,
others I invented myself (or more likely re-invented since they seemed
pretty obvious once I watched the algorithm operate for a while).
Most of this code was written while watching the Marlins sweep the Giants
in the 1997 National League Playoffs - no Braves fans allowed to use this
code (just kidding :-).
I realize that if I wanted to be true to the perl tradition, the only
comment in this file would be something like:
...they shuffled back towards the rear of the line. 'No, not at the
rear!' the slave-driver shouted. 'Three files up. And stay there...
However, I really needed to violate that tradition just so I could keep
track of what happens myself, not to mention some poor fool trying to
understand this years from now :-).
*/
/* ********************************************************** Configuration */
#ifndef QSORT_ORDER_GUESS
#endif
/* QSORT_MAX_STACK is the largest number of partitions that can be stacked up for
future processing - a good max upper bound is log base 2 of memory size
(32 on 32 bit machines, 64 on 64 bit machines, etc). In reality can
safely be smaller than that since the program is taking up some space and
most operating systems only let you grab some subset of contiguous
memory (not to mention that you are normally sorting data larger than
1 byte element size :-).
*/
#ifndef QSORT_MAX_STACK
#define QSORT_MAX_STACK 32
#endif
/* QSORT_BREAK_EVEN is the size of the largest partition we should insertion sort.
Anything bigger and we use qsort. If you make this too small, the qsort
will probably break (or become less efficient), because it doesn't expect
the middle element of a partition to be the same as the right or left -
you have been warned).
*/
#ifndef QSORT_BREAK_EVEN
#define QSORT_BREAK_EVEN 6
#endif
/* ************************************************************* Data Types */
/* hold left and right index values of a partition waiting to be sorted (the
partition includes both left and right - right is NOT one past the end or
anything like that).
*/
struct partition_stack_entry {
int left;
int right;
#ifdef QSORT_ORDER_GUESS
int qsort_break_even;
#endif
};
/* ******************************************************* Shorthand Macros */
/* Note that these macros will be used from inside the qsort function where
we happen to know that the variable 'elt_size' contains the size of an
array element and the variable 'temp' points to enough space to hold a
temp element and the variable 'array' points to the array being sorted
and 'compare' is the pointer to the compare routine.
Also note that there are very many highly architecture specific ways
these might be sped up, but this is simply the most generally portable
code I could think of.
*/
/* Return < 0 == 0 or > 0 as the value of elt1 is < elt2, == elt2, > elt2
*/
#ifdef QSORT_ORDER_GUESS
#define QSORT_NOTICE_SWAP swapped++;
#else
#define QSORT_NOTICE_SWAP
#endif
/* swaps contents of array elements elt1, elt2.
*/
STMT_START { \
} STMT_END
/* rotate contents of elt1, elt2, elt3 such that elt1 gets elt2, elt2 gets
elt3 and elt3 gets elt1.
*/
STMT_START { \
} STMT_END
/* ************************************************************ Debug stuff */
#ifdef QSORT_DEBUG
static void
{
return; /* good place to set a breakpoint */
}
#define qsort_assert(t) (void)( (t) || (break_here(), 0) )
static void
void * array,
{
int i;
}
}
}
}
#else
#define qsort_assert(t) ((void)0)
#endif
/* ****************************************************************** qsort */
STATIC void
{
int next_stack_entry = 0;
int part_left;
int part_right;
#ifdef QSORT_ORDER_GUESS
int qsort_break_even;
int swapped;
#endif
/* Make sure we actually have work to do.
*/
if (num_elts <= 1) {
return;
}
/* Setup the initial partition definition and fall into the sorting loop
*/
part_left = 0;
#ifdef QSORT_ORDER_GUESS
#else
#define qsort_break_even QSORT_BREAK_EVEN
#endif
for ( ; ; ) {
/* OK, this is gonna get hairy, so lets try to document all the
concepts and abbreviations and variables and what they keep
track of:
pc: pivot chunk - the set of array elements we accumulate in the
middle of the partition, all equal in value to the original
pivot element selected. The pc is defined by:
pc_left - the leftmost array index of the pc
pc_right - the rightmost array index of the pc
we start with pc_left == pc_right and only one element
in the pivot chunk (but it can grow during the scan).
u: uncompared elements - the set of elements in the partition
we have not yet compared to the pivot value. There are two
uncompared sets during the scan - one to the left of the pc
and one to the right.
u_right - the rightmost index of the left side's uncompared set
u_left - the leftmost index of the right side's uncompared set
The leftmost index of the left sides's uncompared set
doesn't need its own variable because it is always defined
by the leftmost edge of the whole partition (part_left). The
same goes for the rightmost edge of the right partition
(part_right).
We know there are no uncompared elements on the left once we
get u_right < part_left and no uncompared elements on the
right once u_left > part_right. When both these conditions
are met, we have completed the scan of the partition.
Any elements which are between the pivot chunk and the
uncompared elements should be less than the pivot value on
the left side and greater than the pivot value on the right
side (in fact, the goal of the whole algorithm is to arrange
for that to be true and make the groups of less-than and
greater-then elements into new partitions to sort again).
As you marvel at the complexity of the code and wonder why it
has to be so confusing. Consider some of the things this level
of confusion brings:
Once I do a compare, I squeeze every ounce of juice out of it. I
never do compare calls I don't have to do, and I certainly never
do redundant calls.
I also never swap any elements unless I can prove there is a
good reason. Many sort algorithms will swap a known value with
an uncompared value just to get things in the right place (or
avoid complexity :-), but that uncompared value, once it gets
compared, may then have to be swapped again. A lot of the
complexity of this code is due to the fact that it never swaps
anything except compared values, and it only swaps them when the
compare shows they are out of position.
*/
int s;
/* Qsort works best when the pivot value is also the median value
in the partition (unfortunately you can't find the median value
without first sorting :-), so to give the algorithm a helping
hand, we pick 3 elements and sort them and use the median value
of that tiny set as the pivot value.
Some versions of qsort like to use the left middle and right as
the 3 elements to sort so they can insure the ends of the
partition will contain values which will stop the scan in the
compare loop, but when you have to call an arbitrarily complex
routine to do a compare, its really better to just keep track of
array index values to know when you hit the edge of the
partition and avoid the extra compare. An even better reason to
avoid using a compare call is the fact that you can drop off the
edge of the array if someone foolishly provides you with an
unstable compare function that doesn't always provide consistent
results.
So, since it is simpler for us to compare the three adjacent
elements in the middle of the partition, those are the ones we
pick here (conveniently pointed at by u_right, pc_left, and
u_left). The values of the left, center, and right elements
are refered to as l c and r in the following comments.
*/
#ifdef QSORT_ORDER_GUESS
swapped = 0;
#endif
if (s < 0) {
/* l < c */
/* if l < c, c < r - already in order - nothing to do */
if (s == 0) {
/* l < c, c == r - already in order, pc grows */
++pc_right;
} else if (s > 0) {
/* l < c, c > r - need to know more */
if (s < 0) {
/* l < c, c > r, l < r - swap c & r to get ordered */
} else if (s == 0) {
/* l < c, c > r, l == r - swap c&r, grow pc */
--pc_left;
} else {
/* l < c, c > r, l > r - make lcr into rlc to get ordered */
}
}
} else if (s == 0) {
/* l == c */
if (s < 0) {
/* l == c, c < r - already in order, grow pc */
--pc_left;
} else if (s == 0) {
/* l == c, c == r - already in order, grow pc both ways */
--pc_left;
++pc_right;
} else {
/* l == c, c > r - swap l & r, grow pc */
++pc_right;
}
} else {
/* l > c */
if (s < 0) {
/* l > c, c < r - need to know more */
if (s < 0) {
/* l > c, c < r, l < r - swap l & c to get ordered */
} else if (s == 0) {
/* l > c, c < r, l == r - swap l & c, grow pc */
++pc_right;
} else {
/* l > c, c < r, l > r - rotate lcr into crl to order */
}
} else if (s == 0) {
/* l > c, c == r - swap ends, grow pc */
--pc_left;
} else {
/* l > c, c > r - swap ends to get in order */
}
}
/* We now know the 3 middle elements have been compared and
arranged in the desired order, so we can shrink the uncompared
sets on both sides
*/
--u_right;
++u_left;
/* The above massive nested if was the simple part :-). We now have
the middle 3 elements ordered and we need to scan through the
uncompared sets on either side, swapping elements that are on
the wrong side or simply shuffling equal elements around to get
all equal elements into the pivot chunk.
*/
for ( ; ; ) {
int still_work_on_left;
int still_work_on_right;
/* Scan the uncompared values on the left. If I find a value
equal to the pivot value, move it over so it is adjacent to
the pivot chunk and expand the pivot chunk. If I find a value
less than the pivot value, then just leave it - its already
on the correct side of the partition. If I find a greater
value, then stop the scan.
*/
if (s < 0) {
--u_right;
} else if (s == 0) {
--pc_left;
}
--u_right;
} else {
break;
}
}
/* Do a mirror image scan of uncompared values on the right
*/
if (s < 0) {
++u_left;
} else if (s == 0) {
++pc_right;
}
++u_left;
} else {
break;
}
}
if (still_work_on_left) {
/* I know I have a value on the left side which needs to be
on the right side, but I need to know more to decide
exactly the best thing to do with it.
*/
if (still_work_on_right) {
/* I know I have values on both side which are out of
position. This is a big win because I kill two birds
with one swap (so to speak). I can advance the
uncompared pointers on both sides after swapping both
of them into the right place.
*/
--u_right;
++u_left;
} else {
/* I have an out of position value on the left, but the
right is fully scanned, so I "slide" the pivot chunk
and any less-than values left one to make room for the
greater value over on the right. If the out of position
value is immediately adjacent to the pivot chunk (there
are no less-than values), I can do that with a swap,
otherwise, I have to rotate one of the less than values
into the former position of the out of position value
and the right end of the pivot chunk into the left end
(got all that?).
*/
--pc_left;
} else {
}
--pc_right;
--u_right;
}
} else if (still_work_on_right) {
/* Mirror image of complex case above: I have an out of
position value on the right, but the left is fully
scanned, so I need to shuffle things around to make room
for the right value on the left.
*/
++pc_right;
} else {
}
++pc_left;
++u_left;
} else {
/* No more scanning required on either side of partition,
break out of loop and figure out next set of partitions
*/
break;
}
}
/* The elements in the pivot chunk are now in the right place. They
will never move or be compared again. All I have to do is decide
what to do with the stuff to the left and right of the pivot
chunk.
Notes on the QSORT_ORDER_GUESS ifdef code:
1. If I just built these partitions without swapping any (or
very many) elements, there is a chance that the elements are
already ordered properly (being properly ordered will
certainly result in no swapping, but the converse can't be
proved :-).
2. A (properly written) insertion sort will run faster on
already ordered data than qsort will.
3. Perhaps there is some way to make a good guess about
switching to an insertion sort earlier than partition size 6
(for instance - we could save the partition size on the stack
and increase the size each time we find we didn't swap, thus
switching to insertion sort earlier for partitions with a
history of not swapping).
4. Naturally, if I just switch right away, it will make
artificial benchmarks with pure ascending (or descending)
data look really good, but is that a good reason in general?
Hard to say...
*/
#ifdef QSORT_ORDER_GUESS
if (swapped < 3) {
#if QSORT_ORDER_GUESS == 1
#endif
#if QSORT_ORDER_GUESS == 2
qsort_break_even *= 2;
#endif
#if QSORT_ORDER_GUESS == 3
int prev_break = qsort_break_even;
if (qsort_break_even < prev_break) {
}
#endif
} else {
}
#endif
/* There are elements on the left which need more processing.
Check the right as well before deciding what to do.
*/
if (pc_right < part_right) {
/* We have two partitions to be sorted. Stack the biggest one
and process the smallest one on the next iteration. This
minimizes the stack height by insuring that any additional
stack entries must come from the smallest partition which
(because it is smallest) will have the fewest
opportunities to generate additional stack entries.
*/
/* stack the right partition, process the left */
#ifdef QSORT_ORDER_GUESS
#endif
} else {
/* stack the left partition, process the right */
#ifdef QSORT_ORDER_GUESS
#endif
}
} else {
/* The elements on the left are the only remaining elements
that need sorting, arrange for them to be processed as the
next partition.
*/
}
} else if (pc_right < part_right) {
/* There is only one chunk on the right to be sorted, make it
the new partition and loop back around.
*/
} else {
/* This whole partition wound up in the pivot chunk, so
we need to get a new partition off the stack.
*/
if (next_stack_entry == 0) {
/* the stack is empty - we are done */
break;
}
#ifdef QSORT_ORDER_GUESS
#endif
}
} else {
/* This partition is too small to fool with qsort complexity, just
do an ordinary insertion sort to minimize overhead.
*/
int i;
/* Assume 1st element is in right place already, and start checking
at 2nd element to see where it should be inserted.
*/
int j;
/* Scan (backwards - just in case 'i' is already in right place)
through the elements already sorted to see if the ith element
belongs ahead of one of them.
*/
for (j = i - 1; j >= part_left; --j) {
if (qsort_cmp(i, j) >= 0) {
/* i belongs right after j
*/
break;
}
}
++j;
if (j != i) {
/* Looks like we really need to move some things
*/
int k;
for (k = i - 1; k >= j; --k)
}
}
/* That partition is now sorted, grab the next one, or get out
of the loop if there aren't any more.
*/
if (next_stack_entry == 0) {
/* the stack is empty - we are done */
break;
}
#ifdef QSORT_ORDER_GUESS
#endif
}
}
/* Believe it or not, the array is sorted at this point! */
}
#ifdef PERL_OBJECT
#include "XSUB.h"
#endif
static I32
{
GvSV(PL_firstgv) = a;
GvSV(PL_secondgv) = b;
PL_op = PL_sortcop;
if (!SvNIOKp(*PL_stack_sp))
while (PL_scopestack_ix > oldscopeix) {
}
return result;
}
static I32
{
#ifdef USE_THREADS
#else
#endif
}
}
}
PL_op = PL_sortcop;
if (!SvNIOKp(*PL_stack_sp))
while (PL_scopestack_ix > oldscopeix) {
}
return result;
}
static I32
{
dSP;
SP = PL_stack_base;
*++SP = a;
*++SP = b;
if (!SvNIOKp(*PL_stack_sp))
while (PL_scopestack_ix > oldscopeix) {
}
return result;
}
static I32
{
}
static I32
{
}
if (PL_amagic_generation) { \
right, \
0); \
} \
} STMT_END
static I32
{
if (tmpsv) {
NV d;
if (i > 0)
return 1;
return i? -1 : 0;
}
if (d > 0)
return 1;
return d? -1 : 0;
}
}
static I32
{
if (tmpsv) {
NV d;
if (i > 0)
return 1;
return i? -1 : 0;
}
if (d > 0)
return 1;
return d? -1 : 0;
}
}
static I32
{
if (tmpsv) {
NV d;
if (i > 0)
return 1;
return i? -1 : 0;
}
if (d > 0)
return 1;
return d? -1 : 0;
}
}
static I32
{
if (tmpsv) {
NV d;
if (i > 0)
return 1;
return i? -1 : 0;
}
if (d > 0)
return 1;
return d? -1 : 0;
}
}
static I32
{
int len = 0;
/* I was having segfault trouble under Linux 2.2.5 after a
parse error occured. (Had to hack around it with a test
for PL_error_count == 0.) Solaris doesn't segfault --
not sure where the trouble is yet. XXX */
if (filter_has_file) {
}
if (filter_sub && len >= 0) {
dSP;
int count;
if (filter_state) {
}
if (count > 0) {
}
}
}
if (len <= 0) {
if (filter_child_proc) {
}
if (filter_state) {
}
if (filter_sub) {
}
}
return len;
}
#ifdef PERL_OBJECT
static I32
{
}
static I32
{
}
#endif /* PERL_OBJECT */