Permalink
Browse files

JRUBY-2722: Interpreter passes absolute path to the EventHook for 're…

…quire'ed files

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@7198 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
1 parent 03c1378 commit 50bad77e6d45909793dae606a5476dd163a8358b @enebo enebo committed Jul 17, 2008
Showing with 14 additions and 15 deletions.
  1. +13 −14 src/org/jruby/Ruby.java
  2. +1 −1 src/org/jruby/runtime/load/LoadService.java
  3. 0 test/test_trace_func.rb
View
@@ -1830,9 +1830,18 @@ public IRubyObject setValue(IRubyObject newValue) {
public void defineReadonlyVariable(String name, IRubyObject value) {
globalVariables.defineReadonly(name, new ValueAccessor(value));
}
+
+ /* FIXME: Helper method...we need to do something better than this */
+ private String tweakPath(String filename) {
+ File f = new File(filename);
+
+ if (f.exists() && !f.isAbsolute() && !filename.startsWith("./")) filename = "./" + filename;
+
+ return filename;
+ }
public Node parseFile(InputStream in, String file, DynamicScope scope) {
- return parser.parse(file, in, scope, new ParserConfiguration(0, false, false, true));
+ return parser.parse(tweakPath(file), in, scope, new ParserConfiguration(0, false, false, true));
}
public Node parseInline(InputStream in, String file, DynamicScope scope) {
@@ -2027,22 +2036,12 @@ private void printErrorPos(ThreadContext context, PrintStream errorStream) {
}
public void loadFile(String scriptName, InputStream in, boolean wrap) {
- if (!Ruby.isSecurityRestricted()) {
- File f = new File(scriptName);
- if(f.exists() && !f.isAbsolute() && !scriptName.startsWith("./")) {
- scriptName = "./" + scriptName;
- }
- }
+ if (!Ruby.isSecurityRestricted()) scriptName = tweakPath(scriptName);
- IRubyObject self = null;
- if (wrap) {
- self = TopSelfFactory.createTopSelf(this);
- } else {
- self = getTopSelf();
- }
+ IRubyObject self = wrap ? TopSelfFactory.createTopSelf(this) : getTopSelf();
ThreadContext context = getCurrentContext();
-
String file = context.getFile();
+
try {
secure(4); /* should alter global state */
@@ -494,7 +494,7 @@ private LoadServiceResource findFile(String name, boolean checkCWD) {
RubyFile.expandUserPath(runtime.getCurrentContext(), name));
if (current.isFile()) {
try {
- return new LoadServiceResource(current.toURI().toURL(), current.getPath());
+ return new LoadServiceResource(current.toURI().toURL(), name);
} catch (MalformedURLException e) {
throw runtime.newIOErrorFromException(e);
}
View
No changes.

0 comments on commit 50bad77

Please sign in to comment.