]> git.lyx.org Git - lyx.git/commitdiff
Many small code cleanups suggested by cppcheck
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 15 Sep 2019 22:43:35 +0000 (00:43 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 15 Sep 2019 22:45:20 +0000 (00:45 +0200)
src/insets/InsetCollapsible.cpp
src/insets/InsetCollapsible.h
src/insets/InsetFloat.cpp
src/insets/InsetFloat.h
src/insets/InsetInclude.cpp
src/insets/InsetInfo.cpp
src/insets/InsetInfo.h
src/insets/InsetQuotes.cpp
src/insets/InsetText.cpp

index 0420452bb98d7f8483613e6d1e80681c5989844f..755bb6c30b40e7a11de635f20f0d6d41e775678d 100644 (file)
@@ -65,7 +65,7 @@ InsetCollapsible::InsetCollapsible(InsetCollapsible const & rhs)
 }
 
 
-InsetCollapsible const & InsetCollapsible::operator=(InsetCollapsible const & that)
+InsetCollapsible & InsetCollapsible::operator=(InsetCollapsible const & that)
 {
        if (&that == this)
                return *this;
index dac8440a5cbee6a59071ddd2333747ef7dee0712..423f2349872246f2c1d1c0e1b6f4a4cad8c69314 100644 (file)
@@ -39,7 +39,7 @@ public:
        ///
        InsetCollapsible(InsetCollapsible const & rhs);
        ///
-       InsetCollapsible const & operator=(InsetCollapsible const &);
+       InsetCollapsible & operator=(InsetCollapsible const &);
        ///
        virtual ~InsetCollapsible();
        ///
index 9d92681dd20ccd021d354ee7406c068dfb24dd45..95e9af74d11a6a3e77c2cf61b27761d89c845bde 100644 (file)
@@ -114,7 +114,7 @@ namespace lyx {
 // Lgb
 
 //FIXME: why do we set in stone the type here?
-InsetFloat::InsetFloat(Buffer * buf, string params_str)
+InsetFloat::InsetFloat(Buffer * buf, string const & params_str)
        : InsetCaptionable(buf)
 {
        string2params(params_str, params_);
@@ -431,7 +431,7 @@ void InsetFloat::latex(otexstream & os, OutputParams const & runparams_in) const
        // sidewaysfloats always use their own page,
        // therefore don't output the p option that is always set
        if (!placement.empty()
-           && (!params_.sideways || (params_.sideways && from_ascii(placement) != "p")))
+           && (!params_.sideways || from_ascii(placement) != "p"))
                os << '[' << from_ascii(placement) << ']';
        os << '\n';
 
index 62b5873b9024520e4eb570dad802bf1cce77a3bc..224017e7eafa72d8d389aae4d23e47dbb666ba3d 100644 (file)
@@ -57,7 +57,7 @@ public:
 class InsetFloat : public InsetCaptionable
 {
 public:
-       InsetFloat(Buffer * buffer, std::string params_str);
+       InsetFloat(Buffer * buffer, std::string const & params_str);
        ///
        static void string2params(std::string const &, InsetFloatParams &);
        ///
index 0dead769395caaffd184f025bda69cc55772e486..3cf318906fb3912cd8a96a28f47193cd4fb90b3c 100755 (executable)
@@ -883,15 +883,15 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
                // If needed, use converters to produce a latex file from the child
                if (tmpwritefile != writefile) {
                        ErrorList el;
-                       Converters::RetVal const retval =
+                       Converters::RetVal const conv_retval =
                                theConverters().convert(tmp, tmpwritefile, writefile,
                                    included_file, inc_format, tex_format, el);
-                       if (retval == Converters::KILLED && buffer().isClone() &&
+                       if (conv_retval == Converters::KILLED && buffer().isClone() &&
                            buffer().isExporting()) {
                                // We really shouldn't get here, I don't think.
                                LYXERR0("No conversion exception?");
                                throw ConversionException();
-                       } else if (retval != Converters::SUCCESS && !runparams.silent) {
+                       } else if (conv_retval != Converters::SUCCESS && !runparams.silent) {
                                docstring msg = bformat(_("Included file `%1$s' "
                                                "was not exported correctly.\n "
                                                "LaTeX export is probably incomplete."),
index 58cd25be5f514101628625d90274ac3d7afc0176..f0f731bff2bfaa3ac98a5d9eda9aa0c762ac8920 100644 (file)
@@ -168,7 +168,7 @@ set<string> getTexFileList(string const & filename)
        return list;
 }
 
-bool translateString(docstring const in, docstring & out, string const lcode)
+bool translateString(docstring const & in, docstring & out, string const & lcode)
 {
        out = translateIfPossible(in, lcode);
        return in != out;
@@ -176,7 +176,7 @@ bool translateString(docstring const in, docstring & out, string const lcode)
 } // namespace anon
 
 
-docstring InsetInfoParams::getDate(string const iname, QDate const date) const
+docstring InsetInfoParams::getDate(string const iname, QDate const date) const
 {
        QLocale loc;
        if (lang)
@@ -201,7 +201,7 @@ docstring InsetInfoParams::getDate(string const iname, QDate const date) const
 }
 
 
-docstring InsetInfoParams::getTime(string const iname, QTime const time) const
+docstring InsetInfoParams::getTime(string const iname, QTime const time) const
 {
        QLocale loc;
        if (lang)
index 6fa080d2be6aa05889c7c67ed5fc47c34a130574..fa3cfda72899f653a77dd2ede20ecbfdbae47479 100644 (file)
@@ -139,9 +139,9 @@ public:
                UNKNOWN_INFO,    // Invalid type
        };
        ///
-       docstring getDate(std::string const, QDate const date = QDate::currentDate()) const;
+       docstring getDate(std::string const &, QDate const date = QDate::currentDate()) const;
        ///
-       docstring getTime(std::string const, QTime const time = QTime::currentTime()) const;
+       docstring getTime(std::string const &, QTime const time = QTime::currentTime()) const;
        ///
        std::vector<std::pair<std::string,docstring>> getArguments(Buffer const * buf,
                                                                   std::string const &) const;
index fca77e5c4dfdce3a6587a8f6367480320d8aefd1..d34efa48cd4ed07d920c8c4d969f41e9b286da04 100644 (file)
@@ -111,10 +111,9 @@ InsetQuotesParams::QuoteStyle InsetQuotesParams::getQuoteStyle(string const & s,
                str = "eld";
        }
 
-       int i;
-
        // '.' wildcard means: keep current style
        if (!allow_wildcards || str[0] != '.') {
+               int i;
                for (i = 0; i < stylescount(); ++i) {
                        if (str[0] == style_char[i]) {
                                res = QuoteStyle(i);
@@ -144,10 +143,9 @@ InsetQuotesParams::QuoteSide InsetQuotesParams::getQuoteSide(string const & s,
                str = "eld";
        }
 
-       int i;
-
        // '.' wildcard means: keep current side
        if (!allow_wildcards || str[1] != '.') {
+               int i;
                for (i = 0; i < 2; ++i) {
                        if (str[1] == side_char[i]) {
                                res = InsetQuotesParams::QuoteSide(i);
@@ -177,10 +175,9 @@ InsetQuotesParams::QuoteLevel InsetQuotesParams::getQuoteLevel(string const & s,
                str = "eld";
        }
 
-       int i;
-
        // '.' wildcard means: keep current level
        if (!allow_wildcards || str[2] != '.') {
+               int i;
                for (i = 0; i < 2; ++i) {
                        if (str[2] == level_char[i]) {
                                res = InsetQuotesParams::QuoteLevel(i);
index f2073f6cdff9ae9d9c81c4a254b11b694cbadfde..c7757f1673006b91da449ae35b173234b2c150ec 100644 (file)
@@ -86,10 +86,9 @@ InsetText::InsetText(Buffer * buf, UsePlain type)
 
 
 InsetText::InsetText(InsetText const & in)
-       : Inset(in), text_(this, in.text_)
+       : Inset(in), drawFrame_(in.drawFrame_), frame_color_(in.frame_color_),
+         text_(this, in.text_)
 {
-       drawFrame_ = in.drawFrame_;
-       frame_color_ = in.frame_color_;
 }
 
 
@@ -1142,9 +1141,9 @@ bool InsetText::needsCProtection(bool const maintext, bool const fragile) const
                Paragraph const & par = pars[size_type(pit)];
                if (par.needsCProtection(fragile))
                        return true;
-               docstring const pars = par.asString();
+               docstring const par_str = par.asString();
                for (int k = 0; k < nchars_escape; k++) {
-                       if (contains(pars, chars_escape[k]))
+                       if (contains(par_str, chars_escape[k]))
                                return true;
                }
        }