mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
clean code:remove qmake CONFIG 'old_hunspell' that means libhunspell > 1.5 from now on.
This commit is contained in:
parent
b127144b18
commit
f0d0a56ecc
|
@ -38,7 +38,7 @@ make sure that `qmake` is from Qt 5 installation. If not, you can try
|
|||
finding it at a path like `/usr/lib/x86_64-linux-gnu/qt5/bin/qmake`.
|
||||
Alternatively, you might want to load `goldendict.pro` file from within Qt Creator, especially on Windows.
|
||||
|
||||
Note: To compile with `libhunspell` older than 1.5 pass `"CONFIG+=old_hunspell"` to `qmake`.
|
||||
Note: `libhunspell` version > 1.5.
|
||||
|
||||
### Building with Chinese conversion support
|
||||
|
||||
|
|
|
@ -578,10 +578,6 @@ CONFIG( chinese_conversion_support ) {
|
|||
}
|
||||
}
|
||||
|
||||
CONFIG( old_hunspell ) {
|
||||
DEFINES += OLD_HUNSPELL_INTERFACE
|
||||
}
|
||||
|
||||
RESOURCES += resources.qrc \
|
||||
flags.qrc
|
||||
TRANSLATIONS += locale/ru_RU.ts \
|
||||
|
|
67
hunspell.cc
67
hunspell.cc
|
@ -245,13 +245,7 @@ void HunspellArticleRequest::run()
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef OLD_HUNSPELL_INTERFACE
|
||||
// We'd need to free this if it gets allocated and an exception shows up
|
||||
char ** suggestions = 0;
|
||||
int suggestionsCount = 0;
|
||||
#else
|
||||
vector< string > suggestions;
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -268,24 +262,15 @@ void HunspellArticleRequest::run()
|
|||
|
||||
string encodedWord = encodeToHunspell( hunspell, trimmedWord );
|
||||
|
||||
#ifdef OLD_HUNSPELL_INTERFACE
|
||||
if ( hunspell.spell( encodedWord.c_str() ) )
|
||||
#else
|
||||
if ( hunspell.spell( encodedWord ) )
|
||||
#endif
|
||||
{
|
||||
// Good word -- no spelling suggestions then.
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef OLD_HUNSPELL_INTERFACE
|
||||
suggestionsCount = hunspell.suggest( &suggestions, encodedWord.c_str() );
|
||||
if ( suggestionsCount )
|
||||
#else
|
||||
suggestions = hunspell.suggest( encodedWord );
|
||||
if ( !suggestions.empty() )
|
||||
#endif
|
||||
{
|
||||
// There were some suggestions made for us. Make an appropriate output.
|
||||
|
||||
|
@ -294,15 +279,9 @@ void HunspellArticleRequest::run()
|
|||
|
||||
wstring lowercasedWord = Folding::applySimpleCaseOnly( word );
|
||||
|
||||
#ifdef OLD_HUNSPELL_INTERFACE
|
||||
for( int x = 0; x < suggestionsCount; ++x )
|
||||
{
|
||||
wstring suggestion = decodeFromHunspell( hunspell, suggestions[ x ] );
|
||||
#else
|
||||
for( vector< string >::size_type x = 0; x < suggestions.size(); ++x )
|
||||
{
|
||||
wstring suggestion = decodeFromHunspell( hunspell, suggestions[ x ].c_str() );
|
||||
#endif
|
||||
|
||||
if ( Folding::applySimpleCaseOnly( suggestion ) == lowercasedWord )
|
||||
{
|
||||
|
@ -312,9 +291,6 @@ void HunspellArticleRequest::run()
|
|||
|
||||
finish();
|
||||
|
||||
#ifdef OLD_HUNSPELL_INTERFACE
|
||||
hunspell.free_list( &suggestions, suggestionsCount );
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
string suggestionUtf8 = Utf8::encode( suggestion );
|
||||
|
@ -323,11 +299,7 @@ void HunspellArticleRequest::run()
|
|||
result += Html::escape( suggestionUtf8 ) + "\">";
|
||||
result += Html::escape( suggestionUtf8 ) + "</a>";
|
||||
|
||||
#ifdef OLD_HUNSPELL_INTERFACE
|
||||
if ( x != suggestionsCount - 1 )
|
||||
#else
|
||||
if ( x != suggestions.size() - 1 )
|
||||
#endif
|
||||
result += ", ";
|
||||
}
|
||||
|
||||
|
@ -351,15 +323,6 @@ void HunspellArticleRequest::run()
|
|||
gdWarning( "Hunspell: error: %s\n", e.what() );
|
||||
}
|
||||
|
||||
#ifdef OLD_HUNSPELL_INTERFACE
|
||||
if ( suggestions )
|
||||
{
|
||||
Mutex::Lock _( hunspellMutex );
|
||||
|
||||
hunspell.free_list( &suggestions, suggestionsCount );
|
||||
}
|
||||
#endif
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
|
@ -487,13 +450,7 @@ QVector< wstring > suggest( wstring & word, Mutex & hunspellMutex, Hunspell & hu
|
|||
{
|
||||
QVector< wstring > result;
|
||||
|
||||
#ifdef OLD_HUNSPELL_INTERFACE
|
||||
// We'd need to free this if it gets allocated and an exception shows up
|
||||
char ** suggestions = 0;
|
||||
int suggestionsCount = 0;
|
||||
#else
|
||||
vector< string > suggestions;
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -501,13 +458,8 @@ QVector< wstring > suggest( wstring & word, Mutex & hunspellMutex, Hunspell & hu
|
|||
|
||||
string encodedWord = encodeToHunspell( hunspell, word );
|
||||
|
||||
#ifdef OLD_HUNSPELL_INTERFACE
|
||||
suggestionsCount = hunspell.analyze( &suggestions, encodedWord.c_str() );
|
||||
if ( suggestionsCount )
|
||||
#else
|
||||
suggestions = hunspell.analyze( encodedWord );
|
||||
if ( !suggestions.empty() )
|
||||
#endif
|
||||
{
|
||||
// There were some suggestions made for us. Make an appropriate output.
|
||||
|
||||
|
@ -515,15 +467,9 @@ QVector< wstring > suggest( wstring & word, Mutex & hunspellMutex, Hunspell & hu
|
|||
|
||||
static QRegExp cutStem( "^\\s*st:(((\\s+(?!\\w{2}:)(?!-)(?!\\+))|\\S+)+)" );
|
||||
|
||||
#ifdef OLD_HUNSPELL_INTERFACE
|
||||
for( int x = 0; x < suggestionsCount; ++x )
|
||||
{
|
||||
QString suggestion = gd::toQString( decodeFromHunspell( hunspell, suggestions[ x ] ) );
|
||||
#else
|
||||
for( vector< string >::size_type x = 0; x < suggestions.size(); ++x )
|
||||
{
|
||||
QString suggestion = gd::toQString( decodeFromHunspell( hunspell, suggestions[ x ].c_str() ) );
|
||||
#endif
|
||||
|
||||
// Strip comments
|
||||
int n = suggestion.indexOf( '#' );
|
||||
|
@ -552,15 +498,6 @@ QVector< wstring > suggest( wstring & word, Mutex & hunspellMutex, Hunspell & hu
|
|||
gdWarning( "Hunspell: charset conversion error, no processing's done: %s\n", e.what() );
|
||||
}
|
||||
|
||||
#ifdef OLD_HUNSPELL_INTERFACE
|
||||
if ( suggestions )
|
||||
{
|
||||
Mutex::Lock _( hunspellMutex );
|
||||
|
||||
hunspell.free_list( &suggestions, suggestionsCount );
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -662,11 +599,7 @@ void HunspellPrefixMatchRequest::run()
|
|||
|
||||
string encodedWord = encodeToHunspell( hunspell, trimmedWord );
|
||||
|
||||
#ifdef OLD_HUNSPELL_INTERFACE
|
||||
if ( hunspell.spell( encodedWord.c_str() ) )
|
||||
#else
|
||||
if ( hunspell.spell( encodedWord ) )
|
||||
#endif
|
||||
{
|
||||
// Known word -- add it to the result
|
||||
|
||||
|
|
Loading…
Reference in a new issue