Dsl: Fix displayed headword selection for the case of ignore diacritic

This commit is contained in:
Abs62 2020-10-22 18:32:55 +03:00
parent 332a95b271
commit 5d7d553bb5

12
dsl.cc
View file

@ -263,6 +263,7 @@ private:
/// Loads the article. Does not process the DSL language. /// Loads the article. Does not process the DSL language.
void loadArticle( uint32_t address, void loadArticle( uint32_t address,
wstring const & requestedHeadwordFolded, wstring const & requestedHeadwordFolded,
bool ignoreDiacritics,
wstring & tildeValue, wstring & tildeValue,
wstring & displayedHeadword, wstring & displayedHeadword,
unsigned & headwordIndex, unsigned & headwordIndex,
@ -536,6 +537,7 @@ bool isDslWs( wchar ch )
void DslDictionary::loadArticle( uint32_t address, void DslDictionary::loadArticle( uint32_t address,
wstring const & requestedHeadwordFolded, wstring const & requestedHeadwordFolded,
bool ignoreDiacritics,
wstring & tildeValue, wstring & tildeValue,
wstring & displayedHeadword, wstring & displayedHeadword,
unsigned & headwordIndex, unsigned & headwordIndex,
@ -680,7 +682,13 @@ void DslDictionary::loadArticle( uint32_t address,
unescapeDsl( *i ); unescapeDsl( *i );
normalizeHeadword( *i ); normalizeHeadword( *i );
if ( Folding::trimWhitespace( *i ) == requestedHeadwordFolded ) bool found;
if( ignoreDiacritics )
found = Folding::applyDiacriticsOnly( Folding::trimWhitespace( *i ) ) == Folding::applyDiacriticsOnly( requestedHeadwordFolded );
else
found = Folding::trimWhitespace( *i ) == requestedHeadwordFolded;
if ( found )
{ {
// Found it. Now we should make a displayed headword for it. // Found it. Now we should make a displayed headword for it.
if ( hadFirstHeadword ) if ( hadFirstHeadword )
@ -1707,7 +1715,7 @@ void DslArticleRequest::run()
try try
{ {
dict.loadArticle( chain[ x ].articleOffset, wordCaseFolded, tildeValue, dict.loadArticle( chain[ x ].articleOffset, wordCaseFolded, ignoreDiacritics, tildeValue,
displayedHeadword, headwordIndex, articleBody ); displayedHeadword, headwordIndex, articleBody );
if ( !articlesIncluded.insert( std::make_pair( chain[ x ].articleOffset, if ( !articlesIncluded.insert( std::make_pair( chain[ x ].articleOffset,