]> git.lyx.org Git - lyx.git/blobdiff - src/lyxlex_pimpl.C
Dekels tabular/textinset patches
[lyx.git] / src / lyxlex_pimpl.C
index cc0c0d537ea538db7b1f61e29cabd8a45b889a83..94a268f1713fbe0868ecaac0c4e02f00b9b2d29b 100644 (file)
@@ -30,7 +30,7 @@ struct compare_tags {
 
 LyXLex::Pimpl::Pimpl(keyword_item * tab, int num) 
        : is(&fb__), table(tab), no_items(num),
-         status(0), lineno(0)
+         status(0), lineno(0), commentChar('#')
 {
        verifyTable();
 }
@@ -53,7 +53,7 @@ void LyXLex::Pimpl::printError(string const & message) const
 void LyXLex::Pimpl::printTable(ostream & os)
 {
        os << "\nNumber of tags: " << no_items << '\n';
-       for(int i= 0; i < no_items; ++i)
+       for (int i= 0; i < no_items; ++i)
                os << "table[" << i
                   << "]:  tag: `" << table[i].tag
                   << "'  code:" << table[i].code << '\n';
@@ -107,8 +107,11 @@ void LyXLex::Pimpl::popTable()
 
 bool LyXLex::Pimpl::setFile(string const & filename)
 {
+       // The check only outputs a debug message, because it triggers
+       // a bug in compaq cxx 6.2, where is_open() returns 'true' for a
+       // fresh new filebuf.  (JMarc)
        if (fb__.is_open() || is.tellg() > 0)
-               lyxerr << "Error in LyXLex::setFile: "
+               lyxerr[Debug::LYXLEX] << "Error in LyXLex::setFile: "
                        "file or stream already set." << endl;
        fb__.open(filename.c_str(), ios::in);
        is.rdbuf(&fb__);
@@ -121,12 +124,17 @@ bool LyXLex::Pimpl::setFile(string const & filename)
 void LyXLex::Pimpl::setStream(istream & i)
 {
        if (fb__.is_open() || is.tellg() > 0)
-               lyxerr << "Error in LyXLex::setStream: "
+               lyxerr[Debug::LYXLEX]  << "Error in LyXLex::setStream: "
                        "file or stream already set." << endl;
        is.rdbuf(i.rdbuf());
        lineno = 0;
 }
 
+void LyXLex::Pimpl::setCommentChar(char c)
+{
+       commentChar = c;
+}
+
 
 bool LyXLex::Pimpl::next(bool esc /* = false */)
 {
@@ -143,11 +151,17 @@ bool LyXLex::Pimpl::next(bool esc /* = false */)
                while (is && !status) {
                        is.get(cc);
                        c = cc;
-                       if (c == '#') {
+                       if (c == commentChar) {
                                // Read rest of line (fast :-)
+                               // That is not fast... (Lgb)
+#if 1
                                is.getline(buff, sizeof(buff));
                                lyxerr[Debug::LYXLEX] << "Comment read: `" << c
                                                      << buff << "'" << endl;
+#else
+                               // unfortunately is ignore buggy (Lgb)
+                               is.ignore(100, '\n');
+#endif
                                ++lineno;
                                continue;
                        }
@@ -253,11 +267,18 @@ bool LyXLex::Pimpl::next(bool esc /* = false */)
                                continue;
                        }
                        
-                       if (c == '#') {
+                       if (c == commentChar) {
                                // Read rest of line (fast :-)
+                               // That is still not fast... (Lgb)
+#if 1
                                is.getline(buff, sizeof(buff));
                                lyxerr[Debug::LYXLEX] << "Comment read: `" << c
                                                      << buff << "'" << endl;
+#else
+                               // but ignore is also still buggy (Lgb)
+                               // This is fast (Lgb)
+                               is.ignore(100, '\n');
+#endif
                                ++lineno;
                                continue;
                        }