]> git.lyx.org Git - lyx.git/blobdiff - src/lyxlex_pimpl.C
fix some C++ parsing bugs
[lyx.git] / src / lyxlex_pimpl.C
index 918513a49753e93a942809424c7a9ba487d075f1..35d843f8dfb4f6e3fd07d446ecc52e2f35a0a8fa 100644 (file)
@@ -1,15 +1,13 @@
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <algorithm>
-
 #include "lyxlex_pimpl.h"
+#include "debug.h"
+
 #include "support/lyxalgo.h"
 #include "support/filetools.h"
 #include "support/lstrings.h"
-#include "debug.h"
+
+#include <algorithm>
 
 using std::sort;
 using std::ostream;
@@ -146,7 +144,7 @@ bool LyXLex::Pimpl::next(bool esc /* = false */)
                // There can have been a whole line pushed so
                // we extract the first word and leaves the rest
                // in pushTok. (Lgb)
-               if (pushTok.find(' ') != string::npos) {
+               if (pushTok.find(' ') != string::npos && pushTok[0] == '\\') {
                        string tmp;
                        pushTok = split(pushTok, tmp, ' ');
                        tmp.copy(buff, string::npos);
@@ -172,7 +170,7 @@ bool LyXLex::Pimpl::next(bool esc /* = false */)
 #if 1
                                is.getline(buff, sizeof(buff));
                                lyxerr[Debug::LYXLEX] << "Comment read: `" << c
-                                                     << buff << "'" << endl;
+                                                     << buff << '\'' << endl;
 #else
                                // unfortunately ignore is buggy (Lgb)
                                is.ignore(100, '\n');
@@ -288,7 +286,7 @@ bool LyXLex::Pimpl::next(bool esc /* = false */)
 #if 1
                                is.getline(buff, sizeof(buff));
                                lyxerr[Debug::LYXLEX] << "Comment read: `" << c
-                                                     << buff << "'" << endl;
+                                                     << buff << '\'' << endl;
 #else
                                // but ignore is also still buggy (Lgb)
                                // This is fast (Lgb)
@@ -352,8 +350,8 @@ bool LyXLex::Pimpl::next(bool esc /* = false */)
                                        is.get(cc);
                                        c = cc;
                                } while (c > ' ' && c != ',' && is
-                                        && (i != LEX_MAX_BUFF-1));
-                               if (i == LEX_MAX_BUFF-1) {
+                                        && (i != LEX_MAX_BUFF - 1));
+                               if (i == LEX_MAX_BUFF - 1) {
                                        printError("Line too long");
                                }
                                buff[i] = '\0';
@@ -408,7 +406,7 @@ bool LyXLex::Pimpl::eatLine()
                is.get(cc);
                c = cc;
                //lyxerr[Debug::LYXLEX] << "LyXLex::EatLine read char: `"
-               //                    << c << "'" << endl;
+               //                    << c << '\'' << endl;
                if (c != '\r')
                        buff[i++] = c;
        }
@@ -436,7 +434,7 @@ bool LyXLex::Pimpl::nextToken()
                // There can have been a whole line pushed so
                // we extract the first word and leaves the rest
                // in pushTok. (Lgb)
-               if (pushTok.find(' ') != string::npos) {
+               if (pushTok.find(' ') != string::npos && pushTok[0] == '\\') {
                        string tmp;
                        pushTok = split(pushTok, tmp, ' ');
                        tmp.copy(buff, string::npos);
@@ -464,14 +462,14 @@ bool LyXLex::Pimpl::nextToken()
                                        is.get(cc);
                                        c = cc;
                                } while (c > ' ' && c != '\\' && is
-                                        && i != (LEX_MAX_BUFF-1));
+                                        && i != (LEX_MAX_BUFF - 1));
                        } else {
                                do {
                                        buff[i++] = c;
                                        is.get(cc);
                                        c = cc;
                                } while (c >= ' ' && c != '\\' && is
-                                        && i != (LEX_MAX_BUFF-1));
+                                        && i != (LEX_MAX_BUFF - 1));
                        }
 
                        if (i == (LEX_MAX_BUFF - 1)) {