Skip to content
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

[PATCH]5.005_03 (TOKE) #line handling #983

Closed
p5pRT opened this issue Dec 21, 1999 · 1 comment
Closed

[PATCH]5.005_03 (TOKE) #line handling #983

p5pRT opened this issue Dec 21, 1999 · 1 comment

Comments

@p5pRT
Copy link

p5pRT commented Dec 21, 1999

Migrated from rt.perl.org#1931 (status was 'resolved')

Searchable as RT1931$

@p5pRT
Copy link
Author

p5pRT commented Dec 21, 1999

From andrew@pimlott.ne.mediaone.net

$ cat foo
require 'bar';
$ cat bar
#line 3
die
$ perl foo
Died at foo line 3.

The #line directive makes perl consider bar to be the current file at
the die (in addition to changing the line number). I can't imagine a
situation where this would be desirable, so I changed it in my perl​:

$ cat foo
require 'bar';
$ cat bar
#line 3
die
$ ./perl foo
Died at bar line 3.

This makes sense to me and I can't imagine what it could break.
However, it does appear in the source code that somebody created the
current behaviour purposefully, so I'm not sure.

The reason I want this is that I have a script that does install-time
modification of modules, but I want the reported line numbers to match
the original files. I could embed the filname in the installed modules
(#line 3 "filename"), but I would rather let perl print the filename
exactly as it would otherwise, and don't want to hardcode an absolute
string.

Here's what I did​:

Inline Patch
--- toke.c.orig	Tue Dec 21 15:40:48 1999
+++ toke.c	Tue Dec 21 15:40:54 1999
@@ -368,8 +368,6 @@
     *t = '\0';
     if (t - s > 0)
 	PL_curcop->cop_filegv = gv_fetchfile(s);
-    else
-	PL_curcop->cop_filegv = gv_fetchfile(PL_origfilename);
     *t = ch;
     PL_curcop->cop_line = atoi(n)-1;
 }

Andrew 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant