From 70fd8a8a9762a479a8da2a372e9ef33990c39183 Mon Sep 17 00:00:00 2001 From: "beard%netscape.com" Date: Fri, 5 May 2000 05:24:02 +0000 Subject: [PATCH] added size_t LineReader::readLine(String& wstr) for convenience. --- js/js2/utilities.cpp | 10 +++++++++- js/js2/utilities.h | 3 ++- js2/src/utilities.cpp | 10 +++++++++- js2/src/utilities.h | 3 ++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/js/js2/utilities.cpp b/js/js2/utilities.cpp index b942a9ee3edc..8d03dd0a857b 100644 --- a/js/js2/utilities.cpp +++ b/js/js2/utilities.cpp @@ -1970,7 +1970,7 @@ JS::AsciiFileFormatter JS::stdErr(stderr); // Return the total number of characters read, which is str's length. // Translate and sequences to characters; a sequence // only counts as one character. -size_t JS::LineReader::readLine(string &str) +size_t JS::LineReader::readLine(string& str) { int ch; bool oldCRWasLast = crWasLast; @@ -1995,6 +1995,14 @@ size_t JS::LineReader::readLine(string &str) return str.size(); } +size_t JS::LineReader::readLine(String& wstr) +{ + string str; + size_t n = readLine(str); + wstr.resize(n); + std::transform(str.begin(), str.end(), wstr.begin(), widen); + return n; +} // // Exceptions diff --git a/js/js2/utilities.h b/js/js2/utilities.h index 6cf2870636e9..f850aee72cc9 100644 --- a/js/js2/utilities.h +++ b/js/js2/utilities.h @@ -824,7 +824,8 @@ namespace JavaScript { public: explicit LineReader(FILE *in): in(in), crWasLast(false) {} - size_t readLine(string &str); + size_t readLine(string& str); + size_t readLine(String& wstr); }; diff --git a/js2/src/utilities.cpp b/js2/src/utilities.cpp index b942a9ee3edc..8d03dd0a857b 100644 --- a/js2/src/utilities.cpp +++ b/js2/src/utilities.cpp @@ -1970,7 +1970,7 @@ JS::AsciiFileFormatter JS::stdErr(stderr); // Return the total number of characters read, which is str's length. // Translate and sequences to characters; a sequence // only counts as one character. -size_t JS::LineReader::readLine(string &str) +size_t JS::LineReader::readLine(string& str) { int ch; bool oldCRWasLast = crWasLast; @@ -1995,6 +1995,14 @@ size_t JS::LineReader::readLine(string &str) return str.size(); } +size_t JS::LineReader::readLine(String& wstr) +{ + string str; + size_t n = readLine(str); + wstr.resize(n); + std::transform(str.begin(), str.end(), wstr.begin(), widen); + return n; +} // // Exceptions diff --git a/js2/src/utilities.h b/js2/src/utilities.h index 6cf2870636e9..f850aee72cc9 100644 --- a/js2/src/utilities.h +++ b/js2/src/utilities.h @@ -824,7 +824,8 @@ namespace JavaScript { public: explicit LineReader(FILE *in): in(in), crWasLast(false) {} - size_t readLine(string &str); + size_t readLine(string& str); + size_t readLine(String& wstr); };