From ae4b000c3fe9682be562679e0121f002eb653e15 Mon Sep 17 00:00:00 2001 From: "igor%mir2.org" Date: Sun, 26 Jan 2003 18:28:26 +0000 Subject: [PATCH] Added documentation strings for runCommnad and spawn is changed to pass empty argument array instead of null if function arguments are not specified to avoid a null pointer exception in InterpretedFunction.call --- .../mozilla/javascript/tools/resources/Messages.properties | 7 +++++++ .../toolsrc/org/mozilla/javascript/tools/shell/Global.java | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/js/rhino/toolsrc/org/mozilla/javascript/tools/resources/Messages.properties b/js/rhino/toolsrc/org/mozilla/javascript/tools/resources/Messages.properties index ba76ca47e998..6d9bace117c9 100644 --- a/js/rhino/toolsrc/org/mozilla/javascript/tools/resources/Messages.properties +++ b/js/rhino/toolsrc/org/mozilla/javascript/tools/resources/Messages.properties @@ -129,6 +129,12 @@ msg.must.implement.Script =\ the Script interface. Class files generated by compiling scripts \ will implement Script. +msg.runCommand.bad.args =\ + The first argument to runCommand must be a command name. + +msg.runCommand.bad.env =\ + A value of the env property of option object for runCommnad must be an \ + object. msg.idswitch.same_string =\ The string {0} is used second time in the switch code. \ @@ -184,3 +190,4 @@ Note: the original file will be overwritten without any backup actions\n\ msg.idswitch.version = \ org.mozilla.javascript.tools.idswitch.StringIdMap version 0.2 + diff --git a/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/Global.java b/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/Global.java index 528e87999130..b1736343c19d 100644 --- a/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/Global.java +++ b/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/Global.java @@ -20,6 +20,7 @@ * * Contributor(s): * Patrick Beard + * Igor Bukanov * Norris Boyd * Rob Ginda * Kurt Westerfeld @@ -295,6 +296,7 @@ public class Global extends ImporterTopLevel { if (args.length > 1 && args[1] instanceof Scriptable) { newArgs = cx.getElements((Scriptable) args[1]); } + if (newArgs == null) { newArgs = ScriptRuntime.emptyArgs; } runner = new Runner(scope, (Function) args[0], newArgs); } else if (args.length != 0 && args[0] instanceof Script) { runner = new Runner(scope, (Script) args[0]); @@ -377,7 +379,7 @@ public class Global extends ImporterTopLevel { { int L = args.length; if (L == 0 || (L == 1 && args[0] instanceof Scriptable)) { - throw reportRuntimeError("msg.system.args"); + throw reportRuntimeError("msg.runCommand.bad.args"); } InputStream in = null; @@ -396,7 +398,7 @@ public class Global extends ImporterTopLevel { environment = new String[0]; } else { if (!(envObj instanceof Scriptable)) { - throw reportRuntimeError("msg.system.args"); + throw reportRuntimeError("msg.runCommand.bad.env"); } Scriptable envHash = (Scriptable)envObj; Object[] ids = ScriptableObject.getPropertyIds(envHash);