]> git.lyx.org Git - features.git/commitdiff
more correct check of thesaurus file format
authorStephan Witt <switt@lyx.org>
Mon, 5 Jul 2010 09:20:45 +0000 (09:20 +0000)
committerStephan Witt <switt@lyx.org>
Mon, 5 Jul 2010 09:20:45 +0000 (09:20 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34760 a592a061-630c-0410-9148-cb99ea01b6c8

src/Thesaurus.cpp

index 870f967f41578ba7fcbb70c6c5a6dd4ed174e952..d21453ab0fb01dc2e75e92487509411ce4cd3a95 100644 (file)
@@ -100,9 +100,16 @@ pair<string,string> Thesaurus::Private::getThesaurus(string const & path, docstr
                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) {
+                               // check for appropriate version of index file
+                               string encoding; // first line is encoding
+                               int items = 0;   // second line is no. of items
+                               getline(ifs,encoding);
+                               ifs >> items;
+                               if (ifs.fail()) {
+                                       LYXERR(Debug::FILES, "ignore irregular thesaurus idx file: " << it->absFileName());
+                                       continue;
+                               }
+                               if (encoding.length() == 0 || encoding.find_first_of(',') != string::npos) {
                                        LYXERR(Debug::FILES, "ignore version1 thesaurus idx file: " << it->absFileName());
                                        continue;
                                }