From 4b33543f424398226b386b93c71b71e47186beb5 Mon Sep 17 00:00:00 2001 From: Stas Degteff Date: Tue, 15 May 2012 17:02:39 +0000 Subject: [PATCH] Attempt to fix collateral action of function LoadCharset() which called from schecker.Load(). Bugreport from Vladimir Fyodorov 2:50/15@fidonet --- golded3/geedit.cpp | 6 ++++++ golded3/gemnus.cpp | 5 +++++ goldlib/gall/gespell.cpp | 19 ++++++++++++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/golded3/geedit.cpp b/golded3/geedit.cpp index bfc36c7..1b5613d 100644 --- a/golded3/geedit.cpp +++ b/golded3/geedit.cpp @@ -2851,6 +2851,7 @@ int IEclass::Start(int __mode, uint* __position, GMsg* __msg) { #if defined(GCFG_SPELL_INCLUDED) if (CFG->scheckerenabled) { + int save_chartableno = LoadCharset(NULL,NULL,1); // Workaround: internal for LoadCharset() charset table number changed in the schecker.Load() schecker.Init(CFG->xlatlocalset, CFG->scheckerdicpath); char *str = strdup(AA->adat->scheckerdeflang); char *token = strtok(str, " "); @@ -2861,6 +2862,11 @@ int IEclass::Start(int __mode, uint* __position, GMsg* __msg) { token = strtok(NULL, " "); } free(str); + + if(save_chartableno != -1) // restore value of the default chaset table // workaround: internal for LoadCharset() charset table number changed in the schecker.Load() + LoadCharset(CFG->xlatcharset[save_chartableno].imp, CFG->xlatcharset[save_chartableno].exp); + else + LoadCharset("N/A","N/A"); } #endif diff --git a/golded3/gemnus.cpp b/golded3/gemnus.cpp index 055c82e..bf3cd19 100644 --- a/golded3/gemnus.cpp +++ b/golded3/gemnus.cpp @@ -1242,7 +1242,12 @@ int GMenuSChecker::Run(CSpellChecker &schecker, const char *word) { if (!schecker.IsLoaded(langs[finaltag-TAG_LANG-1]->GetLangCode())) { + int save_chartableno = LoadCharset(NULL,NULL,1); // Workaround: internal for LoadCharset() charset table number changed in the schecker.Load() schecker.Load(langs[finaltag-TAG_LANG-1]->GetLangCode(), CFG->scheckeruserdic); + if(save_chartableno != -1) // restore value of the default chaset table // workaround: internal for LoadCharset() charset table number changed in the schecker.Load() + LoadCharset(CFG->xlatcharset[save_chartableno].imp, CFG->xlatcharset[save_chartableno].exp); + else + LoadCharset("N/A","N/A"); } else { diff --git a/goldlib/gall/gespell.cpp b/goldlib/gall/gespell.cpp index 6a65eb5..6f5431f 100644 --- a/goldlib/gall/gespell.cpp +++ b/goldlib/gall/gespell.cpp @@ -359,7 +359,9 @@ void CMSSpellLang::BuildRTable(const char *codeset) } strcpy(codeset2, "CP"); GetLocaleInfo(mLIDC, LOCALE_IDEFAULTANSICODEPAGE, &codeset2[2], sizeof(codeset2)-2); - +/* + int save_chartableno = LoadCharset(NULL,NULL,1); +*/ LoadCharset(codeset, codeset2); mToDicTable = new Chs; memset(mToDicTable, 0, sizeof(Chs)); @@ -369,6 +371,12 @@ void CMSSpellLang::BuildRTable(const char *codeset) mToLocTable = new Chs; memset(mToLocTable, 0, sizeof(Chs)); if (CharTable ) *mToLocTable = *CharTable; +/* + if(save_chartableno != -1) // restore value of the default chaset table + LoadCharset(CFG->xlatcharset[save_chartableno].imp, CFG->xlatcharset[save_chartableno].exp); + else + LoadCharset("N/A","N/A"); +*/ } @@ -588,6 +596,9 @@ void CMYSpellLang::BuildRTable(const char *codeset) "This is bug in program, please make report to developers." ); return; } +/* + int save_chartableno = LoadCharset(NULL,NULL,1); +*/ LoadCharset(codeset, mMSpell->get_dic_encoding()); mToDicTable = new Chs; memset(mToDicTable, 0, sizeof(Chs)); @@ -597,6 +608,12 @@ void CMYSpellLang::BuildRTable(const char *codeset) mToLocTable = new Chs; memset(mToLocTable, 0, sizeof(Chs)); if (CharTable ) *mToLocTable = *CharTable; +/* + if(save_chartableno != -1) // restore value of the default chaset table + LoadCharset(CFG->xlatcharset[save_chartableno].imp, CFG->xlatcharset[save_chartableno].exp); + else + LoadCharset("N/A","N/A"); +*/ }