mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
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
This commit is contained in:
parent
89eb5d132d
commit
61ba4014ef
@ -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):
|
||||
|
@ -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));
|
||||
|
@ -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 =
|
||||
|
26
src/lyxlex.C
26
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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user