New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Small bug in include directory slash interpretation #12670
Comments
From victor@vsespb.ruCreated by victor@vsespb.ruIf perl ran as "perl -Isrc/ src/myscript.pl" I am getting the but when run as perl -Isrc/ src/myscript.pl I am getting just on slash Perl Info
|
From @jkeenanOn Mon Dec 24 08:42:38 2012, vsespb wrote:
Can you supply more details as to the content of 'src/myscript.pl' and It may be that your code has a problem which truly ought to generate a Thank you very much. |
The RT System itself - Status changed from 'new' to 'open' |
From victor@vsespb.ruOk, I made proof-of-concept code: $ cat src/myscript.pl bug in message "Global symbol "$x" requires explicit package name at Пнд. Дек. 24 20:11:13 2012, jkeenan писал:
|
From @hvds"James E Keenan via RT" <perlbug-followup@perl.org> wrote: I don't think the script content has any particular relevance. Here's an % mkdir mylib ; echo 'print "hello world" . $undef' >mylib/A.pm Note the doubled slash in the warning message "mylib//A.pm"? That still Hugo |
From @wolfsageI've attached a patch that I believe solves this, though I'm not sure of Also, I've tested it through t/run/switchM.t, though the bug is really Hope this helps regardless. -- Matthew Horsfall (alh) |
From @wolfsage0001-RT-116192-If-a-directory-in-INC-already-has-a-traili.patchFrom ae66195d52cc37b0e6c70d2aa2ce01317171f38d Mon Sep 17 00:00:00 2001
From: Matthew Horsfall (alh) <wolfsage@gmail.com>
Date: Thu, 27 Dec 2012 10:38:08 -0500
Subject: [PATCH] RT-116192 - If a directory in @INC already has a trailing '/', don't add another.
---
MANIFEST | 2 ++
pp_ctl.c | 7 ++++++-
t/run/flib/broken.pm | 8 ++++++++
t/run/switchM.t | 19 +++++++++++++++++++
4 files changed, 35 insertions(+), 1 deletions(-)
create mode 100644 t/run/flib/broken.pm
create mode 100644 t/run/switchM.t
diff --git a/MANIFEST b/MANIFEST
index f6ba34c..28ee69a 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -5505,6 +5505,7 @@ t/run/cloexec.t Test close-on-exec.
t/run/dtrace.pl For dtrace.t
t/run/dtrace.t Test for DTrace probes
t/run/exit.t Test perl's exit status.
+t/run/flib/broken.pm Bad .pm file for switchM.t
t/run/fresh_perl.t Tests that require a fresh perl.
t/run/locale.t Tests related to locale handling
t/run/mad.t Test vs MAD environment
@@ -5520,6 +5521,7 @@ t/run/switches.t Tests for the other switches (-0, -l, -c, -s, -M, -m, -V, -v,
t/run/switchF1.t Pathological tests for the -F switch
t/run/switchF.t Test the -F switch
t/run/switchI.t Test the -I switch
+t/run/switchM.t Test the -M switch
t/run/switchn.t Test the -n switch
t/run/switchp.t Test the -p switch
t/run/switcht.t Test the -t switch
diff --git a/pp_ctl.c b/pp_ctl.c
index 199df1f..900bde1 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3889,7 +3889,12 @@ PP(pp_require)
memcpy(tmp, dir, dirlen);
tmp +=dirlen;
- *tmp++ = '/';
+
+ /* Avoid '<dir>//<file>' */
+ if (*(tmp-1) != '/') {
+ *tmp++ = '/';
+ }
+
/* name came from an SV, so it will have a '\0' at the
end that we can copy as part of this memcpy(). */
memcpy(tmp, name, len + 1);
diff --git a/t/run/flib/broken.pm b/t/run/flib/broken.pm
new file mode 100644
index 0000000..18f4d45
--- /dev/null
+++ b/t/run/flib/broken.pm
@@ -0,0 +1,8 @@
+package broken;
+
+use strict;
+use warnings;
+
+$x = 1;
+
+1;
diff --git a/t/run/switchM.t b/t/run/switchM.t
new file mode 100644
index 0000000..72e8908
--- /dev/null
+++ b/t/run/switchM.t
@@ -0,0 +1,19 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+use strict;
+
+require './test.pl';
+
+plan(2);
+
+like(runperl(switches => ['-Irun/flib', '-Mbroken'], stderr => 1),
+ qr/^Global symbol "\$x" requires explicit package name at run\/flib\/broken.pm line 6\./,
+ "Ensure -Irun/flib produces correct filename in warnings");
+
+like(runperl(switches => ['-Irun/flib/', '-Mbroken'], stderr => 1),
+ qr/^Global symbol "\$x" requires explicit package name at run\/flib\/broken.pm line 6\./,
+ "Ensure -Irun/flib/ produces correct filename in warnings");
--
1.7.0.4
|
From victor@vsespb.ruWill it work if dirlen==0 ? On Thu Dec 27 07:45:05 2012, alh wrote:
|
From [Unknown Contact. See original ticket]Will it work if dirlen==0 ? On Thu Dec 27 07:45:05 2012, alh wrote:
|
From @wolfsageOn Thu, Dec 27, 2012 at 10:45 AM, Matthew Horsfall via RT <
Now that I look at this, is it possible for *(tmp-1) to access bad memory? -- Matthew Horsfall (alh) |
From victor@vsespb.ru.. or even better if (dirlen && *(tmp-1) != '/') { ... } On Thu Dec 27 12:49:17 2012, alh wrote:
|
From @wolfsageOn Thu, Dec 27, 2012 at 3:54 PM, Victor Efimov via RT <
Right now '/' is added whether or not dirlen is > 0, so (if !dirlen || if (dirlen && ...) would change that behavior. -- Matthew Horsfall (alh) |
From victor@vsespb.ruOk, get it. Agree. On Fri Dec 28 09:18:51 2012, alh wrote:
|
From [Unknown Contact. See original ticket]Ok, get it. Agree. On Fri Dec 28 09:18:51 2012, alh wrote:
|
From @cpansproutOn Thu Dec 27 12:49:17 2012, alh wrote:
Yes. Thank you. Applied as 6b0bdd7. -- Father Chrysostomos |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#116192 (status was 'resolved')
Searchable as RT116192$
The text was updated successfully, but these errors were encountered: