Bug 86940 - KWrite (KSpell2?) + ASpell6 bug
Summary: KWrite (KSpell2?) + ASpell6 bug
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR major
Target Milestone: ---
Assignee: Stephan Kulow
URL:
Keywords:
: 96189 98713 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-08-10 23:21 UTC by Mashrab Kuvatov
Modified: 2005-02-21 14:43 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Screenshot showing spell-check bug (133.72 KB, image/png)
2004-08-10 23:23 UTC, Mashrab Kuvatov
Details
GEdit spellcheck with an Uzbek Aspell dictionary (74.99 KB, image/png)
2005-02-09 22:20 UTC, Mashrab Kuvatov
Details
A fix UTF-8 encoded spellchecking (1.11 KB, text/plain)
2005-02-12 19:16 UTC, Mashrab Kuvatov
Details
Fix in action for Uzbek language (30.74 KB, image/png)
2005-02-12 19:17 UTC, Mashrab Kuvatov
Details
Fix in action for German language (33.53 KB, image/png)
2005-02-12 19:18 UTC, Mashrab Kuvatov
Details
Fix in action for Russian language (31.40 KB, image/png)
2005-02-12 19:18 UTC, Mashrab Kuvatov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mashrab Kuvatov 2004-08-10 23:21:18 UTC
Version:           4.3 (using KDE KDE 3.3.0)
OS:                Linux

Kevin Atkinson (author of ASpell) very soon is going to release ASpell6 (current is pre2). It supports spell-checking of unicode texts. I have ASpell6-pre2 with Uzbek dictionary and from a command line it works just fine.

However, there is a problem spell-checking the same text with KDE-3.3 (KDE-3.2 too) + ASpell6. Namely, while spell-checking the same text in KWrite it properly shows misspelled word, replacement and suggested words, but it messes with highlighting of a misspelled word in the text and text excerpt. Clicking "Replace" replaces a wrong word.

ASpell and UTF-8 encoding are selected from the Control Center and from the KWrite settings.

Of course, it is applicable for Kate too.

Please have a look at attached screenshot, it is self-explanatory.

Thanks.
Comment 1 Mashrab Kuvatov 2004-08-10 23:23:46 UTC
Created attachment 7065 [details]
Screenshot showing spell-check bug
Comment 2 Mashrab Kuvatov 2005-02-09 22:16:29 UTC
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.
Comment 3 Mashrab Kuvatov 2005-02-09 22:20:35 UTC
Created attachment 9513 [details]
GEdit spellcheck with an Uzbek Aspell dictionary
Comment 4 Mashrab Kuvatov 2005-02-12 02:39:58 UTC
Could anyone please at least point to the right direction, or code to play with? It is getting really frustrating. :-(
Comment 5 Mashrab Kuvatov 2005-02-12 19:13:09 UTC
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.
Comment 6 Mashrab Kuvatov 2005-02-12 19:16:03 UTC
Created attachment 9576 [details]
A fix UTF-8 encoded spellchecking

It is a diff to the current CVS.
Comment 7 Mashrab Kuvatov 2005-02-12 19:17:16 UTC
Created attachment 9577 [details]
Fix in action for Uzbek language
Comment 8 Mashrab Kuvatov 2005-02-12 19:18:03 UTC
Created attachment 9578 [details]
Fix in action for German language
Comment 9 Mashrab Kuvatov 2005-02-12 19:18:55 UTC
Created attachment 9579 [details]
Fix in action for Russian language
Comment 10 Anders Lund 2005-02-12 23:47:44 UTC
This is seemingly not a kate issue.
Comment 11 Mashrab Kuvatov 2005-02-13 00:53:41 UTC
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.
Comment 12 Mashrab Kuvatov 2005-02-15 13:32:40 UTC
Could anyone please have a look at patch and possibly apply it?
Comment 13 Mashrab Kuvatov 2005-02-15 23:10:23 UTC
For us, nonlatin people, it is a major problem. So, please take it seriously.
Comment 14 Don Sanders 2005-02-16 07:03:28 UTC
Please do not add me to the CC list of a bug without my permission. thank you.
Comment 15 Anders Lund 2005-02-18 00:50:40 UTC
*** Bug 96189 has been marked as a duplicate of this bug. ***
Comment 16 Mashrab Kuvatov 2005-02-19 01:38:07 UTC
There is a discussion of this issue at http://lists.kde.org/?t=110845111500003&r=1&w=2
Comment 17 Anders Lund 2005-02-19 09:53:34 UTC
*** Bug 98713 has been marked as a duplicate of this bug. ***
Comment 18 Waldo Bastian 2005-02-20 18:44:39 UTC
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() ),


Comment 19 Peter Volkov 2005-02-21 07:32:40 UTC
I've tried your patch and it works...

Thank you!!!

BTW. I've tried with russian language.
Comment 20 Mashrab Kuvatov 2005-02-21 12:02:59 UTC
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.
Comment 21 tvignaud 2005-02-21 14:43:24 UTC
it's included in kdelibs-3.3.2-82mdk in cooker