From 852dfe3869d4207deb653617fa4f8900289ab870 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Wed, 27 May 2009 22:21:33 +0000 Subject: [PATCH] Fix writing of \bibtex_alternatives and \index_alternatives to the preferences file. Now the alternatives are only written if they have actually been changed, and not always as it was before. Existing preferences files will be automatically trimmed on next save. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29869 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LyXRC.cpp | 60 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 401aa9546d..993fb3889f 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -1370,15 +1370,33 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c } if (tag != RC_LAST) break; - case RC_BIBTEX_ALTERNATIVES: - if (ignore_system_lyxrc || - bibtex_alternatives != system_lyxrc.bibtex_alternatives) { - for (vector::const_iterator it = bibtex_alternatives.begin(); - it != bibtex_alternatives.end(); ++it) - os << "\\bibtex_alternatives \"" << *it << "\"\n"; + case RC_BIBTEX_ALTERNATIVES: { + vector::const_iterator it = bibtex_alternatives.begin(); + vector::const_iterator end = bibtex_alternatives.end(); + if (ignore_system_lyxrc) { + for ( ; it != end; ++it) + os << "\\bibtex_alternatives \"" + << *it << "\"\n"; + } else { + vector::const_iterator sbeg = + system_lyxrc.bibtex_alternatives.begin(); + vector::const_iterator send = + system_lyxrc.bibtex_alternatives.end(); + for ( ; it != end; ++it) { + bool found = false; + for (vector::const_iterator sit = sbeg; + sit != send; ++sit) { + if (*it == *sit) + found = true; + } + if (!found) + os << "\\bibtex_alternatives \"" + << *it << "\"\n"; + } } if (tag != RC_LAST) break; + } case RC_BIBTEX_COMMAND: if (ignore_system_lyxrc || bibtex_command != system_lyxrc.bibtex_command) { @@ -1393,15 +1411,33 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c } if (tag != RC_LAST) break; - case RC_INDEX_ALTERNATIVES: - if (ignore_system_lyxrc || - index_alternatives != system_lyxrc.index_alternatives) { - for (vector::const_iterator it = index_alternatives.begin(); - it != index_alternatives.end(); ++it) - os << "\\index_alternatives \"" << *it << "\"\n"; + case RC_INDEX_ALTERNATIVES: { + vector::const_iterator it = index_alternatives.begin(); + vector::const_iterator end = index_alternatives.end(); + if (ignore_system_lyxrc) { + for ( ; it != end; ++it) + os << "\\index_alternatives \"" + << *it << "\"\n"; + } else { + vector::const_iterator sbeg = + system_lyxrc.index_alternatives.begin(); + vector::const_iterator send = + system_lyxrc.index_alternatives.end(); + for ( ; it != end; ++it) { + bool found = false; + for (vector::const_iterator sit = sbeg; + sit != send; ++sit) { + if (*it == *sit) + found = true; + } + if (!found) + os << "\\index_alternatives \"" + << *it << "\"\n"; + } } if (tag != RC_LAST) break; + } case RC_INDEX_COMMAND: if (ignore_system_lyxrc || index_command != system_lyxrc.index_command) { -- 2.39.5