From c24a699dd840bd6460de2dc0547a912c4a312c06 Mon Sep 17 00:00:00 2001 From: "nboyd%atg.com" Date: Thu, 24 Jan 2002 19:57:01 +0000 Subject: [PATCH] Fix the following problem: Thanks! As promised, I tried the debugger this afternoon and I had a problem with the '-f' option. We use -f to run a standard "startup" script before executing the "main" script. For example, we run the Rhino shell with the options "-f startup.js main.js". When running the debugger's shell with the same options the debugger exits after the startup.js completes; i.e., I can single step starting from startup.js but the debugger exits at the end of startup.js without letting me single step into main.js. This worked fine in the 1.5R2 release of Rhino and the debugger. I have not had a chance to look into the problem closely, but a cursory look at the code suggests (to me) that the problem can be in either the debugger or the shell (since the debugger basically runs the shell after creating the right "hooks".) Of course, it could also be a problem with my embedding. So ... my question is, has anyone tried single stepping when the options to the debugger include a '-f' option. If so, I'll continue to look for a problem in my embedding. Any suggestions would be appreciated. Thanks, dave --- .../mozilla/javascript/tools/shell/Main.java | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/Main.java b/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/Main.java index 3f15ea2cb232..bce04019a0cf 100644 --- a/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/Main.java +++ b/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/Main.java @@ -82,23 +82,12 @@ public class Main { args = processOptions(cx, args); - int skip = 0; - if (fileList.size() == 0 && args.length > 0) { - skip = 1; - fileList.addElement(args[0]); - } if (processStdin) fileList.addElement(null); - // get the command line arguments after the name of the script, - // and define "arguments" array in the top-level object + // define "arguments" array in the top-level object Object[] array = args; - if (args.length > 0) { - int length = args.length - skip; - array = new Object[length]; - System.arraycopy(args, skip, array, 0, length); - } - Scriptable argsObj = cx.newArray(global, array); + Scriptable argsObj = cx.newArray(global, args); global.defineProperty("arguments", argsObj, ScriptableObject.DONTENUM); @@ -119,8 +108,9 @@ public class Main { String arg = args[i]; if (!arg.startsWith("-")) { processStdin = false; - String[] result = new String[args.length - i]; - System.arraycopy(args, i, result, 0, args.length - i); + fileList.addElement(arg); + String[] result = new String[args.length - i - 1]; + System.arraycopy(args, i+1, result, 0, args.length - i - 1); return result; } if (arg.equals("-version")) {