On Wed, 19 May 2004, Mashrab Kuvatov wrote:

> Hi all,
> 
> I'm using aspell-0.60-20040515 with Uzbek dictionary. Over all, it
> works pretty well, but there is a problem of adding a word into the
> personal dictionary. So, I do the following
> 
> aspell -c some.utf8.file.txt
> 
> ... and pressing "a" when I want to add a word Aspell aborts with the
> following error message
> 
> spell: modules/speller/default/suggest.cpp:689: void 
> <unnamed>::Working::try_scan(): Assertion `strlen(sw->word) == sw->word_size' 
> failed.
> Aborted
> 
> Is it a bug in Aspell code or in the Uzbek dictionary?

A bug in Aspell.  Attached is a patch to fix it.

-- 
http://kevin.atkinson.dhs.org
diff -ur aspell-0.60-20040515/common/convert.hpp aspell-0.60-cvs/common/convert.hpp
--- aspell-0.60-20040515/common/convert.hpp     Sat May 15 20:01:29 2004
+++ aspell-0.60-cvs/common/convert.hpp  Thu May 20 00:12:07 2004
@@ -158,7 +158,6 @@
       } else {
         buf.clear();
         decode_->decode(in, size, buf);
-        buf.append(0);
         encode_->encode(buf.pbegin(), buf.pend(), out);
       }
     }
@@ -173,7 +172,6 @@
       } else {
         buf.clear();
         RET_ON_ERR(decode_->decode_ec(in, size, buf, orig));
-        buf.append(0);
         RET_ON_ERR(encode_->encode_ec(buf.pbegin(), buf.pend(), 
                                       out, orig));
       }
@@ -267,6 +265,7 @@
       if (conv) {
         buf.clear();
         conv->convert(str, sz, buf, buf0);
+        buf.ensure_null_end();
         return buf.data();
       } else {
         return str;
@@ -281,6 +280,7 @@
       if (conv) {
         buf.clear();
         conv->convert(str, strlen(str), buf, buf0);
+        buf.ensure_null_end();
         return buf.data();
       } else {
         return str;
@@ -291,6 +291,7 @@
       if (conv) {
         buf.clear();
         conv->convert(str, str.size(), buf, buf0);
+        buf.ensure_null_end();
         return buf.data();
       } else {
         return str;
@@ -304,8 +305,8 @@
         conv->convert(str, 1, buf, buf0);
       } else {
         buf.append(c);
-        buf.append('\0');
       }
+      buf.ensure_null_end();
       return buf.data();
     }
   };
@@ -346,6 +347,7 @@
       if (conv) {
         buf.clear();
         RET_ON_ERR(conv->convert_ec(str, sz, buf, buf0, str));
+        buf.ensure_null_end();
         return buf.data();
       } else {
         return str;
@@ -360,6 +362,7 @@
       if (conv) {
         buf.clear();
         RET_ON_ERR(conv->convert_ec(str, strlen(str), buf, buf0, str));
+        buf.ensure_null_end();
         return buf.data();
       } else {
         return str;
@@ -370,6 +373,7 @@
       if (conv) {
         buf.clear();
         RET_ON_ERR(conv->convert_ec(str, str.size(), buf, buf0, str));
+        buf.ensure_null_end();
         return buf.data();
       } else {
         return str.str();
diff -ur aspell-0.60-20040515/lib/speller-c.cpp aspell-0.60-cvs/lib/speller-c.cpp
--- aspell-0.60-20040515/lib/speller-c.cpp      Sat May 15 20:09:06 2004
+++ aspell-0.60-cvs/lib/speller-c.cpp   Wed May 19 23:28:27 2004
@@ -65,9 +65,8 @@
 {
   ths->temp_str_0.clear();
   ths->to_internal_->convert(word, word_size, ths->temp_str_0);
-  ths->temp_str_0.append('\0');
+  ths->temp_str_0.ensure_null_end();
   unsigned int s0 = ths->temp_str_0.size();
-  ths->to_internal_->append_null(ths->temp_str_0);
   PosibErr<bool> ret = ths->check(MutableString(ths->temp_str_0.data(), s0));
   ths->err_.reset(ret.release_err());
   if (ths->err_ != 0) return -1;
@@ -76,11 +75,11 @@
 
 extern "C" int aspell_speller_add_to_personal(Speller * ths, const char * word, int 
word_size)
 {
+  printf(">>%s %d\n", word, word_size);
   ths->temp_str_0.clear();
   ths->to_internal_->convert(word, word_size, ths->temp_str_0);
-  ths->temp_str_0.append('\0');
+  ths->temp_str_0.ensure_null_end();
   unsigned int s0 = ths->temp_str_0.size();
-  ths->to_internal_->append_null(ths->temp_str_0);
   PosibErr<void> ret = ths->add_to_personal(MutableString(ths->temp_str_0.data(), 
s0));
   ths->err_.reset(ret.release_err());
   if (ths->err_ != 0) return 0;
@@ -91,9 +90,8 @@
 {
   ths->temp_str_0.clear();
   ths->to_internal_->convert(word, word_size, ths->temp_str_0);
-  ths->temp_str_0.append('\0');
+  ths->temp_str_0.ensure_null_end();
   unsigned int s0 = ths->temp_str_0.size();
-  ths->to_internal_->append_null(ths->temp_str_0);
   PosibErr<void> ret = ths->add_to_session(MutableString(ths->temp_str_0.data(), s0));
   ths->err_.reset(ret.release_err());
   if (ths->err_ != 0) return 0;
@@ -147,9 +145,8 @@
 {
   ths->temp_str_0.clear();
   ths->to_internal_->convert(word, word_size, ths->temp_str_0);
-  ths->temp_str_0.append('\0');
+  ths->temp_str_0.ensure_null_end();
   unsigned int s0 = ths->temp_str_0.size();
-  ths->to_internal_->append_null(ths->temp_str_0);
   PosibErr<const WordList *> ret = ths->suggest(MutableString(ths->temp_str_0.data(), 
s0));
   ths->err_.reset(ret.release_err());
   if (ths->err_ != 0) return 0;
@@ -161,14 +158,12 @@
 {
   ths->temp_str_0.clear();
   ths->to_internal_->convert(mis, mis_size, ths->temp_str_0);
-  ths->temp_str_0.append('\0');
+  ths->temp_str_0.ensure_null_end();
   unsigned int s0 = ths->temp_str_0.size();
-  ths->to_internal_->append_null(ths->temp_str_0);
   ths->temp_str_1.clear();
   ths->to_internal_->convert(cor, cor_size, ths->temp_str_1);
-  ths->temp_str_1.append('\0');
+  ths->temp_str_1.ensure_null_end();
   unsigned int s1 = ths->temp_str_1.size();
-  ths->to_internal_->append_null(ths->temp_str_1);
   PosibErr<bool> ret = ths->store_replacement(MutableString(ths->temp_str_0.data(), 
s0), MutableString(ths->temp_str_1.data(), s1));
   ths->err_.reset(ret.release_err());
   if (ths->err_ != 0) return -1;
_______________________________________________
Aspell-user mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/aspell-user

Reply via email to