Closed p5pRT closed 19 years ago
This is an issue with C\<config_re> in Config.pm
% perl -V:'?flags' Surpring works and list all the .*flags config vars.
It works because the regexp used in config_re become /^?flags=/ so the ? (optionally) undoes the ^.
Is this a neat feature\, or should the -V:regexp only accept valid regexps?
I have a patch for the latter case [attached].
Robin
On Wed\, 1 Oct 2003\, Robin Barker wrote:
% perl -V:'?flags' Surpring works and list all the .*flags config vars.
It works because the regexp used in config_re become /^?flags=/ so the ? (optionally) undoes the ^.
Is this a neat feature\, or should the -V:regexp only accept valid regexps?
I have a patch for the latter case [attached].
I think it would be sufficient for configpm to wrap a (?: ) around it\, and let whoever wants to foil it with something like perl -V:')|uv|(' go ahead and do so.
Yitzchak Scott-Thoennes wrote:
On Wed\, 1 Oct 2003\, Robin Barker wrote:
% perl -V:'?flags' Surpring works and list all the .*flags config vars.
It works because the regexp used in config_re become /^?flags=/ so the ? (optionally) undoes the ^.
Is this a neat feature\, or should the -V:regexp only accept valid regexps?
I have a patch for the latter case [attached].
I think it would be sufficient for configpm to wrap a (?: ) around it\, and let whoever wants to foil it with something like perl -V:')|uv|(' go ahead and do so.
Reminds me this old japh : perl '-V:));print"Just another Perl hacker\,\n";(('
(Just for the record: I don't think anything needs to be changed here.)
-- ams
On Mon\, Oct 06\, 2003 at 10:13:39AM +0530\, Abhijit Menon-Sen \ams@​wiw\.org wrote:
(Just for the record: I don't think anything needs to be changed here.)
-- ams
I think perl should complain about Robin Barker's original case:
perl -V:'?flags'
Not having actually submitted a patch of my own\, I'd much rather see his applied than nothing.
In an attempt to close #24081\, here is a simplified patch.
Robin
--- configpm.orig Sun Nov 16 17:26:58 2003 +++ configpm @@ -329\,7 +329\,7 @@
sub config_re { my $re = shift; - return map { chomp; $_ } grep /^$re=/\, split /^/\, $Config_SH; + return map { chomp; $_ } grep eval{ /^(?:$re)=/ }\, split /^/\, $Config_SH; }
sub config_vars { --- lib/Config.t.orig Fri Mar 14 11:50:25 2003 +++ lib/Config.t @@ -6\,7 +6\,7 @@ require "./test.pl"; }
-plan tests => 36; +plan tests => 37;
use_ok('Config');
@@ -77\,10 +77\,15 @@ my $out2 = $$out; $out->clear;
+Config::config_vars('?flags'); +my $out3 = $$out; +$out->clear; + untie *STDOUT;
like($out1\, qr/^cc='\Q$Config{cc}\E';/\, "config_vars cc"); like($out2\, qr/^d_bork='UNKNOWN';/\, "config_vars d_bork is UNKNOWN"); +like($out3\, qr/: not found$/\, "config_vars with invalid regexp");
# Read-only.
This e-mail and any attachments may contain confidential and/or privileged material; it is for the intended addressee(s) only. If you are not a named addressee\, you must not use\, retain or disclose such information.
NPL Management Ltd cannot guarantee that the e-mail or any attachments are free from viruses.
NPL Management Ltd. Registered in England and Wales. No: 2937881 Registered Office: Teddington\, Middlesex\, United Kingdom TW11 0LW.
Robin Barker wrote:
In an attempt to close #24081\, here is a simplified patch.
Your patch (with the necessary adjustments) causes several regression tests to fail on bleadperl\, where the format of output has changed. If you replace qr/: not found$/ by qr/: not found/ your new test passes\, but other tests fail for a reason I've not investigated.
--- configpm.orig Sun Nov 16 17:26:58 2003 +++ configpm @@ -329\,7 +329\,7 @@
sub config_re { my $re = shift; - return map { chomp; $_ } grep /^$re=/\, split /^/\, $Config_SH; + return map { chomp; $_ } grep eval{ /^(?:$re)=/ }\, split /^/\, $Config_SH; }
sub config_vars { --- lib/Config.t.orig Fri Mar 14 11:50:25 2003 +++ lib/Config.t @@ -6\,7 +6\,7 @@ require "./test.pl"; }
-plan tests => 36; +plan tests => 37;
use_ok('Config');
@@ -77\,10 +77\,15 @@ my $out2 = $$out; $out->clear;
+Config::config_vars('?flags'); +my $out3 = $$out; +$out->clear; + untie *STDOUT;
like($out1\, qr/^cc='\Q$Config{cc}\E';/\, "config_vars cc"); like($out2\, qr/^d_bork='UNKNOWN';/\, "config_vars d_bork is UNKNOWN"); +like($out3\, qr/: not found$/\, "config_vars with invalid regexp");
On Wed\, Jun 09\, 2004 at 12:02:01PM +0100\, Robin Barker wrote:
In an attempt to close #24081\, here is a simplified patch.
Robin
--- configpm.orig Sun Nov 16 17:26:58 2003 +++ configpm
- return map { chomp; $_ } grep /^$re=/\, split /^/\, $Config_SH; + return map { chomp; $_ } grep eval{ /^(?:$re)=/ }\, split /^/\, $Config_SH;
+like($out3\, qr/: not found$/\, "config_vars with invalid regexp");
Is the intent that this regex throws an error in the eval\, or just that it doesn't match anything?
Ronald
Ronald J Kimball wrote:
On Wed\, Jun 09\, 2004 at 12:02:01PM +0100\, Robin Barker wrote:
In an attempt to close #24081\, here is a simplified patch.
Robin
--- configpm.orig Sun Nov 16 17:26:58 2003 +++ configpm
- return map { chomp; $_ } grep /^$re=/\, split /^/\, $Config_SH; + return map { chomp; $_ } grep eval{ /^(?:$re)=/ }\, split /^/\, $Config_SH;
+like($out3\, qr/: not found$/\, "config_vars with invalid regexp");
Is the intent that this regex throws an error in the eval\, or just that it doesn't match anything?
in this test that's actually /?flags/ used as an ivalid regexp\, a few lines earlier.
$ perl -ce '/?flags/' Quantifier follows nothing in regex; marked by \<-- HERE in m/? \<-- HERE flags/ at -e line 1.
The intent is that
(1) invalid regexp in V: do not become valid
hence the (?: ) round $re
(2) invalid regexp do not produce an error
hence the eval
(3) invalid regexp do not match
(function of C\
My earlier patch reverse the intent of (2): an invalid regexp produced an intelligible error that was returned to the user.
The problems with doing something with the error from the eval in the map expression are (*) the error has lots of distracting context information (*) the regexp in the error message includes the enclosing /^ =/ which the user did not type.
Robin
-----Original Message----- From: Ronald J Kimball [mailto:rjk-perl-p5p@tamias.net] Sent: 09 June 2004 14:37 To: Robin Barker Cc: 'perl5-porters@perl.org' Subject: Re: [PATCH] Re: [perl #24081] invalid regexp in perl -V
On Wed\, Jun 09\, 2004 at 12:02:01PM +0100\, Robin Barker wrote:
In an attempt to close #24081\, here is a simplified patch.
Robin
--- configpm.orig Sun Nov 16 17:26:58 2003 +++ configpm
- return map { chomp; $_ } grep /^$re=/\, split /^/\, $Config_SH; + return map { chomp; $_ } grep eval{ /^(?:$re)=/ }\, split /^/\, $Config_SH;
+like($out3\, qr/: not found$/\, "config_vars with invalid regexp");
Is the intent that this regex throws an error in the eval\, or just that it doesn't match anything?
Ronald
This e-mail and any attachments may contain confidential and/or privileged material; it is for the intended addressee(s) only. If you are not a named addressee\, you must not use\, retain or disclose such information.
NPL Management Ltd cannot guarantee that the e-mail or any attachments are free from viruses.
NPL Management Ltd. Registered in England and Wales. No: 2937881 Registered Office: Teddington\, Middlesex\, United Kingdom TW11 0LW.
Robin Barker wrote:
In an attempt to close #24081\, here is a simplified patch.
Thanks\, applied as #22921 with the further ajustments you made for bleadperl.
@rgs - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#24081 (status was 'resolved')
Searchable as RT24081$