|
a/src/aspell/rclaspell.cpp |
|
b/src/aspell/rclaspell.cpp |
|
... |
|
... |
28 |
#include ASPELL_INCLUDE
|
28 |
#include ASPELL_INCLUDE
|
29 |
|
29 |
|
30 |
#include "pathut.h"
|
30 |
#include "pathut.h"
|
31 |
#include "execmd.h"
|
31 |
#include "execmd.h"
|
32 |
#include "rclaspell.h"
|
32 |
#include "rclaspell.h"
|
33 |
#include "debuglog.h"
|
33 |
#include "log.h"
|
34 |
#include "unacpp.h"
|
34 |
#include "unacpp.h"
|
35 |
#include "ptmutex.h"
|
35 |
#include "ptmutex.h"
|
36 |
|
36 |
|
37 |
using namespace std;
|
37 |
using namespace std;
|
38 |
|
38 |
|
|
... |
|
... |
82 |
public:
|
82 |
public:
|
83 |
AspellData()
|
83 |
AspellData()
|
84 |
: m_handle(0), m_speller(0)
|
84 |
: m_handle(0), m_speller(0)
|
85 |
{}
|
85 |
{}
|
86 |
~AspellData() {
|
86 |
~AspellData() {
|
87 |
LOGDEB2(("~AspellData\n"));
|
87 |
LOGDEB2("~AspellData\n" );
|
88 |
if (m_handle) {
|
88 |
if (m_handle) {
|
89 |
dlclose(m_handle);
|
89 |
dlclose(m_handle);
|
90 |
m_handle = 0;
|
90 |
m_handle = 0;
|
91 |
}
|
91 |
}
|
92 |
if (m_speller) {
|
92 |
if (m_speller) {
|
93 |
// Dumps core if I do this??
|
93 |
// Dumps core if I do this??
|
94 |
//aapi.delete_aspell_speller(m_speller);
|
94 |
//aapi.delete_aspell_speller(m_speller);
|
95 |
m_speller = 0;
|
95 |
m_speller = 0;
|
96 |
LOGDEB2(("~AspellData: speller done\n"));
|
96 |
LOGDEB2("~AspellData: speller done\n" );
|
97 |
}
|
97 |
}
|
98 |
}
|
98 |
}
|
99 |
|
99 |
|
100 |
void *m_handle;
|
100 |
void *m_handle;
|
101 |
string m_exec;
|
101 |
string m_exec;
|
|
... |
|
... |
238 |
AspExecPv(string *i, Rcl::TermIter *tit, Rcl::Db &db)
|
238 |
AspExecPv(string *i, Rcl::TermIter *tit, Rcl::Db &db)
|
239 |
: m_input(i), m_tit(tit), m_db(db)
|
239 |
: m_input(i), m_tit(tit), m_db(db)
|
240 |
{}
|
240 |
{}
|
241 |
void newData() {
|
241 |
void newData() {
|
242 |
while (m_db.termWalkNext(m_tit, *m_input)) {
|
242 |
while (m_db.termWalkNext(m_tit, *m_input)) {
|
243 |
LOGDEB2(("Aspell::buildDict: term: [%s]\n", m_input->c_str()));
|
243 |
LOGDEB2("Aspell::buildDict: term: [" << (m_input) << "]\n" );
|
244 |
if (!Rcl::Db::isSpellingCandidate(*m_input)) {
|
244 |
if (!Rcl::Db::isSpellingCandidate(*m_input)) {
|
245 |
LOGDEB2(("Aspell::buildDict: SKIP\n"));
|
245 |
LOGDEB2("Aspell::buildDict: SKIP\n" );
|
246 |
continue;
|
246 |
continue;
|
247 |
}
|
247 |
}
|
248 |
if (!o_index_stripchars) {
|
248 |
if (!o_index_stripchars) {
|
249 |
string lower;
|
249 |
string lower;
|
250 |
if (!unacmaybefold(*m_input, lower, "UTF-8", UNACOP_FOLD))
|
250 |
if (!unacmaybefold(*m_input, lower, "UTF-8", UNACOP_FOLD))
|
251 |
continue;
|
251 |
continue;
|
252 |
m_input->swap(lower);
|
252 |
m_input->swap(lower);
|
253 |
}
|
253 |
}
|
254 |
// Got a non-empty sort-of appropriate term, let's send it to
|
254 |
// Got a non-empty sort-of appropriate term, let's send it to
|
255 |
// aspell
|
255 |
// aspell
|
256 |
LOGDEB2(("Apell::buildDict: SEND\n"));
|
256 |
LOGDEB2("Apell::buildDict: SEND\n" );
|
257 |
m_input->append("\n");
|
257 |
m_input->append("\n");
|
258 |
return;
|
258 |
return;
|
259 |
}
|
259 |
}
|
260 |
// End of data. Tell so. Exec will close cmd.
|
260 |
// End of data. Tell so. Exec will close cmd.
|
261 |
m_input->erase();
|
261 |
m_input->erase();
|
|
... |
|
... |
368 |
return true;
|
368 |
return true;
|
369 |
}
|
369 |
}
|
370 |
|
370 |
|
371 |
bool Aspell::check(const string &iterm, string& reason)
|
371 |
bool Aspell::check(const string &iterm, string& reason)
|
372 |
{
|
372 |
{
|
373 |
LOGDEB2(("Aspell::check [%s]\n", iterm.c_str()));
|
373 |
LOGDEB2("Aspell::check [" << (iterm) << "]\n" );
|
374 |
string mterm(iterm);
|
374 |
string mterm(iterm);
|
375 |
|
375 |
|
376 |
if (!ok() || !make_speller(reason))
|
376 |
if (!ok() || !make_speller(reason))
|
377 |
return false;
|
377 |
return false;
|
378 |
if (iterm.empty())
|
378 |
if (iterm.empty())
|
379 |
return true; //??
|
379 |
return true; //??
|
380 |
|
380 |
|
381 |
if (!o_index_stripchars) {
|
381 |
if (!o_index_stripchars) {
|
382 |
string lower;
|
382 |
string lower;
|
383 |
if (!unacmaybefold(mterm, lower, "UTF-8", UNACOP_FOLD)) {
|
383 |
if (!unacmaybefold(mterm, lower, "UTF-8", UNACOP_FOLD)) {
|
384 |
LOGERR(("Aspell::check : cant lowercase input\n"));
|
384 |
LOGERR("Aspell::check : cant lowercase input\n" );
|
385 |
return false;
|
385 |
return false;
|
386 |
}
|
386 |
}
|
387 |
mterm.swap(lower);
|
387 |
mterm.swap(lower);
|
388 |
}
|
388 |
}
|
389 |
|
389 |
|
|
... |
|
... |
411 |
return true; //??
|
411 |
return true; //??
|
412 |
|
412 |
|
413 |
if (!o_index_stripchars) {
|
413 |
if (!o_index_stripchars) {
|
414 |
string lower;
|
414 |
string lower;
|
415 |
if (!unacmaybefold(mterm, lower, "UTF-8", UNACOP_FOLD)) {
|
415 |
if (!unacmaybefold(mterm, lower, "UTF-8", UNACOP_FOLD)) {
|
416 |
LOGERR(("Aspell::check : cant lowercase input\n"));
|
416 |
LOGERR("Aspell::check : cant lowercase input\n" );
|
417 |
return false;
|
417 |
return false;
|
418 |
}
|
418 |
}
|
419 |
mterm.swap(lower);
|
419 |
mterm.swap(lower);
|
420 |
}
|
420 |
}
|
421 |
|
421 |
|
|
... |
|
... |
582 |
int main(int argc, char **argv)
|
582 |
int main(int argc, char **argv)
|
583 |
{return 1;}
|
583 |
{return 1;}
|
584 |
#endif // RCL_USE_ASPELL
|
584 |
#endif // RCL_USE_ASPELL
|
585 |
|
585 |
|
586 |
#endif // TEST_RCLASPELL test driver
|
586 |
#endif // TEST_RCLASPELL test driver
|
|
|
587 |
|