diff --git a/honoka/plugins/wordsdic.cpp b/honoka/plugins/wordsdic.cpp index e7cdcbf..2af1a0d 100644 --- a/honoka/plugins/wordsdic.cpp +++ b/honoka/plugins/wordsdic.cpp @@ -58,27 +58,37 @@ */ vector Honoka::WordsDic::find(const string &word) { - vector res; + vector res,bres; if (fd == -1) return res; if (word.length() > 255) return res; if (fd == -1) return res; - char w[256]; - for(unsigned int i = 0;i < word.length();i ++) w[i] = (char)tolower(word[i]); + char w[256],ow[256]; + for(unsigned int i = 0;i < word.length();i ++) { + w[i] = (char)tolower(word[i]); + ow[i] = word[i]; + } w[word.length()] = 0; + ow[word.length()] = 0; char *p = mmapptr; while(p < mmapptr + mmapsize) { - char b[256]; - for(unsigned int i = 0;i < word.length();i ++) b[i] = (char)tolower(p[i]); + char b[256],ob[256]; + for(unsigned int i = 0;i < word.length();i ++) { + b[i] = (char)tolower(p[i]); + ob[i] = p[i]; + } if (strncmp(w,b,word.length()) == 0) { string s; for(unsigned int i = 0;p[i] != '\n';i ++) { if (p[i] == 0) break; s += p[i]; } - res.push_back(s); + if (strncmp(ow,ob,word.length()) == 0) + res.push_back(s); + else bres.push_back(s); } while(*p != '\n') p ++; p ++; } + for(unsigned int i = 0;i < bres.size();i ++) res.push_back(bres[i]); return res; }