int spell_check(struct sc_config const *config) { int i = 0; int ret = -1; char ch; char buf[MAX_WORD_LENGTH]; FILE *files[FILE_COUNT]; if (open_files(config, files)) goto ERROR; while ((ch = getc(files[FILE_DOC])) != EOF) { if (isspace(ch)) { buf[i] = '\0'; if (i != 0) { if (handle_word(buf, files, config)) goto ERROR; i = 0; } fprintf(files[FILE_OUT], "%c", ch); } else { buf[i++] = ch; } } ret = 0; ERROR: close_files(files); return ret; }
const std::string& query() { if (query_.empty()) { handle_word(); char *quote_word = g_shell_quote(word_.c_str()); query_ = "MATCH " + database_ + " " + strategy_ + ' ' + quote_word + "\r\n"; g_free(quote_word); } return DICT::Cmd::query(); }
static int tokenise(zword dictionarytable, const char *text, int length, zword *parse_dest, int maxwords, zword separatortable, int numseparators, BOOL write_unrecognized) { int i; int parsed_words = 0; int word_start = 0; for(i = 0; i <= length && parsed_words < maxwords; i++) { BOOL do_tokenise = FALSE; BOOL do_add_separator = FALSE; if((i == length) || text[i] == ' ') { /* A space or at the end */ do_tokenise = TRUE; } else { int j; for(j = 0; j < numseparators; j++) { if(text[i] == (char) LOBYTE(separatortable + j)) { do_tokenise = TRUE; do_add_separator = TRUE; break; } } } if(do_tokenise) { int wordlength = i - word_start; if(wordlength > 0) { handle_word(dictionarytable, text, word_start, wordlength, parse_dest, write_unrecognized, &parsed_words); } word_start = i + 1; } if(do_add_separator && parsed_words < maxwords) { handle_word(dictionarytable, text, i, 1, parse_dest, write_unrecognized, &parsed_words); } } return parsed_words; }