[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: [PATCH] KSpell Unicode problem (BR#86940)
From:       Waldo Bastian <bastian () kde ! org>
Date:       2005-02-20 17:46:23
Message-ID: 200502201846.26666.bastian () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


On Saturday 19 February 2005 11:40, Anders Lund wrote:
> On Saturday 19 February 2005 11:26, Lukáš Tinkl wrote:
> > > I vote for "#ifdef HAVE_ASPELL_60" approach. I do not know how to
> > > implement it, though.
> > >
> > > What do the others think? Any idea how to solve it?
> >
> > Yes, I wanted to suggest the ifdef approach too; anyone volunteers to
> > write the configure check? :)
>
> So after upgrading aspell over that line, you'll need to recompile kdelibs?
> Can't aspell be queried for its version, and the string handled
> accordingly?
>
> -anders

Sure, see patch (or update to latest CVS), please test. Does it detect aspell 
v0.60 correctly?

Cheers,
Waldo
-- 
bastian@kde.org   |   Free Novell Linux Desktop 9 Evaluation Download
bastian@suse.com  |   http://www.novell.com/products/desktop/eval.html

["kspell_aspell.patch" (text/x-diff)]

Index: kspell.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kspell.cpp,v
retrieving revision 1.130
diff -u -p -r1.130 kspell.cpp
--- kspell.cpp	25 Nov 2004 06:28:55 -0000	1.130
+++ kspell.cpp	20 Feb 2005 17:41:39 -0000
@@ -33,8 +33,10 @@
 #include <strings.h>
 #endif
 
+#include <qregexp.h>
 #include <qtextcodec.h>
 #include <qtimer.h>
+
 #include <kapplication.h>
 #include <kmessagebox.h>
 #include <kdebug.h>
@@ -76,6 +78,7 @@ public:
   bool checking;
   QValueList<BufferedWord> unchecked;
   QTimer *checkNextTimer;
+  bool aspellV6;
 };
 
 //TODO
@@ -122,11 +125,36 @@ void KSpell::hide() { ksdlg->hide(); }
 int KSpell::heightDlg() const { return ksdlg->height(); }
 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);
+  }
+
+qWarning("Aspell Result: %s", result.latin1());
+  QRegExp rx("Aspell (\\d.\\d)");
+  if (rx.search(result) != -1)
+  {
+     float version = rx.cap(1).toFloat();
+qWarning("Version: %f", version);
+     return (version >= 0.6);       
+  }
+  return false;
+}
+
 
 void
 KSpell::startIspell()
   //trystart = {0,1,2}
 {
+  if ((trystart == 0) && (ksconfig->client() == KS_CLIENT_ASPELL))
+     d->aspellV6 = determineASpellV6();
 
   kdDebug(750) << "Try #" << trystart << endl;
 
@@ -232,6 +260,11 @@ KSpell::startIspell()
 	break;
       case KS_E_UTF8:
         *proc << "-Tutf8";
+        if (ksconfig->client() == KS_CLIENT_ASPELL)
+          *proc << "--encoding=utf-8";
+        else
+          *proc << "-Tutf8";
+
         break;
       case KS_E_KOI8U:
 	*proc << "-w'"; // add ' as a word char
@@ -1011,7 +1044,7 @@ void KSpell::check2( KProcIO * )
         dlgresult=-1;
 
         // 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;
           // kdDebug(750) << "posinline uncorr: " << posinline << endl;
@@ -1408,6 +1441,7 @@ void KSpell::initialize( QWidget *_paren
   d->m_bNoMisspellingsEncountered = true;
   d->type = type;
   d->checking = false;
+  d->aspellV6 = false;
   d->checkNextTimer = new QTimer( this );
   connect( d->checkNextTimer, SIGNAL( timeout() ),
 	   this, SLOT( checkNext() ));

[Attachment #6 (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic