diff --git a/mozilla/js/js2/js2.cpp b/mozilla/js/js2/js2.cpp index e20cb5596a5..34bc660e6eb 100644 --- a/mozilla/js/js2/js2.cpp +++ b/mozilla/js/js2/js2.cpp @@ -384,12 +384,16 @@ static float64 testFunctionCall(World &world, float64 n) return result.f64; } -JSValue *print(const JSValues &argv) +JSValue print(const JSValues &argv) { - for (int i = 0; i < argv.size(); i++) - stdOut << argv[i]; + size_t n = argv.size(); + if (n > 0) { + stdOut << argv[0]; + for (size_t i = 1; i < n; ++i) + stdOut << ' ' << argv[i]; + } stdOut << "\n"; - return new JSValue(); // undefined??? + return kUndefinedValue; } static void testPrint(World &world) diff --git a/mozilla/js2/tests/cpp/js2_shell.cpp b/mozilla/js2/tests/cpp/js2_shell.cpp index e20cb5596a5..34bc660e6eb 100644 --- a/mozilla/js2/tests/cpp/js2_shell.cpp +++ b/mozilla/js2/tests/cpp/js2_shell.cpp @@ -384,12 +384,16 @@ static float64 testFunctionCall(World &world, float64 n) return result.f64; } -JSValue *print(const JSValues &argv) +JSValue print(const JSValues &argv) { - for (int i = 0; i < argv.size(); i++) - stdOut << argv[i]; + size_t n = argv.size(); + if (n > 0) { + stdOut << argv[0]; + for (size_t i = 1; i < n; ++i) + stdOut << ' ' << argv[i]; + } stdOut << "\n"; - return new JSValue(); // undefined??? + return kUndefinedValue; } static void testPrint(World &world)