X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxlex_pimpl.C;h=80b757359aba6fd8828880adec12a68fc4f02494;hb=35204f8f33d7400a5fefeffea533fb4cb4097211;hp=481c579c9bb6a9a84f020f8fec28e8c9f2530ed0;hpb=a19e4ae8887a26c65e0cbf5700f2de364ba149ea;p=lyx.git diff --git a/src/lyxlex_pimpl.C b/src/lyxlex_pimpl.C index 481c579c9b..80b757359a 100644 --- a/src/lyxlex_pimpl.C +++ b/src/lyxlex_pimpl.C @@ -19,14 +19,19 @@ #include "support/filetools.h" #include "support/lyxalgo.h" #include "support/lstrings.h" +#include "support/types.h" +#include "support/unicode.h" #include -using lyx::support::compare_ascii_no_case; -using lyx::support::getFormatFromContents; -using lyx::support::makeDisplayPath; -using lyx::support::split; -using lyx::support::subst; + +namespace lyx { + +using support::compare_ascii_no_case; +using support::getFormatFromContents; +using support::makeDisplayPath; +using support::split; +using support::subst; using std::endl; using std::getline; @@ -65,7 +70,13 @@ LyXLex::Pimpl::Pimpl(keyword_item * tab, int num) string const LyXLex::Pimpl::getString() const { - return string(buff.begin(), buff.end()); + return buff; +} + + +docstring const LyXLex::Pimpl::getDocString() const +{ + return from_utf8(buff); } @@ -73,7 +84,7 @@ void LyXLex::Pimpl::printError(string const & message) const { string const tmpmsg = subst(message, "$$Token", getString()); lyxerr << "LyX: " << tmpmsg << " [around line " << lineno - << " of file " << makeDisplayPath(name) << ']' << endl; + << " of file " << to_utf8(makeDisplayPath(name)) << ']' << endl; } @@ -193,13 +204,12 @@ bool LyXLex::Pimpl::next(bool esc /* = false */) // we extract the first word and leaves the rest // in pushTok. (Lgb) if (pushTok.find(' ') != string::npos && pushTok[0] == '\\') { - string tmp; - pushTok = split(pushTok, tmp, ' '); - buff.assign(tmp.begin(), tmp.end()); + buff.clear(); + pushTok = split(pushTok, buff, ' '); return true; } else { - buff.assign(pushTok.begin(), pushTok.end()); - pushTok.erase(); + buff = pushTok; + pushTok.clear(); return true; } } @@ -243,7 +253,7 @@ bool LyXLex::Pimpl::next(bool esc /* = false */) ++lineno; } - buff.pop_back(); + buff.resize(buff.size()-1); status = LEX_DATA; break; } @@ -364,7 +374,7 @@ bool LyXLex::Pimpl::next(bool esc /* = false */) ++lineno; } - buff.pop_back(); + buff.resize(buff.size() -1); status = LEX_DATA; break; } @@ -443,7 +453,7 @@ bool LyXLex::Pimpl::eatLine() if (c == '\n') { ++lineno; - buff.pop_back(); + buff.resize(buff.size() - 1); status = LEX_DATA; return true; } else { @@ -459,13 +469,12 @@ bool LyXLex::Pimpl::nextToken() // we extract the first word and leaves the rest // in pushTok. (Lgb) if (pushTok.find(' ') != string::npos && pushTok[0] == '\\') { - string tmp; - pushTok = split(pushTok, tmp, ' '); - buff.assign(tmp.begin(), tmp.end()); + buff.clear(); + pushTok = split(pushTok, buff, ' '); return true; } else { - buff.assign(pushTok.begin(), pushTok.end()); - pushTok.erase(); + buff = pushTok; + pushTok.clear(); return true; } } @@ -513,3 +522,6 @@ void LyXLex::Pimpl::pushToken(string const & pt) { pushTok = pt; } + + +} // namespace lyx