The output while debugging findadv is overwhelming, but sometimes one needs only a small subset. Therefore the addition of -dbg findshort.
Also it would be possible to use constructions like LYXERR(Debug::FIND|Debug::FINDSHORT, "Setting regexp to : '" << regexp_str << "'") (mark the '|' in 'Debug::FIND|Debug::FINDSHORT' parameter) The changes to lyxfind.cpp are also attached. OK to commit? Kornel -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
diff --git a/src/support/debug.cpp b/src/support/debug.cpp index b89074120e..a6c6f5b617 100644 --- a/src/support/debug.cpp +++ b/src/support/debug.cpp @@ -70,10 +70,11 @@ DebugErrorItem errorTags[] = { { Debug::MACROS, "macros", N_("Math macros")}, { Debug::RTL, "rtl", N_("RTL/Bidi")}, { Debug::LOCALE, "locale", N_("Locale/Internationalisation")}, { Debug::SELECTION, "selection", N_("Selection copy/paste mechanism")}, { Debug::FIND, "find", N_("Find and replace mechanism")}, + { Debug::FINDSHORT, "findshort", N_("Find and replace mechanism, short version")}, { Debug::DEBUG, "debug", N_("Developers' general debug messages")}, { Debug::ANY, "any", N_("All debugging messages")}, { Debug::ANY, "all", N_("All debugging messages")} }; @@ -191,11 +192,11 @@ void Debug::showLevel(ostream & os, Debug::Type level) void Debug::showTags(ostream & os) { for (DebugErrorItem const & item : errorTags) - os << setw(10) << static_cast<unsigned int>(item.level) + os << setw(12) << static_cast<size_t>(item.level) << setw(13) << item.name << " " << to_utf8(_(item.desc)) << '\n'; os.flush(); } @@ -210,11 +211,11 @@ void LyXErr::enable() { enabled_ = true; } -bool LyXErr::debugging(Debug::Type t) const +bool LyXErr::debugging(size_t t) const { return (dt_ & t); } diff --git a/src/support/debug.h b/src/support/debug.h index 18dd5fa8ce..8b87e73603 100644 --- a/src/support/debug.h +++ b/src/support/debug.h @@ -35,11 +35,11 @@ typedef basic_streambuf<char, char_traits<char> > streambuf; namespace lyx { /// This is all the different debug levels that we have. namespace Debug { /// - enum Type { + enum Type : size_t { /// NONE = 0, /// INFO = (1u << 0), // 1 /// @@ -101,13 +101,15 @@ namespace Debug { /// selection SELECTION = (1u << 29), /// Find and Replace FIND = (1u << 30), /// - DEBUG = (1u << 31), + FINDSHORT = (1u << 31), /// - ANY = 0xffffffff + DEBUG = (1L << 32), + /// + ANY = 0x1ffffffff }; /// Return number of levels int levelCount(); @@ -177,11 +179,11 @@ public: /// Sets the debug level void setLevel(Debug::Type t) { dt_ = t; } /// Returns the current debug level Debug::Type level() const { return dt_; } /// Returns true if t is part of the current debug level - bool debugging(Debug::Type t = Debug::ANY) const; + bool debugging(size_t t = Debug::ANY) const; /// static char const * stripName(char const *); private:
diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index 2ea1e8811b..3f07aec00d 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -873,21 +873,21 @@ string correctRegex(string t, bool withformat) replace = accents["braceleft"]; else if (sub.str(3) == "}") replace = accents["braceright"]; else { // else part should not exist - LASSERT(1, /**/); + LASSERT(0, /**/); } } else { if (sub.str(3) == "{") replace = "\\{"; else if (sub.str(3) == "}") replace = "\\}"; else { // else part should not exist - LASSERT(1, /**/); + LASSERT(0, /**/); } } } else if (sub.str(4) == "{") // transforms '\{' into '{' replace = "{"; @@ -3583,12 +3583,12 @@ MatchStringAdv::MatchStringAdv(lyx::Buffer & buf, FindAndReplaceOptions & opt) } string regexp_str = "(" + lead_as_regex_string + ")()" + par_as_regex_string_nolead; string regexp2_str = "(" + lead_as_regex_string + ")(.*?)" + par_as_regex_string_nolead; CreateRegexp(opt, regexp_str, regexp2_str); use_regexp = true; - LYXERR(Debug::FIND, "Setting regexp to : '" << regexp_str << "'"); - LYXERR(Debug::FIND, "Setting regexp2 to: '" << regexp2_str << "'"); + LYXERR(Debug::FIND|Debug::FINDSHORT, "Setting regexp to : '" << regexp_str << "'"); + LYXERR(Debug::FIND|Debug::FINDSHORT, "Setting regexp2 to: '" << regexp2_str << "'"); return; } if (!opt.ignoreformat) { lead_size = identifyLeading(par_as_string); @@ -3660,12 +3660,12 @@ MatchStringAdv::MatchStringAdv(lyx::Buffer & buf, FindAndReplaceOptions & opt) opt.matchword = false; } regexp_str = "(" + lead_as_regexp + ")()" + par_as_string; regexp2_str = "(" + lead_as_regexp + ")(.*?)" + par_as_string; } - LYXERR(Debug::FIND, "Setting regexp to : '" << regexp_str << "'"); - LYXERR(Debug::FIND, "Setting regexp2 to: '" << regexp2_str << "'"); + LYXERR(Debug::FIND|Debug::FINDSHORT, "Setting regexp to : '" << regexp_str << "'"); + LYXERR(Debug::FIND|Debug::FINDSHORT, "Setting regexp2 to: '" << regexp2_str << "'"); CreateRegexp(opt, regexp_str, regexp2_str, par_as_string); } } MatchResult MatchStringAdv::findAux(DocIterator const & cur, int len, bool at_begin) const @@ -3957,28 +3957,30 @@ docstring stringifyFromCursor(DocIterator const & cur, int len) if (ignoreFormats.getNonContent()) { runparams.for_search |= OutputParams::SearchNonOutput; } LYXERR(Debug::FIND, "Stringifying with cur: " << cur << ", from pos: " << cur.pos() << ", end: " << end); - return from_utf8(latexNamesToUtf8(par.asString(cur.pos(), end, - option, - &runparams))); + docstring res = from_utf8(latexNamesToUtf8(par.asString(cur.pos(), end, + option, + &runparams))); + LYXERR(Debug::FINDSHORT, "Stringified text from pos(" << cur.pos() << ") len(" << len << "): " << res); + return res; } else if (cur.inMathed()) { CursorSlice cs = cur.top(); MathData md = cs.cell(); MathData::const_iterator it_end = (( len == -1 || cs.pos() + len > int(md.size())) ? md.end() : md.begin() + cs.pos() + len ); MathData md2; for (MathData::const_iterator it = md.begin() + cs.pos(); it != it_end; ++it) md2.push_back(*it); - docstring s = from_utf8(latexNamesToUtf8(asString(md2))); - LYXERR(Debug::FIND, "Stringified math: '" << s << "'"); - return s; + docstring res = from_utf8(latexNamesToUtf8(asString(md2))); + LYXERR(Debug::FIND|Debug::FINDSHORT, "Stringified math from pos(" << cur.pos() << ") len(" << len << "): " << res); + return res; } - LYXERR(Debug::FIND, "Don't know how to stringify from here: " << cur); + LYXERR(Debug::FIND|Debug::FINDSHORT, "Don't know how to stringify from here: " << cur); return docstring(); } /** Computes the LaTeX export of buf starting from cur and ending len positions * after cur, if len is positive, or at the paragraph or innermost inset end @@ -4017,13 +4019,12 @@ docstring latexifyFromCursor(DocIterator const & cur, int len) pos_type endpos = cur.paragraph().size(); if (len != -1 && endpos > cur.pos() + len) endpos = cur.pos() + len; TeXOnePar(buf, *cur.innerText(), cur.pit(), os, runparams, string(), cur.pos(), endpos); - string s = lyx::to_utf8(ods.str()); - LYXERR(Debug::FIND, "Latexified +modified text: '" << s << "'"); - return(lyx::from_utf8(s)); + LYXERR(Debug::FINDSHORT, "Latexified text from pos(" << cur.pos() << ") len(" << len << "): " << ods.str()); + return(ods.str()); } else if (cur.inMathed()) { // Retrieve the math environment type, and add '$' or '$[' or others (\begin{equation}) accordingly for (int s = cur.depth() - 1; s >= 0; --s) { CursorSlice const & cs = cur[s]; if (cs.asInsetMath() && cs.asInsetMath()->asHullInset()) { @@ -4054,13 +4055,13 @@ docstring latexifyFromCursor(DocIterator const & cur, int len) TeXMathStream ws(os); inset->asHullInset()->footer_write(ws); break; } } - LYXERR(Debug::FIND, "Latexified math: '" << lyx::to_utf8(ods.str()) << "'"); + LYXERR(Debug::FIND|Debug::FINDSHORT, "Latexified math from pos(" << cur.pos() << ") len(" << len << "): " << ods.str()); } else { - LYXERR(Debug::FIND, "Don't know how to stringify from here: " << cur); + LYXERR(Debug::FIND|Debug::FINDSHORT, "Don't know how to stringify from here: " << cur); } return ods.str(); } #if defined(ResultsDebug) @@ -4340,11 +4341,10 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & match) } // LYXERR0("Leaving first loop"); LYXERR(Debug::FIND, "Finalizing 1"); MatchResult found_match = findAdvFinalize(cur, match, mres); if (found_match.match_len > 0) { - LASSERT(found_match.pos_len > 0, /**/); match.FillResults(found_match); return found_match.pos_len; } else { // try next possible match @@ -4702,11 +4702,11 @@ bool findAdv(BufferView * bv, FindAndReplaceOptions & opt) if (cur.pos() + pos_len > cur.lastpos()) { // Prevent crash in bv->putSelectionAt() // Should never happen, maybe LASSERT() here? pos_len = cur.lastpos() - cur.pos(); } - LYXERR(Debug::FIND, "Putting selection at cur=" << cur << " with len: " << pos_len); + LYXERR(Debug::FIND|Debug::FINDSHORT, "Putting selection at cur=" << cur << " with len: " << pos_len); bv->putSelectionAt(cur, pos_len, !opt.forward); return true; }
pgpBjRrEtY20j.pgp
Description: Digitale Signatur von OpenPGP
-- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel