[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [aspell-devel] clear_session, store_replacement, and support
From: |
Gary Setter |
Subject: |
Re: [aspell-devel] clear_session, store_replacement, and support |
Date: |
Fri, 29 Jul 2005 08:35:24 -0500 |
----- Original Message -----
From: "Bill Moseley" <address@hidden>
To: <address@hidden>
Sent: Thursday, July 28, 2005 4:24 PM
Subject: [aspell-devel] clear_session, store_replacement, and
support
> I'm going to try again, although I've not had much luck with
support
> here. Type in "store_replacement" into google and you see two
posts
> to the Aspell lists that haven't had any response right at the
top.
> Should I be posting to the sf.net tracker, instead?
>
> I'm the author of the Perl interface Text::Aspell, and as you
might
> imagine, I get quite a few emails about the module. I'm no
expert on
> Aspell -- and the module is really a thin layer on top of the
Aspell C
> interface. I'd like to help these people, but often I can't if
I
> cannot receive help from the Aspell developers.
>
> The questions I referred to above are about store_replacement
failing
> to return a true value. aspell.h has only this:
>
___Point 1___
> int aspell_speller_store_replacement(struct AspellSpeller *
ths, const char * mis, int mis_size, const char * cor, int
cor_size);
>
> And from my *brief* look at the code it seems as if it should
return a
> value indicating an error, although I didn't dig that deep:
>
>
> extern "C" int aspell_speller_store_replacement(Speller * ths,
const char * mis, int mis_size, const char * cor, int cor_size)
> {
> ths->temp_str_0.clear();
> ths->to_internal_->convert(mis, mis_size, ths->temp_str_0);
> unsigned int s0 = ths->temp_str_0.size();
> ths->temp_str_1.clear();
> ths->to_internal_->convert(cor, cor_size, ths->temp_str_1);
> unsigned int s1 = ths->temp_str_1.size();
> PosibErr<bool> ret =
ths->store_replacement(MutableString(ths->temp_str_0.mstr(), s0),
MutableString(ths->temp_str_1.mstr(), s1));
> ths->err_.reset(ret.release_err());
> if (ths->err_ != 0) return -1;
> return ret.data;
> }
>
> Actually, I'm not clear what is expected as a return. My Perl
xs code
> does this:
>
> RETVAL =
aspell_speller_store_replacement(self->speller, word, -1,
replacement, -1);
> if ( !RETVAL )
> {
> self->errnum = aspell_speller_error_number( (const
AspellSpeller *)self->speller );
> strncpy(self->lastError, (char*)
aspell_speller_error_message(self->speller), MAX_ERRSTR_LEN);
> XSRETURN_UNDEF;
> }
>
> On linux that seems to run fine. On some versions of BSD the
> store_replacement code returns undefined back to Perl. Oddly,
when I
> added a printf to print RETVAL before the if (!RETVAL) the
problem
> when away -- which made me think I cannot trust the return
value.
>
>
___POINT 2___
> Then today someone else emailed saying another test was
failing. When
> running "make test" on the Perl module I add a new word to the
> session, and then make sure that word is returned in the
session.
> Then I call clear_session() and then check if the word is then
removed
> from the session. It's this last test that is failing -- the
word is
> still being returned from suggest(). The failure report is
from
> someone using OS X, and I've not been able to reproduce the
problem in
> other OS X machines. And the word is not normally in their
dictionary.
>
> Am I not understanding clear_session()? Or is there another
reason the
> word is not removed from the session?
>
>
> Is there more than apsell.h and the page
>
>
http://aspell.sourceforge.net/man-html/Through-the-C-API.html#Through-the-C-API
>
> to use as the API reference?
>
___POINT 1___
The function seems to be in error. Take a look at the
implmentation of store_replacement.
PosibErr<void> SpellerImpl::store_replacement(const String &
mis,
const String &
cor,
bool memory)
It returns a void, not a bool. There is no data returned. So the
code should do something like this:
extern "C" int aspell_speller_store_replacement(Speller * ths,
const char * mis, int mis_size, const char * cor, int cor_size)
{
ths->temp_str_0.clear();
ths->to_internal_->convert(mis, mis_size, ths->temp_str_0);
unsigned int s0 = ths->temp_str_0.size();
ths->temp_str_1.clear();
ths->to_internal_->convert(cor, cor_size, ths->temp_str_1);
unsigned int s1 = ths->temp_str_1.size();
PosibErr<void> ret =
ths->store_replacement(MutableString(ths->temp_str_0.mstr(), s0),
MutableString(ths->temp_str_1.mstr(), s1));
ths->err_.reset(ret.release_err());
if (ths->err_ != 0) return -1; //fail
return 0; //success
}
I haven't tested this at all.
___POINT 2___
Maybe someone else can quickly reproduce the problem, but if your
need someone to investigate, I'm willing as long as you show me
how to reproduce the problem. I have perl, but I don't have the
perl to aspell interface. I don't know what you're talking about
when you say "running "make test" on the Perl module". I don't
know the functions session functions either, but I'm willing to
learn :-).
Best regards,
Gary