]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/biblio.C
fix crash due to invalidated iterator
[lyx.git] / src / frontends / controllers / biblio.C
index 129234c86d70ead97377841afeddc06f59ab931d..32d4f8af3610f172bc9b250fe5d6afe14d716add 100644 (file)
@@ -269,8 +269,9 @@ string const getYear(InfoMap const & map, string const & key)
 namespace {
 
 // A functor for use with std::sort, leading to case insensitive sorting
-struct compareNoCase: public std::binary_function<string, string, bool>
+class compareNoCase: public std::binary_function<string, string, bool>
 {
+public:
        bool operator()(string const & s1, string const & s2) const {
                return compare_ascii_no_case(s1, s2) < 0;
        }
@@ -323,6 +324,7 @@ string const getInfo(InfoMap const & map, string const & key)
        string number     = parseBibTeX(data, "number");
        string volume     = parseBibTeX(data, "volume");
        string pages      = parseBibTeX(data, "pages");
+       string annote     = parseBibTeX(data, "annote");
 
        string media      = parseBibTeX(data, "journal");
        if (media.empty())
@@ -351,6 +353,8 @@ string const getInfo(InfoMap const & map, string const & key)
                result << ", pp. " << pages;
        if (!year.empty())
                result << ", " << year;
+       if (!annote.empty())
+               result << "\n\n" << annote;
 
        string const result_str = rtrim(result.str());
        if (!result_str.empty())
@@ -384,8 +388,9 @@ string const escape_special_chars(string const & expr)
 
 // A functor for use with std::find_if, used to ascertain whether a
 // data entry matches the required regex_
-struct RegexMatch : public std::unary_function<string, bool>
+class RegexMatch : public std::unary_function<string, bool>
 {
+public:
        // re and icase are used to construct an instance of boost::RegEx.
        // if icase is true, then matching is insensitive to case
        RegexMatch(InfoMap const & m, string const & re, bool icase)
@@ -478,7 +483,11 @@ string const parseBibTeX(string data, string const & findkey)
                string::size_type const idx =
                        dummy.empty() ? string::npos : dummy.find('%');
                if (idx != string::npos)
-                       dummy.erase(idx, string::npos);
+                       // Check if this is really a comment or just "\%"
+                       if (idx == 0 || dummy[idx - 1] != '\\')
+                               dummy.erase(idx, string::npos);
+                       else  //  This is "\%", so just erase the '\'
+                               dummy.erase(idx - 1, 1);
                // do we have a new token or a new line of
                // the same one? In the first case we ignore
                // the \n and in the second we replace it