From 28ae543a2a22f187628c5135c4f1d402eb65afa5 Mon Sep 17 00:00:00 2001 From: Richard Kimberly Heck Date: Tue, 13 Oct 2020 17:24:36 -0400 Subject: [PATCH] Fix signed-ness warnings --- src/insets/InsetArgument.cpp | 11 +++++----- src/insets/InsetLayout.cpp | 8 +++---- src/insets/InsetLayout.h | 4 ++-- src/output_latex.cpp | 42 +++++++++++++++++------------------- 4 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/insets/InsetArgument.cpp b/src/insets/InsetArgument.cpp index 00484f791f..2e8d0ba74c 100644 --- a/src/insets/InsetArgument.cpp +++ b/src/insets/InsetArgument.cpp @@ -73,13 +73,14 @@ void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype, bool bool const former_pass_thru = pass_thru_; // Handle pre 2.1 ArgInsets (lyx2lyx cannot classify them) + // "999" is the conventional name given to those by lyx2lyx if (name_ == "999") { - unsigned int const req = insetlayout ? it.inset().getLayout().requiredArgs() + int const req = insetlayout ? it.inset().getLayout().requiredArgs() : it.paragraph().layout().requiredArgs(); - unsigned int const opts = insetlayout ? it.inset().getLayout().optArgs() + int const opts = insetlayout ? it.inset().getLayout().optArgs() : it.paragraph().layout().optArgs(); - unsigned int nr = 0; - unsigned int ours = 0; + int nr = 0; + int ours = 0; InsetList::const_iterator parit = it.paragraph().insetList().begin(); InsetList::const_iterator parend = it.paragraph().insetList().end(); for (; parit != parend; ++parit) { @@ -90,7 +91,7 @@ void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype, bool } } bool done = false; - unsigned int realopts = 0; + int realopts = 0; if (nr > req) { // We have optional arguments realopts = nr - req; diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp index d758a1c3a4..19e4aa68c3 100644 --- a/src/insets/InsetLayout.cpp +++ b/src/insets/InsetLayout.cpp @@ -769,9 +769,9 @@ Layout::LaTeXArgMap InsetLayout::args() const } -unsigned int InsetLayout::optArgs() const +int InsetLayout::optArgs() const { - unsigned int nr = 0; + int nr = 0; Layout::LaTeXArgMap const args = InsetLayout::args(); Layout::LaTeXArgMap::const_iterator it = args.begin(); for (; it != args.end(); ++it) { @@ -782,9 +782,9 @@ unsigned int InsetLayout::optArgs() const } -unsigned int InsetLayout::requiredArgs() const +int InsetLayout::requiredArgs() const { - unsigned int nr = 0; + int nr = 0; Layout::LaTeXArgMap const args = InsetLayout::args(); Layout::LaTeXArgMap::const_iterator it = args.begin(); for (; it != args.end(); ++it) { diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h index 33aa15c2cd..10c7bae4d6 100644 --- a/src/insets/InsetLayout.h +++ b/src/insets/InsetLayout.h @@ -99,9 +99,9 @@ public: /// Those are iterators for different containers. Layout::LaTeXArgMap args() const; /// - unsigned int optArgs() const; + int optArgs() const; /// - unsigned int requiredArgs() const; + int requiredArgs() const; /// docstring preamble() const { return preamble_; } /// Get language dependent macro definitions needed for this inset diff --git a/src/output_latex.cpp b/src/output_latex.cpp index b2d51488cd..b8243c17f0 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -63,16 +63,16 @@ enum OpenEncoding { struct OutputState { - OutputState() : open_encoding_(none), cjk_inherited_(0), - prev_env_language_(nullptr), nest_level_(0) + OutputState() : prev_env_language_(nullptr), open_encoding_(none), + cjk_inherited_(0), nest_level_(0) { } - OpenEncoding open_encoding_; - int cjk_inherited_; Language const * prev_env_language_; - int nest_level_; stack lang_switch_depth_; // Both are always empty when stack open_polyglossia_lang_; // not using polyglossia + OpenEncoding open_encoding_; + int cjk_inherited_; + int nest_level_; }; @@ -164,10 +164,10 @@ string const getPolyglossiaBegin(string const & lang_begin_command, struct TeXEnvironmentData { - bool cjk_nested; Layout const * style; Language const * par_language; Encoding const * prev_encoding; + bool cjk_nested; bool leftindent_open; }; @@ -464,9 +464,9 @@ void TeXEnvironment(Buffer const & buf, Text const & text, void getArgInsets(otexstream & os, OutputParams const & runparams, Layout::LaTeXArgMap const & latexargs, - map ilist, vector required, string const & prefix) + map ilist, vector required, string const & prefix) { - unsigned int const argnr = latexargs.size(); + size_t const argnr = latexargs.size(); if (argnr == 0) return; @@ -480,16 +480,16 @@ void getArgInsets(otexstream & os, OutputParams const & runparams, Layout::LaTeX } } - for (unsigned int i = 1; i <= argnr; ++i) { - map::const_iterator lit = ilist.find(i); + for (size_t i = 1; i <= argnr; ++i) { + map::const_iterator lit = ilist.find(i); bool inserted = false; if (lit != ilist.end()) { - InsetArgument const * ins = (*lit).second; + InsetArgument const * ins = lit->second; if (ins) { Layout::LaTeXArgMap::const_iterator const lait = latexargs.find(ins->name()); if (lait != latexargs.end()) { - Layout::latexarg arg = (*lait).second; + Layout::latexarg arg = lait->second; docstring ldelim; docstring rdelim; if (!arg.nodelims) { @@ -588,7 +588,7 @@ namespace { void addArgInsets(Paragraph const & par, string const & prefix, Layout::LaTeXArgMap const & latexargs, - map & ilist, + map & ilist, vector & required) { for (auto const & table : par.insetList()) { @@ -601,8 +601,7 @@ void addArgInsets(Paragraph const & par, string const & prefix, } string const name = prefix.empty() ? arg->name() : split(arg->name(), ':'); - // why converting into an integer? - unsigned int const nr = convert(name); + size_t const nr = convert(name); if (ilist.find(nr) == ilist.end()) ilist[nr] = arg; Layout::LaTeXArgMap::const_iterator const lit = @@ -623,7 +622,7 @@ void latexArgInsets(Paragraph const & par, otexstream & os, Layout::LaTeXArgMap const & latexargs, string const & prefix) { - map ilist; + map ilist; vector required; addArgInsets(par, prefix, latexargs, ilist, required); getArgInsets(os, runparams, latexargs, ilist, required, prefix); @@ -636,7 +635,7 @@ void latexArgInsets(ParagraphList const & pars, Layout::LaTeXArgMap const & latexargs, string const & prefix) { - map ilist; + map ilist; vector required; depth_type const current_depth = pit->params().depth(); @@ -656,7 +655,6 @@ void latexArgInsets(ParagraphList const & pars, } ParagraphList::const_iterator spit = prev(pit, offset); - for (; spit != pars.end(); ++spit) { if (spit->layout() != current_layout || spit->params().depth() < current_depth) @@ -674,7 +672,7 @@ void latexArgInsetsForParent(ParagraphList const & pars, otexstream & os, Layout::LaTeXArgMap const & latexargs, string const & prefix) { - map ilist; + map ilist; vector required; for (Paragraph const & par : pars) { @@ -1589,7 +1587,7 @@ void latexParagraphs(Buffer const & buf, // The full doc will be exported but it is easier to just rely on // runparams range parameters that will be passed TeXEnvironment. runparams.par_begin = 0; - runparams.par_end = paragraphs.size(); + runparams.par_end = static_cast(paragraphs.size()); } pit_type pit = runparams.par_begin; @@ -1815,7 +1813,7 @@ pair switchEncoding(odocstream & os, BufferParams const & bparams, // shouldn't ever reach here (see above) but avoids warning. return make_pair(true, 0); case Encoding::inputenc: { - int count = inputenc_arg.length(); + size_t count = inputenc_arg.length(); if (oldEnc.package() == Encoding::CJK && state->open_encoding_ == CJK) { os << "\\end{CJK}"; @@ -1843,7 +1841,7 @@ pair switchEncoding(odocstream & os, BufferParams const & bparams, return make_pair(true, count + 16); } case Encoding::CJK: { - int count = inputenc_arg.length(); + size_t count = inputenc_arg.length(); if (oldEnc.package() == Encoding::CJK && state->open_encoding_ == CJK) { os << "\\end{CJK}";