Windows: small adjustments to new aspell management.
This commit is contained in:
parent
7310709e08
commit
d1058dc676
@ -250,8 +250,6 @@ bool Aspell::buildDict(Rcl::Db &db, string &reason)
|
||||
return true;
|
||||
}
|
||||
|
||||
static const unsigned int ldatadiroptsz = strlen("--local-data-dir=");
|
||||
|
||||
bool Aspell::make_speller(string& reason)
|
||||
{
|
||||
if (!ok())
|
||||
@ -259,7 +257,7 @@ bool Aspell::make_speller(string& reason)
|
||||
if (m_data->m_speller.getChildPid() > 0)
|
||||
return true;
|
||||
|
||||
// aspell --lang=[lang] --encoding=utf-8 --master=[dicPath()] --sug-mode=fast pipe
|
||||
// aspell --lang=[lang] --encoding=utf-8 --master=[dicPath()] --sug-mode=fast --mode=none pipe
|
||||
|
||||
string cmdstring(m_data->m_exec);
|
||||
|
||||
@ -276,11 +274,6 @@ bool Aspell::make_speller(string& reason)
|
||||
args.push_back(string("--data-dir=") + m_data->m_datadir);
|
||||
cmdstring += string(" ") + args.back();
|
||||
#endif
|
||||
if (m_data->m_addCreateParam.size() > ldatadiroptsz) {
|
||||
args.push_back(
|
||||
string("--local-data-dir=") + m_data->m_addCreateParam.substr(ldatadiroptsz));
|
||||
cmdstring += string(" ") + args.back();
|
||||
}
|
||||
|
||||
if (!m_data->m_addCreateParam.empty()) {
|
||||
args.push_back(m_data->m_addCreateParam);
|
||||
@ -293,24 +286,21 @@ bool Aspell::make_speller(string& reason)
|
||||
args.push_back(string("--sug-mode=fast"));
|
||||
cmdstring += string(" ") + args.back();
|
||||
|
||||
args.push_back(string("--mode=none"));
|
||||
cmdstring += string(" ") + args.back();
|
||||
|
||||
args.push_back("pipe");
|
||||
cmdstring += string(" ") + args.back();
|
||||
|
||||
// Keep stderr by default when querying?
|
||||
bool keepStderr = true;
|
||||
m_config->getConfParam("aspellKeepStderr", &keepStderr);
|
||||
if (!keepStderr)
|
||||
m_data->m_speller.setStderr("/dev/null");
|
||||
|
||||
LOGDEB("Starting aspell command [" << cmdstring << "]\n");
|
||||
if (m_data->m_speller.startExec(m_data->m_exec, args, true, true) != 0) {
|
||||
LOGERR("Can't start aspell\n");
|
||||
reason += "Can't start aspell: " + cmdstring;
|
||||
return false;
|
||||
}
|
||||
// Read initial line from aspell: version etc.
|
||||
string line;
|
||||
if (m_data->m_speller.getline(line, 2) <= 0) {
|
||||
LOGERR("rclaspell: failed reading initial aspell line. Command was " << cmdstring << "\n");
|
||||
reason += "Aspell: failed reading initial line";
|
||||
m_data->m_speller.zapChild();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -760,7 +760,7 @@ int ExecCmd::startExec(const string &cmd, const vector<string>& args,
|
||||
if (!m->preparePipes(has_input, &hInputRead, has_output,
|
||||
&hOutputWrite, &hErrorWrite)) {
|
||||
LOGERR("ExecCmd::startExec: preparePipes failed\n");
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
STARTUPINFOW siStartInfo;
|
||||
@ -820,7 +820,7 @@ int ExecCmd::startExec(const string &cmd, const vector<string>& args,
|
||||
if (bSuccess) {
|
||||
cleaner.inactivate();
|
||||
}
|
||||
return bSuccess;
|
||||
return bSuccess ? 0 : -1;
|
||||
}
|
||||
|
||||
// Send data to the child.
|
||||
@ -1011,6 +1011,29 @@ int ExecCmd::getline(string& data)
|
||||
return -1;
|
||||
}
|
||||
|
||||
class GetlineWatchdog : public ExecCmdAdvise {
|
||||
public:
|
||||
GetlineWatchdog(int secs) : m_secs(secs), tstart(time(0)) {}
|
||||
void newData(int) {
|
||||
if (time(0) - tstart >= m_secs) {
|
||||
throw std::runtime_error("getline timeout");
|
||||
}
|
||||
}
|
||||
int m_secs;
|
||||
time_t tstart;
|
||||
};
|
||||
|
||||
int ExecCmd::getline(string& data, int timeosecs)
|
||||
{
|
||||
GetlineWatchdog gwd(timeosecs);
|
||||
setAdvise(&gwd);
|
||||
try {
|
||||
return getline(data);
|
||||
} catch (...) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int ExecCmd::wait()
|
||||
{
|
||||
// If killRequest was set, we don't perform the normal
|
||||
|
||||
@ -55,9 +55,7 @@ else
|
||||
export PATH
|
||||
fi
|
||||
|
||||
# We use the mingw-compiled aspell program in both cases. When
|
||||
# compiling with msvc, we copy the msvc dll to the recoll top dir (and
|
||||
# don't use the exec, we keep the already tested mingw one).
|
||||
# We use the mingw-compiled aspell program in both cases, it's only executed as a command
|
||||
ASPELL=${RCLDEPS}/mingw/aspell-0.60.7/aspell-installed
|
||||
|
||||
# Where to find libgcc_s_dw2-1.dll et all for progs compiled with
|
||||
@ -316,9 +314,6 @@ copyaspell()
|
||||
chkcp $MINGWBIN/libgcc_s_dw2-1.dll $DEST
|
||||
chkcp $MINGWBIN/libstdc++-6.dll $DEST
|
||||
chkcp $MINGWBIN/libwinpthread-1.dll $DEST
|
||||
if test $BUILD = MSVC ; then
|
||||
chkcp $RCLDEPS/mingw/build-libaspell-Desktop_Qt_5_14_2_MSVC2017_32bit-Release/release/aspell.dll $DESTDIR/libaspell-15.dll
|
||||
fi
|
||||
}
|
||||
|
||||
# Recoll python package. Only when compiled with msvc as this is what
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user