From 53fe956d871f594a6caf603e03437991d90ef46f Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Sat, 22 May 2010 15:08:10 +0000 Subject: [PATCH] Backport fix for #6649. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@34452 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetIndex.cpp | 6 +++++- src/support/lstrings.cpp | 15 +++++++++++++++ src/support/lstrings.h | 3 +++ status.16x | 2 ++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp index 54254c5b3b..dd43fb9293 100644 --- a/src/insets/InsetIndex.cpp +++ b/src/insets/InsetIndex.cpp @@ -137,15 +137,19 @@ int InsetIndex::latex(odocstream & os, subst(spart2, from_ascii("\\"), docstring()); os << ppart; os << '@'; + i += count_char(ppart, '\n'); } docstring const tpart = *it; os << tpart; + i += count_char(tpart, '\n'); if (it2 < levels_plain.end()) ++it2; } // write the bit that followed "|" - if (!cmd.empty()) + if (!cmd.empty()) { os << "|" << cmd; + i += count_char(cmd, '\n'); + } os << '}'; return i; } diff --git a/src/support/lstrings.cpp b/src/support/lstrings.cpp index a20ae64108..c375c57ad9 100644 --- a/src/support/lstrings.cpp +++ b/src/support/lstrings.cpp @@ -649,6 +649,7 @@ basic_string const subst_char(basic_string const & a, return tmp; } + /// Substitute all \a oldchar with \a newchar docstring const subst_char(docstring const & a, docstring::value_type oldchar, docstring::value_type newchar) @@ -680,6 +681,7 @@ String const subst_string(String const & a, return lstr; } + docstring const subst_string(docstring const & a, docstring const & oldstr, docstring const & newstr) { @@ -725,6 +727,19 @@ docstring const subst(docstring const & a, } +/// Count all occurences of char \a chr inside \a str +int count_char(docstring const & str, docstring::value_type chr) +{ + int count = 0; + docstring::const_iterator lit = str.begin(); + docstring::const_iterator end = str.end(); + for (; lit != end; ++lit) + if ((*lit) == chr) + count++; + return count; +} + + docstring const trim(docstring const & a, char const * p) { LASSERT(p, /**/); diff --git a/src/support/lstrings.h b/src/support/lstrings.h index fd288d4357..513f4375c3 100644 --- a/src/support/lstrings.h +++ b/src/support/lstrings.h @@ -170,6 +170,9 @@ std::string const subst(std::string const & a, docstring const subst(docstring const & a, docstring const & oldstr, docstring const & newstr); +/// Count all occurences of char \a chr inside \a str +int count_char(docstring const & str, docstring::value_type chr); + /** Trims characters off the end and beginning of a string. \code trim("ccabccc", "c") == "ab". diff --git a/status.16x b/status.16x index 43c8a9e317..d2b31ef826 100644 --- a/status.16x +++ b/status.16x @@ -56,6 +56,8 @@ What's new * USER INTERFACE +- Improve reverse search for documents with index insets (bug 6649). + * DOCUMENTATION AND LOCALIZATION