Fix error when adding a word to the dictionary when the user dictionary file doesn't already exist
Originally committed to SVN as r6381.
This commit is contained in:
parent
bc9c521cfd
commit
78f1198426
1 changed files with 14 additions and 14 deletions
|
@ -92,12 +92,17 @@ void HunspellSpellChecker::AddWord(wxString word) {
|
||||||
}
|
}
|
||||||
// Read the old contents of the user's dictionary
|
// Read the old contents of the user's dictionary
|
||||||
else {
|
else {
|
||||||
std::auto_ptr<std::istream> stream(agi::io::Open(STD_STR(userDicPath)));
|
try {
|
||||||
std::remove_copy_if(
|
agi::scoped_ptr<std::istream> stream(agi::io::Open(STD_STR(userDicPath)));
|
||||||
++agi::line_iterator<std::string>(*stream.get()),
|
remove_copy_if(
|
||||||
agi::line_iterator<std::string>(),
|
++agi::line_iterator<std::string>(*stream.get()),
|
||||||
std::back_inserter(words),
|
agi::line_iterator<std::string>(),
|
||||||
std::mem_fun_ref(&std::string::empty));
|
back_inserter(words),
|
||||||
|
mem_fun_ref(&std::string::empty));
|
||||||
|
}
|
||||||
|
catch (agi::FileNotFoundError&) {
|
||||||
|
LOG_I("dictionary/hunspell/add") << "User dictionary not found; creating it";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the word
|
// Add the word
|
||||||
|
@ -105,14 +110,9 @@ void HunspellSpellChecker::AddWord(wxString word) {
|
||||||
words.sort();
|
words.sort();
|
||||||
|
|
||||||
// Write the new dictionary
|
// Write the new dictionary
|
||||||
try {
|
agi::io::Save writer(STD_STR(userDicPath));
|
||||||
agi::io::Save writer(STD_STR(userDicPath));
|
writer.Get() << words.size() << "\n";
|
||||||
writer.Get() << words.size() << "\n";
|
copy(words.begin(), words.end(), std::ostream_iterator<std::string>(writer.Get(), "\n"));
|
||||||
std::copy(words.begin(), words.end(), std::ostream_iterator<std::string>(writer.Get(), "\n"));
|
|
||||||
}
|
|
||||||
catch (const agi::Exception&) {
|
|
||||||
// Failed to open file
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HunspellSpellChecker::CheckWord(wxString word) {
|
bool HunspellSpellChecker::CheckWord(wxString word) {
|
||||||
|
|
Loading…
Reference in a new issue