From 333485fa34449c5a543f35abac040285c2851042 Mon Sep 17 00:00:00 2001 From: Stephan Witt Date: Sat, 3 Jul 2010 16:26:47 +0000 Subject: [PATCH] add check for version 1 index files - skip them if present git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34750 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Thesaurus.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Thesaurus.cpp b/src/Thesaurus.cpp index 83eed55ea0..870f967f41 100644 --- a/src/Thesaurus.cpp +++ b/src/Thesaurus.cpp @@ -29,6 +29,7 @@ #include #include +#include using namespace std; using namespace lyx::support; @@ -91,10 +92,21 @@ pair Thesaurus::Private::getThesaurus(string const & path, docstr FileNameList const data_files = base.dirList("dat"); string idx; string data; + string basename; LYXERR(Debug::FILES, "thesaurus path: " << path); for (FileNameList::const_iterator it = idx_files.begin(); it != idx_files.end(); ++it) { - if (contains(it->onlyFileName(), to_ascii(lang))) { + basename = it->onlyFileNameWithoutExt(); + if (contains(basename, to_ascii(lang))) { + ifstream ifs(it->absFileName().c_str()); + if (ifs) { + string s; + getline(ifs,s); + if (s.find_first_of(',') != string::npos) { + LYXERR(Debug::FILES, "ignore version1 thesaurus idx file: " << it->absFileName()); + continue; + } + } idx = it->absFileName(); LYXERR(Debug::FILES, "selected thesaurus idx file: " << idx); break; @@ -104,7 +116,7 @@ pair Thesaurus::Private::getThesaurus(string const & path, docstr return make_pair(string(), string()); } for (support::FileNameList::const_iterator it = data_files.begin(); it != data_files.end(); ++it) { - if (contains(it->onlyFileName(), to_ascii(lang))) { + if (contains(it->onlyFileName(), basename)) { data = it->absFileName(); LYXERR(Debug::FILES, "selected thesaurus data file: " << data); break; @@ -164,6 +176,8 @@ bool Thesaurus::thesaurusAvailable(docstring const & lang) const bool Thesaurus::thesaurusInstalled(docstring const & lang) const { + if (thesaurusAvailable(lang)) + return true; pair files = d->getThesaurus(lang); return (!files.first.empty() && !files.second.empty()); }