| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
To avoid having to create deferred elements every time a sparse array
is pushed on to the stack, store a magic scalar in the array itself,
which av_exists and refto recognise as not existing.
This means there is only a one-time cost for putting such arrays on
the stack.
It also means that deferred elements that live long enough don’t
start pointing to the wrong array entry if the array gets shifted (or
unshifted/spliced) in the mean time. Instead, the scalar is already
in the array, so it cannot lose its place. This fix only applies
when the array as a whole is pushed on to the stack, but it could be
extended in future commits to apply to other places where we currently
use deferred elements.
|
|
|
|
|
| |
require calls now require ./ to be prepended to the file since . is no
longer guaranteed to be in @INC.
|
| |
|
|
|
|
| |
It is no longer in use, as of two commits ago.
|
|
|
|
|
| |
Perl cannot know whether the magic will modify the SV, so it should
give the benefit of the doubt.
|
|
|
|
|
| |
Also correct the description of lvref magic. When it was first added,
it was for list assignments only, but that soon changed.
|
| |
|
|
|
|
|
| |
I just couldn’t resist using the backslash for the character, even
though I had to tweak mg_vtable.pl to make it work.
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When a scalar is returned from (??{...}) inside a regexp, it gets com-
piled into a regexp if it is not one already. Then the regexp is sup-
posed to be cached on that scalar (in magic), so that the same scalar
returned again will not require another compilation.
Commit e4bfbed39b disabled caching except on references to overloaded
objects. But in that one case the caching caused erroneous behaviour,
which was just fixed by 636209429f and this commit’s parent, effect-
ively disabling the cache altogether.
The cache is disabled because it does not apply to TEMP variables
(those about to be freed anyway, for which caching would be a waste
of CPU), and all non-overloaded non-qr thingies get copied into
new mortal (TEMP) scalars (as of e4bfbed39b) before reaching the
caching code.
This commit skips the copy if the return value is already a non-magi-
cal string or number. It also allows the caching to happen on con-
stants, which has never been permitted before. (There is actually no
reason for disallowing qr magic on read-only variables.)
|
|
|
|
|
|
| |
See this p5p thread for more details
<20121218144018.GQ1842@iabyn.com>
|
|
|
|
|
|
|
|
|
| |
It is not possible to know how to interpret the returned length
without accessing the UTF8 flag, which is not reliable until
the SV has been stringified, which requires get-magic. So length
magic has not made senses since utf8 support was added. I have
removed all uses of length magic from the core, so this is now
dead code.
|
|
|
|
|
|
| |
fm magic uses want_vtbl_fm, which is #defined as want_vtbl_regexp.
The definition in regen/mg_vtable.pl does not affect anything except
the documentation. It was listed as using regdata which was wrong.
|
|
|
|
|
|
|
|
| |
This will be used for storing the prototype CV of a ‘my’ sub. The
clone needs to occupy the pad entry so that padcv ops will be able to
find it. That means the clone has to displace its prototype. In case
the same sub is called recursively, we still need to be able to access
the prototype.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A substitution forces its target to a string upon successful substitu-
tion, even if the substitution did nothing:
$ ./perl -Ilib -le '$a = *f; $a =~ s/f/f/; print ref \$a'
SCALAR
Notice that $a is no longer a glob after s///.
But vstrings are different:
$ ./perl -Ilib -le '$a = v102; $a =~ s/f/f/; print ref \$a'
VSTRING
I fixed this in 5.16 (1e6bda93) for those cases where the vstring ends
up with a value that doesn’t correspond to the actual string:
$ ./perl -Ilib -le '$a = v102; $a =~ s/f/o/; print ref \$a'
SCALAR
It works through vstring set-magic, that does the check and removes
the magic if it doesn’t match.
I did it that way because I couldn’t think of any other way to fix
bug #29070, and I didn’t realise at the time that I hadn’t fixed
all the bugs.
By making SvTHINKFIRST true on a vstring, we force it through
sv_force_normal before any in-place string operations. We can also
make sv_force_normal handle vstrings as well. This fixes all the lin-
gering-vstring-magic bugs in just two lines, making the vstring set-
magic (which is also slow) redundant. It also allows the special case
in sv_setsv_flags to be removed.
Or at least that was what I had hoped.
It turns out that pp_subst, twists and turns in tortuous ways, and
needs special treatment for things like this.
And do_trans functions wasn’t checking SvTHINKFIRST when arguably it
should have.
I tweaked sv_2pv{utf8,byte} to avoid copying magic variables that do
not need copying.
|
| |
|
|
|
|
| |
This fixes RT #75596.
|
|
|
|
| |
I’m running out of synonyms for ‘remove’.
|
|
|
|
|
|
|
|
|
| |
How ironic! Overloading is called ‘A’ magic internally all over the
place, because of the letter used as its magic type. But now it does
not even use that magic.
I left a comment in mg_vtable.pl, so that future maintainers will have
some clue as to what AMAGIC means.
|
|
|
|
|
| |
Otherwise cv_set_call_checker has no effect inside an attribute han-
dler for a closure.
|
| |
|
|
|
|
|
|
|
| |
regen/mg_vtable.pl was modified a while ago to generate the table
for copying and pasting, but at least twice since then it has not
been updated properly; once by me and once by the author of that
part of regen/mg_vtable.pl.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Some operators, like pp_complement, assign their argument to TARG
(which copies vstring magic), modify it in place, and then call set-
magic. That’s supposed to work, but vstring magic was remaining as it
was, such that ~v7 would still be treated as "v7" by vstring-aware
code, even though the resulting string is not "\7".
This commit adds vstring set-magic that checks to see whether the pv
still matches the vstring. It cannot simply free the vstring magic,
as that would prevent $x=v0 from working.
|
|
|
|
|
|
| |
study uses magic to call SvSCREAM_off() if the scalar is modified. Allocate it
its own magic type ('G' for now - pos magic is 'g'). Share the same "set"
routine and vtable as regexp/bm/fm (setregxp and vtbl_regexp).
|
|
|
|
|
|
|
|
|
| |
This fixes a regression introduced after 5.14.0.
Commit 6f83ef0e5a4 got dbfile and dbline magic mixed up and ended up
apply set-magic to the hash (dbfile), not to the element (dbline).
The result was that debugger breakpoints simply did not work at all.
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes a couple of errors and omissions, and resorts the table in the same
case insensitive order as the header files. It eliminates 1 overlong verbatim
line of pod.
As there's no good way to include component files into the core pods, and the
regen scripts aren't designed to modify in place, generate this to STDOUT (if
-g is added to the command line), to be hand edited into place. It would be
nice to be able to automate this fully.
|
| |
|
|
|
|
|
| |
Magic is sorted case insensitively, with upper case before lower case.
vtable names are all lowercase letters.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Use this to simplify the logic in Perl_sv_magic().
This introduces a small change of behaviour for error cases involving unknown
magic types. Previously, if Perl_sv_magic() was passed a magic type unknown to
it, it would
1: Croak "Modification of a read-only value attempted" if read only
2: Return without error if the SV happened to already have this magic
3: otherwise croak "Don't know how to handle magic of type \\%o"
Now it will always croak "Don't know how to handle magic of type \\%o", even
on read only values, or SVs which already have the unknown magic type.
|
|
|
|
| |
Use this to replace S_is_container_magic() in mg.c with a direct lookup.
|
|
|
|
|
|
|
|
|
|
|
| |
Use it to eliminate the large switch statement in Perl_sv_magic().
As the table needs to be keyed on magic type, which is expressed as C character
constants, the order depends on the compiler's character set. Frustratingly,
EBCDIC variants don't agree on the code points for '~' and ']', which we use
here. Instead of having (at least) 4 tables, get the local runtime to sort the
table for us. Hence the regen script writes out the (unsorted) mg_raw.h, which
generate_uudmap sorts to generate mg_data.h
|
|
|
|
|
|
| |
As it's a 1 to 1 mapping with the vtables in PL_magic_vtables[], refactor
Perl_do_magic_dump() to index into it directly to find the name for an
arbitrary mg_virtual, avoiding a long switch statement.
|
|
|
|
|
| |
Also, in Perl_sv_magic() merge the case for PERL_MAGIC_dbfile with the others
that return a NULL vtable.
|
|
|
|
|
| |
They became copies in 488344d27a84a21a, which merged Perl_magic_setbm() and
Perl_magic_setfm() into Perl_magic_setregexp().
|
|
|
|
| |
Provide magic_vtable_max, the number of elements in PL_magic_vtables[].
|
|
|
|
|
|
| |
Define each PL_vtbl_* name as a macro which expands to the correct array
element. Using a single array instead of multiple named variables will allow
the simplification of various pieces of code.
|
| |
|
|
|
|
|
|
| |
Generating mg_vtable.h with MGVTBL_SET() effectively pre-expanded makes things
clearer. This eliminates use of the macro MGVTBL_SET(), which can be deleted
as nothing outside the core is relying on it.
|
|
|
|
|
|
| |
Putting the cast inside the initialiser (the only initialiser using it)
eliminates use of the macro MGVTBL_SET_CONST_MAGIC_GET(), which can be deleted
as nothing outside the core is relying on it.
|
|
Previously perl.h contained a long section of MGVTBL_SET() macros declaring
the core's various magic vtables. Convert the information into data structures
in a new script regen/mg_table.pl, and use this to generate a new file
mg_vtable.h, included by perl.h
This is the first step in reducing the number of places that data relating to
magic vtables is declared (and has to be kept in sync), and will allow more
flexibility in parts of the core's implementation.
|