| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
pp_sselect (4-arg select) process its first three bitfield arguments
first, making sure each one has a valid PV, and then it moves on to
the final, timeout argument.
SvGETMAGIC() on the timeout argument will wipe out any values the SV
holds, so if the same scalar is used as a bitfield argument *and* as
the timeout, it will no longer hold a valid PV.
Assertions later in pp_sselect make sure there is a valid PV.
This commit solves the assertion failure by making a temporary copy of
any gmagical or overloaded argument. When the temporary copy is made,
the values written to the temporary copies of the bitfield arguments
are then copied back to the original magical arguments.
(cherry picked from commit e26c6904d9f9f5ea818e590331b14038279332d1)
|
|
|
|
|
|
| |
Some vars have been tagged as const because they do not change in their
new scopes. In pp_reverse in pp.c, I32 tmp is only used to hold a char,
so is changed to char.
|
|
|
|
| |
This was my fault; oops.
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
Perl 5.10 deprecated using the same symbol to open both a filehandle
and a dirhandle, as this can lead to confusing code.
In Pelr 5.28, this will become a fatal error. This patch changes the
warning to reflect this.
|
|
|
|
| |
Vertically align some components of an 'if' for readability.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
C++11 requires space between the end of a string literal and a macro, so
that a feature can unambiguously be added to the language. Starting in
g++ 6.2, the compiler emits a warning when there isn't a space
(presumably so that future versions can support C++11). Unfortunately
there are many such instances in the perl core. This commit fixes
those, including those in ext/, but individual commits will be used for
the other modules, those in dist/ and cpan/.
This commit also inserts space at the end of a macro before a string
literal, even though that is not deprecated, and removes useless ""
literals following a macro (instead of inserting a blank). The result
is easier to read, making the macro stand out, and be clearer as to the
intention.
Code and modules included with the Perl core need to be compilable using
C++. This is so that perl can be embedded in C++ programs. (Actually,
only the hdr files need to be so compilable, but it would be hard to
test that just the hdrs are compilable.) So we need to accommodate
changes to the C++ language.
|
|
|
|
|
| |
This brings the error messages in line with the ones used for normal
method calls, despite not using call_method().
|
|
|
|
| |
as they should be for deprecation warnings
|
|
|
|
|
| |
chdir with no argument didn't ensure there was stack space available
for its result.
|
| |
|
|
|
|
|
|
|
|
| |
This encodes a simple pattern that may not be immediately obvious to
someone needing it. If you have a fixed-size buffer that is full of
purportedly UTF-8 bytes, is it valid or not? It's easy to do, as shown
in this commit. The file test operators -T and -B can be simpified by
using this function.
|
|
|
|
|
|
|
|
| |
This new function can be used in the implementation of the file test
operators, -B and -T, to see if the whole fixed length buffer is valid
UTF-8. Previously if all bytes were UTF-8 except the bytes at the end
that could have been a partial character, it assumed the whole thing was
UTF-8. This improves the prediction slightly
|
|
|
|
|
|
| |
This changes the places in the core to use the clearer synonym added by
the previous commit. It also changes one place that hand-rolled its own
code to use this function instead.
|
|
|
|
|
|
|
| |
Specifically in the S_space_join_names_mortal static function that
several pp functions call. On some platforms (such as Gentoo Linux
with torsocks), hent->h_aliases (where hent is a struct hostent *) may
be null after a gethostent call.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The value of gimme stored in the context stack is U8.
Make all other uses in the main core consistent with this.
My primary motivation on this was that the new function cx_pushblock(),
which I gave a 'U8 gimme' parameter, was generating warnings where callers
were passing I32 gimme vars to it. Rather than play whack-a-mole, it
seemed simpler to just uniformly use U8 everywhere.
Porting/bench.pl shows a consistent reduction of about 2 instructions on
the loop and sub benchmarks, so this change isn't harming performance.
|
|
|
|
|
|
| |
Replace CX_PUSHFORMAT() with cx_pushformat() etc.
No functional changes.
|
|
|
|
|
|
| |
Replace CX_PUSHBLOCK() with cx_pushblock() etc.
No functional changes.
|
|
|
|
|
|
|
| |
Earlier all the POPFOO macros were renamed to CX_POPFOO to reflect
the changed API (like POPBLOCK no longer decremented cxstack_ix).
Now rename the PUSH ones for consistency.
|
|
|
|
|
| |
Make cv and gv explicit parameters of PUSHFORMAT(), rather than just
assuming that there are such vars in scope.
|
|
|
|
|
| |
Make gimme a parameter of PUSHBLOCK() rather than just assuming that
there's a 'gimme' var in scope.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently blku_oldsaveix was being set by the various PUSHFOO macros,
except for PUSHSUB and PUSHEVAL which expected their caller to do it
manually.
Now that all the main context state is stored on the context stack
rather than than some on the save stack too, things are a lot simpler,
and this messy transitional state can now be rationalised, whereby
blku_oldsaveix is now always set by PUSHBLOCK; the exact value being
specified by a new arg to PUSHBLOCK.
|
|
|
|
|
|
|
|
| |
This macro is defined as NOOP on all platforms except for MacOS classic,
where it was added as a hook to allow for OSes that have a small CPU
stack size. Since pp_entersub et al don't actually use the CPU stack,
this hook looks misconceived from the beginning. So remove all
uses of it in the core.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Rename all the context-popping macros such as POPBLOCK and POPSUB, by
giving them a CX_ prefix. (Do TOPBLOCK too).
This is principally to deliberately break any existing non-core use of
these non-API macros, as their behaviour has changed in this branch.
In particular, POPBLOCK(cx) no longer decrements the cxt stack pointer
nor sets cx; instead, cx is now expected to already point to the stack
frame which POPBLOCK should process.
At the same time, giving them a CX_ prefix makes it clearer that these
are all part of a family of macros that manipulate the context stack.
The PUSHFOO() macros will be renamed in a later commit.
|
|
|
|
|
|
| |
This is simply
#define CX_CUR() (&cxstack[cxstack_ix])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In code like
sub DESTROY { exit }
sub f { push @_, bless [] }
f()
While leaving f, POPSUB will attempt to clear @_. This triggers the
destructor, which calls exit, which unwinds the context stack, calling
POPSUB again on thr same context stack entry.
Thus we need to to be careful that POPSUB can be called multiple times
on the same CX stack entry.
The general way of doing this is to NULL or update pointers *before*
calling SvREFCNT_dec() on the old value.
This commit also removes the old CxPOPSUB_DONE mechanism which was a poor
bandaid added at the last minute to 5.22 to try and achieve the basics
of what this commit does comprehensively (hopefully). Also, CxPOPSUB_DONE
was mainly a protection against re-entrantly calling LEAVE_SCOPE(). Since
that's now done before POPSUB rather than in the middle of it, it has
become reentrant-safe by default.
|
|
|
|
| |
but with extra checking goodness on debugging builds.
|
|
|
|
|
|
|
|
|
|
| |
Currently every POPFOO macro has CX_LEAVE_SCOPE(cx) as its first action.
Since this is common code and not specific to a particular POPFOO type,
remove it from each POPFOO macro and make each caller of POPFOO explicitly
call CX_LEAVE_SCOPE() instead.
This should make no functional difference (but will help if you're
single-stepping the code in a debugger :-)
|
|
|
|
|
|
|
| |
Since all core usage of POPBLOCK now immediately restores PL_curpm,
there's no need to copy the old value to a temp var specified by the
caller; just make POPBLOCK itself restore PL_curpm in the same way that
it restores all the other PL_ vars.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently most pp_leavefoo subs have something along the lines of
POPBLOCK(cx);
POPFOO(cx);
where POPBLOCK does cxstack_ix-- and sets cx to point to the top CX stack
entry. It then restores a bunch of PL_ vars saved in the CX struct.
Then POPFOO does any type-specific restoration, e.g. POPSUB decrements the
ref count of the cv that was just executed.
However, this is logically the wrong order. When we *enter* a scope, we do
PUSHBLOCK;
PUSHFOO;
so undoing the PUSHBLOCK should be the last thing we do. As it happens,
it doesn't really make any difference to the running, which is why we've
never fixed it before.
Reordering it has two advantages.
First, it allows the steps for scope exit to be the exact logical reverse
of scope exit, which makes understanding what's going on and debugging
easier.
It allows us to make the code cleaner.
This commit also removes the cxstack_ix-- and setting cx steps from
POPBLOCK; now we already expect cx to be set (which it usually already is)
and we do the cxstack_ix-- ourselves. This also means we can remove a
whole bunch of cxstack_ix++'s that were added immediately after the
POPBLOCK in order to prevent the context being inadvertently overwritten
before we've finished using it.
So in full,
POPBLOCK(cx);
POPFOO(cx);
is now implemented as:
cx = &cxstack[cxstack_ix];
... other stuff done with cx ...
POPFOO(cx);
POPBLOCK(cx);
cxstack_ix--;
Finally, this commit also tweaks PL_curcop in pp_leaveeval, since
otherwise PL_curcop could temporarily be NULL when debugging code is
called in the presence of 'use re Debug'. It also stops the debugging code
crashing if PL_curcop is still NULL.
|
|
|
|
|
|
| |
This macro used to set these two vars as a side-effect.
Since we now usually access those values before we call POPBLOCK,
it's wasteful to set them again.
|
|
|
|
|
|
| |
To match the recent work in this branch on CXt_SUB, make CXt_FORMAT save
PL_savestack_ix and PL_tmps_floor in the context structure rather than
doing ENTER/SAVETMPS. It's more efficient and more consistent.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently when we call a sub, the old value of PL_comppad is
saved on the save stack using SAVECOMPPAD(). Instead, save it in
a new field in the context struct, called prevcomppad. This is simpler
and more efficient.
Note that there is already a confusingly-named field in the CXt_SUB
context struct called oldcomppad, which holds the value of PL_comppad for
the *current* sub, not for its caller. So the new field had to be called
something else.
One side effect of this is that an existing bug - which causes too much
to be popped off the savestack when dieing while leaving a sub scope - is
now more noticeable, since PL_curpad and SAVEt_CLEARSV are now out of
sync: formerly, the unwinding of the save stack restored PL_curpad in
lockstep. The fix for this will come later in this branch, when the whole
issue of context stack popping order and reentrancy is addressed; for
now, a TODO test has been added.
|
|
|
|
|
|
| |
GvIOn() already performs the checks and produces a nice error message,
and similar functions, such as open() and socket(), don't have
assertions on this condition.
|
|
|
|
| |
The warning is harmless but annoying
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Perl_nextargv has to have access to the Stat_t that is written to inside
S_openn_cleanup or else run/switches.t, io/argv.t, io/inplace.t, and
io/iprefix.t will fail. Removing the uses of PL_statbuf that are using
PL_statbuf due to historical reason, and not using PL_statbuf to pass data
between different funcs/different callstacks. This patch makes it easier to
remove PL_statbuf in the future since the number uses of it has been
reduced.
-in Perl_apply move SETERRNO before tot--; so the branch can be combined
with other "tot--;" branches by CC optmizer
-combine 2 Perl_croak(aTHX_ "Illegal suidscript"); statements in
S_validate_suid to make code look simpler, drop my_perl arg for space
efficiency on threads of rarely executed code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The previous commit made it clear that the N argument to EXTEND()
is supposed to be signed, in particular SSize_t, and now typically
triggers compiler warnings where this isn't the case.
This commit fixes the various places in core that passed the wrong sort of
N to EXTEND(). The fixes are in three broad categories.
First, where sensible, I've changed the relevant var to be SSize_t.
Second, where its expected that N could never be large enough to wrap,
I've just added an assert and a cast.
Finally, I've added extra code to detect whether the cast could
wrap/truncate, and if so set N to -1, which will trigger a panic in
stack_grow().
This also fixes
[perl #125937] 'x' operator on list causes segfault with possible
stack corruption
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Largely reimplements 839a9f02, 54fa14d7, e8432c63, 40262ff4.
The upside is that now doio.c and pp_sys.c have much less AmigaOS
specific ifdefs. As a downside, the exec code is now forked (pun
only partially accidental.)
The earlier story regarding fork+exec, that the AmigaOS creating
thread doesn't terminate but instead continues running is both true
and false. The more detailed story is that the user-observable
behaviour is as with POSIX/UNIX. The thread that created the new
"task" (to use the AmigaOS terms) does hang around -- but all it
does is to wait for the new task to terminate, and more importantly,
it holds on to the resources like filehandles. If the task were to
immediately terminate, the resources would be reclaimed by the kernel.
|
| |
|
| |
|
| |
|
|
|
|
| |
Removes 'the' in front of parameter names in some instances.
|
|
|
|
|
|
|
|
| |
This may break places which have the FD_CLOEXEC functionality
but do not have the FD_CLOEXEC define.
In any case, using a boolean for the F_SETFD flag is icky.
Using an explicit 1 is also dubious.
|
| |
|
| |
|
| |
|
| |
|