[Perl/perl5]

2022-07-30 Thread James E Keenan via perl5-changes
  Branch: refs/heads/leont/cv_method_off
  Home:   https://github.com/Perl/perl5


[Perl/perl5] ff5bbe: Fix typo in CvMETHOD_off definition

2022-07-30 Thread Leon Timmermans via perl5-changes
  Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: ff5bbe677ed155d1e571d4175ba86925b353173e
  
https://github.com/Perl/perl5/commit/ff5bbe677ed155d1e571d4175ba86925b353173e
  Author: Leon Timmermans 
  Date:   2022-07-30 (Sat, 30 Jul 2022)

  Changed paths:
M cv.h

  Log Message:
  ---
  Fix typo in CvMETHOD_off definition

The definition uses the wrong name for the argument (off instead of cv), and
therefore causes compilation failures.




[Perl/perl5] f6be34: Add PERL_MAGIC_value

2022-07-30 Thread Leon Timmermans via perl5-changes
  Branch: refs/heads/leont/value_magic
  Home:   https://github.com/Perl/perl5
  Commit: f6be3435594ebf5b137b5ff500a99e562262bc37
  
https://github.com/Perl/perl5/commit/f6be3435594ebf5b137b5ff500a99e562262bc37
  Author: Leon Timmermans 
  Date:   2022-07-30 (Sat, 30 Jul 2022)

  Changed paths:
M mg_names.inc
M mg_raw.h
M mg_vtable.h
M pod/perldelta.pod
M pod/perlguts.pod
M regen/mg_vtable.pl

  Log Message:
  ---
  Add PERL_MAGIC_value

A new magic type PERL_MAGIC_value has been added. This is available for
use like PERL_MAGIC_ext, but is a value magic: upon localization the new
value will not be magical.




[Perl/perl5] 941dfc: Fix typo in CvMETHOD_off definition

2022-07-30 Thread Leon Timmermans via perl5-changes
  Branch: refs/heads/leont/cv_method_off
  Home:   https://github.com/Perl/perl5
  Commit: 941dfc7e259a3a1e4d023c2cd90c1805a9a6d62f
  
https://github.com/Perl/perl5/commit/941dfc7e259a3a1e4d023c2cd90c1805a9a6d62f
  Author: Leon Timmermans 
  Date:   2022-07-30 (Sat, 30 Jul 2022)

  Changed paths:
M cv.h

  Log Message:
  ---
  Fix typo in CvMETHOD_off definition

The definition uses the wrong name for the argument (off instead of cv), and
therefore causes compilation failures.




[Perl/perl5] f8115e: regen/mk_invlists.pl - under DEBUG=1 show some pro...

2022-07-30 Thread Yves Orton via perl5-changes
  Branch: refs/heads/yves/regnode_typedefs
  Home:   https://github.com/Perl/perl5
  Commit: f8115e7402b31e49afff9e7bfb410a21f57b520b
  
https://github.com/Perl/perl5/commit/f8115e7402b31e49afff9e7bfb410a21f57b520b
  Author: Yves Orton 
  Date:   2022-07-30 (Sat, 30 Jul 2022)

  Changed paths:
M charclass_invlists.h
M lib/unicore/uni_keywords.pl
M regen/mk_invlists.pl
M uni_keywords.h

  Log Message:
  ---
  regen/mk_invlists.pl - under DEBUG=1 show some progress output


  Commit: cbe03f6d6f8975cf0446bac200218dbfb5fc956b
  
https://github.com/Perl/perl5/commit/cbe03f6d6f8975cf0446bac200218dbfb5fc956b
  Author: Yves Orton 
  Date:   2022-07-30 (Sat, 30 Jul 2022)

  Changed paths:
M regcomp.c

  Log Message:
  ---
  regcomp.c - replace repeated OP(n) with variable 'op'.

Declutter code.


  Commit: f252facc66068f0cb5e599d346f13add25072a7b
  
https://github.com/Perl/perl5/commit/f252facc66068f0cb5e599d346f13add25072a7b
  Author: Yves Orton 
  Date:   2022-07-30 (Sat, 30 Jul 2022)

  Changed paths:
M regcomp.c

  Log Message:
  ---
  regcomp.c - replace OP(n) macro with variable 'op' in S_dumpuntil()

Declutters the code and allows us to remove the casting as well.

As a byproduct the loop control logic is a bit simplified.


  Commit: 47a9bef26d64bd655a8b446ef69e29df23bd3543
  
https://github.com/Perl/perl5/commit/47a9bef26d64bd655a8b446ef69e29df23bd3543
  Author: Yves Orton 
  Date:   2022-07-30 (Sat, 30 Jul 2022)

  Changed paths:
M globvar.sym
M pod/perlreguts.pod
M regcomp.c
M regcomp.h
M regen/regcomp.pl
M regnodes.h

  Log Message:
  ---
  regen/regcomp.pl - Make regarglen available as PL_regarglen in regexec.c

In a follow up patch we will use this data from regexec.c which
currently cannot see the variable.

This changes a comment in regen/mk_invlists.pl which necessitated
rebuilding several files related to unicode. Only the hashes associated
with mk_invlists.pl were changed.


  Commit: 6009a0858508a895dfae715aae030c943380877c
  
https://github.com/Perl/perl5/commit/6009a0858508a895dfae715aae030c943380877c
  Author: Yves Orton 
  Date:   2022-07-30 (Sat, 30 Jul 2022)

  Changed paths:
M regen/regcomp.pl
M regnodes.h

  Log Message:
  ---
  regen/regcomp.pl - create typedefs for all regnode types

Currently we hard code the struct used by the different regop types.
This makes it awkward to change the structure used by a specific regop
as the struct it uses might be used in many contexts, and each cases
of a regop using that structure must be reviewed to see if it needs
to be changed.

This patch adds a typedef for each regnode. The typedefs are named
'tregnode_OP', for instance 'tregnode_TRIE' is typedefed to 'struct
charclass' (at the time of this commit). This allows the code to do
things like 'sizeof(tregnode_TRIE)' and should the exact struct used
for TRIE regops change in the future then no code need be reviewed
or changed.


  Commit: 66881d4016b4e39224906535c269602ce9769ac4
  
https://github.com/Perl/perl5/commit/66881d4016b4e39224906535c269602ce9769ac4
  Author: Yves Orton 
  Date:   2022-07-30 (Sat, 30 Jul 2022)

  Changed paths:
M dist/Devel-PPPort/parts/base/5003007
M embed.fnc
M embed.h
M pod/perlreguts.pod
M proto.h
M regcomp.c
M regcomp.h
M regexec.c

  Log Message:
  ---
  regcomp.c - rename NEXTOPER to REGNODE_AFTER and related logic

It is really easy to get confused about the difference between
NEXTOPER() and regnext() of a regnode. The two concepts are related,
similar, but importantly distinct. NEXTOPER() is also defined in such a
way that it is easy to abuse and misunderstand and encourages producing
code that is fragile to larger change, effectively "baking in"
assumptions to the code that are difficult to discover by searching.
Changing the type and storage requirements of a regnode may break things
in subtle and hard to debug ways.

An example of how NEXTOPER() is problematic is that this:
NEXTOPER(NEXTOPER(branch)) does not mean "find the second node after the
branch node", it means "jump forward by a regnode which happens to be
two regnodes large". In other words NEXTOPER is just a fancy way of
writing "node+1".

This patch replaces NEXTOPER() with three new macros:

REGNODE_AFTER_dynamic(node)
REGNODE_AFTER_opcode(node,op)
REGNODE_AFTER_type(node,tregnode_OPNAME)

The first is the most generic case, it jumps forward by the size of the
node, and determines that size by consulting OP(node). The second is
where you have already extracted OP(node), and the third is where you
know the actual structure that you want to jump forward by. Every
regnode type has a corresponding type, which is known at compile time,
so using the third will produce the most efficient code. However in many
cases the code operates on one of several types, whose size may be the
same now, but may change in the future, in which case one 

[Perl/perl5] c3489c: Add PERL_MAGIC_value

2022-07-30 Thread Leon Timmermans via perl5-changes
  Branch: refs/heads/leont/value_magic
  Home:   https://github.com/Perl/perl5
  Commit: c3489cda7605cac42fd2683a2a798cf54fbe1198
  
https://github.com/Perl/perl5/commit/c3489cda7605cac42fd2683a2a798cf54fbe1198
  Author: Leon Timmermans 
  Date:   2022-07-30 (Sat, 30 Jul 2022)

  Changed paths:
M mg_names.inc
M mg_raw.h
M mg_vtable.h
M pod/perldelta.pod
M pod/perlguts.pod
M regen/mg_vtable.pl

  Log Message:
  ---
  Add PERL_MAGIC_value

A new magic type PERL_MAGIC_value has been added. This is available for
use like PERL_MAGIC_ext, but is a value magic: upon localization the new
value will not be magical.




[Perl/perl5] 450dff: Add PERL_MAGIC_value

2022-07-30 Thread Leon Timmermans via perl5-changes
  Branch: refs/heads/leont/value_magic
  Home:   https://github.com/Perl/perl5
  Commit: 450dff1cc2e761d5e89748a280d08d8f3e2a8fc5
  
https://github.com/Perl/perl5/commit/450dff1cc2e761d5e89748a280d08d8f3e2a8fc5
  Author: Leon Timmermans 
  Date:   2022-07-30 (Sat, 30 Jul 2022)

  Changed paths:
M mg_names.inc
M mg_raw.h
M mg_vtable.h
M pod/perldelta.pod
M pod/perlguts.pod
M regen/mg_vtable.pl

  Log Message:
  ---
  Add PERL_MAGIC_value

A new magic type C has been added. This is available
for use like C, but is a value magic: upon localization
the new value will not be magical.




[Perl/perl5] 1753a6: Allow binary and hex "digit" vars, and explicit oc...

2022-07-30 Thread Yves Orton via perl5-changes
  Branch: refs/heads/yves/hex_oct_digit_vars
  Home:   https://github.com/Perl/perl5
  Commit: 1753a64dfe1bc135f45981efdbf023b33c689cce
  
https://github.com/Perl/perl5/commit/1753a64dfe1bc135f45981efdbf023b33c689cce
  Author: Yves Orton 
  Date:   2022-07-30 (Sat, 30 Jul 2022)

  Changed paths:
M t/comp/parser_run.t
M t/re/pat.t
M toke.c

  Log Message:
  ---
  Allow binary and hex "digit" vars, and explicit octal under strict

Prior to this patch ${0x10} would require "no strict refs", with this patch
it is a legal alternative spelling for $16, likewise with ${0b1},
and explicit octal (eg, with 0o prefix) as well. Note that ${0x010} and
${0b0001} and similar are also allowed and will both also map to $16.

Since these values are constant it seems reasonable to treat them like
their decimal equivalents. Note that $0x10 does not work as one might
think, it parses as $0 x 10, only ${0x10} is allowed, similarly
$0b10 is forbidden, but ${0b10} is not. Note that $::0x10 and $::0b10
are NOT digits vars equivalent to $16 and $2, but rather $main::0x10
and $main::0b10.




[Perl/perl5] 2f856a: Fix assorted bugs related to not having a UNIVERSA...

2022-07-30 Thread Yves Orton via perl5-changes
  Branch: refs/heads/yves/fix_universal_import_fragility
  Home:   https://github.com/Perl/perl5
  Commit: 2f856ad101c4c6dd680b1c26847d56d090e7c7bf
  
https://github.com/Perl/perl5/commit/2f856ad101c4c6dd680b1c26847d56d090e7c7bf
  Author: Yves Orton 
  Date:   2022-07-30 (Sat, 30 Jul 2022)

  Changed paths:
M gv.c
M lib/UNIVERSAL.pm
M t/op/universal.t
M universal.c

  Log Message:
  ---
  Fix assorted bugs related to not having a UNIVERSAL::import

Since perl 5.0 the methods "import" and "unimport" have been
special cased in gv.c (unimport was removed for a while) to
not produce errors if they are called. This is partly
because

use Foo;

is defined to be

BEGIN {
require Foo;
Foo->import();
}

which would blow up if there is no import function defined in
Foo, for instance if it were defining a class and not a package
which exports modules.

This special case can be broken by simple code like

\::isa

which will create a stub function which then blows up when it is
used. Notably the module "autouse" which is shipped with perl will
trigger this behavior.

A related issue is that if you ask for a function to be exported
from a module that does not have support for exporting there is no
error, eg:

use File::Spec qw(catfile);

will silently succeed without exporting a catfile function. This is
exacerbated on case insensitive file systems when the module name
is case-mismatched, the use succeeds but the export does not, leading
to confusion, eg:

use LIst::Util qw(sum);

will load List::Util but will not export the sum function.

This patch defines UNIVERSAL::import() and UNIVERSAL::unimport()
functions. This prevents the "reference to \::import" bug.
The function is defined to be a no-op unless arguments are passed into
the functions, in which case a fatal exception is thrown indicating
that there is likely a problem. The error is modelled after the
error produced by calling a non-existent method or function:

./perl -Ilib -le'BEGIN{ my $import_sub= \::import;}
use File::Spec qw(catfile);'
Attempt to call UNIVERSAL::import() with arguments via package File::Spec
(Perhaps you forgot to load "File::Spec"?) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

This fixes Issue #19416, Issue #19417, Issue #19418. See also Issue #19410 for
discussion, however this patch does not fix that case (it may not be
fixable.)




[Perl/perl5] c432f9: toke.c - consistently refuse octal digit vars, and...

2022-07-30 Thread Yves Orton via perl5-changes
  Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: c432f9f481035e7fd99dbaa182996c34f312fc9d
  
https://github.com/Perl/perl5/commit/c432f9f481035e7fd99dbaa182996c34f312fc9d
  Author: Yves Orton 
  Date:   2022-07-30 (Sat, 30 Jul 2022)

  Changed paths:
M t/comp/parser_run.t
M t/re/pat.t
M toke.c

  Log Message:
  ---
  toke.c - consistently refuse octal digit vars, and allow ${10} under strict.

Executive summary: in ${ .. } style notation consistently forbid octal
and allow multi-digit longer decimal values under strict. The vars
${1} through ${9} have always been allowed under strict, but ${10} threw
an error unlike its equivalent variable $10.

In 60267e1d0e12bb5bdc88c62a18294336ab03d4b8 I patched toke.c to refuse
octal like $001 but did not properly handle ${001} and related cases when
the code was under 'use utf8'. Part of the reason was the confusing macro
VALID_LEN_ONE_IDENT() which despite its name does not restrict what it
matches to things which are one character long.

Since the VALID_LEN_ONE_IDENT() macro is used in only one place and its
name and placement is confusing I have moved it back into the code
inline as part of this fix. I have also added more comments about what
is going on, and moved the related comment directly next to the code
that it affects. If it moved out of this code then we should think of a
better name and be more careful and clear about checking things like
length. I would argue the logic is used to parse what might be called a
variable "description", and thus it is not identical to code which might
validate an actual parsed variable name. Eg, ${^Var} is a description of
the variable whose "name" is "\026ar". The exception of course is $^
whose name actually is "^".

This includes more tests for allowed vars and forbidden var names.

See Issue #12948, Issue #19986, and Issue #19989.