aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/perl/perl/fixes/getopt-long-3.diff
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/perl/perl/fixes/getopt-long-3.diff')
-rw-r--r--meta/recipes-devtools/perl/perl/fixes/getopt-long-3.diff41
1 files changed, 41 insertions, 0 deletions
diff --git a/meta/recipes-devtools/perl/perl/fixes/getopt-long-3.diff b/meta/recipes-devtools/perl/perl/fixes/getopt-long-3.diff
new file mode 100644
index 0000000000..8d14362e88
--- /dev/null
+++ b/meta/recipes-devtools/perl/perl/fixes/getopt-long-3.diff
@@ -0,0 +1,41 @@
+From f2a5c8b66c83fe4719dee9c50edeb2d6f8925c19 Mon Sep 17 00:00:00 2001
+From: Andrew Gregory <andrew.gregory.8@gmail.com>
+Date: Sun, 21 May 2017 21:12:21 -0400
+Subject: [PATCH] provide a default value for optional arguments
+
+When using gnu_compat, FindOption would return undef as the value for
+the options with optional arguments if none was provided. Subsequent
+processing in GetOptionsFromArray is skipped entirely for undef values,
+causing the option to be silently discarded. The following code snippet
+demonstrates the issue:
+
+ use Getopt::Long qw(GetOptionsFromArray :config gnu_compat);
+ GetOptionsFromArray( ['--foo'], 'foo:s' => sub { print("success") } );
+
+Origin: backport, https://github.com/sciurius/perl-Getopt-Long/commit/2d16f355e25537aa742eb2833a7d52a63051429b
+Patch-Name: fixes/getopt-long-3.diff
+
+---
+ cpan/Getopt-Long/lib/Getopt/Long.pm | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/cpan/Getopt-Long/lib/Getopt/Long.pm b/cpan/Getopt-Long/lib/Getopt/Long.pm
+index 9d38673..e7e033b 100644
+--- a/cpan/Getopt-Long/lib/Getopt/Long.pm
++++ b/cpan/Getopt-Long/lib/Getopt/Long.pm
+@@ -1120,8 +1120,13 @@ sub FindOption ($$$$$) {
+ # We do, since not doing so breaks existing scripts.
+ $optargtype = 3;
+ }
+- return (1, $opt, $ctl, $ctl->[CTL_DEFAULT])
+- if (($optargtype == 0) && !$mand);
++ if(($optargtype == 0) && !$mand) {
++ my $val
++ = defined($ctl->[CTL_DEFAULT]) ? $ctl->[CTL_DEFAULT]
++ : $type eq 's' ? ''
++ : 0;
++ return (1, $opt, $ctl, $val);
++ }
+ return (1, $opt, $ctl, $type eq 's' ? '' : 0)
+ if $optargtype == 1; # --foo= -> return nothing
+ }