diff options
author | Perl 5 Porters <perl5-porters@africa.nicoh.com> | 1997-03-22 15:34:25 +1200 |
---|---|---|
committer | Chip Salzenberg <chip@atlantic.net> | 1997-03-22 15:34:25 +1200 |
commit | 3fe9a6f19eb206c685bd7389e54e2838fdfd04b7 (patch) | |
tree | 94845bcda5f58956e6c9ccef24340d1b5c93d182 /op.c | |
parent | 9a2c4ce3a0904191a580ec822adeb696331d31ce (diff) | |
download | perl-3fe9a6f19eb206c685bd7389e54e2838fdfd04b7.tar.gz |
[inseparable changes from match from perl-5.003_94 to perl-5.003_95]
CORE LANGUAGE CHANGES
Subject: Don't compile scalar mods of aggregates, like C<@a =~ s/a/b/>
From: Chip Salzenberg <chip@perl.com>
Files: op.c t/op/misc.t
Subject: Warn about undef magic values just like non-magic
From: Chip Salzenberg <chip@perl.com>
Files: ext/Opcode/Safe.pm sv.c t/lib/db-btree.t t/lib/db-hash.t t/lib/db-recno.t t/pragma/locale.t
CORE PORTABILITY
Subject: Win32 update (five patches)
From: Gurusamy Sarathy <gsar@engin.umich.edu>
Files: MANIFEST README.win32 doio.c dosish.h pp_sys.c lib/ExtUtils/Command.pm t/comp/multiline.t t/op/magic.t t/op/mkdir.t t/op/runlevel.t t/op/stat.t t/op/write.t win32/Makefile win32/config.H win32/config.w32 win32/win32.c win32/win32.h win32/win32aux.c win32/*.mak win32/VC-2.0/*.mak
DOCUMENTATION
Subject: INSTALL-1.8 to INSTALL-1.9 updates
Date: Tue, 25 Mar 1997 13:52:53 -0500 (EST)
From: Andy Dougherty <doughera@fractal.phys.lafayette.edu>
Files: INSTALL
Msg-ID: Pine.SOL.3.95q.970325135138.3374A-100000@fractal.lafayette.e
(applied based on p5p patch as commit 9b1ae96a0b4301a9588f62b3175bc0312302f4b9)
Subject: Document possible problems with -Mdiagnostics after upgrade
From: Chip Salzenberg <chip@perl.com>
Files: INSTALL
Subject: Mention perldelta in INSTALL
From: Chip Salzenberg <chip@perl.com>
Files: INSTALL
Subject: Describe pod format at top of INSTALL
From: Chip Salzenberg <chip@perl.com>
Files: INSTALL
Subject: Document C</a *b/x> fix
From: Chip Salzenberg <chip@perl.com>
Files: pod/perldelta.pod
Subject: pods for subroutine argument autovivication
Date: Mon, 24 Mar 1997 07:25:21 +0000
From: "M.J.T. Guy" <mjtg@cus.cam.ac.uk>
Files: pod/perldelta.pod pod/perlsub.pod
Msg-ID: E0w9489-0005YT-00@ursa.cus.cam.ac.uk
(applied based on p5p patch as commit db8878faa51a8a1541a40745a8613adb5db155e4)
Subject: Missing item in perldiag
Date: Sun, 23 Mar 1997 09:24:09 +0000
From: "M.J.T. Guy" <mjtg@cus.cam.ac.uk>
Files: pod/perldiag.pod
Msg-ID: E0w8jVZ-0005va-00@ursa.cus.cam.ac.uk
(applied based on p5p patch as commit c00a529017138505fcbe538b74c7884abe1d18e1)
Subject: Pod problems & fixes
Date: Mon, 24 Mar 1997 21:31:51 +0100 (MET)
From: Hallvard B Furuseth <h.b.furuseth@usit.uio.no>
Files: INSTALL lib/Term/Complete.pm lib/subs.pm pod/perlcall.pod pod/perldata.pod pod/perldiag.pod pod/perlembed.pod pod/perlguts.pod pod/perlmod.pod pod/perlop.pod pod/perlpod.pod pod/pod2html.PL
Msg-ID: 199703242031.VAA14997@bombur2.uio.no
(applied based on p5p patch as commit 55a864fe4cea1a0586891b83d359ba71e0972da5)
Subject: FAQ update
From: Nathan Torkington <gnat@prometheus.frii.com>
Files: pod/perlfaq*.pod
OTHER CORE CHANGES
Subject: Improve 'prototype mismatch' warning
From: Chip Salzenberg <chip@perl.com>
Files: global.sym op.c pod/perldiag.pod proto.h sv.c t/comp/redef.t
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 101 |
1 files changed, 89 insertions, 12 deletions
@@ -39,6 +39,7 @@ static I32 list_assignment _((OP *op)); static OP *bad_type _((I32 n, char *t, char *name, OP *kid)); static OP *modkids _((OP *op, I32 type)); static OP *no_fh_allowed _((OP *op)); +static bool scalar_mod_type _((OP *op, I32 type)); static OP *scalarboolean _((OP *op)); static OP *too_few_arguments _((OP *op, char* name)); static OP *too_many_arguments _((OP *op, char* name)); @@ -1031,6 +1032,8 @@ I32 type; } /* FALL THROUGH */ case OP_RV2GV: + if (scalar_mod_type(op, type)) + goto nomod; ref(cUNOP->op_first, op->op_type); /* FALL THROUGH */ case OP_AASSIGN: @@ -1059,6 +1062,8 @@ I32 type; modcount = 10000; if (type == OP_REFGEN && op->op_flags & OPf_PARENS) return op; /* Treat \(@foo) like ordinary list. */ + if (scalar_mod_type(op, type)) + goto nomod; /* FALL THROUGH */ case OP_PADSV: modcount++; @@ -1126,6 +1131,52 @@ I32 type; return op; } +static bool +scalar_mod_type(op, type) +OP *op; +I32 type; +{ + switch (type) { + case OP_SASSIGN: + if (op->op_type == OP_RV2GV) + return FALSE; + /* FALL THROUGH */ + case OP_PREINC: + case OP_PREDEC: + case OP_POSTINC: + case OP_POSTDEC: + case OP_I_PREINC: + case OP_I_PREDEC: + case OP_I_POSTINC: + case OP_I_POSTDEC: + case OP_POW: + case OP_MULTIPLY: + case OP_DIVIDE: + case OP_MODULO: + case OP_REPEAT: + case OP_ADD: + case OP_SUBTRACT: + case OP_I_MULTIPLY: + case OP_I_DIVIDE: + case OP_I_MODULO: + case OP_I_ADD: + case OP_I_SUBTRACT: + case OP_LEFT_SHIFT: + case OP_RIGHT_SHIFT: + case OP_BIT_AND: + case OP_BIT_XOR: + case OP_BIT_OR: + case OP_CONCAT: + case OP_SUBST: + case OP_TRANS: + case OP_ANDASSIGN: /* may work later */ + case OP_ORASSIGN: /* may work later */ + return TRUE; + default: + return FALSE; + } +} + OP * refkids(op, type) OP *op; @@ -3051,9 +3102,39 @@ CV* proto; return cv_clone2(proto, CvOUTSIDE(proto)); } +void +cv_ckproto(cv, gv, p) +CV* cv; +GV* gv; +char* p; +{ + if ((!p != !SvPOK(cv)) || (p && strNE(p, SvPVX(cv)))) { + char* buf; + SV* name = Nullsv; + + if (gv) + gv_efullname3(name = NEWSV(606, 40), gv, Nullch); + New(607, buf, ((name ? SvCUR(name) : 0) + + (SvPOK(cv) ? SvCUR(cv) : 0) + + (p ? strlen(p) : 0) + + 60), char); + strcpy(buf, "Prototype mismatch:"); + if (name) { + sprintf(buf + strlen(buf), " sub %s", SvPVX(name)); + SvREFCNT_dec(name); + } + if (SvPOK(cv)) + sprintf(buf + strlen(buf), " (%s)", SvPVX(cv)); + strcat(buf, " vs "); + sprintf(buf + strlen(buf), p ? "(%s)" : "none", p); + warn("%s", buf); + Safefree(buf); + } +} + SV * cv_const_sv(cv) -CV *cv; +CV* cv; { OP *o; SV *sv = Nullsv; @@ -3084,21 +3165,20 @@ OP *block; { char *name = op ? SvPVx(cSVOP->op_sv, na) : Nullch; GV *gv = gv_fetchpv(name ? name : "__ANON__", GV_ADDMULTI, SVt_PVCV); + char *ps = proto ? SvPVx(((SVOP*)proto)->op_sv, na) : Nullch; register CV *cv; AV *av; I32 ix; if (op) SAVEFREEOP(op); + if (proto) + SAVEFREEOP(proto); + if (!name || GvCVGEN(gv)) cv = Nullcv; else if (cv = GvCV(gv)) { - /* prototype mismatch? */ - char *p = proto ? SvPVx(((SVOP*)proto)->op_sv, na) : Nullch; - if ((!proto != !SvPOK(cv)) || (p && strNE(p, SvPVX(cv)))) { - warn("Prototype mismatch: (%s) vs (%s)", - SvPOK(cv) ? SvPVX(cv) : "none", p ? p : "none"); - } + cv_ckproto(cv, gv, ps); /* already defined (or promised)? */ if (CvROOT(cv) || CvXSUB(cv) || GvASSUMECV(gv)) { SV* const_sv; @@ -3142,11 +3222,8 @@ OP *block; CvFILEGV(cv) = curcop->cop_filegv; CvSTASH(cv) = curstash; - if (proto) { - char *p = SvPVx(((SVOP*)proto)->op_sv, na); - sv_setpv((SV*)cv, p); - op_free(proto); - } + if (ps) + sv_setpv((SV*)cv, ps); if (error_count) { op_free(block); |