示例#1
0
/* {{{ proto bool pspell_check(int pspell, string word)
   Returns true if word is valid */
static PHP_FUNCTION(pspell_check)
{
	size_t word_len;
	zend_long scin;
	char *word;
	PspellManager *manager;

	if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &scin, &word, &word_len) == FAILURE) {
		return;
	}

	PSPELL_FETCH_MANAGER;

	if (pspell_manager_check(manager, word)) {
		RETURN_TRUE;
	} else {
		RETURN_FALSE;
	}
}
示例#2
0
static int
aspell_dict_check (EnchantDict * me, const char *const word, size_t len)
{
	PspellManager *manager;
	int val;
	char *normalizedWord;

	manager = (PspellManager *) me->user_data;

	normalizedWord = g_utf8_normalize (word, len, G_NORMALIZE_NFC);
	val = pspell_manager_check (manager, normalizedWord, strlen(normalizedWord));
	g_free(normalizedWord);

	if (val == 0)
		return 1;
	else if (val > 0)
		return 0;
	else {
		enchant_dict_set_error (me, pspell_manager_error_message (manager));
		return -1;
	}
}