| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
| |
This patch changes the core functions to use the common names for the
fields that are shared between op.c and regcomp.c, just for consistency
of using one name throughout the core for the same thing.
A grep of cpan shows that both names are used in various modules; so
both names must be retained.
|
|
|
|
|
|
|
|
|
|
|
| |
Eliminate the #define pp_foo Perl_pp_foo(pTHX) macros, and update the 13
locations that relied on them.
regen/opcode.pl now generates prototypes for the PP functions directly, into
pp_proto.h. It no longer writes pp.sym, and regen/embed.pl no longer reads
this, removing the only ordering dependency in the regen scripts. opcode.pl
is now responsible for prototypes for pp_* functions. (embed.pl remains
responsible for ck_* functions, reading from regen/opcodes)
|
|
|
|
|
|
|
|
|
| |
# 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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
require() sets the file name for PL_compiling but localises it to the
calling scope, not the scope that it creates. As a result, caller()
during or after require (in the same scope that require was called
from) will return the wrong file name for whichever code is being com-
piled at the time and any scope sharing the same CopFILE (or something
like that):
$ ./miniperl -Ilib -e 'BEGIN{require strict; warn join ", ", caller(0)}'
main, lib/strict.pm, 1, main::BEGIN, 1, , , , 0, , at -e line 1.
^^^^^^^^^^^^^ should be -e
This commit moves the SAVECOPFILE_FREE and CopFILE_set down below the
ENTER_with_name to put it in the right scope. It was in its existing
location presumably because namesv needed to be freed before any code
that could die (and the CopFILE_set call reads a PV allocated for
namesv). So now namesv is mortalised instead.
The if(tryrsfp) is no longer necessary, as that code is never reached
when tryrsfp is false.
The block in between that sets %INC was reading CopFILE. It can simply
use the same tryname variable that is passed to CopFILE_set.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
More precisely: Make run-time (?{...}) inherit pragmata.
This commit makes Perl_sv_compile_2op_is_broken (nice name!) copy the
hints from PL_curcop if invoked during run time. Usually they are
inherited from the code that is currently being compiled (which works
for $foo =~ /(?{...})/), but the code currently being compiled is not
the enclosing scope at run time ($bar = '(?{...})'; $foo =~ $bar),
hence the need for copying in a similar manner to pp_entereval.
Theoretically this code should also have to avoid copying a statement
label, but goto inside a regexp eval does not currently work, so I
cannot prove or disprove that yet.
|
|
|
|
|
|
|
| |
Set $@ early in a die as well as late, so that it continues to function
as an unreliable indicator of whether unwinding in progress is due to
an exception. This is a stopgap arrangement, until the unwinding process
can be introspected properly.
|
|
|
|
|
| |
This commit just avoids a redundant hv_delete call if leave_scope is
already going to do it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes the rest of [perl #78438].
eval "BEGIN{die}" creates a *{"_<(eval 1)"} glob regardless of $^P’s
setting in non-threaded builds as of change f9bddea (5.12.0).
Here are the results with various configurations:
version threaded eval text $^P Is *{"_<(eval 1)"} set?
------- -------- --------- --- -----------------------
5.10.1 yes BEGIN{} 0 no
5.10.1 yes BEGIN{die} 0 no
5.10.1 yes BEGIN{} 0xA yes
5.10.1 yes BEGIN{die} 0xA no
5.10.1 no BEGIN{} 0 no
5.10.1 no BEGIN{die} 0 no
5.10.1 no BEGIN{} 0xA yes
5.10.1 no BEGIN{die} 0xA no
5.13.7 yes BEGIN{} 0 no
5.13.7 yes BEGIN{die} 0 no
5.13.7 yes BEGIN{} 0xA yes
5.13.7 yes BEGIN{die} 0xA yes
5.13.7 no BEGIN{} 0 no
5.13.7 no BEGIN{die} 0 yes
5.13.7 no BEGIN{} 0xA yes
5.13.7 no BEGIN{die} 0xA yes
Notice that, for non-threaded builds, BEGIN{die} goes from never sav-
ing the text to always saving it.
The commit in question is:
commit f9bddea7d2a0d824366014c8ee6ba57e7dedd8c3
Author: Nicholas Clark <nick@ccl4.org>
Date: Tue Dec 2 20:43:58 2008 +0000
Implement PERLDBf_SAVESRC_INVALID, which saves source lines for string
evals that fail to compile.
p4raw-id: //depot/perl@34985
It stops unconditionally using the scoping mechanism to delete
$::{"_<(eval $num)"} on compilation failure:
- safestr = savepvn(tmpbuf, len);
- SAVEDELETE(PL_defstash, safestr, len);
but instead does it explicitly in this block:
+ if (doeval(gimme, NULL, runcv, seq)) {
+ if (was != PL_breakable_sub_gen /* Some subs defined here. */
+ ? (PERLDB_LINE || PERLDB_SAVESRC)
+ : PERLDB_SAVESRC_NOSUBS) {
+ /* Retain the filegv we created. */
+ } else {
+ char *const safestr = savepvn(tmpbuf, len);
+ SAVEDELETE(PL_defstash, safestr, len);
+ }
+ return DOCATCH(PL_eval_start);
+ } else {
+ /* We have already left the scope set up earler thanks to the LEAVE
+ in doeval(). */
+ if (PERLDB_SAVESRC_INVALID) {
+ /* Retain the filegv we created. */
+ } else {
+ (void)hv_delete(PL_defstash, tmpbuf, len, G_DISCARD);
+ }
+ return PL_op->op_next;
+ }
In the case of BEGIN{die}, that doeval() never returns, so the
clean-up code is not reached.
S_doeval never returns because call_list calls Perl_croak if it
catches a BEGIN error (appending the extra ‘BEGIN failed--compilation
aborted’, etc.). That takes execution all the way back to perl_run, so
it bypasses the clean-up code in pp_entereval.
What’s leaking is the GV created earlier in pp_entereval by this line:
CopFILE_set(&PL_compiling, tmpbuf+2);
CopFILE_set simply stores a string under threads, but creates a GV
under non-threaded builds.
This commit solves the problem by scheduling a deletion *before* call-
ing doeval, if the source lines have not been saved.
This works because the usual code to handle it is only bypassed when
there is a BEGIN block (a subroutine), so PL_breakable_sub_gen will
have gone up. So we never need to delete the saved lines when that
code is bypassed.
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
Previously in a BEGIN block, require was behaving identically to use 5.12.0 -
ie erroneously executing the use feature ':5.12.0'; and use strict;
use warnings behaviour, which only use was documented to provide.
|
|
|
|
|
|
|
|
|
| |
It attempted to provide an API to compile code down to an optree, but failed
to bind correctly to lexicals in the enclosing scope. It's not possible to
fix this problem within the constraints of its parameters and return value.
Searches suggest +that nothing on CPAN is using it, so removing it should have
zero impact.
|
|
|
|
|
|
|
|
|
| |
The format accumulator $^A now becomes tainted when formline() is
called with tainted data.
There is still one failing test from the TODO set; it seems
that the $^A get magic is handled too late for the taintedness
to show up.
|
|
|
|
|
|
|
| |
A private (tainted) string did not get its share of space
in the destination string, causing a buffer overflow later.
Originally reported by Roland Kuhn as http://bugs.debian.org/575318
|
| |
|
|
|
|
|
|
|
| |
This saves creating a mortal SV on every file require (and a strlen()).
This commit brought to you with the aid of the campaign for elimination of
strlen().
|
|
|
|
|
| |
Previously S_doopen_pm() took a char */STRLEN pair, but it happened that the
pointer was always from an SV. So pass the SV directly.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Refactoring of the grammar around statements. New production <barestmt>
encompasses a statement without label. It includes all statement types,
including declarations, with no unnecessary intermediate non-terminals.
It generates an op tree for the statement's content, with no leading
state op. The <fullstmt> production has just one rule, consisting of
optional label followed by <barestmt>. It puts a state op on the front
of the statement's content ops.
To support the regular statement op structure, the op sequence for for(;;)
loops no longer has a second state op between the initialisation and
the loop. Instead, the unstack op type is slightly adapted to achieve
the stack clearing without a state op.
The newFOROP() constructor function no longer generates a state op,
that now being the job of the <fullstmt> production. Consequently it
no longer takes a parameter stating what label is to go in the state op.
This brings it in line with the other op constructors.
|
|
|
|
|
|
|
|
| |
Dying and returning from a format both relied on the state of a
just-popped context frame being preserved across a LEAVE. Don't rely
on it. Test using an operator ripped off from Scope::Cleanup, which makes
it easy to run arbitrary Perl code during cleanup, without isolating it
on a separate context stack as the DESTROY mechanism does.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Expose cop hint hashes as a type COPHH, with a cophh_* API which is a
macro layer over the refcounted_he_* API. The documentation for cophh_*
describes purely API-visible behaviour, whereas the refcounted_he_*
documentation describes the functions mainly in terms of the
implementation. Revise the cop_hints_* API, using the flags parameter
consistently and reimplementing in terms of cophh_*. Use the cophh_*
and cop_hints_* functions consistently where appropriate.
[Modified by the committer to update two calls to
Perl_refcounted_he_fetch recently added to newPMOP.]
|
|
|
|
|
| |
lex_start() is added to the API, marked experimental, and documented.
It also gains a flags parameter for foreseeable future use.
|
|
|
|
|
|
|
| |
The lex_end() function is redundant, because the lexer context object
is actually finalised by parser_free(), triggered by the save stack.
The lex_end() function has historically been empty, except when the
PL_doextract global was being misused to store lexer state.
|
|
|
|
|
|
|
|
| |
The only uses of lex_start that had the new_filter parameter false,
to make the new lexer context share source filters with the previous
lexer context, were uses with rsfp null, which therefore never invoked
source filters. Inheriting source filters from a logically unrelated
file seems like a silly idea anyway.
|
|
|
|
| |
Based on a patch proposed by Niko Tyni.
|
|
|
|
|
|
|
|
|
| |
Allowing BhkENTRY(bhk, start) to look up the bhk_start member defeats
much of the point of having a bhk_ prefix in the first place: if a
member is added later called (say) 'bhk_die', any invocation of
BhkENTRY(bhk, die) will expand to BhkENTRY(bhk, Perl_die) because of the
API macros. Requiring BhkENTRY(bhk, bhk_start), while tedious, is much
safer.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The former behaviour of map and grep was to never free any temps.
Thus for large lists (and even worse, nested maps), the tmps stack could
grow very large. For all cases expect list-context map, the fix is easy:
just do a FREETMPS at the end of each iteration.
The list-context map however, needs to accumulate a list of temporaries
over the course of the iterations, and finally return that list to the
caller (which is responsible for freeing them). We get round this by, at
the end of each iteration, directly manipulating the tmps stack to free
everything *except* the values to be returned. To make this efficient,
we splice in the returned tmp items at the base of the stack frame, move
PL_tmps_floor above them, then do a FREETMPS (so they may appear twice on
the temps stack, but initially only get freed once).
|
|
|
|
|
|
| |
eval_sv(sv,G_KEEPERR) is supposed to warn on errors, rather than
set $@; but in the particular case of compile-time errors it still
set $@ instead. See [perl ##3719].
|
|
|
|
|
|
| |
This fixes m and s. It modifies pp_regcomp to avoid extra magic. It
also corrects a bug in sv_catsv_flags, which would still call
mg_get(ssv) even without the SV_GMAGIC flag set.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This case can be reduced to:
eval "UNITCHECK{ eval 0 }"
(eval 0 triggers the bug more reliably than eval ''.)
The inner eval clobbers PL_eval_start, so when the UNITCHECK finishes,
the outer eval tries to call the inner eval’s code, which has been
freed already.
This commit saves PL_eval_start and restores it after UNITCHECK.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
$ perl -le '$_="CCCGGG"; s!.!@a{print("[$&]"),/./}!g'
[C]
[C]
[C]
[C]
[C]
[C]
What’s happening is that the s/// does not reset PL_curpm for each
iteration, because it doesn’t usually have to.
The RHS’s scoping takes care of it most of the time. This happens with
the /e modifier and with @{...}.
In this example, though, we have a subscript, not a block. This sub-
script is in the same scope as the s/// itself.
The assumption that the substitution operator will never have to reset
PL_curpm itself appears to be incorrect. This fixes it.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
fix for [perl #21469]:
since the GP may be pulled from under us and freed, coredumps and strange
things can happen.
Fix this by storing a pointer to the GV in the loop block, rather than a
pointer to the GvSV slot. The ITHREADS variant already stores GV rather
than than &GvSV; extend this to non-threaded builds too.
Also, for both threaded and non-threaded, it used to push &GvSV on the
save stack. Fix this by introducing a new save type, SAVEt_GVSV.
This behaves similarly to SAVEt_SV, but without magic get/set.
This means that
for $package_var (...)
is now close in behaviour to
local $package_var = ...
(except for the magic bit).
|
| |
|
| |
|
|
|
|
|
|
|
| |
make it clearer what types of pointer to the iterator variable can be
stored, reduce the amount of #ifdef USE_ITHREADS, get rid of some macros,
and generally make the code easier to follow. No change to the size of the
structure.
|
|
|
|
|
|
| |
This field is only used in non-threaded builds, and the comments imply
that this is because in non-threaded builds this value may be
modified. But nothing in core modifies it.
|
|
|
|
|
|
|
| |
Add hinthash_fetch(sv|pv[ns]) as a replacement for refcounted_he_fetch,
which is not API (and should not be). Also add caller_cx, as the correct
XS equivalent to caller(). Lots of modules seem to have copies of this,
so a proper API function will be more maintainable in future.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
yyparse() becomes reentrant. The yacc stack and related resources
are allocated in yyparse(), rather than in lex_start(), and they are
localised to yyparse(), preserving their values from any outer parser.
yyparse() now takes a parameter which determines which production it
will parse at the top level. New API function parse_fullstmt() uses this
facility to parse just a single statement. The top-level single-statement
production that is used for this then messes with the parser's head so
that the parsing stops without seeing EOF, and any lookahead token seen
after the statement is pushed back to the lexer.
|
|
|
|
|
|
|
|
|
|
| |
From a suggestion from Ben Morrow.
The first argument used to be struct refcounted_he *, which exposed an
implementation detail - that the COP's labels are (now) stored in this way.
Google Code Search and an unpacked CPAN both fail to find any users of this
API, so the impact should be minimal.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These are left from PERL_OBJECT, which was an implementation of
multiplicity using C++ objects. PERL_OBJECT was removed in 5.8, but the
macros seem to have been cargo-culted all over the core (including in
places where they would have been inappropriate originally). Since they
now do exactly nothing, it's cleaner to remove them.
I have left the definitions in perl.h, under #ifndef PERL_CORE, since
some CPAN XS code uses them (also often incorrectly). I have also left
STATIC alone, since it seems potentially more useful and is much more
ingrained.
The only appearance of these macros this patch doesn't touch is in
Devel-PPPort, because that's a CPAN module.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Ticket is entitled:
"panic: top_env when localizing a lexical variable in qr{(?{...})}"
but a better description would be:
"(?{...}) does not catch yyparse() exceptions in regex compilation"
Changes Perl_sv_compile_2op() to tell doeval() that it must use
S_try_yyparse() to catch any exception that yyparse() may throw.
|
|
|
|
|
| |
Add a flags member, so it can be extended later if necessary. Add a
bhk_eval member, called from doeval to catch requires and string evals.
|
|
|
|
|
|
|
|
| |
Commit faee19b51573e81abe8811f1256a1d27777d6d04 was incomplete
and only stopped features from being enabled under 'no'.
This patch merges all 'use N.NN' type logic into a single if clause
and then checks version numbers in separate if statements within it.
|
| |
|
|
|
|
|
|
| |
PL_amagic_generation is non-zero even without the presence of
'use overload', so don't bother using it as a short-cut test of
whether we can skip AMAGIC processing
|
| |
|