]> git.lyx.org Git - lyx.git/commitdiff
Fix minor annoyance with previous commit.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Tue, 29 Sep 2020 02:07:08 +0000 (22:07 -0400)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Tue, 29 Sep 2020 02:07:08 +0000 (22:07 -0400)
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.

src/Layout.cpp
src/Layout.h
src/TextClass.cpp
src/TextClass.h

index 1f5a8982e061d023518ef9374f8c0abd0aaaaaea..48328cca43c6ba687dd8ccf43be9ed3f9a140deb 100644 (file)
@@ -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);
index 590c52d34168033f13dc7644f86a1a6a33698391..a3390219fa4a89e578ab309214f126b595581503 100644 (file)
@@ -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;
        ///
index 2c467b6d4cf5262145938a62226f5c3bb5b058d5..3628872ae306dc3ec7f571d62d06c927431ac177 100644 (file)
@@ -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);
index bf061acd0ff64e3fae2e4a819563babfe371ab07..11710edfe461043198fc969fe33d34a51441df33 100644 (file)
@@ -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 &);
        ///