Test changes
[p5sagit/p5-mst-13.2.git] / op.c
diff --git a/op.c b/op.c
index bd2f09a..a0309de 100644 (file)
--- a/op.c
+++ b/op.c
@@ -42,8 +42,7 @@ static PADOFFSET pad_findlex _((char* name, PADOFFSET newoff, U32 seq,
        CV* startcv, I32 cx_ix));
 
 static char*
-gv_ename(gv)
-GV* gv;
+gv_ename(GV *gv)
 {
     SV* tmpsv = sv_newmortal();
     gv_efullname3(tmpsv, gv, Nullch);
@@ -51,8 +50,7 @@ GV* gv;
 }
 
 static OP *
-no_fh_allowed(o)
-OP *o;
+no_fh_allowed(OP *o)
 {
     yyerror(form("Missing comma after first argument to %s function",
                 op_desc[o->op_type]));
@@ -60,37 +58,28 @@ OP *o;
 }
 
 static OP *
-too_few_arguments(o, name)
-OP* o;
-char* name;
+too_few_arguments(OP *o, char *name)
 {
     yyerror(form("Not enough arguments for %s", name));
     return o;
 }
 
 static OP *
-too_many_arguments(o, name)
-OP *o;
-char* name;
+too_many_arguments(OP *o, char *name)
 {
     yyerror(form("Too many arguments for %s", name));
     return o;
 }
 
 static void
-bad_type(n, t, name, kid)
-I32 n;
-char *t;
-char *name;
-OP *kid;
+bad_type(I32 n, char *t, char *name, OP *kid)
 {
     yyerror(form("Type of arg %d to %s must be %s (not %s)",
                 (int)n, name, t, op_desc[kid->op_type]));
 }
 
 void
-assertref(o)
-OP *o;
+assertref(OP *o)
 {
     int type = o->op_type;
     if (type != OP_AELEM && type != OP_HELEM) {
@@ -104,8 +93,7 @@ OP *o;
 /* "register" allocation */
 
 PADOFFSET
-pad_allocmy(name)
-char *name;
+pad_allocmy(char *name)
 {
     dTHR;
     PADOFFSET off;
@@ -119,7 +107,7 @@ char *name;
        }
        croak("Can't use global %s in \"my\"",name);
     }
-    if (AvFILL(comppad_name) >= 0) {
+    if (dowarn && AvFILL(comppad_name) >= 0) {
        SV **svp = AvARRAY(comppad_name);
        for (off = AvFILL(comppad_name); off > comppad_name_floor; off--) {
            if ((sv = svp[off])
@@ -295,8 +283,7 @@ pad_findlex(char *name, PADOFFSET newoff, U32 seq, CV* startcv, I32 cx_ix)
 }
 
 PADOFFSET
-pad_findmy(name)
-char *name;
+pad_findmy(char *name)
 {
     dTHR;
     I32 off;
@@ -345,8 +332,7 @@ char *name;
 }
 
 void
-pad_leavemy(fill)
-I32 fill;
+pad_leavemy(I32 fill)
 {
     I32 off;
     SV **svp = AvARRAY(comppad_name);
@@ -365,9 +351,7 @@ I32 fill;
 }
 
 PADOFFSET
-pad_alloc(optype,tmptype)      
-I32 optype;
-U32 tmptype;
+pad_alloc(I32 optype, U32 tmptype)
 {
     dTHR;
     SV *sv;
@@ -488,7 +472,7 @@ pad_swipe(PADOFFSET po)
 }
 
 void
-pad_reset()
+pad_reset(void)
 {
     dTHR;
     register I32 po;
@@ -514,8 +498,7 @@ pad_reset()
 /* Destructor */
 
 void
-op_free(o)
-OP *o;
+op_free(OP *o)
 {
     register OP *kid, *nextkid;
 
@@ -580,8 +563,7 @@ OP *o;
 }
 
 static void
-null(o)
-OP* o;
+null(OP *o)
 {
     if (o->op_type != OP_NULL && o->op_targ > 0)
        pad_free(o->op_targ);
@@ -595,8 +577,7 @@ OP* o;
 #define LINKLIST(o) ((o)->op_next ? (o)->op_next : linklist((OP*)o))
 
 OP *
-linklist(o)
-OP *o;
+linklist(OP *o)
 {
     register OP *kid;
 
@@ -620,8 +601,7 @@ OP *o;
 }
 
 OP *
-scalarkids(o)
-OP *o;
+scalarkids(OP *o)
 {
     OP *kid;
     if (o && o->op_flags & OPf_KIDS) {
@@ -632,11 +612,11 @@ OP *o;
 }
 
 static OP *
-scalarboolean(o)
-OP *o;
+scalarboolean(OP *o)
 {
     if (dowarn &&
        o->op_type == OP_SASSIGN && cBINOPo->op_first->op_type == OP_CONST) {
+       dTHR;
        line_t oldline = curcop->cop_line;
 
        if (copline != NOLINE)
@@ -648,8 +628,7 @@ OP *o;
 }
 
 OP *
-scalar(o)
-OP *o;
+scalar(OP *o)
 {
     OP *kid;
 
@@ -697,7 +676,7 @@ OP *o;
            else
                scalar(kid);
        }
-       curcop = &compiling;
+       WITH_THR(curcop = &compiling);
        break;
     case OP_SCOPE:
     case OP_LINESEQ:
@@ -708,15 +687,14 @@ OP *o;
            else
                scalar(kid);
        }
-       curcop = &compiling;
+       WITH_THR(curcop = &compiling);
        break;
     }
     return o;
 }
 
 OP *
-scalarvoid(o)
-OP *o;
+scalarvoid(OP *o)
 {
     OP *kid;
     char* useless = 0;
@@ -821,7 +799,7 @@ OP *o;
 
     case OP_NEXTSTATE:
     case OP_DBSTATE:
-       curcop = ((COP*)o);             /* for warning below */
+       WITH_THR(curcop = ((COP*)o));           /* for warning below */
        break;
 
     case OP_CONST:
@@ -860,7 +838,7 @@ OP *o;
 
     case OP_NULL:
        if (o->op_targ == OP_NEXTSTATE || o->op_targ == OP_DBSTATE)
-           curcop = ((COP*)o);         /* for warning below */
+           WITH_THR(curcop = ((COP*)o));       /* for warning below */
        if (o->op_flags & OPf_STACKED)
            break;
        /* FALL THROUGH */
@@ -899,8 +877,7 @@ OP *o;
 }
 
 OP *
-listkids(o)
-OP *o;
+listkids(OP *o)
 {
     OP *kid;
     if (o && o->op_flags & OPf_KIDS) {
@@ -911,8 +888,7 @@ OP *o;
 }
 
 OP *
-list(o)
-OP *o;
+list(OP *o)
 {
     OP *kid;
 
@@ -957,7 +933,7 @@ OP *o;
            else
                list(kid);
        }
-       curcop = &compiling;
+       WITH_THR(curcop = &compiling);
        break;
     case OP_SCOPE:
     case OP_LINESEQ:
@@ -967,7 +943,7 @@ OP *o;
            else
                list(kid);
        }
-       curcop = &compiling;
+       WITH_THR(curcop = &compiling);
        break;
     case OP_REQUIRE:
        /* all requires must return a boolean value */
@@ -978,8 +954,7 @@ OP *o;
 }
 
 OP *
-scalarseq(o)
-OP *o;
+scalarseq(OP *o)
 {
     OP *kid;
 
@@ -989,6 +964,7 @@ OP *o;
             o->op_type == OP_LEAVE ||
             o->op_type == OP_LEAVETRY)
        {
+           dTHR;
            for (kid = cLISTOPo->op_first; kid; kid = kid->op_sibling) {
                if (kid->op_sibling) {
                    scalarvoid(kid);
@@ -1006,9 +982,7 @@ OP *o;
 }
 
 static OP *
-modkids(o, type)
-OP *o;
-I32 type;
+modkids(OP *o, I32 type)
 {
     OP *kid;
     if (o && o->op_flags & OPf_KIDS) {
@@ -1021,9 +995,7 @@ I32 type;
 static I32 modcount;
 
 OP *
-mod(o, type)
-OP *o;
-I32 type;
+mod(OP *o, I32 type)
 {
     dTHR;
     OP *kid;
@@ -1034,6 +1006,7 @@ I32 type;
 
     switch (o->op_type) {
     case OP_UNDEF:
+       modcount++;
        return o;
     case OP_CONST:
        if (!(o->op_private & (OPpCONST_ARYBASE)))
@@ -1107,6 +1080,8 @@ I32 type;
 
     case OP_RV2AV:
     case OP_RV2HV:
+       if (!type && cUNOPo->op_first->op_type != OP_GV)
+           croak("Can't localize through a reference");
        if (type == OP_REFGEN && o->op_flags & OPf_PARENS) {
            modcount = 10000;
            return o;           /* Treat \(@foo) like ordinary list. */
@@ -1128,7 +1103,7 @@ I32 type;
        break;
     case OP_RV2SV:
        if (!type && cUNOPo->op_first->op_type != OP_GV)
-           croak("Can't localize a reference");
+           croak("Can't localize through a reference");
        ref(cUNOPo->op_first, o->op_type); 
        /* FALL THROUGH */
     case OP_GV:
@@ -1213,9 +1188,7 @@ I32 type;
 }
 
 static bool
-scalar_mod_type(o, type)
-OP *o;
-I32 type;
+scalar_mod_type(OP *o, I32 type)
 {
     switch (type) {
     case OP_SASSIGN:
@@ -1259,9 +1232,7 @@ I32 type;
 }
 
 OP *
-refkids(o, type)
-OP *o;
-I32 type;
+refkids(OP *o, I32 type)
 {
     OP *kid;
     if (o && o->op_flags & OPf_KIDS) {
@@ -1272,9 +1243,7 @@ I32 type;
 }
 
 OP *
-ref(o, type)
-OP *o;
-I32 type;
+ref(OP *o, I32 type)
 {
     OP *kid;
 
@@ -1283,7 +1252,7 @@ I32 type;
 
     switch (o->op_type) {
     case OP_ENTERSUB:
-       if ((type == OP_DEFINED) &&
+       if ((type == OP_DEFINED || type == OP_LOCK) &&
            !(o->op_flags & OPf_STACKED)) {
            o->op_type = OP_RV2CV;             /* entersub => rv2cv */
            o->op_ppaddr = ppaddr[OP_RV2CV];
@@ -1355,8 +1324,7 @@ I32 type;
 }
 
 OP *
-my(o)
-OP *o;
+my(OP *o)
 {
     OP *kid;
     I32 type;
@@ -1383,8 +1351,7 @@ OP *o;
 }
 
 OP *
-sawparens(o)
-OP *o;
+sawparens(OP *o)
 {
     if (o)
        o->op_flags |= OPf_PARENS;
@@ -1392,10 +1359,7 @@ OP *o;
 }
 
 OP *
-bind_match(type, left, right)
-I32 type;
-OP *left;
-OP *right;
+bind_match(I32 type, OP *left, OP *right)
 {
     OP *o;
 
@@ -1433,8 +1397,7 @@ OP *right;
 }
 
 OP *
-invert(o)
-OP *o;
+invert(OP *o)
 {
     if (!o)
        return o;
@@ -1443,11 +1406,10 @@ OP *o;
 }
 
 OP *
-scope(o)
-OP *o;
+scope(OP *o)
 {
     if (o) {
-       if (o->op_flags & OPf_PARENS || perldb || tainting) {
+       if (o->op_flags & OPf_PARENS || PERLDB_NOOPT || tainting) {
            o = prepend_elem(OP_LINESEQ, newOP(OP_ENTER, 0), o);
            o->op_type = OP_LEAVE;
            o->op_ppaddr = ppaddr[OP_LEAVE];
@@ -1471,8 +1433,7 @@ OP *o;
 }
 
 int
-block_start(full)
-int full;
+block_start(int full)
 {
     dTHR;
     int retval = savestack_ix;
@@ -1496,9 +1457,7 @@ int full;
 }
 
 OP*
-block_end(floor, seq)
-I32 floor;
-OP* seq;
+block_end(I32 floor, OP *seq)
 {
     dTHR;
     int needblockscope = hints & HINT_BLOCK_SCOPE;
@@ -1513,8 +1472,7 @@ OP* seq;
 }
 
 void
-newPROG(o)
-OP *o;
+newPROG(OP *o)
 {
     dTHR;
     if (in_eval) {
@@ -1534,7 +1492,7 @@ OP *o;
        compcv = 0;
 
        /* Register with debugger */
-       if (perldb) {
+       if (PERLDB_INTER) {
            CV *cv = perl_get_cv("DB::postponed", FALSE);
            if (cv) {
                dSP;
@@ -1548,9 +1506,7 @@ OP *o;
 }
 
 OP *
-localize(o, lex)
-OP *o;
-I32 lex;
+localize(OP *o, I32 lex)
 {
     if (o->op_flags & OPf_PARENS)
        list(o);
@@ -1572,8 +1528,7 @@ I32 lex;
 }
 
 OP *
-jmaybe(o)
-OP *o;
+jmaybe(OP *o)
 {
     if (o->op_type == OP_LIST) {
        o = convert(OP_JOIN, 0,
@@ -1585,8 +1540,7 @@ OP *o;
 }
 
 OP *
-fold_constants(o)
-register OP *o;
+fold_constants(register OP *o)
 {
     dTHR;
     register OP *curop;
@@ -1604,6 +1558,16 @@ register OP *o;
     if (!(opargs[type] & OA_FOLDCONST))
        goto nope;
 
+    switch (type) {
+    case OP_SPRINTF:
+    case OP_UCFIRST:
+    case OP_LCFIRST:
+    case OP_UC:
+    case OP_LC:
+       if (o->op_private & OPpLOCALE)
+           goto nope;
+    }
+
     if (error_count)
        goto nope;              /* Don't try to run w/ errors */
 
@@ -1669,8 +1633,7 @@ register OP *o;
 }
 
 OP *
-gen_constant_list(o)
-register OP *o;
+gen_constant_list(register OP *o)
 {
     dTHR;
     register OP *curop;
@@ -1698,10 +1661,7 @@ register OP *o;
 }
 
 OP *
-convert(type, flags, o)
-I32 type;
-I32 flags;
-OP* o;
+convert(I32 type, I32 flags, OP *o)
 {
     OP *kid;
     OP *last = 0;
@@ -1735,10 +1695,7 @@ OP* o;
 /* List constructors */
 
 OP *
-append_elem(type, first, last)
-I32 type;
-OP* first;
-OP* last;
+append_elem(I32 type, OP *first, OP *last)
 {
     if (!first)
        return last;
@@ -1761,10 +1718,7 @@ OP* last;
 }
 
 OP *
-append_list(type, first, last)
-I32 type;
-LISTOP* first;
-LISTOP* last;
+append_list(I32 type, LISTOP *first, LISTOP *last)
 {
     if (!first)
        return (OP*)last;
@@ -1789,10 +1743,7 @@ LISTOP* last;
 }
 
 OP *
-prepend_elem(type, first, last)
-I32 type;
-OP* first;
-OP* last;
+prepend_elem(I32 type, OP *first, OP *last)
 {
     if (!first)
        return last;
@@ -1823,14 +1774,13 @@ OP* last;
 /* Constructors */
 
 OP *
-newNULLLIST()
+newNULLLIST(void)
 {
     return newOP(OP_STUB, 0);
 }
 
 OP *
-force_list(o)
-OP *o;
+force_list(OP *o)
 {
     if (!o || o->op_type != OP_LIST)
        o = newLISTOP(OP_LIST, 0, o, Nullop);
@@ -1839,11 +1789,7 @@ OP *o;
 }
 
 OP *
-newLISTOP(type, flags, first, last)
-I32 type;
-I32 flags;
-OP* first;
-OP* last;
+newLISTOP(I32 type, I32 flags, OP *first, OP *last)
 {
     LISTOP *listop;
 
@@ -1878,9 +1824,7 @@ OP* last;
 }
 
 OP *
-newOP(type, flags)
-I32 type;
-I32 flags;
+newOP(I32 type, I32 flags)
 {
     OP *o;
     Newz(1101, o, 1, OP);
@@ -1898,10 +1842,7 @@ I32 flags;
 }
 
 OP *
-newUNOP(type, flags, first)
-I32 type;
-I32 flags;
-OP* first;
+newUNOP(I32 type, I32 flags, OP *first)
 {
     UNOP *unop;
 
@@ -1925,11 +1866,7 @@ OP* first;
 }
 
 OP *
-newBINOP(type, flags, first, last)
-I32 type;
-I32 flags;
-OP* first;
-OP* last;
+newBINOP(I32 type, I32 flags, OP *first, OP *last)
 {
     BINOP *binop;
     Newz(1101, binop, 1, BINOP);
@@ -1960,10 +1897,7 @@ OP* last;
 }
 
 OP *
-pmtrans(o, expr, repl)
-OP *o;
-OP *expr;
-OP *repl;
+pmtrans(OP *o, OP *expr, OP *repl)
 {
     SV *tstr = ((SVOP*)expr)->op_sv;
     SV *rstr = ((SVOP*)repl)->op_sv;
@@ -1973,13 +1907,13 @@ OP *repl;
     register U8 *r = (U8*)SvPV(rstr, rlen);
     register I32 i;
     register I32 j;
-    I32 delete;
+    I32 Delete;
     I32 complement;
     register short *tbl;
 
     tbl = (short*)cPVOPo->op_pv;
     complement = o->op_private & OPpTRANS_COMPLEMENT;
-    delete     = o->op_private & OPpTRANS_DELETE;
+    Delete     = o->op_private & OPpTRANS_DELETE;
     /* squash  = o->op_private & OPpTRANS_SQUASH; */
 
     if (complement) {
@@ -1989,7 +1923,7 @@ OP *repl;
        for (i = 0, j = 0; i < 256; i++) {
            if (!tbl[i]) {
                if (j >= rlen) {
-                   if (delete)
+                   if (Delete)
                        tbl[i] = -2;
                    else if (rlen)
                        tbl[i] = r[j-1];
@@ -2002,14 +1936,14 @@ OP *repl;
        }
     }
     else {
-       if (!rlen && !delete) {
+       if (!rlen && !Delete) {
            r = t; rlen = tlen;
        }
        for (i = 0; i < 256; i++)
            tbl[i] = -1;
        for (i = 0, j = 0; i < tlen; i++,j++) {
            if (j >= rlen) {
-               if (delete) {
+               if (Delete) {
                    if (tbl[t[i]] == -1)
                        tbl[t[i]] = -2;
                    continue;
@@ -2027,9 +1961,7 @@ OP *repl;
 }
 
 OP *
-newPMOP(type, flags)
-I32 type;
-I32 flags;
+newPMOP(I32 type, I32 flags)
 {
     dTHR;
     PMOP *pmop;
@@ -2053,10 +1985,7 @@ I32 flags;
 }
 
 OP *
-pmruntime(o, expr, repl)
-OP *o;
-OP *expr;
-OP *repl;
+pmruntime(OP *o, OP *expr, OP *repl)
 {
     PMOP *pm;
     LOGOP *rcop;
@@ -2064,6 +1993,7 @@ OP *repl;
     if (o->op_type == OP_TRANS)
        return pmtrans(o, expr, repl);
 
+    hints |= HINT_BLOCK_SCOPE;
     pm = (PMOP*)o;
 
     if (expr->op_type == OP_CONST) {
@@ -2171,10 +2101,7 @@ OP *repl;
 }
 
 OP *
-newSVOP(type, flags, sv)
-I32 type;
-I32 flags;
-SV *sv;
+newSVOP(I32 type, I32 flags, SV *sv)
 {
     SVOP *svop;
     Newz(1101, svop, 1, SVOP);
@@ -2191,10 +2118,7 @@ SV *sv;
 }
 
 OP *
-newGVOP(type, flags, gv)
-I32 type;
-I32 flags;
-GV *gv;
+newGVOP(I32 type, I32 flags, GV *gv)
 {
     dTHR;
     GVOP *gvop;
@@ -2212,10 +2136,7 @@ GV *gv;
 }
 
 OP *
-newPVOP(type, flags, pv)
-I32 type;
-I32 flags;
-char *pv;
+newPVOP(I32 type, I32 flags, char *pv)
 {
     PVOP *pvop;
     Newz(1101, pvop, 1, PVOP);
@@ -2232,8 +2153,7 @@ char *pv;
 }
 
 void
-package(o)
-OP *o;
+package(OP *o)
 {
     dTHR;
     SV *sv;
@@ -2258,12 +2178,7 @@ OP *o;
 }
 
 void
-utilize(aver, floor, version, id, arg)
-int aver;
-I32 floor;
-OP *version;
-OP *id;
-OP *arg;
+utilize(int aver, I32 floor, OP *version, OP *id, OP *arg)
 {
     OP *pack;
     OP *meth;
@@ -2339,10 +2254,7 @@ OP *arg;
 }
 
 OP *
-newSLICEOP(flags, subscript, listval)
-I32 flags;
-OP *subscript;
-OP *listval;
+newSLICEOP(I32 flags, OP *subscript, OP *listval)
 {
     return newBINOP(OP_LSLICE, flags,
            list(force_list(subscript)),
@@ -2350,8 +2262,7 @@ OP *listval;
 }
 
 static I32
-list_assignment(o)
-register OP *o;
+list_assignment(register OP *o)
 {
     if (!o)
        return TRUE;
@@ -2385,11 +2296,7 @@ register OP *o;
 }
 
 OP *
-newASSIGNOP(flags, left, optype, right)
-I32 flags;
-OP *left;
-I32 optype;
-OP *right;
+newASSIGNOP(I32 flags, OP *left, I32 optype, OP *right)
 {
     OP *o;
 
@@ -2518,17 +2425,14 @@ OP *right;
 }
 
 OP *
-newSTATEOP(flags, label, o)
-I32 flags;
-char *label;
-OP *o;
+newSTATEOP(I32 flags, char *label, OP *o)
 {
     dTHR;
     U32 seq = intro_my();
     register COP *cop;
 
     Newz(1101, cop, 1, COP);
-    if (perldb && curcop->cop_line && curstash != debstash) {
+    if (PERLDB_LINE && curcop->cop_line && curstash != debstash) {
        cop->op_type = OP_DBSTATE;
        cop->op_ppaddr = ppaddr[ OP_DBSTATE ];
     }
@@ -2559,7 +2463,7 @@ OP *o;
     cop->cop_filegv = (GV*)SvREFCNT_inc(curcop->cop_filegv);
     cop->cop_stash = curstash;
 
-    if (perldb && curstash != debstash) {
+    if (PERLDB_LINE && curstash != debstash) {
        SV **svp = av_fetch(GvAV(curcop->cop_filegv),(I32)cop->cop_line, FALSE);
        if (svp && *svp != &sv_undef && !SvIOK(*svp)) {
            (void)SvIOK_on(*svp);
@@ -2573,7 +2477,7 @@ OP *o;
 
 /* "Introduce" my variables to visible status. */
 U32
-intro_my()
+intro_my(void)
 {
     SV **svp;
     SV *sv;
@@ -2595,11 +2499,7 @@ intro_my()
 }
 
 OP *
-newLOGOP(type, flags, first, other)
-I32 type;
-I32 flags;
-OP* first;
-OP* other;
+newLOGOP(I32 type, I32 flags, OP *first, OP *other)
 {
     dTHR;
     LOGOP *logop;
@@ -2700,11 +2600,7 @@ OP* other;
 }
 
 OP *
-newCONDOP(flags, first, trueop, falseop)
-I32 flags;
-OP* first;
-OP* trueop;
-OP* falseop;
+newCONDOP(I32 flags, OP *first, OP *trueop, OP *falseop)
 {
     dTHR;
     CONDOP *condop;
@@ -2757,10 +2653,7 @@ OP* falseop;
 }
 
 OP *
-newRANGE(flags, left, right)
-I32 flags;
-OP *left;
-OP *right;
+newRANGE(I32 flags, OP *left, OP *right)
 {
     dTHR;
     CONDOP *condop;
@@ -2805,11 +2698,7 @@ OP *right;
 }
 
 OP *
-newLOOPOP(flags, debuggable, expr, block)
-I32 flags;
-I32 debuggable;
-OP *expr;
-OP *block;
+newLOOPOP(I32 flags, I32 debuggable, OP *expr, OP *block)
 {
     dTHR;
     OP* listop;
@@ -2820,7 +2709,8 @@ OP *block;
     if (expr) {
        if (once && expr->op_type == OP_CONST && !SvTRUE(((SVOP*)expr)->op_sv))
            return block;       /* do {} while 0 does once */
-       if (expr->op_type == OP_READLINE || expr->op_type == OP_GLOB) {
+       if (expr->op_type == OP_READLINE || expr->op_type == OP_GLOB
+           || (expr->op_type == OP_NULL && expr->op_targ == OP_GLOB)) {
            expr = newUNOP(OP_DEFINED, 0,
                newASSIGNOP(0, newSVREF(newGVOP(OP_GV, 0, defgv)), 0, expr) );
        }
@@ -2844,13 +2734,7 @@ OP *block;
 }
 
 OP *
-newWHILEOP(flags, debuggable, loop, expr, block, cont)
-I32 flags;
-I32 debuggable;
-LOOP *loop;
-OP *expr;
-OP *block;
-OP *cont;
+newWHILEOP(I32 flags, I32 debuggable, LOOP *loop, I32 whileline, OP *expr, OP *block, OP *cont)
 {
     dTHR;
     OP *redo;
@@ -2859,7 +2743,8 @@ OP *cont;
     OP *o;
     OP *condop;
 
-    if (expr && (expr->op_type == OP_READLINE || expr->op_type == OP_GLOB)) {
+    if (expr && (expr->op_type == OP_READLINE || expr->op_type == OP_GLOB
+                || (expr->op_type == OP_NULL && expr->op_targ == OP_GLOB))) {
        expr = newUNOP(OP_DEFINED, 0,
            newASSIGNOP(0, newSVREF(newGVOP(OP_GV, 0, defgv)), 0, expr) );
     }
@@ -2869,8 +2754,14 @@ OP *cont;
 
     if (cont)
        next = LINKLIST(cont);
-    if (expr)
+    if (expr) {
        cont = append_elem(OP_LINESEQ, cont, newOP(OP_UNSTACK, 0));
+       if ((line_t)whileline != NOLINE) {
+           copline = whileline;
+           cont = append_elem(OP_LINESEQ, cont,
+                              newSTATEOP(0, Nullch, Nullop));
+       }
+    }
 
     listop = append_list(OP_LINESEQ, (LISTOP*)block, (LISTOP*)cont);
     redo = LINKLIST(listop);
@@ -2928,10 +2819,10 @@ newFOROP(I32 flags,char *label,line_t forline,OP *sv,OP *expr,OP *block,OP *cont
 #endif /* CAN_PROTOTYPE */
 {
     LOOP *loop;
+    OP *wop;
     int padoff = 0;
     I32 iterflags = 0;
 
-    copline = forline;
     if (sv) {
        if (sv->op_type == OP_RV2SV) {  /* symbol table variable */
            sv->op_type = OP_RV2GV;
@@ -2958,14 +2849,13 @@ newFOROP(I32 flags,char *label,line_t forline,OP *sv,OP *expr,OP *block,OP *cont
     assert(!loop->op_next);
     Renew(loop, 1, LOOP);
     loop->op_targ = padoff;
-    return newSTATEOP(0, label, newWHILEOP(flags, 1, loop,
-       newOP(OP_ITER, 0), block, cont));
+    wop = newWHILEOP(flags, 1, loop, forline, newOP(OP_ITER, 0), block, cont);
+    copline = forline;
+    return newSTATEOP(0, label, wop);
 }
 
 OP*
-newLOOPEX(type, label)
-I32 type;
-OP* label;
+newLOOPEX(I32 type, OP *label)
 {
     dTHR;
     OP *o;
@@ -2986,8 +2876,7 @@ OP* label;
 }
 
 void
-cv_undef(cv)
-CV *cv;
+cv_undef(CV *cv)
 {
     dTHR;
 #ifdef USE_THREADS
@@ -2996,11 +2885,6 @@ CV *cv;
        Safefree(CvMUTEXP(cv));
        CvMUTEXP(cv) = 0;
     }
-    if (CvCONDP(cv)) {
-       COND_DESTROY(CvCONDP(cv));
-       Safefree(CvCONDP(cv));
-       CvCONDP(cv) = 0;
-    }
 #endif /* USE_THREADS */
 
     if (!CvXSUB(cv) && CvROOT(cv)) {
@@ -3063,7 +2947,7 @@ CV* cv;
     SV** ppad;
     I32 ix;
 
-    PerlIO_printf(Perl_debug_log, "\tCV=0x%p (%s), OUTSIDE=0x%p (%s)\n",
+    PerlIO_printf(Perl_debug_log, "\tCV=0x%lx (%s), OUTSIDE=0x%lx (%s)\n",
                  cv,
                  (CvANON(cv) ? "ANON"
                   : (cv == main_cv) ? "MAIN"
@@ -3086,7 +2970,7 @@ CV* cv;
 
     for (ix = 1; ix <= AvFILL(pad_name); ix++) {
        if (SvPOK(pname[ix]))
-           PerlIO_printf(Perl_debug_log, "\t%4d. 0x%p (%s\"%s\" %ld-%ld)\n",
+           PerlIO_printf(Perl_debug_log, "\t%4d. 0x%lx (%s\"%s\" %ld-%ld)\n",
                          ix, ppad[ix],
                          SvFAKE(pname[ix]) ? "FAKE " : "",
                          SvPVX(pname[ix]),
@@ -3097,9 +2981,7 @@ CV* cv;
 #endif /* DEBUG_CLOSURES */
 
 static CV *
-cv_clone2(proto, outside)
-CV* proto;
-CV* outside;
+cv_clone2(CV *proto, CV *outside)
 {
     dTHR;
     AV* av;
@@ -3131,8 +3013,6 @@ CV* outside;
 #ifdef USE_THREADS
     New(666, CvMUTEXP(cv), 1, perl_mutex);
     MUTEX_INIT(CvMUTEXP(cv));
-    New(666, CvCONDP(cv), 1, perl_cond);
-    COND_INIT(CvCONDP(cv));
     CvOWNER(cv)                = 0;
 #endif /* USE_THREADS */
     CvFILEGV(cv)       = CvFILEGV(proto);
@@ -3233,17 +3113,13 @@ CV* outside;
 }
 
 CV *
-cv_clone(proto)
-CV* proto;
+cv_clone(CV *proto)
 {
     return cv_clone2(proto, CvOUTSIDE(proto));
 }
 
 void
-cv_ckproto(cv, gv, p)
-CV* cv;
-GV* gv;
-char* p;
+cv_ckproto(CV *cv, GV *gv, char *p)
 {
     if ((!p != !SvPOK(cv)) || (p && strNE(p, SvPVX(cv)))) {
        SV* msg = sv_newmortal();
@@ -3266,8 +3142,7 @@ char* p;
 }
 
 SV *
-cv_const_sv(cv)
-CV* cv;
+cv_const_sv(CV *cv)
 {
     OP *o;
     SV *sv;
@@ -3302,11 +3177,7 @@ CV* cv;
 }
 
 CV *
-newSUB(floor,o,proto,block)
-I32 floor;
-OP *o;
-OP *proto;
-OP *block;
+newSUB(I32 floor, OP *o, OP *proto, OP *block)
 {
     dTHR;
     char *name = o ? SvPVx(cSVOPo->op_sv, na) : Nullch;
@@ -3373,8 +3244,6 @@ OP *block;
     CvOWNER(cv) = 0;
     New(666, CvMUTEXP(cv), 1, perl_mutex);
     MUTEX_INIT(CvMUTEXP(cv));
-    New(666, CvCONDP(cv), 1, perl_cond);
-    COND_INIT(CvCONDP(cv));
 #endif /* USE_THREADS */
 
     if (ps)
@@ -3452,7 +3321,7 @@ OP *block;
     if (name) {
        char *s;
 
-       if (perldb && curstash != debstash) {
+       if (PERLDB_SUBLINE && curstash != debstash) {
            SV *sv = NEWSV(0,0);
            SV *tmpstr = sv_newmortal();
            static GV *db_postponed;
@@ -3508,10 +3377,10 @@ OP *block;
            av_store(endav, 0, (SV *)cv);
            GvCV(gv) = 0;
        }
-       else if (strEQ(s, "RESTART") && !error_count) {
-           if (!restartav)
-               restartav = newAV();
-           av_push(restartav, SvREFCNT_inc(cv));
+       else if (strEQ(s, "INIT") && !error_count) {
+           if (!initav)
+               initav = newAV();
+           av_push(initav, SvREFCNT_inc(cv));
        }
     }
 
@@ -3537,10 +3406,7 @@ char *filename;
 #endif
 
 CV *
-newXS(name, subaddr, filename)
-char *name;
-void (*subaddr) _((CV*));
-char *filename;
+newXS(char *name, void (*subaddr) (CV *), char *filename)
 {
     dTHR;
     GV *gv = gv_fetchpv(name ? name : "__ANON__", GV_ADDMULTI, SVt_PVCV);
@@ -3580,8 +3446,6 @@ char *filename;
 #ifdef USE_THREADS
     New(666, CvMUTEXP(cv), 1, perl_mutex);
     MUTEX_INIT(CvMUTEXP(cv));
-    New(666, CvCONDP(cv), 1, perl_cond);
-    COND_INIT(CvCONDP(cv));
     CvOWNER(cv) = 0;
 #endif /* USE_THREADS */
     CvFILEGV(cv) = gv_fetchfile(filename);
@@ -3606,10 +3470,10 @@ char *filename;
            av_store(endav, 0, (SV *)cv);
            GvCV(gv) = 0;
        }
-       else if (strEQ(s, "RESTART")) {
-           if (!restartav)
-               restartav = newAV();
-           av_push(restartav, (SV *)cv);
+       else if (strEQ(s, "INIT")) {
+           if (!initav)
+               initav = newAV();
+           av_push(initav, (SV *)cv);
        }
     }
     else
@@ -3619,10 +3483,7 @@ char *filename;
 }
 
 void
-newFORM(floor,o,block)
-I32 floor;
-OP *o;
-OP *block;
+newFORM(I32 floor, OP *o, OP *block)
 {
     dTHR;
     register CV *cv;
@@ -3666,34 +3527,28 @@ OP *block;
 }
 
 OP *
-newANONLIST(o)
-OP* o;
+newANONLIST(OP *o)
 {
     return newUNOP(OP_REFGEN, 0,
        mod(list(convert(OP_ANONLIST, 0, o)), OP_REFGEN));
 }
 
 OP *
-newANONHASH(o)
-OP* o;
+newANONHASH(OP *o)
 {
     return newUNOP(OP_REFGEN, 0,
        mod(list(convert(OP_ANONHASH, 0, o)), OP_REFGEN));
 }
 
 OP *
-newANONSUB(floor, proto, block)
-I32 floor;
-OP *proto;
-OP *block;
+newANONSUB(I32 floor, OP *proto, OP *block)
 {
     return newUNOP(OP_REFGEN, 0,
        newSVOP(OP_ANONCODE, 0, (SV*)newSUB(floor, 0, proto, block)));
 }
 
 OP *
-oopsAV(o)
-OP *o;
+oopsAV(OP *o)
 {
     switch (o->op_type) {
     case OP_PADSV:
@@ -3715,8 +3570,7 @@ OP *o;
 }
 
 OP *
-oopsHV(o)
-OP *o;
+oopsHV(OP *o)
 {
     switch (o->op_type) {
     case OP_PADSV:
@@ -3740,8 +3594,7 @@ OP *o;
 }
 
 OP *
-newAVREF(o)
-OP *o;
+newAVREF(OP *o)
 {
     if (o->op_type == OP_PADANY) {
        o->op_type = OP_PADAV;
@@ -3752,9 +3605,7 @@ OP *o;
 }
 
 OP *
-newGVREF(type,o)
-I32 type;
-OP *o;
+newGVREF(I32 type, OP *o)
 {
     if (type == OP_MAPSTART)
        return newUNOP(OP_NULL, 0, o);
@@ -3762,8 +3613,7 @@ OP *o;
 }
 
 OP *
-newHVREF(o)
-OP *o;
+newHVREF(OP *o)
 {
     if (o->op_type == OP_PADANY) {
        o->op_type = OP_PADHV;
@@ -3774,8 +3624,7 @@ OP *o;
 }
 
 OP *
-oopsCV(o)
-OP *o;
+oopsCV(OP *o)
 {
     croak("NOT IMPL LINE %d",__LINE__);
     /* STUB */
@@ -3783,16 +3632,13 @@ OP *o;
 }
 
 OP *
-newCVREF(flags, o)
-I32 flags;
-OP *o;
+newCVREF(I32 flags, OP *o)
 {
     return newUNOP(OP_RV2CV, flags, scalar(o));
 }
 
 OP *
-newSVREF(o)
-OP *o;
+newSVREF(OP *o)
 {
     if (o->op_type == OP_PADANY) {
        o->op_type = OP_PADSV;
@@ -3805,8 +3651,7 @@ OP *o;
 /* Check routines. */
 
 OP *
-ck_anoncode(o)
-OP *o;
+ck_anoncode(OP *o)
 {
     PADOFFSET ix;
     SV* name;
@@ -3826,16 +3671,14 @@ OP *o;
 }
 
 OP *
-ck_bitop(o)
-OP *o;
+ck_bitop(OP *o)
 {
     o->op_private = hints;
     return o;
 }
 
 OP *
-ck_concat(o)
-OP *o;
+ck_concat(OP *o)
 {
     if (cUNOPo->op_first->op_type == OP_CONCAT)
        o->op_flags |= OPf_STACKED;
@@ -3843,8 +3686,7 @@ OP *o;
 }
 
 OP *
-ck_spair(o)
-OP *o;
+ck_spair(OP *o)
 {
     if (o->op_flags & OPf_KIDS) {
        OP* newop;
@@ -3869,8 +3711,7 @@ OP *o;
 }
 
 OP *
-ck_delete(o)
-OP *o;
+ck_delete(OP *o)
 {
     o = ck_fun(o);
     o->op_private = 0;
@@ -3887,8 +3728,7 @@ OP *o;
 }
 
 OP *
-ck_eof(o)
-OP *o;
+ck_eof(OP *o)
 {
     I32 type = o->op_type;
 
@@ -3896,7 +3736,7 @@ OP *o;
        if (cLISTOPo->op_first->op_type == OP_STUB) {
            op_free(o);
            o = newUNOP(type, OPf_SPECIAL,
-               newGVOP(OP_GV, 0, gv_fetchpv("main'ARGV", TRUE, SVt_PVAV)));
+               newGVOP(OP_GV, 0, gv_fetchpv("main::ARGV", TRUE, SVt_PVAV)));
        }
        return ck_fun(o);
     }
@@ -3904,8 +3744,7 @@ OP *o;
 }
 
 OP *
-ck_eval(o)
-OP *o;
+ck_eval(OP *o)
 {
     hints |= HINT_BLOCK_SCOPE;
     if (o->op_flags & OPf_KIDS) {
@@ -3946,8 +3785,7 @@ OP *o;
 }
 
 OP *
-ck_exec(o)
-OP *o;
+ck_exec(OP *o)
 {
     OP *kid;
     if (o->op_flags & OPf_STACKED) {
@@ -3962,8 +3800,7 @@ OP *o;
 }
 
 OP *
-ck_exists(o)
-OP *o;
+ck_exists(OP *o)
 {
     o = ck_fun(o);
     if (o->op_flags & OPf_KIDS) {
@@ -3976,8 +3813,7 @@ OP *o;
 }
 
 OP *
-ck_gvconst(o)
-register OP *o;
+ck_gvconst(register OP *o)
 {
     o = fold_constants(o);
     if (o->op_type == OP_CONST)
@@ -3986,8 +3822,7 @@ register OP *o;
 }
 
 OP *
-ck_rvconst(o)
-register OP *o;
+ck_rvconst(register OP *o)
 {
     dTHR;
     SVOP *kid = (SVOP*)cUNOPo->op_first;
@@ -4047,8 +3882,7 @@ register OP *o;
 }
 
 OP *
-ck_ftst(o)
-OP *o;
+ck_ftst(OP *o)
 {
     dTHR;
     I32 type = o->op_type;
@@ -4069,7 +3903,7 @@ OP *o;
     else {
        op_free(o);
        if (type == OP_FTTTY)
-           return newGVOP(type, OPf_REF, gv_fetchpv("main'STDIN", TRUE,
+           return newGVOP(type, OPf_REF, gv_fetchpv("main::STDIN", TRUE,
                                SVt_PVIO));
        else
            return newUNOP(type, 0, newSVREF(newGVOP(OP_GV, 0, defgv)));
@@ -4078,8 +3912,7 @@ OP *o;
 }
 
 OP *
-ck_fun(o)
-OP *o;
+ck_fun(OP *o)
 {
     dTHR;
     register OP *kid;
@@ -4217,10 +4050,15 @@ OP *o;
 }
 
 OP *
-ck_glob(o)
-OP *o;
+ck_glob(OP *o)
 {
-    GV *gv = gv_fetchpv("glob", FALSE, SVt_PVCV);
+    GV *gv;
+
+    if ((o->op_flags & OPf_KIDS) && !cLISTOPo->op_first->op_sibling)
+       append_elem(OP_GLOB, o, newSVREF(newGVOP(OP_GV, 0, defgv)));
+
+    if (!((gv = gv_fetchpv("glob", FALSE, SVt_PVCV)) && GvIMPORTED_CV(gv)))
+       gv = gv_fetchpv("CORE::GLOBAL::glob", FALSE, SVt_PVCV);
 
     if (gv && GvIMPORTED_CV(gv)) {
        static int glob_index;
@@ -4235,10 +4073,10 @@ OP *o;
                    append_elem(OP_LIST, o, 
                                scalar(newUNOP(OP_RV2CV, 0,
                                               newGVOP(OP_GV, 0, gv)))));
-       return ck_subr(o);
+       o = newUNOP(OP_NULL, 0, ck_subr(o));
+       o->op_targ = OP_GLOB;           /* hint at what it used to be */
+       return o;
     }
-    if ((o->op_flags & OPf_KIDS) && !cLISTOPo->op_first->op_sibling)
-       append_elem(OP_GLOB, o, newSVREF(newGVOP(OP_GV, 0, defgv)));
     gv = newGVgen("main");
     gv_IOadd(gv);
     append_elem(OP_GLOB, o, newGVOP(OP_GV, 0, gv));
@@ -4247,8 +4085,7 @@ OP *o;
 }
 
 OP *
-ck_grep(o)
-OP *o;
+ck_grep(OP *o)
 {
     LOGOP *gwop;
     OP *kid;
@@ -4299,8 +4136,7 @@ OP *o;
 }
 
 OP *
-ck_index(o)
-OP *o;
+ck_index(OP *o)
 {
     if (o->op_flags & OPf_KIDS) {
        OP *kid = cLISTOPo->op_first->op_sibling;       /* get past pushmark */
@@ -4311,32 +4147,28 @@ OP *o;
 }
 
 OP *
-ck_lengthconst(o)
-OP *o;
+ck_lengthconst(OP *o)
 {
     /* XXX length optimization goes here */
     return ck_fun(o);
 }
 
 OP *
-ck_lfun(o)
-OP *o;
+ck_lfun(OP *o)
 {
     OPCODE type = o->op_type;
     return modkids(ck_fun(o), type);
 }
 
 OP *
-ck_rfun(o)
-OP *o;
+ck_rfun(OP *o)
 {
     OPCODE type = o->op_type;
     return refkids(ck_fun(o), type);
 }
 
 OP *
-ck_listiob(o)
-OP *o;
+ck_listiob(OP *o)
 {
     register OP *kid;
     
@@ -4374,8 +4206,7 @@ OP *o;
 }
 
 OP *
-ck_fun_locale(o)
-OP *o;
+ck_fun_locale(OP *o)
 {
     o = ck_fun(o);
 
@@ -4389,8 +4220,7 @@ OP *o;
 }
 
 OP *
-ck_scmp(o)
-OP *o;
+ck_scmp(OP *o)
 {
     o->op_private = 0;
 #ifdef USE_LOCALE
@@ -4402,23 +4232,20 @@ OP *o;
 }
 
 OP *
-ck_match(o)
-OP *o;
+ck_match(OP *o)
 {
     o->op_private |= OPpRUNTIME;
     return o;
 }
 
 OP *
-ck_null(o)
-OP *o;
+ck_null(OP *o)
 {
     return o;
 }
 
 OP *
-ck_repeat(o)
-OP *o;
+ck_repeat(OP *o)
 {
     if (cBINOPo->op_first->op_flags & OPf_PARENS) {
        o->op_private |= OPpREPEAT_DOLIST;
@@ -4430,8 +4257,7 @@ OP *o;
 }
 
 OP *
-ck_require(o)
-OP *o;
+ck_require(OP *o)
 {
     if (o->op_flags & OPf_KIDS) {      /* Shall we supply missing .pm? */
        SVOP *kid = (SVOP*)cUNOPo->op_first;
@@ -4452,8 +4278,7 @@ OP *o;
 }
 
 OP *
-ck_retarget(o)
-OP *o;
+ck_retarget(OP *o)
 {
     croak("NOT IMPL LINE %d",__LINE__);
     /* STUB */
@@ -4461,8 +4286,7 @@ OP *o;
 }
 
 OP *
-ck_select(o)
-OP *o;
+ck_select(OP *o)
 {
     OP* kid;
     if (o->op_flags & OPf_KIDS) {
@@ -4482,8 +4306,7 @@ OP *o;
 }
 
 OP *
-ck_shift(o)
-OP *o;
+ck_shift(OP *o)
 {
     I32 type = o->op_type;
 
@@ -4512,8 +4335,7 @@ OP *o;
 }
 
 OP *
-ck_sort(o)
-OP *o;
+ck_sort(OP *o)
 {
     o->op_private = 0;
 #ifdef USE_LOCALE
@@ -4562,8 +4384,7 @@ OP *o;
 }
 
 OP *
-ck_split(o)
-OP *o;
+ck_split(OP *o)
 {
     register OP *kid;
     PMOP* pm;
@@ -4620,8 +4441,7 @@ OP *o;
 }
 
 OP *
-ck_subr(o)
-OP *o;
+ck_subr(OP *o)
 {
     dTHR;
     OP *prev = ((cUNOPo->op_first->op_sibling)
@@ -4649,7 +4469,7 @@ OP *o;
        }
     }
     o->op_private |= (hints & HINT_STRICT_REFS);
-    if (perldb && curstash != debstash)
+    if (PERLDB_SUB && curstash != debstash)
        o->op_private |= OPpENTERSUB_DB;
     while (o2 != cvop) {
        if (proto) {
@@ -4739,22 +4559,21 @@ OP *o;
        prev = o2;
        o2 = o2->op_sibling;
     }
-    if (proto && !optional && *proto == '$')
+    if (proto && !optional &&
+         (*proto && *proto != '@' && *proto != '%' && *proto != ';'))
        return too_few_arguments(o, gv_ename(namegv));
     return o;
 }
 
 OP *
-ck_svconst(o)
-OP *o;
+ck_svconst(OP *o)
 {
     SvREADONLY_on(cSVOPo->op_sv);
     return o;
 }
 
 OP *
-ck_trunc(o)
-OP *o;
+ck_trunc(OP *o)
 {
     if (o->op_flags & OPf_KIDS) {
        SVOP *kid = (SVOP*)cUNOPo->op_first;
@@ -4771,8 +4590,7 @@ OP *o;
 /* A peephole optimizer.  We visit the ops in the order they're to execute. */
 
 void
-peep(o)
-register OP* o;
+peep(register OP *o)
 {
     dTHR;
     register OP* oldop = 0;
@@ -4864,6 +4682,24 @@ register OP* o;
            o->op_seq = op_seqmax++;
            break;
 
+       case OP_PADAV:
+           if (o->op_next->op_type == OP_RV2AV
+               && (o->op_next->op_flags && OPf_REF))
+           {
+               null(o->op_next);
+               o->op_next = o->op_next->op_next;
+           }
+           break;
+           
+       case OP_PADHV:
+           if (o->op_next->op_type == OP_RV2HV
+               && (o->op_next->op_flags && OPf_REF))
+           {
+               null(o->op_next);
+               o->op_next = o->op_next->op_next;
+           }
+           break;
+
        case OP_MAPWHILE:
        case OP_GREPWHILE:
        case OP_AND: