]> git.lyx.org Git - lyx.git/blobdiff - src/lyxlex_pimpl.C
more changes, read the Changelog
[lyx.git] / src / lyxlex_pimpl.C
index 8f9b86ff11c7f48d1c1bb2b09cbdf1f4da8ca3aa..4068b7eb2ade0a1e97ec65a05e87203b404ececa 100644 (file)
@@ -52,7 +52,7 @@ LyXLex::Pimpl::Pimpl(keyword_item * tab, int num)
 }
 
 
-string const LyXLex::Pimpl::GetString() const
+string LyXLex::Pimpl::GetString() const
 {
        return string(buff);
 }
@@ -119,11 +119,11 @@ void LyXLex::Pimpl::popTable()
 
 bool LyXLex::Pimpl::setFile(string const & filename)
 {
-       if (fb__.is_open())
-               lyxerr << "Error in LyXLex::setFile: "
-                       "file or stream already set." << endl;
+       //if (fb__.is_open())
+       //      lyxerr << "Error in LyXLex::setFile: "
+       //              "file or stream already set." << endl;
        fb__.open(filename.c_str(), ios::in);
-       is.rdbuf(&fb__);
+       //is.rdbuf(&fb__);
        name = filename;
        lineno = 0;
        return fb__.is_open() && is.good();
@@ -140,8 +140,14 @@ void LyXLex::Pimpl::setStream(istream & i)
 }
 
 
-bool LyXLex::Pimpl::next(bool esc = false)
+bool LyXLex::Pimpl::next(bool esc /* = false */)
 {
+       if (!pushTok.empty()) {
+               pushTok.copy(buff, string::npos);
+               buff[pushTok.length()] = '\0';
+               pushTok.erase();
+               return true;
+       }
        if (!esc) {
                unsigned char c = 0; // getc() returns an int
                char cc = 0;
@@ -395,6 +401,13 @@ bool LyXLex::Pimpl::EatLine()
 
 bool LyXLex::Pimpl::nextToken()
 {
+       if (!pushTok.empty()) {
+               pushTok.copy(buff, string::npos);
+               buff[pushTok.length()] = '\0';
+               pushTok.erase();
+               return true;
+       }
+
        status = 0;
        while (is && !status) {
                unsigned char c = 0;
@@ -438,3 +451,9 @@ bool LyXLex::Pimpl::nextToken()
        buff[0] = '\0';
        return false;
 }
+
+
+void LyXLex::Pimpl::pushToken(string const & pt)
+{
+       pushTok = pt;
+}