summaryrefslogtreecommitdiff
path: root/pp.c
Commit message (Collapse)AuthorAgeFilesLines
* $ref++, $ref-- leaked referentDavid Mitchell2010-09-061-0/+4
| | | | | | | | | [perl #9466] pp_postinc and pp_postdec used a pad TARG to return a copy of the original value. When that value was a reference, it meant a copy of the reference would hang out in the pad forever and so the referent would leak. Fix this by using a mortal instead.
* use more efficient sv_reftype_len() interfaceYves Orton2010-08-301-2/+3
|
* Fix my $x = 3; $x = length(undef);.Ben Morrow2010-08-201-3/+6
| | | | | | | | Assignment of length() to a lexical is optimized by passing the assigned-to variable as TARG, avoiding a pp_padsv and pp_sassign. 9f621b which changed length(undef) to return undef didn't take this into account, and used SETs (which doesn't set TARG), so the code above left $x == 3.
* Fix untimely destruction introduced by lvalue ops [RT#67838] by returning a ↵Eric Brine2010-08-131-70/+53
| | | | TEMP instead of using TARG. Made appropriate TODO tests live.
* Make srand() return "0 but true" for 0, for backwards compatible behaviour.Nicholas Clark2010-07-281-1/+8
|
* srand: change to return its seedKarl Williamson2010-07-281-3/+3
| | | | | | | | | | | | | | This commit changes srand to to return the seed instead of always returning 1. The motivation behind this is to allow applications to not have to come up with their own pseudo-random generator if they want repeatable results. The previous return behavior has never been documented. Note that it is possible, but very unlikely, for the seed to end up being 0, which means that if someone were relying on the undocumented previous behavior of srand returning true, that in very rare instances it would return 0, failing, and the next time they ran it, it would succeed, possibly leading to puzzlement and very rare unexplained failures.
* add CvGV_set() macro and make CvGV() rvalue onlyDavid Mitchell2010-07-181-1/+1
| | | | | | Now that CvGV can sometimes be reference counted, stop people from directly assigning to it (by using CvGV as an lvalue), and instead force them to use CvGV_set()
* protect CvGV weakref with backrefDavid Mitchell2010-07-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Each CV usually has a pointer, CvGV(cv), back to the GV that corresponds to the CV's name (or to *foo::__ANON__ for anon CVs). This pointer wasn't reference counted, to avoid loops. This could leave it dangling if the GV is deleted. We fix this by: For named subs, adding backref magic to the GV, so that when the GV is freed, it can trigger processing the CV's CvGV field. This processing consists of: if it looks like the freeing of the GV is about to trigger freeing of the CV too, set it to NULL; otherwise make it point to *foo::__ANON__ (and set CvAONON(cv)). For anon subs, make CvGV a strong reference, i.e. increment the refcnt of *foo::__ANON__. This doesn't cause a loop, since in this case the __ANON__ glob doesn't point to the CV. This also avoids dangling pointers if someone does an explicit 'delete $foo::{__ANON__}'. Note that there was already some partial protection for CvGV with commit f1c32fec87699aee2eeb638f44135f21217d2127. This worked by anonymising any corresponding CV when freeing a stash or stash entry. This had two drawbacks. First it didn't fix CVs that were anonmous or that weren't currently pointed to by the GV (e.g. after local *foo), and second, it caused *all* CVs to get anonymised during cleanup, even the ones that would have been deleted shortly afterwards anyway. This commit effectively removes that former commit, while reusing a bit of the actual anonymising code.
* Code for allowing uppercase X/B in hexadecimal/binary numbers (#76296).Bo Lindbergh2010-07-061-2/+2
| | | | Signed-off-by: David Golden <dagolden@cpan.org>
* Add Perl_croak_no_modify() to implement Perl_croak("%s", PL_no_modify).Nicholas Clark2010-06-271-4/+4
| | | | | This reduces object code size, reducing CPU cache pressure on the non-exception paths.
* Return DIE(...) to *return*ing Perl_die(...).Nicholas Clark2010-06-271-2/+0
| | | | | | | | | Much simplification ensues - witness the diffstat. Changes Perl_die_unwind() to use Perl_croak() rather than DIE(). Reverses an unwise part of bb4c52e023e0fcad. Reverts 9e95c6350a60744d and 805bf316c58ab2d7.
* RT 75902: Add prototypes for tie() and untie() to allow overloadingFather Chrysostomos2010-06-251-0/+8
|
* uc(): Handle Greek YPOGEGRAMMENIKarl Williamson2010-06-151-26/+34
| | | | | | | | | | | | | | | | | | | | | Unicode contains two context-sensitive case-changing rules. This patch enables one of them, dealing with the Greek YPOGEGRAMMENI. The code had been #ifdef'd out, so the changes here are more than what the diff shows. The reason it was #ifdef'd out was because more research was needed to verify that it was correct, which I have now done, and think it is. The issue is we may just be uppercasing a portion of the context, so don't have complete knowledge of what should be done. This patch causes us to move the ypogegrammeni to as far right as it should go, or to the end of the context we know about, whichever comes first. That's the best we can do. If it really should be moved further to the right, there's no way we can do it, because the user has not called uc() with the full information needed. So, in all cases, this is better than just leaving it where it was in the input. Also, the applicable context is limited to a logical character, that matched by /\X/, so if the user is calling uc() on a subset of a logical character, it really is their mistake.
* rename DM_ARRAY flag to DM_ARRAY_ISADavid Mitchell2010-06-041-1/+1
| | | | | This better represents its current role as specifically delaying magic on @ISA as opposed to a general array magic delay mechanism.
* Make pp_reverse fetch the lexical $_ from the correct padVincent Pit2010-06-031-8/+1
| | | | | | This is achieved by introducing a new find_rundefsv() function in pad.c This fixes [perl #75436].
* add OPpDEREFed flag to avoid double mg_get()David Mitchell2010-05-251-1/+2
| | | | | | | | | | | | | The previous commit made various ops such as rv2av unconditionally do an SvGETMAGIC(). Under some circumstances this could cause a double mg_get() (and hence double FETCH etc). In particular, when the proceeding op was something like aelem with OPpDEREF, the aelem would call vivify_ref(), which would call magic. So in peep(), mark OP_RV2[SAH]V ops with the new OPpDEREFed flag if the preceding op was OPpDEREF. Then use this flag to avoid a second dose of magic. Note that RV2GV probably needs this flag too, but there weren't any spare private flag bits left for that op (I think).
* Deref ops ignore get-magic when SvROK(sv)Father Chrysostomos (via RT)2010-05-251-11/+2
| | | | | This is just like bug 68192, except in this case it’s a different set of operators that have had this problem for much longer.
* followup to magic/overload fixDavid Mitchell2010-05-211-6/+6
| | | | | | | 6f1401dc2acd2a2b85df22b0a74e5f7e6e0a33aa was over-enthusiastic on removing redundant code in the comparison ops. This code was only used on 64-bit #ifdef branches which is why I failed to spot it earlier. So restore that code!
* make overload respect get magicDavid Mitchell2010-05-211-174/+221
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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, <>.
* shift; optimizationRuslan Zakirov2010-05-031-1/+2
|
* avoid use of operator name in macroRobin Barker2010-04-261-2/+2
|
* use cBOOL for bool castsDavid Mitchell2010-04-151-1/+1
| | | | | | | | | | | | | bool b = (bool)some_int doesn't necessarily do what you think. In some builds, bool is defined as char, and that cast's behaviour is thus undefined. So this line in mg.c: const bool was_temp = (bool)SvTEMP(sv); was actually setting was_temp to false even when the SVs_TEMP flag was set. Fix this by replacing all the (bool) casts with a new cBOOL() cast macro that (hopefully) does the right thing.
* Merge commit 'origin/davem/post-5.12' into bleadDavid Mitchell2010-04-131-0/+1
|\
| * [perl #45167] Taint removal by sprintfDavid Mitchell2010-03-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Under some circumstances the value returned by sprintf wasn't tainted, even though its args were. While trying to fix this, I also came across a second bug (which made fixing the first bug very confusing!) where the TARG of the sprintf op, after getting tainted once, permanently retained taint magic, which depending on circumstances, wasn't always set to untainted (mg_len =0) The original bug basically boiled down to parts of Perl_sv_vcatpvfn() directly manipulating the target with SvGROW() / Copy(), which failed to taint the target. Other parts used sv_catsv(), which did. So for example: "%s%s" failed, (only SvGROW) "%s %s" worked (the space char was appended using sv_catsv).
* | [perl #74168] Assertion failure when emitting a stricture error messageRafael Garcia-Suarez2010-04-091-2/+2
| |
* | Don't initialize end in pp_reverse when begin is NULLVincent Pit2010-03-311-5/+8
| | | | | | | | | | | | This change is a complement to 572558b47236782e60e41bd235c96eae7cbca3db. Arithmetic on null pointers isn't defined by the C standard, so it may crash even before entering the loop.
* | Avoid a segfault when reversing an empty array in-place.Rafael Garcia-Suarez2010-03-311-1/+1
|/
* Symbol S_no_symref_sv should be static (local to the compilation unit).Jan Dubois2010-02-231-1/+1
|
* Convert Perl_sv_pos_u2b_proper() to Perl_sv_pos_u2b_flags().Nicholas Clark2010-02-141-3/+3
| | | | | | | Change from a value/return offset pointer to passing a Unicode offset, and returning a byte offset. The optional length value/return pointer remains. Add a flags argument, passed to SvPV_flags(). This allows the caller to specify whether mg_get() should be called on sv.
* Remove a vestigial STRLEN case and convert a label to lowercase.Nicholas Clark2010-02-141-5/+5
| | | | (Tweaking 777f7c561610dee6.)
* Removes 32-bit limit on substr arguments. The full range of IV and UV is ↵Eric Brine2010-02-141-50/+93
| | | | available for the pos and len arguments, with safe conversion to STRLEN where it's smaller than an IV.
* Revert "[perl #62646] Maximum string length with substr"Rafael Garcia-Suarez2010-01-181-10/+7
| | | | | | | | This reverts commit b6d1426f94a845fb8fece8b6ad0b7d9f35f2d62e. Conflicts: pp.c
* A fig leaf for calling sv_pos_u2b with IV* where it expects I32*.Craig A. Berry2010-01-161-1/+4
| | | | | | | | | | | Following v5.11.3-103-gb6d1426, any compiler paying attention whines about the pointer mismatch (which on VMS breaks the build). Zefram reports a further patch in progress: Message-ID: <20100116022631.GA10264@fysh.org> but this gets the warning out of the way so other work can proceed.
* [perl #62646] Maximum string length with substrZefram2010-01-151-7/+7
| | | | (This is only a partial fix, since it doesn't handle lvalue substr)
* Another C<return NORMAL> needed post bb4c52e023e0, missed from 805bf316c58a.Nicholas Clark2009-12-031-0/+1
|
* Add assertions that pp_padav and pp_padhv push scalars of the correct type.Gerard Goossen2009-11-251-0/+2
|
* Inline PL_no_symref_sv into its users. Deprecate the visible global variable.Nicholas Clark2009-11-151-2/+5
| | | | | | | | | As the core no longer needs this fixed string outside of pp.c, it seems daft to make it public just in case any module wants to use it. Modules that do should provide their own inline copy in future. Also restore the visible global PL_no_symref_sv back to the original format specificiation (of 5.10.0 and earlier).
* add code for Unicode semantics for non-utf8 latin1 charsKarl Williamson2009-11-141-104/+632
|
* Fix compiler warning:Jerry D. Hedden2009-11-131-1/+1
| | | | | pp.c: In function `Perl_pp_delete': pp.c:4297: warning: 'sv' might be used uninitialized in this function
* Add ENTER_with_name and LEAVE_with_name to automaticly check for matching ↵Gerard Goossen2009-11-121-8/+8
| | | | ENTER/LEAVE when debugging is enabled
* Optimize reversing an array in-placeVincent Pit2009-11-101-8/+67
|
* SvREFCNT_dec already checks if the SV is non-NULL (continued)Vincent Pit2009-11-081-4/+2
|
* move JMPENV_JUMP to die_where and mark it as "noreturn"Gerard Goossen2009-11-061-0/+1
|
* SvREFCNT_dec already checks if the SV is non-NULLVincent Pit2009-11-051-6/+3
|
* [perl #69875] Slow down split in scalar context :-)Father Chrysostomos2009-10-311-1/+3
| | | | | | | | | The patch to speed up split in scalar context broke Font::GlyphNames, because it stops scalar(@array = split) from working. The attached patch fixes this, and ineluctably slows it down slightly. (Patch amended by replacing the 2nd GIMME_V macro call by the gimme variable)
* Avoid adding magic with rvalue $#aEric Brine2009-10-281-5/+12
|
* add an elipses to string/ref warnings when str longer than 32 charsYves Orton2009-10-261-2/+2
| | | | | | Wasted a few minutes more than necessary trying to work out why the string was truncated when in fact it was the error message that was truncating the string.
* Fix built-in prototype of each, keys, and valuesRafael Garcia-Suarez2009-10-221-0/+4
| | | | | | | Since those keywords can now compile to two different ops each, the usual inspection of opflags is not sufficient for perl to return a meaningful prototype. So we hardcode the correct return value for 5.12 : \[@%]
* Optimise if (%foo) to be faster than if(keys %foo)demerphq2009-10-151-0/+18
| | | | | | | | | | | Thread was "[PATCH] Make if (%hash) {} act the same as if (keys %hash) {}" http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2006-11/msg00432.html but the implementation evolved from the approach described in the subject, to instead add a new opcode pp_boolkeys, to exactly preserve the existing behaviour. Various conflicts with the passage of time resolved, 'register' removed, and a $VERSION bump.
* Add Perl_ck_warner(), which combines Perl_ckwarn() and Perl_warner().Nicholas Clark2009-10-121-16/+13
| | | | | | | 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.