From 61ba4014ef67f5c47bbec91e6e735e8d03f55784 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Matox?= Date: Fri, 20 Aug 2004 13:06:33 +0000 Subject: [PATCH] Remove findToken from lyxlyex, first step to its complete removal. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8960 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 9 +++++++++ src/ParagraphParameters.C | 23 ++++++++++++++++++++++- src/bufferparams.C | 38 +++++++++++++++++++++++++++++++++----- src/lyxlex.C | 26 -------------------------- src/lyxlex.h | 2 -- 5 files changed, 64 insertions(+), 34 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 578f044b61..7185f5cbd6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2004-08-20 José Matos + + * 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 * ParagraphParameters.C (write): diff --git a/src/ParagraphParameters.C b/src/ParagraphParameters.C index a1e62c521e..428063f0fd 100644 --- a/src/ParagraphParameters.C +++ b/src/ParagraphParameters.C @@ -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)); diff --git a/src/bufferparams.C b/src/bufferparams.C index d5b40ba8ee..da933c112b 100644 --- a/src/bufferparams.C +++ b/src/bufferparams.C @@ -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 = diff --git a/src/lyxlex.C b/src/lyxlex.C index 3e4f0d70dc..664d95cfe9 100644 --- a/src/lyxlex.C +++ b/src/lyxlex.C @@ -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 diff --git a/src/lyxlex.h b/src/lyxlex.h index 13937e6a7d..9797b8a8a9 100644 --- a/src/lyxlex.h +++ b/src/lyxlex.h @@ -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); -- 2.39.5