From 4634345331a883c3d4dca52fdc6367388d67d332 Mon Sep 17 00:00:00 2001 From: "beard%netscape.com" Date: Fri, 5 May 2000 04:10:01 +0000 Subject: [PATCH] can't use std::getline() with a String on all platforms. git-svn-id: svn://10.0.0.236/trunk@68332 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/js2/debugger.cpp | 20 ++++++++++++++------ mozilla/js2/src/debugger.cpp | 20 ++++++++++++++------ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/mozilla/js/js2/debugger.cpp b/mozilla/js/js2/debugger.cpp index c706ed390e3..170497e1c7b 100644 --- a/mozilla/js/js2/debugger.cpp +++ b/mozilla/js/js2/debugger.cpp @@ -34,6 +34,7 @@ #include "world.h" #include "debugger.h" +#include #include #include #include @@ -171,6 +172,13 @@ registers, or set the value of a single register."}, } } + static String widen(string& str) + { + String s(str.size(), char16()); + std::transform(str.begin(), str.end(), s.begin(), JavaScript::widen); + return s; + } + void Shell::listen(Context* cx, InterpretStage stage) { @@ -181,9 +189,9 @@ registers, or set the value of a single register."}, if (!(mStopMask & stage)) return; - static String lastLine (widenCString("help\n")); - String line; - + static string lastLine("help\n"); + string line; + do { ICodeModule *iCode = cx->getICode(); InstructionIterator pc = cx->getPC(); @@ -192,16 +200,16 @@ registers, or set the value of a single register."}, printFormat (stdOut, "%04X", (pc - iCode->its_iCode->begin())); stdOut << "]> "; - getline(cin, line); + std::getline(mIn, line); if (line.size() == 0) line = lastLine; else { - line.append(widenCString("\n")); + line.append("\n"); lastLine = line; } - } while (doCommand(cx, line)); + } while (doCommand(cx, widen(line))); } diff --git a/mozilla/js2/src/debugger.cpp b/mozilla/js2/src/debugger.cpp index c706ed390e3..170497e1c7b 100644 --- a/mozilla/js2/src/debugger.cpp +++ b/mozilla/js2/src/debugger.cpp @@ -34,6 +34,7 @@ #include "world.h" #include "debugger.h" +#include #include #include #include @@ -171,6 +172,13 @@ registers, or set the value of a single register."}, } } + static String widen(string& str) + { + String s(str.size(), char16()); + std::transform(str.begin(), str.end(), s.begin(), JavaScript::widen); + return s; + } + void Shell::listen(Context* cx, InterpretStage stage) { @@ -181,9 +189,9 @@ registers, or set the value of a single register."}, if (!(mStopMask & stage)) return; - static String lastLine (widenCString("help\n")); - String line; - + static string lastLine("help\n"); + string line; + do { ICodeModule *iCode = cx->getICode(); InstructionIterator pc = cx->getPC(); @@ -192,16 +200,16 @@ registers, or set the value of a single register."}, printFormat (stdOut, "%04X", (pc - iCode->its_iCode->begin())); stdOut << "]> "; - getline(cin, line); + std::getline(mIn, line); if (line.size() == 0) line = lastLine; else { - line.append(widenCString("\n")); + line.append("\n"); lastLine = line; } - } while (doCommand(cx, line)); + } while (doCommand(cx, widen(line))); }