diff --git a/src/aspell/rclaspell.cpp b/src/aspell/rclaspell.cpp index 67029bdf..67061bc8 100644 --- a/src/aspell/rclaspell.cpp +++ b/src/aspell/rclaspell.cpp @@ -270,6 +270,7 @@ public: #endif // Got a non-empty sort-of appropriate term, let's send it to // aspell + LOGDEB2(("ASpExecPv: [%s]\n", m_input->c_str())); m_input->append("\n"); return; } @@ -454,7 +455,8 @@ RclConfig *rclconfig; static char usage [] = " -b : build dictionary\n" " -s : suggestions for term\n" -"\n\n" +" -c : check term\n" +"\n" ; static void Usage(void) @@ -467,6 +469,7 @@ static int op_flags; #define OPT_MOINS 0x1 #define OPT_s 0x2 #define OPT_b 0x4 +#define OPT_c 0x8 int main(int argc, char **argv) { @@ -483,6 +486,10 @@ int main(int argc, char **argv) while (**argv) switch (*(*argv)++) { case 'b': op_flags |= OPT_b; break; + case 'c': op_flags |= OPT_c; if (argc < 2) Usage(); + word = *(++argv); + argc--; + goto b1; case 's': op_flags |= OPT_s; if (argc < 2) Usage(); word = *(++argv); argc--; @@ -526,6 +533,18 @@ int main(int argc, char **argv) cerr << "buildDict failed: " << reason << endl; exit(1); } + } else if (op_flags & OPT_c) { + bool ret = aspell.check(word, reason); + if (!ret && reason.size()) { + cerr << "Aspell error: " << reason << endl; + return 1; + } + cout << word; + if (ret) { + cout << " is in dictionary" << endl; + } else { + cout << " not in dictionary" << endl; + } } else { list suggs; if (!aspell.suggest(rcldb, word, suggs, reason)) { diff --git a/src/aspell/rclaspell.h b/src/aspell/rclaspell.h index b969aa75..a493b5d9 100644 --- a/src/aspell/rclaspell.h +++ b/src/aspell/rclaspell.h @@ -54,7 +54,12 @@ class Aspell { * of an indexing pass. */ bool buildDict(Rcl::Db &db, std::string &reason); - /** Check that word is in dictionary. ret==false && !reason.empty() => err*/ + /** Check that word is in dictionary. Note that this would mean + * that the EXACT word is: aspell just does a lookup, no + * grammatical, case or diacritics magic of any kind + * + * @return true if word in dic, false if not. reason.size() -> error + */ bool check(const std::string& term, std::string& reason); /** Return a list of possible expansions for a given word */