summaryrefslogtreecommitdiff
path: root/pp.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix typos (spelling errors) in Perl sources.Peter J. Acklam) (via RT2011-01-071-3/+3
| | | | | | | | | # New Ticket Created by (Peter J. Acklam) # Please include the string: [perl #81904] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=81904 > Signed-off-by: Abigail <abigail@abigail.be>
* Convert tied SPLICE to using Perl_tied_method()Nicholas Clark2011-01-051-8/+3
|
* Avoid using OP_NAME() in unimplemented_op(), as it won't give useful strings.Nicholas Clark2010-12-311-2/+12
| | | | | | | | | | | Using OP_NAME() isn't going to be helpful here. Firstly, it doesn't cope with out of range op numbers - it only "special" cases op_custom. Secondly, as the three ops we "panic" on are padmy, mapstart and custom, if we get here for a custom op then that means that the custom op didn't have an implementation. Given that OP_NAME() looks up the custom op by its pp_addr, likely it will return NULL, unless someone (unhelpfully) registers &PL_unimplemented_op as the address of their custom op. NULL doesn't generate a useful error message. "custom" does. */
* standardise amagic method namingDavid Mitchell2010-12-311-2/+2
| | | | | | | | | | | | | | Some amagic-related macros take the full method enumeration name, (e.g. "add_amg"); while others "helpfully" allow you to pass a shortened version, ("add"), and do a CAT2(meth,_amg) behind the scenes. Standardise on passing the full name; this makes it less confusing and allows you to grep for the enumeration name in the source. It updates two macros to accept full enumeration names: tryAMAGICunTARGET (which isn't used outside the core apparently), and AMG_CALLun, which is replaced by a new AMG_CALLunary (since AMG_CALLun is used outside the core).
* Move do_chomp() from pp.c to doop.c, and make it static.Nicholas Clark2010-12-271-0/+167
| | | | It was never part of the public API, and only ever used by pp_{s,}cho{,m}p.
* Merge the opcode bodies for chop/chomp and schop/schomp.Nicholas Clark2010-12-271-22/+9
|
* Merge Perl_do_chop() and Perl_do_chomp().Nicholas Clark2010-12-271-4/+4
| | | | | | They share code for dealing with PVAVs, PVHVs, read only values and handling PL_encoding. They are not part of the public API, and Google codesearch shows no users outside the core.
* Convert Perl_do_chomp() to the same prototype as Perl_do_chop().Nicholas Clark2010-12-271-3/+5
| | | | Pass in an SV to hold the count, rather than returning the count.
* Refactor pp_chomp to process arguments in the same order as pp_chop.Nicholas Clark2010-12-271-4/+5
| | | | | Previously list chomp worked from last to first, whilst list chop worked from first to last.
* only call amagic_deref_call() if we have toDavid Mitchell2010-12-161-5/+8
|
* don't upgrade overload IV return values to NVDavid Mitchell2010-12-151-9/+9
| | | | | | | | (if we can avoid it). Fix for RT #77456. Basically it extends the usage of the AMGf_numeric flag to the remaining overloadable numeric ops that behave differently with IV and NV.
* No need to nest printfs. DIE() takes format strings.Rafael Garcia-Suarez2010-11-261-2/+2
|
* pp.c: tiny performance enhancementKarl Williamson2010-11-221-4/+4
| | | | | I believe on many processors two increments are faster than two additions
* pp.c, utf8.c: Convert to use TWO_BYTE_UTF8_TO_UNIKarl Williamson2010-11-221-3/+3
|
* [perl #77926] Glob reification during localisationFather Chrysostomos2010-11-201-4/+4
| | | | | | | | | | This was supposed to have been fixed by 2acc3314e31a9, but the code it added was in the wrong spot. (This is the code that makes *{} return a new glob if its argument is FAKE.) Consequently, local *$foo was localising $foo, not *$foo. This changes the order of the statements and adds a test.
* Eliminate the newname param from mro_package_movedFather Chrysostomos2010-11-201-1/+1
| | | | Nothing is using this any more, as of the previous commit.
* Remove redundant conditional added by e530fb81dFather Chrysostomos2010-11-111-1/+1
| | | | The else is never reached if the assignment in the protasis succeeds.
* undef *glob should update isa(rev)Father Chrysostomos2010-11-111-6/+23
|
* Inline tryAMAGICunDEREF_var() into its callers and eliminate it.Nicholas Clark2010-11-031-2/+4
| | | | Nothing outside the core was using this macro.
* y///rFather Chrysostomos2010-11-021-1/+6
|
* Expand AMG_CALLun_var() into all its users, and eliminate it.Nicholas Clark2010-11-021-2/+2
| | | | | Aside from the 2 callers where it can be replaced with AMG_CALLun(). AMG_CALLun_var was only used in core.
* Allow push/pop/keys/etc to act on referencesDavid Golden2010-10-311-2/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All built-in functions that operate directly on array or hash containers now also accept hard references to arrays or hashes: |----------------------------+---------------------------| | Traditional syntax | Terse syntax | |----------------------------+---------------------------| | push @$arrayref, @stuff | push $arrayref, @stuff | | unshift @$arrayref, @stuff | unshift $arrayref, @stuff | | pop @$arrayref | pop $arrayref | | shift @$arrayref | shift $arrayref | | splice @$arrayref, 0, 2 | splice $arrayref, 0, 2 | | keys %$hashref | keys $hashref | | keys @$arrayref | keys $arrayref | | values %$hashref | values $hashref | | values @$arrayref | values $arrayref | | ($k,$v) = each %$hashref | ($k,$v) = each $hashref | | ($k,$v) = each @$arrayref | ($k,$v) = each $arrayref | |----------------------------+---------------------------| This allows these built-in functions to act on long dereferencing chains or on the return value of subroutines without needing to wrap them in C<@{}> or C<%{}>: push @{$obj->tags}, $new_tag; # old way push $obj->tags, $new_tag; # new way for ( keys %{$hoh->{genres}{artists}} ) {...} # old way for ( keys $hoh->{genres}{artists} ) {...} # new way For C<push>, C<unshift> and C<splice>, the reference will auto-vivify if it is not defined, just as if it were wrapped with C<@{}>. Calling C<keys> or C<values> directly on a reference gives a substantial performance improvement over explicit dereferencing. For C<keys>, C<values>, C<each>, when overloaded dereferencing is present, the overloaded dereference is used instead of dereferencing the underlying reftype. Warnings are issued about assumptions made in the following three ambiguous cases: (a) If both %{} and @{} overloading exists, %{} is used (b) If %{} overloading exists on a blessed arrayref, %{} is used (c) If @{} overloading exists on a blessed hashref, @{} is used
* [perl #78580] Stop a simple *glob from calling get-magicFather Chrysostomos2010-10-311-1/+1
| | | | | | | | This also happens to apply to *{ $::{glob} }, but not to *{\*glob} or *{$thing = *glob}. In other words, it’s only when the operand is a real glob, and not a reference or a SVt_FAKE glob.
* Switch the core MRO code over to HvENAMEFather Chrysostomos2010-10-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | This has the side-effect of fixing these one-liners: $ perl5.13.5 -le' my $glob = \*foo::ISA; delete $::{"foo::"}; *$glob = *a' Bus error $ perl5.13.5 -le' my $glob = \*foo::ISA; delete $::{"foo::"}; *$glob = []' Bus error $ perl5.13.6 -le'sub baz; my $glob = \*foo::bar; delete $::{"foo::"}; *$glob = *baz;' Bus error $ perl5.13.6 -le'sub foo::bar; my $glob = \*foo::bar; delete $::{"foo::"}; *$glob = *baz;' Bus error In the first two cases the crash was inadvertently fixed (isn’t it nice when that happens?) in 5.13.6 (by 6f86b615fa7), but there was still a fatal error: Can't call mro_isa_changed_in() on anonymous symbol table at -e line 1. Because sv_clear calls ->DESTROY, if an object’s stash has been detached from the symbol table, mro_get_linear_isa can be called on a hash with no HvENAME. So HvNAME is used as a fallback for those cases.
* -$zero should not modify $zeroFather Chrysostomos2010-10-251-1/+1
| | | | | With change a5b92898, negation started modifying numeric arguments, causing problems for modules like Data::Float.
* [perl #77498] Assignment ignores magick when the RHS holds a globFather Chrysostomos2010-10-251-1/+1
|
* [perl #77810] Scalars vs globsFather Chrysostomos2010-10-241-1/+9
| | | | | | | | | | Stop *{} from returning globs with the SVf_FAKE flag on. It removes three tests from t/op/gv.t (that I added) that test buggy edge cases that can no longer occur. It also modifies tests in t/io/defout.t to keep them passing. I am not sure that test script serves any purpose any more.
* Make splice invoke set magicFlorian Ragwitz2010-10-151-0/+4
|
* [perl #20661] Constant strings representing a number can BECOME numbersFather Chrysostomos2010-10-041-0/+8
| | | | | The & | ^ operators now avoid turning on numericness of read-only arguments.
* [perl #57706] Unary minus on 'numeric' inputs like '-1'Renée Bäcker2010-10-041-0/+5
| | | | | The attached patch adds the conversion if the value of the SV looks_like_number.
* [perl #76814] FETCH called twice - !Father Chrysostomos2010-09-241-1/+1
| | | | | | This fixes ! by changing sv_2bool to sv_2bool_flags (with a macro wrapper) and adding SvTRUE_nomg. It also corrects the docs that state incorrectly that SvTRUE does not handle magic.
* [perl #76814] FETCH called twice - string comparison opsFather Chrysostomos2010-09-241-6/+6
| | | | | | This patch changes sv_eq, sv_cmp, sv_cmp_locale and sv_collxfrm to _flags forms, with macros under the old names for sv_eq and sv_collxfrm, but functions for sv_cmp* since pp_sort.c needs them.
* Back out the mauve module and related changesFlorian Ragwitz2010-09-161-3/+2
| | | | | | | | | | | | | | | | | | | | | It's was intended as a temporary namespace only, and we really don't want to ship it in any release until we've figured out what it should really look like. This reverts commit 05c0d6bbe3ec5cc9af99d105b8648ad02ed7cc95, "add sv_reftype_len() and make sv_reftype() be a wrapper for it" commit 792477b9c2e4c75cb03d07bd6d25dc7e1fdf448e, "create the "mauve" temporary namespace for things like reftype" commit 8df6b97c1de8326d50ac9c8cae4bf716393b45bb, "mauve.t needs access to %Config, make sure it's available" commit cfe9162d0d593cd12a979c73df82c7509b324343, "use more efficient sv_reftype_len() interface" and commit 47b13905e23c2a72acdde8bb4669e25e5eaefec4 "add more tests to lib/mauve.t so it tests also that mauve::reftype can return "LVALUE"" There's a `mauve' branch still containing all the code for the temporary mauve namespace. That should be used to work on it until it's mostly ready to be released, and only then merged to blead. Alternatively, it should be deleted if another way to provide mauve's features in the core is found.
* $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.