X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Faspell.C;h=1d711a3bf40e9e92add4fb09534f89ef8c142419;hb=de161c40b1e8c5896f18f503c12cf29ec57bbf1e;hp=a59ff568717eb3cce94d849c5d2560944a93a2d7;hpb=99215ea58fc2b6088a71e71c02a4af9af5548133;p=lyx.git diff --git a/src/aspell.C b/src/aspell.C index a59ff56871..1d711a3bf4 100644 --- a/src/aspell.C +++ b/src/aspell.C @@ -1,17 +1,16 @@ /** * \file aspell.C - * Copyright 2001 the LyX Team - * Read the file COPYING + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * * \author Kevin Atkinson - * \author John Levon + * \author John Levon + * + * Full author contact details are available in file CREDITS. */ #include -#ifdef USE_ASPELL - -#include "support/LAssert.h" #include "debug.h" #include @@ -19,7 +18,12 @@ #include "aspell_local.h" #include "WordLangTuple.h" -using std::endl; +#include + +using lyx::docstring; + +using std::string; + ASpell::ASpell(BufferParams const &, string const & lang) : els(0), spell_error_object(0) @@ -69,9 +73,9 @@ void ASpell::addSpeller(string const & lang) } -enum ASpell::Result ASpell::check(WordLangTuple const & word) +ASpell::Result ASpell::check(WordLangTuple const & word) { - Result res = UNKNOWN; + Result res = UNKNOWN_WORD; Spellers::iterator it = spellers_.find(word.lang_code()); if (it == spellers_.end()) { @@ -84,20 +88,20 @@ enum ASpell::Result ASpell::check(WordLangTuple const & word) AspellSpeller * m = it->second.speller; - int word_ok = aspell_speller_check(m, word.word().c_str(), -1); - lyx::Assert(word_ok != -1); + int const word_ok = aspell_speller_check(m, word.word().c_str(), -1); + BOOST_ASSERT(word_ok != -1); if (word_ok) { res = OK; } else { AspellWordList const * sugs = aspell_speller_suggest(m, word.word().c_str(), -1); - lyx::Assert(sugs != 0); + BOOST_ASSERT(sugs != 0); els = aspell_word_list_elements(sugs); if (aspell_word_list_empty(sugs)) - res = UNKNOWN; + res = UNKNOWN_WORD; else - res = MISSED; + res = SUGGESTED_WORDS; } return res; } @@ -125,23 +129,18 @@ string const ASpell::nextMiss() if (els) str = aspell_string_enumeration_next(els); - if (str) - return str; - return ""; + + return (str ? str : ""); } -string const ASpell::error() +docstring const ASpell::error() { char const * err = 0; - + if (spell_error_object && aspell_error_number(spell_error_object) != 0) { err = aspell_error_message(spell_error_object); } - if (err) - return err; - return ""; + return (err ? lyx::from_utf8(err) : docstring()); } - -#endif // USE_ASPELL