summaryrefslogtreecommitdiff
path: root/pp_ctl.c
Commit message (Collapse)AuthorAgeFilesLines
* Slience compiler warnings for NV, [IU]V compareKarl Williamson2020-11-221-1/+1
| | | | | | | | | | | | | | These were occurring on FreeBSD smokes. warning: implicit conversion from 'IV' (aka 'long') to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion] 9223372036854775807 is IV_MAX. What needed to be done here was to use the NV containing IV_MAX+1, a value that already exists in perl.h In other instances, simply casting to an NV before doing the comparison with the NV was what was needed. This fixes #18328
* autodoc.pl: Enhance apidoc_section featureKarl Williamson2020-11-061-1/+1
| | | | | | | | | | | This feature allows documentation destined for perlapi or perlintern to be split into sections of related functions, no matter where the documentation source is. Prior to this commit the line had to contain the exact text of the title of the section. Now it can be a $variable name that autodoc.pl expands to the title. It still has to be an exact match for the variable in autodoc, but now, the expanded text can be changed in autodoc alone, without other files needing to be updated at the same time.
* Non-Configure code required to implement a strict by default optionTodd Rinaldo2020-09-151-1/+1
|
* Reorganize perlapiKarl Williamson2020-09-041-1/+1
| | | | | This uses a new organization of sections that I came up with. I asked for comments on p5p, but there were none.
* die_unwind(): global destructionNicolas R2020-08-211-1/+5
| | | | | | | | | | Fix #18063 During global destruction make sure we preserve the string by using mortalcopy. This is an update on 8c86f0238ecb5f32c2e7fba36e3edfdb54069068 change which avoided sv_mortalcopy in favor of sv_2mortal.
* pp_ctl.c: Convert to use av_count()Karl Williamson2020-08-191-23/+23
|
* Remove use of dVAR in coreDagfinn Ilmari Mannsåker2020-07-201-3/+3
| | | | | It only does anything under PERL_GLOBAL_STRUCT, which is gone. Keep the dNOOP defintion for CPAN back-compat
* Remove Symbian portDagfinn Ilmari Mannsåker2020-07-201-12/+0
| | | | | Also eliminate USE_HEAP_INSTEAD_OF_STACK and SETSOCKOPT_OPTION_VALUE_T, since Symbian was the only user of those.
* Fix a bunch of repeated-word typosDagfinn Ilmari Mannsåker2020-05-221-3/+3
| | | | | Mostly in comments and docs, but some in diagnostic messages and one case of 'or die die'.
* always treat undef in %INC as a failed requireTony Cook2020-01-271-2/+5
| | | | | | | | | | | Previously require would check for the specific \&PL_sv_undef SV in %INC, this meant that if %INC was copied, or undef assigned to a member the entry would erroneously be treated as if a previous require of that file was successful. So check for SvOK() instead, with appropriate magic tests. fixes #17428
* clean up quadmath_format_*() functionsTony Cook2019-11-161-6/+3
| | | | | | | | | | | This includes: - remove them from the API - simplify quadmath_format_single()'s interface, and rename it to match the new interface fixes #17288
* Faster feature checksTony Cook2019-10-301-0/+3
| | | | | | | | | | | | | | | Perform only a bit check instead of a much more expensive hash lookup to test features. For now I've just added a U32 to the cop structure to store the bits, if we need more we could either add more bits directly, or make it a pointer. We don't have the immediate need for a pointer that warning do since we don't dynamically add new features during compilation/runtime. The changes to %^H are retained so that caller() can be used from perl code to check the features enabled at a given caller's scope.
* si_cxsubix not restored on goto &XS_subDavid Mitchell2019-09-231-0/+3
| | | | | | | My recent merge commit v5.31.3-198-gd2cd363728 (temporarily reverted by v5.31.4-0-g20ef288c53) added a si_cxsubix field to the stackinfo struct to track the most recent sub context. This field wasn't being restored correctly with 'goto &XS-sub', and broke Test::Deep.
* Un-revert "[MERGE] add+use si_cxsubix field"David Mitchell2019-09-231-6/+13
| | | | | | | | original merge commit: v5.31.3-198-gd2cd363728 reverted by: v5.31.4-0-g20ef288c53 The commit following this commit fixes the breakage, which that means the revert can be undone.
* Revert "[MERGE] add+use PL_curstackinfo->si_cxsubix field"v5.31.4Max Maischein2019-09-201-13/+6
| | | | | | | | | | | | This reverts commit d2cd363728088adada85312725ac9d96c29659be, reversing changes made to 068b48acd4bdf9e7c69b87f4ba838bdff035053c. This change breaks installing Test::Deep: ... not ok 37 - Test 'isa eq' completed ok 38 - Test 'isa eq' no premature diagnostication ...
* add Perl_gimme_V() static inline fn for GIMME_VDavid Mitchell2019-09-191-0/+2
| | | | | | This function makes use of PL_curstackinfo->si_cxsubix to avoid the overhead of a call to block_gimme() when the context of the op is unknown.
* add PL_curstackinfo->si_cxsubix fieldDavid Mitchell2019-09-191-1/+5
| | | | | | | | | | | | | This tracks the most recent sub/eval/format context pushed onto the context stack. Then make dopopto_cursub use it. The previous value is saved in the cxt struct, and is restored whenever the context is popped. This adds a tiny overhead for every sub call, but speeds up other operations, such as determining the caller context when returning a value from a sub - this has to be dpne for every sub call where the last expression is context sensitive, so its often a win.
* add dopopto_cursub() macro to pp_ctl.cDavid Mitchell2019-09-191-6/+7
| | | | short for dopoptosub(cxstack_ix), a common idiom in that file.
* Avoid panic when last s///g is tainted and utf8David Mitchell2019-09-141-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | RT #134409 In a repeated substitution, where the replacement is an expression, and when the last replacement value is both tainted and utf8, and everything earlier has been plain, and the final string is suitably shorter than the original, a panic resulted: sv_pos_b2u: bad byte offset, blen=1, byte=6 This is because when at the end, taint magic is being being added to the target of the s///, the target SV has already had its buffer updated with the shorter result string, but still has the pos() magic set which corresponded to the original longer string (this pos value would, in the normal flow of things, be reset shortly afterwards). One quirk of sv_magic(), which adds any sort of magic including taint magic, is that it always checks for the presence of pos() magic, and if so, converts the byte to utf8 offset if necessary. This was seeing the invalid pos() offset and panicing. The check was added by v5.19.3-111-g25fdce4a16: "Stop pos() from being confused by changing utf8ness" It seems like a bit of hack to recalibrate pos() each time sv_magic() is called, but I've left that alone (sleeping dogs and all that) and instead added a hack in the taint code path in pp_substcont to reset pos before setting taint.
* (perl #134266) make sure $@ is writable when we write to itTony Cook2019-08-081-2/+8
| | | | | | | | when unwinding. Since except_sv might be ERRSV we try to preserve it's value, if not the actual SV (which we have an extra refcount on if it is except_sv).
* (perl #133695) "0".."-1" should act like 0..-1Hauke D2019-08-081-3/+7
| | | | | | | | | | | | | | | | | | Previously, *any* string beginning with 0, including the string "0" itself, would be subject to the magic string auto-increment, instead of being treated like a number. This meant that "-2".."-1" was the same as -2..-1 and "1".."-1" was the same as 1..-1, but "0".."-1" was the same as "0".."99". This patch fixes that inconsistency, while still allowing ranges like "01".."31" to produce the strings "01", "02", ... "31", which is what the "begins with 0" exception was intended for. This patch also expands the documentation in perlop and states the rules for the range operator in list context with both operands being strings more explicitly. See also #18165 and #18114.
* pp_ctl.c: Use safe UTF8SKIPKarl Williamson2019-03-191-1/+2
|
* Use sv_catpvs where appropriate vs sv_catpvKarl Williamson2018-08-061-4/+4
| | | | | This moves calculations definitely to compile time; some optimizing compilers may already do this, but some may not.
* Allow goto into glob’s argFather Chrysostomos2018-02-241-0/+1
| | | | | | | | | | | | $ ./perl -Ilib -Xe 'goto foo; glob do { foo: $1}' Can't "goto" into a binary or list expression at -e line 1. What binary or list expression? True, glob has the *precedence* of a list operator, but so does not: $ ./perl -Ilib -Xe 'goto foo; not do { foo: $1}; prt "ok\n"' ok Glob seems to be the only exception, due to its ‘special’ op tree.
* [perl #132854] Allow goto into first arg of bin opFather Chrysostomos2018-02-231-0/+8
| | | | | This particular case does not risk any stack corruption, and there is a CPAN module depending on it working (PerlX::AsyncAwait).
* [perl #132799] Fix goto within block within exprFather Chrysostomos2018-02-041-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When goto looks for a label, it builds up a list of ops to enter. But it begins its search a little too far out relative to the ‘goto’. Hence, the first op gets skipped. In 6d90e983841, I forbade same cases of inward goto-into-expression to avoid stack corruption and crashes. I did this by pushing a marker on to the list of ops to enter, indicating that an error should be thrown instead. Because goto starts the search too far up the context stack, it would sometimes end up looking inside an expression, which would cause the first op on the entry list to be such a marker, meaning that the next item, which should have been skipped, would not be. That could really screw up the context stack for cases like: my $e = eval { goto label; label: } because the entry list would be: <croak-marker> entertry instead of the previous: entertry Hence, entertry (which enters eval{}) would be executed from *within* the eval, causing the exit of the eval to leave an eval on the context stack. Crashes ensued. This commit fixes it by checking whether we have moved past the begin- ning of the list of entry ops before pushing a croak-marker on to it. Goto’s implementation is really complex, and always has been. It could be greatly simplified now thot ops have parent pointers. But that should wait for another developement cycle.
* Fix goto-into-string-eval under PERL_UNICODEFather Chrysostomos2018-01-121-0/+1
| | | | | | | | | | More precisely, goto-to-jump-into-the-parameter-of-a-string-eval, which is tested in goto.t as of 6d90e98384, but fails as of that commit under PERL_UNICODE, because entereval gets a second kid op (a hintseval op) and ‘looks like’ a list operator, which 6d90e98384 generally forbad. The easiest way to fix this is simply to add another exception.
* [perl #130936] Forbid some cases of inward gotoFather Chrysostomos2018-01-081-6/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit in general forbids entry into the parameter of a binary or list operator, to avoid crashes and stack corruption. In cases like goto f; push @array, do { f: } and goto f; $a + do { f: }; it’s not possible to fix this in general. Cases like goto f; do { f: } + $a; (jumping into the first parameter) have never caused problems, but I went ahead and forbad that usage too, since it would be too compli- cated to figure out exactly which parameter is being jumped into. (It’s not impossible; it would just double the amount of code used to find labels.) List operators taking just a simple list, such as die(), have never worked properly, because goto() bypasses the pushmark. They could be made to work, but that would require extra work to distinguish cases like push and print that have a first operand (sometimes implicit for print) of a specific type. I figured it was easier just to forbid jumping into any list operator. It’s also much easier to document.
* revert smartmatch to 5.27.6 behaviourZefram2017-12-291-46/+643
| | | | | | | | | | | | | The pumpking has determined that the CPAN breakage caused by changing smartmatch [perl #132594] is too great for the smartmatch changes to stay in for 5.28. This reverts most of the merge in commit da4e040f42421764ef069371d77c008e6b801f45. All core behaviour and documentation is reverted. The removal of use of smartmatch from a couple of tests (that aren't testing smartmatch) remains. Customisation of a couple of CPAN modules to make them portable across smartmatch types remains. A small bugfix in scope.c also remains.
* make false whereso yield undef in scalar contextZefram2017-12-231-1/+4
| | | | Fixes [perl #132634].
* pp_ctl.c: Add -D output for inward gotoFather Chrysostomos2017-12-171-0/+2
|
* merge branch zefram/dumb_matchZefram2017-12-171-643/+46
|\
| * internally change "when" to "whereso"Zefram2017-12-051-18/+18
| | | | | | | | | | The names of ops, context types, functions, etc., all change in accordance with the change of keyword.
| * change "when" keyword to "whereso"Zefram2017-12-051-2/+2
| |
| * merge leavegiven op type into leaveloopZefram2017-12-051-26/+1
| | | | | | | | | | The leaveloop op type can already do the whole job, with leavegiven being a near duplicate of it. Replace all uses of leavegiven with leaveloop.
| * make "outside a loop" error messages consistentZefram2017-11-291-1/+1
| | | | | | | | | | | | The message for leaving a "when" block outside a loop had different wording from the message for performing "next" et al outside a loop. Make the "when" message consistent with the existing loop control ones.
| * remove unused CXp_FOR_DEF and OPpITER_DEFZefram2017-11-291-4/+0
| | | | | | | | | | These were used to identify foreach loops that qualify as topicalizers. That's no longer a relevant classification.
| * make "when" do implicit "next"Zefram2017-11-291-34/+5
| | | | | | | | | | | | | | | | A "when" construct, upon reaching the end of its conditionally-executed block, used to perform an implicit jump to the end of the enclosing topicalizer, defined as either a "given" block or a "foreach" operating on $_. Change it to jump to the enclosing loop of any kind (which now includes "given" blocks).
| * remove useless "break" mechanismZefram2017-11-291-23/+0
| |
| * make loop control apply to "given"Zefram2017-11-291-10/+10
| | | | | | | | A "given" construct is now officially a one-iteration loop.
| * revise block_givwhen for sole use by "when"Zefram2017-11-291-1/+1
| | | | | | | | This context frame type doesn't need to cater for "given" any more.
| * use blk_loop format for CXt_GIVENZefram2017-11-291-3/+3
| |
| * remove useless "default" mechanismZefram2017-11-281-4/+2
| |
| * canonicalise smartmatch overload truth valuesZefram2017-11-221-1/+1
| | | | | | | | | | | | This enforces that a smartmatch overload returns just a truth value indicating whether the lhs matches the criterion, not some more complex kind of result that doesn't fit the smartmatch concept.
| * eviscerate smartmatchZefram2017-11-221-525/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Regularise smartmatch's operand handling, by removing the implicit enreferencement and just supplying scalar context. Eviscerate its runtime behaviour, by removing all the matching rules other than rhs overloading. Overload smartmatching in the Regexp package to perform regexp matching. There are consequential customisations to autodie, in two areas. Firstly, autodie::exception objects are matchers, but autodie has been advising smartmatching with the exception on the lhs. This has to change to the rhs, in both documentation and tests. Secondly, it uses smartmatching as part of its hint mechanism. Most of the hint examples, in documentation and tests, have to change to subroutines, to be portable across Perl versions.
* | semicolon-friendly diagnostic controlZefram2017-12-161-2/+2
| | | | | | | | | | | | New macros {GCC,CLANG}_DIAG_{IGNORE,RESTORE}_{DECL,STMT}, which take a following semicolon. It is necessary to use the _DECL or _STMT version as appropriate to the context. Fixes [perl #130726].
* | [perl #74764] Forbid ‘goto’ jumping into ‘given’Father Chrysostomos2017-12-101-1/+5
| | | | | | | | | | | | | | It does not make sense to jump into a ‘given’ any more than it makes sense to jump into ‘foreach’, which has long been forbidden, since there is no value to turn into a topic. Up till now this construct has always crashed.
* | pp_ctl.c: Move goto-into-foreach errorFather Chrysostomos2017-12-101-6/+13
|/ | | | | Put it in a static function, instead of repeating the code. This way I can add more conditions to that code in subsequent commits.
* fix tainting of s/// with overloaded replacementZefram2017-11-191-2/+2
| | | | | | | | | | | | | | The substitution code was trying to track the taintedness of the replacement string itself, but it didn't account for the replacement being an untainted object with overloading that returns a tainted stringification. It looked at the taintedness of the object value, not realising that taint could arise during the string concatenation per se. Change the taint checks to look at the actual TAINT_get flag after string concatenation. This may falsely ascribe to the replacement taint that actually came from somewhere else, but the end result is the same anyway: there's no visible behaviour that distinguishes taint specifically from the replacement. Also remove a related taint check that seems to be not needed at all. Fixes [perl #115266].
* fix handling of registered warning categoriesZefram2017-11-151-10/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There were some problems arising from some warning bitsets being shorter than others, which happens when registration of a new warning category makes new bitsets longer. Most obviously, if a scope used "use warnings 'all'" to turn on all warnings and then turned off some specific warnings, then that scope wouldn't get warnings for subsequently-registered warning categories, because its bitset doesn't extend to the bit controlling the new category. (If just "use warnings 'all'" was used, without any customisation, then a special hack made that work for new categories.) It was also possible for a longer bitset to get truncated by a warnings pragma, because the bitset editing code assumed that all bitsets are the same length. To fix this, first the warning bits for the "all" category have to change meaning. Unlike all other warning categories, the bits for "all" used to be set only when there were no warning categories disabled; disabling any would also clear the "all" bits. That was supporting the special hack mentioned above that the all-warnings bitset work for new categories. This exception is now removed, so the meaning of the "all" bits is now the more obvious meaning, of indicating the default treatment that the scope wants for warnings not falling into any category known to the bitset. In warnings::warnif() et al, if the caller's bitset is found to be too short to have a bit for the relevant category, then the setting for the "all" category is used instead. Because the length of a bitset is an integral number of bytes, but only two bits are used per category, the length of a bitset doesn't precisely indicate which categories had been registered by the time it was constructed. So the standard bitsets for the "all" category are now always filled to their byte length, with bits set preemptively for categories not yet registered that fall within the current bitset length. When a warnings pragma operates on a bitset, it first expands it to the preferred length, by duplicating the "all" bits for the categories covered by the new length. It is careful to maintain the length when combining the bitset with the standard bitsets for categories. When a bitset is read from ${^WARNING_BITS} or from caller(), the standard pWARN_ALL setting is no longer expanded by the core to $warnings::Bits{all}, because the core's short WARN_ALLstring will now be expanded correctly just like any other bitset. Fixes [perl #108778].