Summary: | KWrite (KSpell2?) + ASpell6 bug | ||
---|---|---|---|
Product: | [Frameworks and Libraries] kdelibs | Reporter: | Mashrab Kuvatov <kmashrab> |
Component: | general | Assignee: | Stephan Kulow <coolo> |
Status: | RESOLVED FIXED | ||
Severity: | major | CC: | cberger, torre_cremata, wolfram, zack |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: |
Screenshot showing spell-check bug
GEdit spellcheck with an Uzbek Aspell dictionary A fix UTF-8 encoded spellchecking Fix in action for Uzbek language Fix in action for German language Fix in action for Russian language |
Description
Mashrab Kuvatov
2004-08-10 23:21:18 UTC
Created attachment 7065 [details]
Screenshot showing spell-check bug
Sorry, it is not ASpell6, but ASpell-0.60 series. Meanwhile, for already quite some time ASpell-0.60.2 is out. I'm using CVS HEAD and this bug report unfortunately is still valid. For sure it is not ASpell bug, I asked my friend who is using GNOME to try GEdit with an Uzbek ASpell dictionary (the same what I have). It works properly. Please have a look at the screenshot, it is attached. By the way, ASpell-0.60.2 is in Mandrakelinux Cooker, that is, soon it will be in Mandrakelinux-10.2. I expect a lot of complains and bug reports since it is not usable with KDE (3.3.2 in Mdk-10.2) for nonlatin languages. I tried it for Russian as well, does not work. Created attachment 9513 [details]
GEdit spellcheck with an Uzbek Aspell dictionary
Could anyone please at least point to the right direction, or code to play with? It is getting really frustrating. :-( I finally found a problem. It is in KSpell::check2 of kdelibs/kdeui/kspell.cpp. It treats Unicode strings in unnecessary special way, which is not correct. I tested it with ASpell-0.60 (which can spellcheck Unicode texts) for Russian, German and Uzbek (have a look at the attached screenshots). It works properly. The patch is attached. Could anyone please review and commit it? Also to KDE_3_3_BRANCH? Thanks. Created attachment 9576 [details]
A fix UTF-8 encoded spellchecking
It is a diff to the current CVS.
Created attachment 9577 [details]
Fix in action for Uzbek language
Created attachment 9578 [details]
Fix in action for German language
Created attachment 9579 [details]
Fix in action for Russian language
This is seemingly not a kate issue. Yeah, it is not. At the beginning I did not know, that's why KWrite. Now, I know it is KSpell of kdelibs. Thanks for reassigning. Could anyone please have a look at patch and possibly apply it? For us, nonlatin people, it is a major problem. So, please take it seriously. Please do not add me to the CC list of a bug without my permission. thank you. *** Bug 96189 has been marked as a duplicate of this bug. *** There is a discussion of this issue at http://lists.kde.org/?t=110845111500003&r=1&w=2 *** Bug 98713 has been marked as a duplicate of this bug. *** CVS commit by waba: Fix spell checking with aspell-0.60 Please test. BUG: 86940 M +33 -1 kspell.cpp 1.131 [POSSIBLY UNSAFE: popen] --- kdelibs/kdeui/kspell.cpp #1.130:1.131 @@ -34,4 +34,5 @@ #endif +#include <qregexp.h> #include <qtextcodec.h> #include <qtimer.h> @@ -77,4 +79,5 @@ public: QValueList<BufferedWord> unchecked; QTimer *checkNextTimer; + bool aspellV6; }; @@ -123,4 +126,25 @@ int KSpell::heightDlg() const { return k int KSpell::widthDlg() const { return ksdlg->width(); } +// Check if aspell is at least version 0.6 +static bool determineASpellV6() +{ + QString result; + FILE *fs = popen("aspell -v", "r"); + if (fs) + { + QTextStream ts(fs, IO_ReadOnly); + result = ts.read().stripWhiteSpace(); + pclose(fs); + } + + QRegExp rx("Aspell (\\d.\\d)"); + if (rx.search(result) != -1) + { + float version = rx.cap(1).toFloat(); + return (version >= 0.6); + } + return false; +} + void @@ -128,4 +152,6 @@ KSpell::startIspell() //trystart = {0,1,2} { + if ((trystart == 0) && (ksconfig->client() == KS_CLIENT_ASPELL)) + d->aspellV6 = determineASpellV6(); kdDebug(750) << "Try #" << trystart << endl; @@ -233,4 +259,9 @@ KSpell::startIspell() case KS_E_UTF8: *proc << "-Tutf8"; + if (ksconfig->client() == KS_CLIENT_ASPELL) + *proc << "--encoding=utf-8"; + else + *proc << "-Tutf8"; + break; case KS_E_KOI8U: @@ -1012,5 +1043,5 @@ void KSpell::check2( KProcIO * ) // for multibyte encoding posinline needs correction - if (ksconfig->encoding() == KS_E_UTF8) { + if ((ksconfig->encoding() == KS_E_UTF8) && !d->aspellV6) { // kdDebug(750) << "line: " << origbuffer.mid(lastlastline, // lastline-lastlastline) << endl; @@ -1409,4 +1440,5 @@ void KSpell::initialize( QWidget *_paren d->type = type; d->checking = false; + d->aspellV6 = false; d->checkNextTimer = new QTimer( this ); connect( d->checkNextTimer, SIGNAL( timeout() ), I've tried your patch and it works... Thank you!!! BTW. I've tried with russian language. It works for me too. Thanks. Could anyone please do the same for KDE_3_3_BRANCH? If not, I'm afraid Mandrakelinux 10.2 users (and many others) flood you with bug reports. it's included in kdelibs-3.3.2-82mdk in cooker |