[perl.git] branch blead updated. v5.27.6-189-gd269f586dd

2017-12-10 Thread Father Chrysostomos
In perl.git, the branch blead has been updated



- Log -
commit d269f586dd6705f80163f642c0aa81f0e7a72bca
Author: Father Chrysostomos 
Date:   Sun Dec 10 20:25:59 2017 -0800

Declaration after statement in typemap

A follow-up to 6da090e6cb and 732d3893ab.

---

Summary of changes:
 dist/Time-HiRes/typemap | 2 +-
 lib/ExtUtils/typemap| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/dist/Time-HiRes/typemap b/dist/Time-HiRes/typemap
index 768e56a4f5..ffe60e3694 100644
--- a/dist/Time-HiRes/typemap
+++ b/dist/Time-HiRes/typemap
@@ -283,8 +283,8 @@ T_ARRAY
 T_STDIO
{
GV *gv = (GV *)sv_newmortal();
-   gv_init(gv, gv_stashpv("$Package",1),"__ANONIO__",10,0);
PerlIO *fp = PerlIO_importFILE($var,0);
+   gv_init(gv, gv_stashpv("$Package",1),"__ANONIO__",10,0);
if ( fp && do_open(gv, "+<&", 3, FALSE, 0, 0, fp) )
sv_setsv($arg, sv_bless(newRV((SV*)gv), 
gv_stashpv("$Package",1)));
else
diff --git a/lib/ExtUtils/typemap b/lib/ExtUtils/typemap
index ca923cf67b..db700b75bf 100644
--- a/lib/ExtUtils/typemap
+++ b/lib/ExtUtils/typemap
@@ -399,8 +399,8 @@ T_ARRAY
 T_STDIO
{
GV *gv = (GV *)sv_newmortal();
-   gv_init_pvn(gv, gv_stashpvs("$Package",1),"__ANONIO__",10,0);
PerlIO *fp = PerlIO_importFILE($var,0);
+   gv_init_pvn(gv, gv_stashpvs("$Package",1),"__ANONIO__",10,0);
if ( fp && do_open(gv, "+<&", 3, FALSE, 0, 0, fp) ) {
SV *rv = newRV_inc((SV*)gv);
rv = sv_bless(rv, GvSTASH(gv));

-- 
Perl5 Master Repository


[perl.git] branch blead updated. v5.27.6-188-g244d268258

2017-12-10 Thread Father Chrysostomos
In perl.git, the branch blead has been updated



- Log -
commit 244d26825825c6a1d5bc181e6da699d48bcb51a4
Author: Father Chrysostomos 
Date:   Sun Dec 10 17:13:17 2017 -0800

perldelta for #115814

db9848c8d3fb and 6da090e6cb.

commit 76eb84800b51f32ecd4ab68d15ca549f2f67721b
Author: Father Chrysostomos 
Date:   Sun Dec 10 16:54:44 2017 -0800

Increase $ExtUtils::Typemaps::VERSION to 3.37

commit 732d3893ab63739910640c98c1cc83ab7bb1332c
Author: Father Chrysostomos 
Date:   Sun Dec 10 16:53:45 2017 -0800

Avoid newGVgen in blead-upstream modules

ExtUtils::ParseXS::Typemaps:
Just in documentation, but it’s good to change it, in case peo-
ple copy it.

Time::HiRes:
It doesn’t even use these typemap entries, but I changed it in case
they get used in the future.  (The changes are not identical to the
default typemap, because Time::HiRes is 5.6-compatible, at least
nominally.)

os2/os2.c:
No, this is not a module, but I changed it, too.

Some other instances of newGVgen are already handled properly, or are
just in tests, so I left them alone.

commit 6da090e6cb9d18c5db3bb70c8c4d0c7e58183273
Author: Father Chrysostomos 
Date:   Sun Dec 10 16:37:11 2017 -0800

Avoid newGVgen in default typemap

newGVgen leaks memory, because it puts it vivifies a typeglob in the
symbol table, without arranging for it to be deleted.  A typemap is not
an appropriate place to use it, since callers of newGVgen are responsible
for seeing that the GV is freed, if they care.

This came up in #115814.

commit 463029d782557372dfee8afb1aa234047cc01247
Author: Father Chrysostomos 
Date:   Sun Dec 10 16:33:22 2017 -0800

perlapio: wrong param type

---

Summary of changes:
 dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps.pm |  6 --
 dist/Time-HiRes/typemap| 12 
 ext/XS-APItest/APItest.xs  | 14 ++
 lib/ExtUtils/typemap   | 12 
 os2/os2.c  |  3 ++-
 pod/perlapio.pod   |  2 +-
 pod/perldelta.pod  | 10 ++
 t/op/svleak.t  |  8 +++-
 8 files changed, 54 insertions(+), 13 deletions(-)

diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps.pm 
b/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps.pm
index d7a219e7fd..eae1190d1f 100644
--- a/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps.pm
+++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps.pm
@@ -2,7 +2,7 @@ package ExtUtils::Typemaps;
 use 5.006001;
 use strict;
 use warnings;
-our $VERSION = '3.36';
+our $VERSION = '3.37';
 
 require ExtUtils::ParseXS;
 require ExtUtils::ParseXS::Constants;
@@ -781,7 +781,9 @@ corresponding OUTPUT code:
 $var.context.value().size());
   ',
 'T_OUT' => '{
-GV *gv = newGVgen("$Package");
+GV *gv = (GV *)sv_newmortal();
+gv_init_pvn(gv, gv_stashpvs("$Package",1),
+   "__ANONIO__",10,0);
 if ( do_open(gv, "+>&", 3, FALSE, 0, 0, $var) )
 sv_setsv(
   $arg,
diff --git a/dist/Time-HiRes/typemap b/dist/Time-HiRes/typemap
index 3fa91f3a0b..768e56a4f5 100644
--- a/dist/Time-HiRes/typemap
+++ b/dist/Time-HiRes/typemap
@@ -282,7 +282,8 @@ T_ARRAY
 }
 T_STDIO
{
-   GV *gv = newGVgen("$Package");
+   GV *gv = (GV *)sv_newmortal();
+   gv_init(gv, gv_stashpv("$Package",1),"__ANONIO__",10,0);
PerlIO *fp = PerlIO_importFILE($var,0);
if ( fp && do_open(gv, "+<&", 3, FALSE, 0, 0, fp) )
sv_setsv($arg, sv_bless(newRV((SV*)gv), 
gv_stashpv("$Package",1)));
@@ -291,7 +292,8 @@ T_STDIO
}
 T_IN
{
-   GV *gv = newGVgen("$Package");
+   GV *gv = (GV *)sv_newmortal();
+   gv_init(gv, gv_stashpv("$Package",1),"__ANONIO__",10,0);
if ( do_open(gv, "<&", 2, FALSE, 0, 0, $var) )
sv_setsv($arg, sv_bless(newRV((SV*)gv), 
gv_stashpv("$Package",1)));
else
@@ -299,7 +301,8 @@ T_IN
}
 T_INOUT
{
-   GV *gv = newGVgen("$Package");
+   GV *gv = (GV *)sv_newmortal();
+   gv_init(gv, gv_stashpv("$Package",1),"__ANONIO__",10,0);
if ( do_open(gv, "+<&", 3, FALSE, 0, 0, $var) )
sv_setsv($arg, sv_bless(newRV((SV*)gv), 
gv_stashpv("$Package",1)));
else
@@ -307,7 +310,8 @@ T_INOUT
}
 T_OUT
{
-   GV *gv = newGVgen("$Package");
+   GV *gv 

[perl.git] branch blead updated. v5.27.6-183-gb5145c7d47

2017-12-10 Thread Zefram
In perl.git, the branch blead has been updated



- Log -
commit b5145c7d479fcfcb104fc6d3d89b4d757ca3cd15
Author: Zefram 
Date:   Mon Dec 11 00:28:43 2017 +

revise documentation about set-id

perlsec's section on set-id scripts was written confusingly, with several
half-formed references to the long-ago-deleted suidperl, and with temporal
references that are well out of date.  Revise that section, and slightly
expand the perldiag entry for the message about detecting a set-id script.
Add another section to perlsec about sudo.  Fixes [perl #74142].

---

Summary of changes:
 pod/perldiag.pod |  6 +++--
 pod/perlsec.pod  | 75 +---
 2 files changed, 59 insertions(+), 22 deletions(-)

diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index cfc8528be0..f813a87a89 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -7546,8 +7546,10 @@ the end of the string being unpacked.  See 
L.
 
 (F) And you probably never will, because you probably don't have the
 sources to your kernel, and your vendor probably doesn't give a rip
-about what you want.  Your best bet is to put a setuid C wrapper around
-your script.
+about what you want.  There is a vulnerability anywhere that you have a
+set-id script, and to close it you need to remove the set-id bit from
+the script that you're attempting to run.  To actually run the script
+set-id, your best bet is to put a set-id C wrapper around your script.
 
 =item You need to quote "%s"
 
diff --git a/pod/perlsec.pod b/pod/perlsec.pod
index ab126f753e..bf1c9b4974 100644
--- a/pod/perlsec.pod
+++ b/pod/perlsec.pod
@@ -370,7 +370,7 @@ abusing perl bugs to make the host interpreter crash or 
behave in
 unpredictable ways.  In any case it's better avoided completely if you're
 really concerned about security.
 
-=head2 Security Bugs
+=head2 Shebang Race Condition
 
 Beyond the obvious problems that stem from giving special privileges to
 systems as flexible as scripts, on many versions of Unix, set-id scripts
@@ -380,14 +380,34 @@ see which interpreter to run and when the (now-set-id) 
interpreter turns
 around and reopens the file to interpret it, the file in question may have
 changed, especially if you have symbolic links on your system.
 
-Fortunately, sometimes this kernel "feature" can be disabled.
-Unfortunately, there are two ways to disable it.  The system can simply
-outlaw scripts with any set-id bit set, which doesn't help much.
-Alternately, it can simply ignore the set-id bits on scripts.
+Some Unices, especially more recent ones, are free of this
+inherent security bug.  On such systems, when the kernel passes the name
+of the set-id script to open to the interpreter, rather than using a
+pathname subject to meddling, it instead passes I.  This is a
+special file already opened on the script, so that there can be no race
+condition for evil scripts to exploit.  On these systems, Perl should be
+compiled with C<-DSETUID_SCRIPTS_ARE_SECURE_NOW>.  The F
+program that builds Perl tries to figure this out for itself, so you
+should never have to specify this yourself.  Most modern releases of
+SysVr4 and BSD 4.4 use this approach to avoid the kernel race condition.
 
-However, if the kernel set-id script feature isn't disabled, Perl will
-complain loudly that your set-id script is insecure.  You'll need to
-either disable the kernel set-id script feature, or put a C wrapper around
+If you don't have the safe version of set-id scripts, all is not lost.
+Sometimes this kernel "feature" can be disabled, so that the kernel
+either doesn't run set-id scripts with the set-id or doesn't run them
+at all.  Either way avoids the exploitability of the race condition,
+but doesn't help in actually running scripts set-id.
+
+If the kernel set-id script feature isn't disabled, then any set-id
+script provides an exploitable vulnerability.  Perl can't avoid being
+exploitable, but will point out vulnerable scripts where it can.  If Perl
+detects that it is being applied to a set-id script then it will complain
+loudly that your set-id script is insecure, and won't run it.  When Perl
+complains, you need to remove the set-id bit from the script to eliminate
+the vulnerability.  Refusing to run the script doesn't in itself close
+the vulnerability; it is just Perl's way of encouraging you to do this.
+
+To actually run a script set-id, if you don't have the safe version of
+set-id scripts, you'll need to put a C wrapper around
 the script.  A C wrapper is just a compiled program that does nothing
 except call your Perl program.   Compiled programs are not subject to the
 kernel bug that plagues set-id scripts.  Here's a simple 

[perl.git] branch blead updated. v5.27.6-182-gcc85e83f9e

2017-12-10 Thread Zefram
In perl.git, the branch blead has been updated



- Log -
commit cc85e83f9e22c43fcb37b072c8d9d20a3e8d9a64
Author: Zefram 
Date:   Sun Dec 10 23:20:18 2017 +

assert well-formedness of argv in perl_parse()

---

Summary of changes:
 perl.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/perl.c b/perl.c
index c7673fc511..dabe45d42e 100644
--- a/perl.c
+++ b/perl.c
@@ -1693,6 +1693,13 @@ perl_parse(pTHXx_ XSINIT_t xsinit, int argc, char 
**argv, char **env)
 }
 #endif
 
+{
+   int i;
+   assert(argc >= 0);
+   for(i = 0; i != argc; i++)
+   assert(argv[i]);
+   assert(!argv[argc]);
+}
 PL_origargc = argc;
 PL_origargv = argv;
 

-- 
Perl5 Master Repository


[perl.git] branch blead updated. v5.27.6-181-g3b2fee47cd

2017-12-10 Thread Zefram
In perl.git, the branch blead has been updated



- Log -
commit 3b2fee47cdd823a304d1ec8183060c268f39c6d3
Author: Zefram 
Date:   Sun Dec 10 22:23:31 2017 +

remove incorrect doc para about exit from BEGIN

I misinterpreted the behaviour of exit from BEGIN when writing that
paragraph.  exit from BEGIN actually does cause perl_parse() to return
normally, but perl_run() wouldn't subsequently do anything.

---

Summary of changes:
 perl.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/perl.c b/perl.c
index 918854bb00..c7673fc511 100644
--- a/perl.c
+++ b/perl.c
@@ -1644,13 +1644,6 @@ zero exit code can be augmented with a set bit that will 
be ignored.
 In any case, this function is not the correct place to acquire an exit
 code: one should get that from L.
 
-In most cases, if something happens during initialisation and parsing
-that causes the Perl interpreter to want to exit, this will cause this
-function to return normally with a non-zero return value.  Historically,
-a call to the Perl built-in function C from inside a C
-block has been an exception, causing the process to actually exit.
-That behaviour may change in the future.
-
 =cut
 */
 

-- 
Perl5 Master Repository


[perl.git] branch blead updated. v5.27.6-180-g0301e89953

2017-12-10 Thread Zefram
In perl.git, the branch blead has been updated



- Log -
commit 0301e899536a22752f40481d8a1d141b7a7dda82
Author: Zefram 
Date:   Sun Dec 10 21:37:16 2017 +

properly define perl_parse() return value

perl_parse()'s return value has historically had conflicting purposes.
perlmain.c uses it as a truth value, but perlembed.pod has shown it being
used as an exit code.  perl_parse() has not had its own documentation.
What the function has actually done is to return zero for normal
completion and an exit code for early termination.  For this to be
a usable convention depended on early termination never using exit
code 0, and that's specifically *native* exit code 0, which could have
any significance.  In fact exit code 0 could arise for a compile-time
termination even on Unix through "CHECK { exit 0 }", and the mishandling
of that situation was bug [perl #2754].

Since perl_destruct() provides a native exit code unencumbered by any
attempt to simultaneously be a truth value, perl_parse() doesn't really
need to provide an exit code.  So define that perl_parse()'s return
value is principally a truth value.  Change the perlembed tutorial to
show it being so used, with an exit code coming from perl_destruct().
However, most of the historical usage of perl_parse()'s return value
as an exit code can be preserved.  Make it return 0x100 for exit(0),
which both serves as the essential truth value and on Unix also serves
as the proper exit code, because that set bit will be masked off when
actually exiting.  This works on Unix but will have variable effect on
other OSes; at least it will reliably indicate an actual exit.

perl_run() has a similar problem in the interpretation of its return
value, but not affecting the main perl executable, because perlmain.c
ignores its return value.  Similarly define that it is principally a
truth value, with preserved usage of non-zero return values as exit
codes, with exit code 0 transformed into 0x100.  This requires some
extra logic to distinguish between local completion and exit(0), which
were not previously distinguished.

Fully document perl_parse(), perl_run(), and perl_destruct() as API
functions.  Make the perlembed tutorial always show a proper exit
from main(), using "exit(EXIT_SUCCESS)" for portability when errors
are not being checked.  Make perlembed always show a null argv[argc]
being supplied to perl_parse(), where an argv is constructed.  (Commit
54c85bb058e15520a2fc0ba34007743aae56be34 added a note to perlembed saying
that that's required, but didn't fix the examples to show it being done.)

---

Summary of changes:
 perl.c| 147 +-
 pod/perlembed.pod |  30 ++-
 t/op/blocks.t |  17 ---
 3 files changed, 163 insertions(+), 31 deletions(-)

diff --git a/perl.c b/perl.c
index a81ffd0eb0..918854bb00 100644
--- a/perl.c
+++ b/perl.c
@@ -593,9 +593,33 @@ Perl_dump_sv_child(pTHX_ SV *sv)
 #endif
 
 /*
-=for apidoc perl_destruct
-
-Shuts down a Perl interpreter.  See L.
+=for apidoc Am|int|perl_destruct|PerlInterpreter *my_perl
+
+Shuts down a Perl interpreter.  See L for a tutorial.
+
+C points to the Perl interpreter.  It must have been previously
+created through the use of L and L.  It may
+have been initialised through L, and may have been used
+through L and other means.  This function should be called for
+any Perl interpreter that has been constructed with L,
+even if subsequent operations on it failed, for example if L
+returned a non-zero value.
+
+If the interpreter's C word has the
+C flag set, then this function will execute code
+in C blocks before performing the rest of destruction.  If it is
+desired to make any use of the interpreter between L and
+L other than just calling L, then this flag
+should be set early on.  This matters if L will not be called,
+or if anything else will be done in addition to calling L.
+
+Returns a value be a suitable value to pass to the C library function
+C (or to return from C), to serve as an exit code indicating
+the nature of the way the interpreter terminated.  This takes into account
+any failure of L and any early exit from L.
+The exit code is of the type required by the host operating system,
+so because of differing exit code conventions it is not portable to
+interpret specific numeric values as having specific meanings.
 
 =cut
 */
@@ -1570,9 +1594,62 @@ Perl_call_atexit(pTHX_ ATEXIT_t fn, void *ptr)
 }
 
 /*
-=for apidoc perl_parse
-
-Tells a Perl interpreter to parse a Perl script.  See L.
+=for 

[perl.git] branch blead updated. v5.27.6-179-gc9ffefcc81

2017-12-10 Thread Father Chrysostomos
In perl.git, the branch blead has been updated



- Log -
commit c9ffefcc81905ed7e70f5e766cd1a0f2f7d90d51
Author: Father Chrysostomos 
Date:   Sun Dec 10 12:11:13 2017 -0800

sort perldiag

---

Summary of changes:
 pod/perldiag.pod | 53 -
 1 file changed, 28 insertions(+), 25 deletions(-)

diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index d18baa8a39..cfc8528be0 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -2276,6 +2276,26 @@ to denote a capturing group of the form
 L|perlre/(?PARNO) (?-PARNO) (?+PARNO) (?R) (?0)>,
 but omitted the C<")">.
 
+=item Expecting close paren for nested extended charclass in regex; marked
+by <-- HERE in m/%s/
+
+(F) While parsing a nested extended character class like:
+
+(?[ ... (?flags:(?[ ... ])) ... ])
+ ^
+
+we expected to see a close paren ')' (marked by ^) but did not.
+
+=item Expecting close paren for wrapper for nested extended charclass in
+regex; marked by <-- HERE in m/%s/
+
+(F) While parsing a nested extended character class like:
+
+(?[ ... (?flags:(?[ ... ])) ... ])
+  ^
+
+we expected to see a close paren ')' (marked by ^) but did not.
+
 =item Expecting '(?flags:(?[...' in regex; marked by S<<-- HERE> in m/%s/
 
 (F) The C<(?[...])> extended character class regular expression construct
@@ -6446,31 +6466,6 @@ to find out why that isn't happening.
 (F) The unexec() routine failed for some reason.  See your local FSF
 representative, who probably put it there in the first place.
 
-=item Unexpected ']' with no following ')' in (?[... in regex; marked by <-- 
HERE in m/%s/
-
-(F) While parsing an extended character class a ']' character was encountered
-at a point in the definition where the only legal use of ']' is to close the
-character class definition as part of a '])', you may have forgotten the close
-paren, or otherwise confused the parser.
-
-=item Expecting close paren for nested extended charclass in regex; marked by 
<-- HERE in m/%s/
-
-(F) While parsing a nested extended character class like:
-
-(?[ ... (?flags:(?[ ... ])) ... ])
- ^
-
-we expected to see a close paren ')' (marked by ^) but did not.
-
-=item Expecting close paren for wrapper for nested extended charclass in 
regex; marked by <-- HERE in m/%s/
-
-(F) While parsing a nested extended character class like:
-
-(?[ ... (?flags:(?[ ... ])) ... ])
-  ^
-
-we expected to see a close paren ')' (marked by ^) but did not.
-
 =item Unexpected binary operator '%c' with no preceding operand in regex;
 marked by S<<-- HERE> in m/%s/
 
@@ -6520,6 +6515,14 @@ The C<")"> is out-of-place.  Something apparently was 
supposed to
 be combined with the digits, or the C<"+"> shouldn't be there, or
 something like that.  Perl can't figure out what was intended.
 
+=item Unexpected ']' with no following ')' in (?[... in regex; marked by
+<-- HERE in m/%s/
+
+(F) While parsing an extended character class a ']' character was
+encountered at a point in the definition where the only legal use of
+']' is to close the character class definition as part of a '])', you
+may have forgotten the close paren, or otherwise confused the parser.
+
 =item Unexpected '(' with no preceding operator in regex; marked by
 S<<-- HERE> in m/%s/
 

-- 
Perl5 Master Repository


[perl.git] branch blead updated. v5.27.6-178-ga01f464026

2017-12-10 Thread Father Chrysostomos
In perl.git, the branch blead has been updated



- Log -
commit a01f4640266aacbed7ecc9df01890abb555c69b2
Author: Father Chrysostomos 
Date:   Sun Dec 10 07:07:07 2017 -0800

[perl #74764] Forbid ‘goto’ jumping into ‘given’

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.

commit e7afb05e35570e271ae017d47b64dd5aad3e2009
Author: Father Chrysostomos 
Date:   Wed Dec 6 13:55:26 2017 -0800

Explicitly test goto-into-foreach

It is already tested in t/op/goto.t, but only as part of an existing
test to see which of multiple identical labels gets chosen.

commit b537774295099f6b543a9e2b7375f72593328389
Author: Father Chrysostomos 
Date:   Wed Dec 6 13:44:32 2017 -0800

pp_ctl.c: Move goto-into-foreach error

Put it in a static function, instead of repeating the code.  This way I
can add more conditions to that code in subsequent commits.

---

Summary of changes:
 pod/perldelta.pod  |  5 -
 pod/perldiag.pod   |  5 +
 pod/perlfunc.pod   |  3 ++-
 pp_ctl.c   | 25 ++---
 t/lib/croak/pp_ctl | 22 ++
 5 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 21c855a0c8..5cf9d5e3fc 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -212,7 +212,10 @@ and New Warnings
 
 =item *
 
-XXX L
+L
+
+(F) A "goto" statement was executed to jump into the middle of a C
+block.  You can't get there from here.  See L.
 
 =back
 
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 77726f54a1..d18baa8a39 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -1031,6 +1031,11 @@ pipe, Perl can't retrieve its name for later use.
 (P) An error peculiar to VMS.  Perl asked $GETSYI how big you want your
 mailbox buffers to be, and didn't get an answer.
 
+=item Can't "goto" into a "given" block
+
+(F) A "goto" statement was executed to jump into the middle of a C
+block.  You can't get there from here.  See L.
+
 =item Can't "goto" into the middle of a foreach loop
 
 (F) A "goto" statement was executed to jump into the middle of a foreach
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 32f0e64f2c..8e3a9079b5 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -3400,7 +3400,8 @@ assignment.
 Use of C or C to jump into a construct is
 deprecated and will issue a warning.  Even then, it may not be used to
 go into any construct that requires initialization, such as a
-subroutine or a C loop.  It also can't be used to go into a
+subroutine, a C loop, or a C
+block.  It also can't be used to go into a
 construct that is optimized away.
 
 The C form is quite different from the other forms of
diff --git a/pp_ctl.c b/pp_ctl.c
index 4026d4d579..9ff2abecd3 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2658,7 +2658,8 @@ S_dofindlabel(pTHX_ OP *o, const char *label, STRLEN len, 
U32 flags, OP **opstac
o->op_type == OP_SCOPE ||
o->op_type == OP_LEAVELOOP ||
o->op_type == OP_LEAVESUB ||
-   o->op_type == OP_LEAVETRY)
+   o->op_type == OP_LEAVETRY ||
+   o->op_type == OP_LEAVEGIVEN)
 {
*ops++ = cUNOPo->op_first;
if (ops >= oplimit)
@@ -2709,6 +2710,20 @@ S_dofindlabel(pTHX_ OP *o, const char *label, STRLEN 
len, U32 flags, OP **opstac
 }
 
 
+static void
+S_check_op_type(pTHX_ OP * const o)
+{
+/* Eventually we may want to stack the needed arguments
+ * for each op.  For now, we punt on the hard ones. */
+/* XXX This comment seems to me like wishful thinking.  --sprout */
+if (o->op_type == OP_ENTERITER)
+Perl_croak(aTHX_
+  "Can't \"goto\" into the middle of a foreach loop");
+if (o->op_type == OP_ENTERGIVEN)
+Perl_croak(aTHX_
+  "Can't \"goto\" into a \"given\" block");
+}
+
 /* also used for: pp_dump() */
 
 PP(pp_goto)
@@ -3050,8 +3065,7 @@ PP(pp_goto)
if (leaving_eval && *enterops && enterops[1]) {
I32 i;
 for (i = 1; enterops[i]; i++)
-if (enterops[i]->op_type == OP_ENTERITER)
-DIE(aTHX_ "Can't \"goto\" into the middle of a foreach 
loop");
+S_check_op_type(aTHX_ enterops[i]);
}
 
if (*enterops && enterops[1]) {
@@ -3077,10 +3091,7 @@ PP(pp_goto)
ix = enterops[1]->op_type == OP_ENTER && in_block ? 2 : 1;
for (; enterops[ix]; ix++) {
  

[perl.git] branch blead updated. v5.27.6-175-g436908e565

2017-12-10 Thread James Keenan
In perl.git, the branch blead has been updated



- Log -
commit 436908e565f0e613465123e7cb08fa54487c3b8f
Author: James E Keenan 
Date:   Thu Dec 7 16:09:54 2017 -0500

Clarify different cases of assignment to list of scalars.

Prepared in response to RT #132538, with feedback from Father Chrysostomos.

---

Summary of changes:
 pod/perldata.pod | 47 +++
 1 file changed, 47 insertions(+)

diff --git a/pod/perldata.pod b/pod/perldata.pod
index 9d714f2e79..c0463fc388 100644
--- a/pod/perldata.pod
+++ b/pod/perldata.pod
@@ -778,6 +778,53 @@ As of Perl 5.22, you can also use C<(undef)x2> instead of 
C.
 (You can also do C<($x) x 2>, which is less useful, because it assigns to
 the same variable twice, clobbering the first value assigned.)
 
+When you assign a list of scalars to an array, all previous values in that
+array are wiped out and the number of elements in the array will now be equal 
to
+the number of elements in the right-hand list -- the list from which
+assignment was made.  The array will automatically resize itself to precisely
+accommodate each element in the right-hand list.
+
+use warnings;
+my (@xyz, $x, $y, $z);
+
+@xyz = (1, 2, 3);
+print "@xyz\n"; # 1 2 3
+
+@xyz = ('al', 'be', 'ga', 'de');
+print "@xyz\n"; # al be ga de
+
+@xyz = (101, 102);
+print "@xyz\n"; # 101 102
+
+When, however, you assign a list of scalars to another list of scalars, the
+results differ according to whether the left-hand list -- the list being
+assigned to -- has the same, more or fewer elements than the right-hand list.
+
+($x, $y, $z) = (1, 2, 3);
+print "$x $y $z\n"; # 1 2 3
+
+($x, $y, $z) = ('al', 'be', 'ga', 'de');
+print "$x $y $z\n"; # al be ga
+
+($x, $y, $z) = (101, 102);
+print "$x $y $z\n"; # 101 102
+# Use of uninitialized value $z in concatenation (.)
+# or string at [program] line [line number].
+
+If the number of scalars in the left-hand list is less than that in the
+right-hand list, the "extra" scalars in the right-hand list will simply not be
+assigned.
+
+If the number of scalars in the left-hand list is greater than that in the
+left-hand list, the "missing" scalars will become undefined.
+
+($x, $y, $z) = (101, 102);
+for my $el ($x, $y, $z) {
+(defined $el) ? print "$el " : print "";
+}
+print "\n";
+# 101 102 
+
 List assignment in scalar context returns the number of elements
 produced by the expression on the right side of the assignment:
 

-- 
Perl5 Master Repository