mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 21:21:32 +00:00
Fix minor annoyance with previous commit.
When validating local layout, in particular, we create a dummy text TextClass and so are not necessarily modifying previously declared material. Hence, we get a spurious (but harmless) "Incomplete argument definition!" warning. This suppresses it, but to do that we need to propogate the ReadType.
This commit is contained in:
parent
6f643e52d4
commit
594401912b
@ -194,15 +194,15 @@ Layout::Layout()
|
||||
}
|
||||
|
||||
|
||||
bool Layout::read(Lexer & lex, TextClass const & tclass)
|
||||
bool Layout::read(Lexer & lex, TextClass const & tclass, bool validating)
|
||||
{
|
||||
// If this is an empty layout, or if no force local version is set,
|
||||
// we know that we will not discard the stuff to read
|
||||
if (forcelocal == 0)
|
||||
return readIgnoreForcelocal(lex, tclass);
|
||||
return readIgnoreForcelocal(lex, tclass, validating);
|
||||
Layout tmp(*this);
|
||||
tmp.forcelocal = 0;
|
||||
bool const ret = tmp.readIgnoreForcelocal(lex, tclass);
|
||||
bool const ret = tmp.readIgnoreForcelocal(lex, tclass, validating);
|
||||
// Keep the stuff if
|
||||
// - the read version is higher
|
||||
// - both versions are infinity (arbitrary decision)
|
||||
@ -214,7 +214,8 @@ bool Layout::read(Lexer & lex, TextClass const & tclass)
|
||||
}
|
||||
|
||||
|
||||
bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
|
||||
bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass,
|
||||
bool validating)
|
||||
{
|
||||
// This table is sorted alphabetically [asierra 30March96]
|
||||
LexerKeyword layoutTags[] = {
|
||||
@ -441,7 +442,7 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
|
||||
break;
|
||||
|
||||
case LT_ARGUMENT:
|
||||
readArgument(lex);
|
||||
readArgument(lex, validating);
|
||||
break;
|
||||
|
||||
case LT_NEED_PROTECT:
|
||||
@ -1242,7 +1243,7 @@ void Layout::readArgument(Lexer & lex, bool validating)
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
if (arg.labelstring.empty())
|
||||
if (!validating && arg.labelstring.empty()) {
|
||||
LYXERR0("Incomplete Argument definition!");
|
||||
// remove invalid definition
|
||||
lam.erase(id);
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
void setUnknown(bool unknown) { unknown_ = unknown; }
|
||||
/// Reads a layout definition from file
|
||||
/// \return true on success.
|
||||
bool read(Lexer &, TextClass const &);
|
||||
bool read(Lexer &, TextClass const &, bool validating = false);
|
||||
///
|
||||
void readAlign(Lexer &);
|
||||
///
|
||||
@ -74,7 +74,7 @@ public:
|
||||
///
|
||||
void readSpacing(Lexer &);
|
||||
///
|
||||
void readArgument(Lexer &);
|
||||
void readArgument(Lexer &, bool);
|
||||
/// Write a layout definition in utf8 encoding
|
||||
void write(std::ostream &) const;
|
||||
///
|
||||
@ -411,7 +411,7 @@ public:
|
||||
private:
|
||||
/// Reads a layout definition from file
|
||||
/// \return true on success.
|
||||
bool readIgnoreForcelocal(Lexer &, TextClass const &);
|
||||
bool readIgnoreForcelocal(Lexer &, TextClass const &, bool validating);
|
||||
/// generates the default CSS for this layout
|
||||
void makeDefaultCSS() const;
|
||||
///
|
||||
|
@ -148,10 +148,10 @@ TextClass::TextClass()
|
||||
}
|
||||
|
||||
|
||||
bool TextClass::readStyle(Lexer & lexrc, Layout & lay) const
|
||||
bool TextClass::readStyle(Lexer & lexrc, Layout & lay, ReadType rt) const
|
||||
{
|
||||
LYXERR(Debug::TCLASS, "Reading style " << to_utf8(lay.name()));
|
||||
if (!lay.read(lexrc, *this)) {
|
||||
if (!lay.read(lexrc, *this, rt == VALIDATION)) {
|
||||
LYXERR0("Error parsing style `" << to_utf8(lay.name()) << '\'');
|
||||
return false;
|
||||
}
|
||||
@ -515,7 +515,7 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
|
||||
Layout lay;
|
||||
// Since we couldn't read the name, we just scan the rest
|
||||
// of the style and discard it.
|
||||
error = !readStyle(lexrc, lay);
|
||||
error = !readStyle(lexrc, lay, rt);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -526,14 +526,14 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
|
||||
// block.
|
||||
if (have_layout && !providestyle) {
|
||||
Layout & lay = operator[](name);
|
||||
error = !readStyle(lexrc, lay);
|
||||
error = !readStyle(lexrc, lay, rt);
|
||||
}
|
||||
// If the layout does not exist, then we want to create a new
|
||||
// one, but not if we are in a ModifyStyle block.
|
||||
else if (!have_layout && !modifystyle) {
|
||||
Layout layout;
|
||||
layout.setName(name);
|
||||
error = !readStyle(lexrc, layout);
|
||||
error = !readStyle(lexrc, layout, rt);
|
||||
if (!error)
|
||||
layoutlist_.push_back(layout);
|
||||
|
||||
@ -551,7 +551,7 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
|
||||
else {
|
||||
Layout lay;
|
||||
// signal to coverity that we do not care about the result
|
||||
(void)readStyle(lexrc, lay);
|
||||
(void)readStyle(lexrc, lay, rt);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1862,7 +1862,7 @@ Layout TextClass::createBasicLayout(docstring const & name, bool unknown) const
|
||||
defaultLayout = new Layout;
|
||||
defaultLayout->setUnknown(unknown);
|
||||
defaultLayout->setName(name);
|
||||
if (!readStyle(lex, *defaultLayout)) {
|
||||
if (!readStyle(lex, *defaultLayout, BASECLASS)) {
|
||||
// The only way this happens is because the hardcoded layout above
|
||||
// is wrong.
|
||||
LATTEST(false);
|
||||
|
@ -389,7 +389,7 @@ private:
|
||||
/// Reads the layout file without running layout2layout.
|
||||
ReturnValues readWithoutConv(support::FileName const & filename, ReadType rt);
|
||||
/// \return true for success.
|
||||
bool readStyle(Lexer &, Layout &) const;
|
||||
bool readStyle(Lexer &, Layout &, ReadType) const;
|
||||
///
|
||||
void readOutputType(Lexer &);
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user