summaryrefslogtreecommitdiff
path: root/pp_ctl.c
Commit message (Collapse)AuthorAgeFilesLines
* s/.../$_++/ge assertion failureDavid Mitchell2015-04-221-1/+7
| | | | | | | | The code that updated pos() on a match string assumed that it was SvPOK(). Cunning code like the following converted $_ to SvIOK only: $_ = 0; s/.?/$_++/ge;
* Replace common Emacs file-local variables with dir-localsDagfinn Ilmari Mannsåker2015-03-221-6/+0
| | | | | | | | | | | | | | | | An empty cpan/.dir-locals.el stops Emacs using the core defaults for code imported from CPAN. Committer's work: To keep t/porting/cmp_version.t and t/porting/utils.t happy, $VERSION needed to be incremented in many files, including throughout dist/PathTools. perldelta entry for module updates. Add two Emacs control files to MANIFEST; re-sort MANIFEST. For: RT #124119.
* Change some locale manipulation macros in prep for APIKarl Williamson2015-03-191-1/+2
| | | | | | | | | | This changes the way some of the current internal-only macros are named and used in order to simplify things and minimize what gets exposed as part of the API. Although these have not been listed as publicly available, it costs essentially nothing to keep the old names around in case someone was illegally using them.
* smartmatch: handle stack reallocDavid Mitchell2015-03-191-4/+11
| | | | | | | | | | | | | | | | | | When smartmatch is matching a pattern against something, it was failing to do appropriate PUTBACK and SPAGAIN's before calling matcher_matches_sv() (which pushes an arg an calls pp_match()). If the stack was almost full, the extra push in matcher_matches_sv() could cause a stack realloc, which would then be ignored when pp_smartmatch() returned, setting PL_stack_sp to point to the old (freed) stack. Adding SPAGAIN ensures that PL_stack_sp points to the new stack, while PUTBACK causes PL_stack_sp to no longer see the two args to pp_smartmatch, so the PUSH in matcher_matches_sv() pushes the SV us9ng ones of two two reclaimed slots, so the stack won't re-alloc anyway. Thus by doing the "right thing" with both PUTBACK and SPAGAIN, we doubly ensure that PL_stack_sp will always be right.
* update PL_stack_sp when we exit matcher_matches_sv()Tony Cook2015-03-191-1/+5
|
* [perl #123836] dump LABEL shouldn't be goto LABELTony Cook2015-02-171-2/+1
|
* Corrections to spelling and grammatical errors.Lajos Veres2015-01-281-2/+2
| | | | Extracted from patch submitted by Lajos Veres in RT #123693.
* [perl #123538] always set chophere and itembytes at the same timeTony Cook2015-01-191-0/+1
| | | | | Previously this would crash in FF_MORE because chophere was still NULL.
* Detect infnan range ends.Jarkko Hietaniemi2015-01-121-0/+2
|
* Separate bad range end detection.Jarkko Hietaniemi2015-01-121-21/+22
|
* Win32: stat() only after a failed open() on a moduleDaniel Dragan2015-01-121-2/+25
| | | | See RT ticket for this patch for details.
* avoid integer overflow in pp_flop()David Mitchell2014-12-311-1/+3
| | | | | | | | | | | | | | This; @a=(0x7ffffffffffffffe..0x7fffffffffffffff); could produce under ASan: pp_ctl.c:1212:19: runtime error: signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'IV' (aka 'long') so avoid post-incrementing the loop var on the last iteration. This fix is more to shut ASan up than an actual bug, since the bad value on the last iteration wouldn't actually be used.
* [perl #103260] Fix s/// with long stringsFather Chrysostomos2014-12-231-1/+1
| | | | | | | | | | | | | | | | | This is also the subject of perl #123071. The iteration count was stored in an I32 and was overflowing. If the maximum number of iterations possible overflowed, then it would become negative, and the substitution would fail immediately with ‘Substitu- tion loop’. I tried fixing this without increasing the size of the context stack entries on 64-bit builds (by skipping the loop check for long strings), but was unable to, because we have to return the number of iterations, which was also stored as I32. If we change just that one to SSize_t, we get an I32-sized alignment hole, so we might as well make maxiters a SSize_t as well, fixing the bug that way (the more straightforward way).
* pp_ctl.c: Only do GIMME_V once in pp_callerFather Chrysostomos2014-12-191-3/+3
| | | | | | | | | | | This shrinks the machine code. Before and after: $ ls -l pp_ctl.o -rw-r--r-- 1 sprout staff 96156 Dec 19 16:05 pp_ctl.o $ ls -l pp_ctl.o -rw-r--r-- 1 sprout staff 96044 Dec 19 16:09 pp_ctl.o
* Use GIMME_V in preference to GIMMEFather Chrysostomos2014-12-191-5/+5
| | | | | | | | | GIMME_V is a simpler macro that results in smaller machine code. GIMME does not distinguish between scalar and void context. The two instances of GIMME == G_SCALAR that I changed (which used to match void context too, but no longer do) are in code paths unreachable in void context, so we don’t need to check for it.
* [perl #123245] avoid a panic in sv_chop() in formatsTony Cook2014-12-101-2/+2
| | | | | | | | | | | | | | | This fixes two issues: 1) if you don't supply enough arguments to the format, pp_formline() uses &PL_sv_no as the sv, since we've already warned about the missing format argument, we don't need to produce a read only error for an SV the caller didn't supply 2) when the supplied string is empty for FF_LINESNGL and FF_LINEGLOB the case would skip most of its processing, including setting chophere, this meant that when the following FF_CHOP operator was processed it would pass a pointer into a different string, producing a panic.
* Change OP_SIBLING to OpSIBLINGFather Chrysostomos2014-12-071-7/+7
| | | | | | | | | to match the existing convention (OpREFCNT, OpSLAB). Dave Mitchell asked me to wait until after his multideref work was merged. Unfortunately, there are now CPAN modules using OP_SIBLING.
* Revert ‘Used pad name lists for pad ids’Father Chrysostomos2014-12-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 8771da69db30134352181c38401c7e50753a7ee8. Pad lists need to carry IDs around with them, so that when something tries to close over a pad, it is possible to confirm that the right pad is being closed over (either the original outer pad, or a clone of it). (See the commit message of db4cf31d1, in which commit I added an ID to the padlist struct.) In 8771da69 I found that I could use the memory address of the pad’s name list (name lists are shared) and avoid the extra field. Some time after 8771da69 I realised that a pad list could be freed, and the same address reused for another pad list, so using a memory address may not be so wise. I thought it highly unlikely, though, and put it on the back burner. I have just run into that. t/comp/form_scope.t is now failing for me with test 13, added by db4cf31d1. It bisects to 3d6de2cd1 (PERL_PADNAME_MINIMAL), but that’s a red herring. Trivial changes to the script make the problem go away. And it only happens on non- debugging builds, and only on my machine. Stepping through with gdb shows that the format-cloning is following the format prototype’s out- side pointer and confirming that it is has the correct pad (yes, the memory addresses are the same), which I know it doesn’t, because I can see what the test is doing. While generation numbers can still fall afoul of the same problem, it is much less likely. Anyway, the worst thing about 8771da69 is the typo in the first word of the commit message.
* make more use of NOT_REACHEDLukas Mai2014-11-291-5/+5
| | | | In particular, remove all instances of 'assert(0);'.
* Report inaccesible file on failed requirePetr Písař2014-11-211-1/+2
| | | | | | | | | | | | | | | | | | Commit 2433d39e6 (require should die if a file exists but can't be read) made first failed opened file fatal as request in [perl #113422]. However error message produced in that case is not much helpful in identifying which file ound not been accessed: $ LANG=C perl -I/root -e 'require strict' Can't locate strict.pm: Permission denied at -e line 1. This patch adds the name of the failed file to the message to help identify which @INC directory is erroneous: $ LANG=C ./perl -I/root -I./lib -e 'require strict' Can't locate strict.pm: /root/strict.pm: Permission denied at -e line 1. Signed-off-by: Petr Písař <ppisar@redhat.com>
* Make encoding pragma lexical in scopeKarl Williamson2014-11-201-8/+0
| | | | | | | | | | | | | | | | | | | | The encoding pragma is deprecated, but in the meantime it causes spooky action at a distance with other modules that it may be combined with. In these modules, operations such as chr(), ord(), and utf8::upgrade() will suddenly start doing the wrong thing. The documentation for 'encoding' has said to call it after loading other modules, but this may be impractical. This is especially bad with anything that auto-loads at first use, like \N{} does now for charnames. There is an issue with combining this with setting the variable ${^ENCODING} directly. The potential for conflicts has always been there, and remains. This commit introduces a shadow hidden variable, subservient to ${^ENCODING} (to preserve backwards compatibility) that has lexical scope validity. The pod for 'encoding' has been revamped to be more concise, clear, use more idiomatic English, and to speak from a modern perspective.
* Don’t check OPpTARGET_MY on match ops at run timeFather Chrysostomos2014-11-091-1/+1
| | | | | The offset in op_targ is sufficient. The next commit will take advan- tage of this.
* fuse returning branches in pp_gotoDaniel Dragan2014-11-041-7/+10
| | | | | | | | | | | | | | | | | | | before 0xA08 bytes of machine code on miniperl VC2003, after 0x9B0 All 3 exit/return paths of pp_goto call PERL_ASYNC_CHECK, but due to subtle differences between them, they were 3 separate branches in machine code that shared nothing. In the first, a plain C return was done instead of a RETURNOP (which contains "PL_stack_sp = sp"). In the 2 RETURNOPs, one returned a OP * from a CV*, the other returned a C auto. They couldn't be fused therefore, since PERL_ASYNC_CHECK could, according to C lang, rewrite CvSTART. To fix this, reorder the order of operations so 1 instance of PERL_ASYNC_CHECK is shared by the 3 different exit paths. Also due to the "if (!(do_dump || label_len)) DIE" it is impossible to not run one or the other. The isolated if(do_dump) and if(label_len), mean that unless a C optimizer was very smart (VC wasnt), there was an control path where PERL_ASYNC_CHECK would execute twice in row. Remove that control path explicitly. There might be questionable stack usage/stack reallocation near PERLDB_GOTO but I am not looking for that in this patch.
* free up CvPADLIST slot for XSUBs for future useDaniel Dragan2014-10-311-1/+1
| | | | | | | | | | | | | | | | | | | CvRESERVED is a placeholder, it will be replaced with a sentinal value from future revised BOOTCHECK API. CvPADLIST_set was helpful during development of this patch, so keep it around for now. PoisonPADLIST's magic value is from PERL_POISON 0xEF pattern. Some PoisonPADLIST locations will get code from future BOOTCHECK API. Make padlist_dup a NN function to avoid overhead of calling it for XSUBs during closing. Perl_cv_undef_flags's else if (CvISXSUB(&cvbody)) is to avoid whitespace changes. Filed as perl [#123059].
* foreach \$varFather Chrysostomos2014-10-111-1/+11
| | | | Some passing tests are still marked to-do. We need more tests still.
* [perl #122445] use magic on $DB::single etc to avoid overload issuesTony Cook2014-10-091-1/+1
| | | | | | | | | This prevents perl recursing infinitely when an overloaded object is assigned to $DB::single, $DB::trace or $DB::signal This is done by referencing their values as IVs instead of as SVs in dbstate, and by adding magic to those variables so that assignments to the scalars update the PL_DBcontrol array.
* Make list assignment respect foreach aliasingFather Chrysostomos2014-10-021-0/+1
| | | | | | | | | | | | See ff2a62e0c8 for the explanation. The bug fix in that commit did not apply to foreach’s aliasing. In short, ($a,$b)=($c,$d) needs to account for whether two of those variable names could be referring to the same variable. This commit causes the test suite to exercise a code path in scope.c added by ff2a62e0c8, which turned out to be buggy. (I forgot to test it at the time.)
* Add flags to cv_name; allow unqualified retvalFather Chrysostomos2014-09-241-1/+1
| | | | | | | | | | One of the main purposes of cv_name was to provide a way for CPAN mod- ules easily to obtain the name of a sub. As written, it was not actually sufficient, as some modules, such as Devel::Declare, need an unqualified name. So I am breaking compatibility with 5.21.4 (which introduced cv_name, but is only a dev release) by adding a flags parameter.
* Fix read-only flag checks in lvalue sub exitFather Chrysostomos2014-09-201-9/+4
| | | | | | | | | | | | | | | See the previous commit for the explanation. This fixes this discrepancy: $ ./miniperl -Ilib -e '+sub:lvalue{my $x = 3; Internals::SvREADONLY $x, 1; $x }->() = 3' Can't return a readonly value from lvalue subroutine at -e line 1. $ ./miniperl -Ilib -e '+sub:lvalue{my $x = *foo; Internals::SvREADONLY $x, 1; $x }->() = 3' Modification of a read-only value attempted at -e line 1. It was not just a flag check that this commit fixed, but also a bogus SvREADONLY(TOPs) where TOPs may not even be the scalar we are dying for, giving ‘a temporary’ for some read-only values. That mistake was my own, made in commit d25b0d7b8.
* comment pp_foo aliases in pp*.cDavid Mitchell2014-09-191-1/+7
| | | | | | | | Where pp_foo() also handles OP_BAR, add a comment above the function mentioning that it also does pp_bar. This means that "grep pp_bar pp*.c" quickly locates the file/function that handles OP_BAR.
* quadmath NV formatted I/O.Jarkko Hietaniemi2014-09-191-1/+15
|
* remove duplicate SvNV calls in pp_enteriterDaniel Dragan2014-09-181-12/+13
| | | | | | | | | | commit a2309040b8 added duplicate SvNV calls, remove them. Reorder the "SvUV_nomg(sv) > (UV)IV_MAX || SvNV_nomg(sv) > (NV)UV_MAX" so the var will be stored in a FP CPU reg for all comparisons, and not saved/fetched to/from mem across the SvUV func call. Due to complexity, I am not unrolling and fusing SvNV_nomg and SvOK. VC 2003 32b size of func in machine code bytes before 0x4d3 after 0x4a2
* Rename S_adjust_stack_on_leaveFather Chrysostomos2014-09-181-9/+15
| | | | | It now does more than that, so use a name that describes when it is called, rather than what it does.
* factor out TAINT_NOT into S_adjust_stack_on_leaveDaniel Dragan2014-09-181-6/+1
| | | | | | | | All callers of S_adjust_stack_on_leave had TAINT_NOT before the call to S_adjust_stack_on_leave. Factor it into the func to make the callers smallers machine code wise. More things can be factored out into adjust_stack_on_leave from its callers, but this particular change is very easy.
* Remove !IS_PADGV assertionsFather Chrysostomos2014-09-171-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 60779a30f stopped setting PADTMP on GVs in pads, and changed many instances of if(SvPADTMP && !IS_PADGV) to if(SvPADTMP){assert(!IS_PADGV)...}. This PADTMP was leftover from the original ithreads implementation that marked these as PADTMP under the assumption that anything in a pad had to be marked PADMY or PADTMP. Since we don’t want these GVs copied the way operator targets are (PADTMP indicates the latter), we needed this !IS_PADGV check all over the place. 60779a30f was actually right in removing the flag and the !IS_PADGV check, because it should be possible for XS modules to create ops that return copiable GVs. But the assertions prevent that from working. More importantly (to me at least), this IS_PADGV doesn’t quite make sense and I am trying to eliminate it. BTW, you have to be doubly naughty, but it is possible to fail these assertions: $ ./perl -Ilib -e 'BEGIN { sub { $::{foo} = \@_; constant::_make_const(@_) }->(*bar) } \ foo' Assertion failed: (!IS_PADGV(sv)), function S_refto, file pp.c, line 576. Abort trap: 6
* Exclude lex sub package name from (caller $n)[3]Father Chrysostomos2014-09-151-5/+2
| | | | | | | | | | Commit ae77754ae caused it to start including the package name. Pre- viously, lexical subs were reported as ‘(unknown)’. Now we have more expected output: $ ./perl -Ilib -XMfeature=:all -e 'my sub x{warn +(caller 0)[3]} x' x at -e line 1.
* pp_ctl.c: Remove junk from #endifFather Chrysostomos2014-09-121-2/+2
| | | | What was I thinking?
* pp_ctl.c: Remove PL_curcop assignmentFather Chrysostomos2014-09-121-6/+5
| | | | | | | | This was added years ago in commit 7fb6a879. Now that save_re_context does nothing (and die_unwind no longer even calls it), we don’t need to assign to PL_curcop. In the case where it matters, that is, the implicit eval scope that require provides, the values of PL_curcop and oldcop should always be the same.
* If USE_LONG_DOUBLE, NVff is PERL_PRIldbl.Jarkko Hietaniemi2014-09-091-14/+2
|
* Make ‘require $tied_undef’ behave consistentlyFather Chrysostomos2014-08-091-1/+2
| | | | | | | | | | | | | | | | | | | | As of f04d2c345 perl does not give uninitialized warnings for ‘require undef’. But the check was not happening soon enough, causing tied variables to behave erratically: $ ./perl -Ilib -we 'sub TIESCALAR{bless[]}sub FETCH{undef}sub STORE{}tie $x,""; $x="a"; require $x' Use of uninitialized value $x in require at -e line 1. Missing or undefined argument to require at -e line 1. (Uninit warning where muggle variables lack one.) $ ./perl -Ilib -we 'sub TIESCALAR{bless[]}sub FETCH{undef}sub STORE{}tie $x,""; $x=3; require $x' Invalid version format (non-numeric data) at -e line 1. (undef being treated as a version string.) We have to call get-magic on the argument before we check its definedness.
* make "require" handle no argument more gracefully, and add testsYves Orton2014-07-301-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in Perl 5.14 the following segfaults: *CORE::GLOBAL::require = sub { }; eval "require"; in Perl 5.18 perl -wle'eval "require";' produces a spurious warning: Use of uninitialized value $_ in require at (eval 1) line 1. In other perls: perl -e 'eval q/require $this/ or print $@' produces: Null filename used at (eval 1) line 1. The error message is crappy, totally unfit for a perl audience, and the spurious warning is just confusing. There is no $_ in use here, why do we warn about it. It looks like 9e3fb20c fixed the segfault (by accident), and also somehow meant that the "Null filename" error would not ever be produced. So this patch ditches the crappy error and replaces it with something meaningful and informative, and tests that we do not regress and start segfaulting again.
* add op_lastsib and -DPERL_OP_PARENTDavid Mitchell2014-07-081-4/+7
| | | | | | | | | | | | | | | | | | | | Add the boolean field op_lastsib to OPs. Within the core, this is set on the last op in an op_sibling chain (so it is synonymous with op_sibling being null). By default, its value is set but not used. In addition, add a new build define (not yet enabled by default), -DPERL_OP_PARENT, that forces the core to use op_lastsib to detect the last op in a sibling chain, rather than op_sibling being NULL. This frees up the last op_sibling pointer in the chain, which rather than being set to NULL, is now set to point back to the parent of the sibling chain (if any). This commit also adds a C-level op_parent() function and B parent() method; under default builds they just return NULL, under PERL_OP_PARENT they return the parent of the current op. Collectively this provides a facility not previously available from B:: nor C, of being able to follow an op tree up as well as down.
* wrap op_sibling field access in OP_SIBLING* macrosDavid Mitchell2014-07-081-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | Remove (almost all) direct access to the op_sibling field of OP structs, and use these three new macros instead: OP_SIBLING(o); OP_HAS_SIBLING(o); OP_SIBLING_set(o, new_value); OP_HAS_SIBLING is intended to be a slightly more efficient version of OP_SIBLING when only boolean context is needed. For now these three macros are just defined in the obvious way: #define OP_SIBLING(o) (0 + (o)->op_sibling) #define OP_HAS_SIBLING(o) (cBOOL((o)->op_sibling)) #define OP_SIBLING_set(o, sib) ((o)->op_sibling = (sib)) but abstracting them out will allow us shortly to make the last pointer in an op_sibling chain point back to the parent rather than being null, with a new flag indicating whether this is the last op. Perl_ck_fun() still has a couple of direct uses of op_sibling, since it takes the field's address, which is not covered by these macros.
* s///e on tainted utf8 strings got pos() messed upDavid Mitchell2014-07-021-2/+2
| | | | | | | | | | | | | | | | | RT #122148: In 5.20, commit 25fdce4a165 changed the way pos() was stored in magic attached to SVs from being a byte offset to a char offset, *except* that, for efficiency, strings being used for pattern matching were kept as byte offsets (with a flag indicating thus), *except* where the SV already had magic attached (such as taint, as in the bug report and in this commit's test), in which case it kept it as chars. The code that updated pos() after an iteration of s///e was faulty: the string buffer it used for converting byte legnths to char lengths (via utf8_length()) was the wrong buffer: rather than using the src string being matched against, it was using the destination string being built up via iterations of s///. Once double-byte utf8 chars were involved, all the pos() calculations went wrong, and utf8 warnings started mysteriously appearing.
* Follow-up to 51f14a05: not ignoring my_snprintf return values.Jarkko Hietaniemi2014-06-251-1/+4
|
* Remove or downgrade unnecessary dVAR.Jarkko Hietaniemi2014-06-251-62/+22
| | | | | | | | You need to configure with g++ *and* -Accflags=-DPERL_GLOBAL_STRUCT or -Accflags=-DPERL_GLOBAL_STRUCT_PRIVATE to see any difference. (g++ does not do the "post-annotation" form of "unused".) The version code has some of these issues, reported upstream.
* Unused snprintf results noticed by clang in Linux.Jarkko Hietaniemi2014-06-251-2/+2
| | | | | | | A bit dubious to ignore the snprintf results, but at least for these cases it looks acceptable. We could assign the length and croak if not expected, but it seems that with gcc brace groups we already do that.
* Silence -Wunused-parameter my_perl under threads.Jarkko Hietaniemi2014-06-191-0/+3
| | | | | | | | | | | | | | For S_ functions, remove the context. For Perl_ functions, add PERL_UNUSED_CONTEXT. Tricky because sometimes depends on DEBUGGING, and sometimes on whether we are have PERL_IMPLICIT_SYS. (Why all the mathoms Perl_is_uni_... and Perl_is_utf8_... functions are not being whined about is a mystery.) vutil.c (included via util.c) has one of these, but it's cpan/, and a known problem: https://rt.cpan.org/Ticket/Display.html?id=96100
* Revert "/* NOTREACHED */ belongs *before* the unreachable."Jarkko Hietaniemi2014-06-191-14/+7
| | | | | | This reverts commit 148f39b7de6eae9ddd59e0b0aff691d6abea7aca. (Still needs more work, but wanted to see how well this passed with Jenkins.)
* /* NOTREACHED */ belongs *before* the unreachable.Jarkko Hietaniemi2014-06-191-7/+14
| | | | | | Definitely not *after* it. It marks the start of the unreachable, not the first unrechable line. And if they are in that order, it looks better to linebreak after the lint hint.