From ec4a10847162ea936d62ebbec90f2d250d137b1c Mon Sep 17 00:00:00 2001 From: "beard%netscape.com" Date: Tue, 9 May 2000 03:56:56 +0000 Subject: [PATCH] print now returns JSValue, added space between args when printing git-svn-id: svn://10.0.0.236/trunk@68796 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/js2/js2.cpp | 12 ++++++++---- mozilla/js2/tests/cpp/js2_shell.cpp | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) 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)