summaryrefslogtreecommitdiff
path: root/gv.c
Commit message (Collapse)AuthorAgeFilesLines
* make overload respect get magicDavid Mitchell2010-05-211-0/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In most places, ops checked their args for overload *before* doing mg_get(). This meant that, among other issues, tied vars that returned overloaded objects wouldn't trigger calling the overloaded method. (Actually, for tied and arrays and hashes, it still often would since mg_get gets called beforehand in rvalue context). This patch does the following: Makes sure get magic is called first. Moves most of the overload code formerly included by macros at the start of each pp function into the separate helper functions Perl_try_amagic_bin, Perl_try_amagic_un, S_try_amagic_ftest, with 3 new wrapper macros: tryAMAGICbin_MG, tryAMAGICun_MG, tryAMAGICftest_MG. This made the code 3800 bytes smaller. Makes sure that FETCH is not called multiple times. Much of this bit was helped by some earlier work from Father Chrysostomos. Added new functions and macros sv_inc_nomg(), sv_dec_nomg(), dPOPnv_nomg, dPOPXiirl_ul_nomg, dPOPTOPnnrl_nomg, dPOPTOPiirl_ul_nomg dPOPTOPiirl_nomg, SvIV_please_nomg, SvNV_nomg (again, some of these were based on Father Chrysostomos's work). Fixed the list version of the repeat operator (x): it now only calls overloaded methods for the scalar version: (1,2,$overloaded) x 10 no longer erroneously calls x_method($overloaded,10)) The only thing I haven't checked/fixed yet is overloading the iterator operator, <>.
* [perl #73712] ‘Variable is not imported’ cannot be suppressedFather Chrysostomos2010-04-131-2/+7
| | | | | | | | | | | | | | | | The message ‘Variable "%s" is not imported’ cannot be suppressed, even with -X (local $SIG{__WARN__}=sub{} is what I have to use): perl -Xle '$foo;use strict; eval q/$foo/ or die "---$@---"' Variable "$foo" is not imported at (eval 1) line 2. ---Global symbol "$foo" requires explicit package name at (eval 1) line 2. --- at -e line 1. This is because we have what appears to the user to be a multi-line error message. It is in fact a warning ‘Variable...’ followed by an error ‘Global symbol...’. The attached patch assigns a warning category to the warning.
* PL_defoutgv isn't always a GV.David Mitchell2010-03-301-2/+2
| | | | | | | | | | | | | | | | | | | | Nasty code like the following results in PL_defoutgv not pointing to a valid GV: my $x = *STDERR; select($x); $x = 1; This causes all sorts of SEGVs when PL_defoutgv is subsequently accessed, because most code assumes that it has a valid gv_gp pointer. It also turns out that PL_defoutgv is under-tested; for example, temporarily hacking pp_close to make an arg-less close() croak didn't cause any minitest failures. Add a new test file that does some basic testing of a bad PL_defoutgv, and fix all the obvious badness in accessing it. This also fixes #20727, which although ostensibly a tie bug, was due to PL_defoutgv pointing to a tiedelem scalar, and fun like that described above happening.
* [perl #72740]: Blead breaks LEMBARK/LinkedList-Single-0.99.1.tar.gzZefram2010-03-101-10/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | f7461760003db2ce68155c97ea6c1658e96fcd27 improved the PL_check hook for bareword subs, but broke the above module. This is Zefram's followup: The issue is that speculative function lookups were leaving detritus consisting of empty GVs in the stash. These didn't affect normal functioning, but code that looks inside the stash could see them, and code that makes unreliable assumptions about the format of the stash can be broken. This is the same general mode of failure that we saw with namespace::clean. LinkedList-Single's failing test was using direct stash access poorly, in a way that made for a poor test, quite apart from making too many assumptions about stash structure. In the latest version of the package, 0.99.6, the test has been changed to a much better form, which actually tests what it meant to and incidentally doesn't read the stash at all. Although they don't affect normal functioning, the empty GVs shouldn't be there. It's much like the upgraded constant subs, which we concluded ought to be downgraded when the upgraded form is no longer required, in order to save memory. The solution here is similar: delete the empty GV when it is detected that a real GV is no longer required. The present patch does this at the same time as checking for constant-sub downgradability.
* Make perl's magic variables in gv.c grep-ableÆvar Arnfjörð Bjarmason2010-01-201-35/+35
| | | | | | It can be hard especially for those unfamiliar with the source to find where variables like $` and $[ are set up, now they're just a ack -Q away.
* fix bug 67156: overload: nomethod(..., '!') return value invertedMichael Breen2009-12-141-20/+10
|
* Bareword sub lookupsZefram2009-11-081-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Attached is a patch that changes how the tokeniser looks up subroutines, when they're referenced by a bareword, for prototype and const-sub purposes. Formerly, it has looked up bareword subs directly in the package, which is contrary to the way the generated op tree looks up the sub, via an rv2cv op. The patch makes the tokeniser generate the rv2cv op earlier, and dig around in that. The motivation for this is to allow modules to hook the rv2cv op creation, to affect the name->subroutine lookup process. Currently, such hooking affects op execution as intended, but everything goes wrong with a bareword ref where the tokeniser looks at some unrelated CV, or a blank space, in the package. With the patch in place, an rv2cv hook correctly affects the tokeniser and therefore the prototype-based aspects of parsing. The patch also changes ck_subr (which applies the argument context and checking parts of prototype behaviour) to handle subs referenced by an RV const op inside the rv2cv, where formerly it would only handle a gv op inside the rv2cv. This is to support the most likely kind of modified rv2cv op. The attached patch is the resulting revised version of the bareword sub patch. It incorporates the original patch (allowing rv2cv op hookers to control prototype processing), the GV-downgrading addition, and a mention in perldelta.
* Implement the 'qr' overload type.Ben Morrow2009-11-011-0/+1
| | | | | | | | | | | If this is defined, it will be called instead of stringification whenever an object is used as a regexp or interpolated into a regexp. This will fall back to stringification even without C<fallback => 1>, for compatibility. An overloaded 'qr' must return either a REGEXP or a ref to a REGEXP (such as created by qr//). Any further overloading on the return value will be ignored.
* Enable deprecation warnings by default.Nicholas Clark2009-10-161-3/+3
|
* Remove category 'syntax' from 5 warnings that should just be in 'deprecated'.Nicholas Clark2009-10-131-1/+1
| | | | | | | None were documented as also being in 'syntax'. Effectively, this completes the reorganisation of commits 12bcd1a617c74d6e and 9014280dc8264580. See http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2009-10/msg00601.html and http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2002-03/msg00850.html
* Add Perl_ck_warner_d(), which combines Perl_ckwarn_d() and Perl_warner().Nicholas Clark2009-10-121-9/+8
| | | | | Replace ckWARN_d{,2,3,4}() && Perl_warner() with it, which trades reduced code size for 1 more function call if warnings are not enabled.
* Add Perl_ck_warner(), which combines Perl_ckwarn() and Perl_warner().Nicholas Clark2009-10-121-7/+5
| | | | | | | Replace ckWARN{,2,3,4}() && Perl_warner() with it, which trades reduced code size (about 0.2%), for 1 more function call if warnings are not enabled. However, if we're now in the L1 or L2 cache when we weren't previously, that's still going to be a speed win.
* Don't modify namelen in the first half of gv_stashpvn()Vincent Pit2009-09-101-6/+7
| | | | | | | | | | As it may be needed later when the lookup failed. This fixes [perl #69066]. However, from now, "package ::" and "package foo::" respectively introduce the "::" and "foo::" packages. Deciding if this is the correct thing to do ought to be addressed separately.
* Merge gv_IOadd() into gv_add_by_type().Nicholas Clark2009-08-081-32/+23
|
* Perl_newIO() can become a mathom by making newIO() a wrapper around newSV_type()Nicholas Clark2009-08-081-21/+0
| | | | and tweaking Perl_sv_upgrade().
* Merge gv_AVadd(), gv_HVadd() and gv_SVadd() into gv_add_by_type().Nicholas Clark2009-08-081-29/+13
| | | | The "short" names become macro wrappers, and the Perl_* versions become mathoms.
* Make gv_IOadd accept a NULL argumentRafael Garcia-Suarez2009-08-061-2/+0
| | | | This fixes bug #68182
* Modify the return value of Gv_AMupdate to indicate a compilation errorRafael Garcia-Suarez2009-07-091-5/+10
| | | | | This way we'll restore most of the performance on object desctruction lost by the previous commit
* Add a parameter "destructing" to Gv_AMupdate()Rafael Garcia-Suarez2009-07-081-8/+25
| | | | | | | | This boolean parameter indicates if the function has been called to update the overload magic table while looking up the DESTROY method. In this case, it's probably best to avoid croaking if those tables could not be updated (for example due to a method that could not be loaded.)
* Add test to make sure everything that outputs an exception or warning has a ↵James Mastros2009-06-271-0/+2
| | | | matching entry in perldiag (and fix it so that more of the existing ones do).
* Move the code to add magic to $0 into Perl_gv_fetchpvn_flags().Nicholas Clark2009-05-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Curiously, this appears to always have been implemented slightly inefficiently. It dates from perl 4.000, which added the functionality to make assigning to $0 set the process name. The equivalent fix for 4.000 is: --- a/perl.c +++ b/perl.c @@ -738,7 +738,7 @@ FIX YOUR KERNEL, PUT A C WRAPPER AROUND THIS SCRIPT, OR USE -u AND UNDUMP!\n"); (void)hadd(sigstab); } - magicalize("!#?^~=-%.+&*()<>,\\/[|`':\004\t\020\024\027\006"); + magicalize("!#?^~=-%.+&*()<>,\\/[|`':0\004\t\020\024\027\006"); userinit(); /* in case linked C routines want magical variables */ amperstab = stabent("&",allstabs); @@ -828,7 +828,6 @@ FIX YOUR KERNEL, PUT A C WRAPPER AROUND THIS SCRIPT, OR USE -u AND UNDUMP!\n"); #endif if (tmpstab = stabent("0",allstabs)) { str_set(stab_val(tmpstab),origfilename); - magicname("0", Nullch, 0); } if (tmpstab = stabent("\030",allstabs)) str_set(stab_val(tmpstab),origargv[0]);
* Use only one block of memory for both PL_psig_name and PL_psig_ptr.Nicholas Clark2009-05-211-5/+4
|
* In Perl_gv_fetchpvn_flags(), don't re-zero memory from Newxz().Nicholas Clark2009-05-191-3/+13
| | | | | Explicitly zero the memory for PL_psig_ptr, PL_psig_name and PL_psig_pend if we didn't need to allocate it this time round.
* GvUNIQUE* have been defined as 0 since 2005/06/30 - high time to remove them.Nicholas Clark2009-04-131-5/+0
|
* Fall back to "" overload for -X.Ben Morrow2009-03-251-0/+1
|
* In amagic_call(), offset should be strictly lesser than the SV len to be ↵Vincent Pit2009-01-021-1/+1
| | | | allowed to access the corresponding string buffer byte
* Fix overload index mismatch in overloading logic.Vincent Pit2009-01-021-1/+1
| | | | In amagic_call(), the 'method' arg comes the overload enum in overload.h, but is expected to match the bit set from %overloading::numbers::names. It values wrongly start at 1, differing by 1 from the enum indexes. This didn't appear in the tests because 'method' was reduced modulo 7 instead of 8.
* Bump copyright year after previous change d15cd8313063e574Rafael Garcia-Suarez2009-01-021-1/+1
|
* Move variable declaration without initialisation at the topRafael Garcia-Suarez2009-01-021-1/+2
| | | | Plus a comment by Nicholas
* 'overloading' pragmaYuval Kogman2009-01-021-0/+20
|
* Merge S_is_gv_magical() into Perl_is_gv_magical_sv().Nicholas Clark2008-11-261-23/+6
| | | p4raw-id: //depot/perl@34931
* is_gv_magical() is only called from within gv.c.Nicholas Clark2008-11-261-1/+1
| | | p4raw-id: //depot/perl@34926
* Hard-coded Perl_pp_entersub and Perl_pp_entereval should use PL_ppaddrTim Bunce2008-11-201-1/+1
| | | | | | | Message-ID: <20081120131719.GA32120@timac.local> [tweaked for blead because of change 27941] p4raw-id: //depot/perl@34896
* [perl #948] [PATCH] Allow tied $,Chip Salzenberg2008-11-141-2/+0
| | | | | Message-ID: <20081114084436.GJ5779@tytlal.topaz.cx> p4raw-id: //depot/perl@34831
* Fix DBM module handling broken by #34653.Marcus Holland-Moritz2008-11-031-11/+10
| | | p4raw-id: //depot/perl@34710
* Re: @{"_<$filename"} is unreasonably tied to use of DB::DB ($^P & 0x2)Tim Bunce2008-11-031-1/+1
| | | | | | Message-ID: <20081103160130.GA45762@timac.local> Date: Mon, 3 Nov 2008 16:01:31 +0000 p4raw-id: //depot/perl@34705
* PATCH: Large omnibus patch to clean up the JRRT quotesTom Christiansen2008-11-021-1/+3
| | | | | | Message-ID: <25940.1225611819@chthon> Date: Sun, 02 Nov 2008 01:43:39 -0600 p4raw-id: //depot/perl@34698
* Add MUTABLE_GV(), and eliminate (V *) casts in *.c.Nicholas Clark2008-10-311-8/+9
| | | | | | Can't easily do gv.h, as GvGP() (at least) needs to split into two macros - one const for reading, one non-const for writing. p4raw-id: //depot/perl@34679
* Eliminate (SV *) casts from the rest of *.c, picking up one (further)Nicholas Clark2008-10-301-26/+27
| | | | | erroneous const in dump.c. p4raw-id: //depot/perl@34675
* Add MUTABLE_IO(), and eliminate (IO *) casts in *.c.Nicholas Clark2008-10-291-1/+1
| | | p4raw-id: //depot/perl@34654
* Use pvs macros instead of pvn where possible.Marcus Holland-Moritz2008-10-291-8/+8
| | | p4raw-id: //depot/perl@34653
* Add MUTABLE_CV(), and eliminate (CV *) casts in *.c.Nicholas Clark2008-10-291-2/+2
| | | p4raw-id: //depot/perl@34647
* Every remaining (HV *) cast in *.cNicholas Clark2008-10-281-2/+2
| | | p4raw-id: //depot/perl@34629
* Update copyright years.Nicholas Clark2008-10-251-2/+2
| | | p4raw-id: //depot/perl@34585
* Run Porting/checkARGS_ASSERT.pl and fix what it picks up. (Which,Nicholas Clark2008-05-101-1/+3
| | | | | coincidentally were both from changes I made) p4raw-id: //depot/perl@33814
* Remove a dead case from the error reporting inNicholas Clark2008-04-171-5/+5
| | | | | Perl_gv_fetchmethod_flags() p4raw-id: //depot/perl@33707
* Perl_gv_fetchmethod{,_autoload,_flags} are actually never* called withNicholas Clark2008-04-171-1/+1
| | | | | | a non-NULL stash. So change the parameter to NN. * Fixed the one really obscure hitherto untested case. p4raw-id: //depot/perl@33706
* %.*s mandates an "int", says the C standardRafael Garcia-Suarez2008-04-171-1/+1
| | | p4raw-id: //depot/perl@33704
* Fix warning with int size in printf formatRafael Garcia-Suarez2008-04-171-1/+1
| | | p4raw-id: //depot/perl@33703
* /* This code tries to figure out just what went wrong withNicholas Clark2008-04-171-11/+41
| | | | | | | | | | | gv_fetchmethod. It therefore needs to duplicate a lot of the internals of that function. "Duplicate". <snigger>. You said a naughty word. Now sanitised. [All tests pass, but I'm not 100% confident that this code is equivalent in all reachable corner cases, and it may be possible to simplify the error reporting logic now in gv_fetchmethod_flags] p4raw-id: //depot/perl@33702