]> git.lyx.org Git - lyx.git/commitdiff
Remove findToken from lyxlyex, first step to its complete removal.
authorJosé Matox <jamatos@lyx.org>
Fri, 20 Aug 2004 13:06:33 +0000 (13:06 +0000)
committerJosé Matox <jamatos@lyx.org>
Fri, 20 Aug 2004 13:06:33 +0000 (13:06 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8960 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/ParagraphParameters.C
src/bufferparams.C
src/lyxlex.C
src/lyxlex.h

index 578f044b61feb7b7027306a7e900cb46efa4a378..7185f5cbd6627e2c0e0d6a6ca77b7d41c36fb076 100644 (file)
@@ -1,3 +1,12 @@
+2004-08-20  José Matos  <jamatos@lyx.org>
+
+       * lyxlex.[Ch] (findToken): remove function.
+
+       * ParagraphParameters.C (findToken):
+       * bufferparams.C (findToken): replace call for previous function
+       with local copy. This local function has one more argument, the
+       read string argument.
+
 2004-08-16  José Matos  <jamatos@lyx.org>
 
        * ParagraphParameters.C (write):
index a1e62c521ef25ea99bf1222c5b7dbc193fa00b31..428063f0fd6ac90b0288b72d3b55b040a1c9589f 100644 (file)
@@ -38,6 +38,26 @@ using std::ostream;
 using std::ostringstream;
 using std::string;
 
+// anonym namespace
+namespace {
+int findToken(char const * const str[], string const search_token)
+{
+       int i = 0;
+
+       if (search_token != "default") {
+               while (str[i][0] && str[i] != search_token) {
+                       ++i;
+               }
+               if (!str[i][0]) {
+                       i = -1;
+               }
+       }
+
+       return i;
+}
+
+}
+
 
 ParagraphParameters::ParagraphParameters()
        : noindent_(false),
@@ -208,7 +228,8 @@ void ParagraphParameters::read(LyXLex & lex)
                                lex.printError("Unknown spacing token: '$$Token'");
                        }
                } else if (token == "\\align") {
-                       int tmpret = lex.findToken(string_align);
+                       lex.next();
+                       int tmpret = findToken(string_align, lex.getString());
                        if (tmpret == -1)
                                ++tmpret;
                        align(LyXAlignment(1 << tmpret));
index d5b40ba8ee8524957c54d4e96472ecbb2750b762..da933c112bea7d12b9358d3f1095199e0f9d497d 100644 (file)
@@ -58,6 +58,29 @@ using std::pair;
 namespace biblio = lyx::biblio;
 
 
+// anonym namespace
+namespace {
+int findToken(char const * const str[], string const search_token)
+{
+       int i = 0;
+
+       if (search_token != "default") {
+               while (str[i][0] && str[i] != search_token) {
+                       ++i;
+               }
+               if (!str[i][0]) {
+                       lyxerr << "Unknown argument: '"
+                              << search_token << "'\n";
+                       i = -1;
+               }
+       }
+
+       return i;
+}
+
+}
+
+
 struct BufferParams::Impl
 {
        Impl();
@@ -250,7 +273,8 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
                lex.next();
                fonts = lex.getString();
        } else if (token == "\\paragraph_separation") {
-               int tmpret = lex.findToken(string_paragraph_separation);
+               lex.next();
+               int tmpret = findToken(string_paragraph_separation, lex.getString());
                if (tmpret == -1)
                        ++tmpret;
                paragraph_separation =
@@ -260,7 +284,8 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
                pimpl_->defskip = VSpace(lex.getString());
        } else if (token == "\\quotes_language") {
                // FIXME: should be params.readQuotes()
-               int tmpret = lex.findToken(string_quotes_language);
+               lex.next();
+               int tmpret = findToken(string_quotes_language, lex.getString());
                if (tmpret == -1)
                        ++tmpret;
                InsetQuotes::quote_language tmpl =
@@ -298,13 +323,15 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
                        break;
                }
        } else if (token == "\\papersize") {
-               int tmpret = lex.findToken(string_papersize);
+               lex.next();
+               int tmpret = findToken(string_papersize, lex.getString());
                if (tmpret == -1)
                        ++tmpret;
                else
                        papersize2 = VMARGIN_PAPER_TYPE(tmpret);
        } else if (token == "\\paperpackage") {
-               int tmpret = lex.findToken(string_paperpackages);
+               lex.next();
+               int tmpret = findToken(string_paperpackages, lex.getString());
                if (tmpret == -1) {
                        ++tmpret;
                        paperpackage = PACKAGE_NONE;
@@ -370,7 +397,8 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
                ss >> a;
                author_map.push_back(pimpl_->authorlist.record(a));
        } else if (token == "\\paperorientation") {
-               int tmpret = lex.findToken(string_orientation);
+               lex.next();
+               int tmpret = findToken(string_orientation, lex.getString());
                if (tmpret == -1)
                        ++tmpret;
                orientation =
index 3e4f0d70dc137fc46ce8fcce36ed2c8f2bae7935..664d95cfe91a5e8febc8ff2cdb0f90fe759d6766 100644 (file)
@@ -230,32 +230,6 @@ void LyXLex::pushToken(string const & pt)
        pimpl_->pushToken(pt);
 }
 
-
-int LyXLex::findToken(char const * const str[])
-{
-       if (!next()) {
-               pimpl_->printError("file ended while scanning string token");
-               return -1;
-       }
-
-       int i = 0;
-
-       string const search_token = pimpl_->getString();
-
-       if (search_token != "default") {
-               while (str[i][0] && str[i] != search_token) {
-                       ++i;
-               }
-               if (!str[i][0]) {
-                       pimpl_->printError("Unknown argument `$$Token'");
-                       i = -1;
-               }
-       }
-
-       return i;
-}
-
-
 LyXLex::operator void const *() const
 {
        // This behaviour is NOT the same as the std::streams which would
index 13937e6a7d8b9f7f21974eeca6db6f4e4f2984d6..9797b8a8a9cd81b3c48d1c83fd054662a51a1c2e 100644 (file)
@@ -111,8 +111,6 @@ public:
 
        ///
        bool eatLine();
-       ///
-       int findToken(char const * const str[]);
 
        /// Pushes a token list on a stack and replaces it with a new one.
        void pushTable(keyword_item *, int);