diff --git a/honoka/plugins/primeprediction.cpp b/honoka/plugins/primeprediction.cpp index 038eea6..6fcdc42 100644 --- a/honoka/plugins/primeprediction.cpp +++ b/honoka/plugins/primeprediction.cpp @@ -37,6 +37,10 @@ #define bind_textdomain_codeset(domain,codeset) #endif +#include +#include + + // �ץ饤�����󲽤Τ��ޤ��ʤ��Ǥ��� HonokaPluginRegister(PrimePrediction); @@ -100,6 +104,8 @@ */ ResultList PrimePrediction::getPredictionList(const WideString &str) { + ResultList l; + if (!con) return l; String s = lookup_method + "\t"; String t; m_iconv.convert(t,str); @@ -121,26 +127,9 @@ } else t += s[i]; } if (t.length()) sl.push_back(t); - ResultList l; l.Title = utf8_mbstowcs(String(_("lookup result"))); l.kType = PREDICTION; for(unsigned int i = 1;i < sl.size();i ++) { - /*vector rl; - String r; - for(unsigned int j = 0;j < sl[i].length();j ++) { - if ((sl[i][j] == '\t') || (sl[i][j] == ' ')) { - if (r.length()) { - rl.push_back(r); - r = ""; - } - } else r += sl[i][j]; - } - if (r.length()) rl.push_back(r); - if (rl.size() < 2) continue; - WideString w; - m_iconv.convert(w,rl[1]); - l.kouho.push_back(ResultEntry(w)); - */ ResultEntry e = parser(sl[i]); if (e.kanji.length()) l.kouho.push_back(e); } @@ -153,10 +142,12 @@ */ void PrimePrediction::disconnect() { + if (!con) return; String s = "close\n"; write(ifd,s.c_str(),s.length()); close(ifd); close(ofd); + con = false; } @@ -169,8 +160,7 @@ if (con) return true; if (pipe(in_fd) == -1) return false; if (pipe(out_fd) == -1) return false; - con = true; - switch(fork()) { + switch(vfork()) { case -1: { close(in_fd[0]); close(in_fd[1]); @@ -186,9 +176,10 @@ dup2(out_fd[1],1); close(in_fd[0]); close(out_fd[1]); + con = true; execlp("prime",NULL); con = false; - exit(1); + _exit(0); } } close(in_fd[0]);