diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2004-03-09 00:31:17 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2004-03-09 00:31:17 +0000 |
commit | e375ffddb457cd25695c46a720b20f5a8f70ccd7 (patch) | |
tree | 855c9e4cf21118a858500c8703699835f7182470 /ext/enchant | |
parent | b303ba089ca0255f4ced082e9ca2908d2b3dade4 (diff) | |
download | php-git-e375ffddb457cd25695c46a720b20f5a8f70ccd7.tar.gz |
Added enchant_dict_quick_check() function.
Made enchant_dict_check() return a boolean.
Diffstat (limited to 'ext/enchant')
-rw-r--r-- | ext/enchant/CREDITS | 2 | ||||
-rwxr-xr-x | ext/enchant/enchant.c | 45 | ||||
-rwxr-xr-x | ext/enchant/package.xml | 7 | ||||
-rw-r--r-- | ext/enchant/php_enchant.h | 1 |
4 files changed, 53 insertions, 2 deletions
diff --git a/ext/enchant/CREDITS b/ext/enchant/CREDITS new file mode 100644 index 0000000000..481febbfc2 --- /dev/null +++ b/ext/enchant/CREDITS @@ -0,0 +1,2 @@ +enchant +Pierre-Alain Joye, Ilia Alshanetsky diff --git a/ext/enchant/enchant.c b/ext/enchant/enchant.c index 02876c3618..1700279345 100755 --- a/ext/enchant/enchant.c +++ b/ext/enchant/enchant.c @@ -13,6 +13,7 @@ | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Pierre-Alain Joye <paj@pearfr.org> | + | Ilia Alshanetsky <ilia@prohost.org> | +----------------------------------------------------------------------+ $Id$ @@ -81,6 +82,7 @@ function_entry enchant_functions[] = { PHP_FE(enchant_dict_store_replacement, NULL) PHP_FE(enchant_dict_get_error, NULL) PHP_FE(enchant_dict_describe, NULL) + PHP_FE(enchant_dict_quick_check, third_arg_force_ref) {NULL, NULL, NULL} /* Must be the last line in enchant_functions[] */ }; @@ -496,8 +498,47 @@ PHP_FUNCTION(enchant_broker_describe) } /* }}} */ +PHP_FUNCTION(enchant_dict_quick_check) +{ + zval *dict, *sugg = NULL; + char *word; + int wordlen; + enchant_dict *pdict; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|z/", &dict, &word, &wordlen, &sugg) == FAILURE) { + RETURN_FALSE; + } + + if (sugg) { + zval_dtor(sugg); + } + + PHP_ENCHANT_GET_DICT; + + if (enchant_dict_check(pdict->pdict, word, wordlen) > 0) { + if (!sugg && ZEND_NUM_ARGS() == 2) { + RETURN_FALSE; + } + + int n_sugg; + char **suggs; + + array_init(sugg); + + suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, &n_sugg); + if (suggs && n_sugg) { + int i; + for (i = 0; i < n_sugg; i++) { + add_next_index_string(sugg, suggs[i], 1); + } + } + RETURN_FALSE; + } + RETURN_TRUE; +} + /* {{{ proto long enchant_dict_check(resource broker) - 0 if the word is correctly spelled, positive if not, negative if error */ + If the word is correctly spelled return true, otherwise return false */ PHP_FUNCTION(enchant_dict_check) { zval *dict; @@ -511,7 +552,7 @@ PHP_FUNCTION(enchant_dict_check) PHP_ENCHANT_GET_DICT; - RETURN_LONG((long)enchant_dict_check(pdict->pdict, word, wordlen)); + RETURN_BOOL(!enchant_dict_check(pdict->pdict, word, wordlen)); } /* }}} */ diff --git a/ext/enchant/package.xml b/ext/enchant/package.xml index f075f3f9ac..a8170bbeaa 100755 --- a/ext/enchant/package.xml +++ b/ext/enchant/package.xml @@ -10,6 +10,12 @@ <email>paj@pearfr.org</email> <role>lead</role> </maintainer> + <maintainer> + <user>iliaa</user> + <name>Ilia Alshanetsky</name> + <email>ilia@php.net</email> + <role>developer</role> + </maintainer> </maintainers> <description>Enchant is a binder for libenchant. Libenchant provides a common API for many spell libraries: @@ -31,6 +37,7 @@ see www.abisource.com/enchant/</description> <file role="src" name="config.w32"/> <file role="src" name="enchant.c"/> <file role="src" name="php_enchant.h"/> + <file role="doc" name="CREDITS"/> <dir name="docs" role="doc"> <dir name="examples"> <file name="example1.php"/> diff --git a/ext/enchant/php_enchant.h b/ext/enchant/php_enchant.h index 54ae7910d3..e0d98730ca 100644 --- a/ext/enchant/php_enchant.h +++ b/ext/enchant/php_enchant.h @@ -59,6 +59,7 @@ PHP_FUNCTION(enchant_dict_is_in_session); PHP_FUNCTION(enchant_dict_store_replacement); PHP_FUNCTION(enchant_dict_get_error); PHP_FUNCTION(enchant_dict_describe); +PHP_FUNCTION(enchant_dict_quick_check); #ifdef ZTS #define ENCHANT_G(v) TSRMG(enchant_globals_id, zend_enchant_globals *, v) |