diff --git a/NEWS b/NEWS index 7089480653d0..5cdd07cb7f0d 100644 --- a/NEWS +++ b/NEWS @@ -31,6 +31,7 @@ PHP NEWS - Enchant: . Added enchant_dict_remove_from_session(). (nielsdos) + . Added enchant_dict_remove(). (nielsdos) -GD: . Fixed bug #68629 (Transparent artifacts when using imagerotate). (pierre, diff --git a/UPGRADING b/UPGRADING index 5420358fd4a5..34c9afa1030a 100644 --- a/UPGRADING +++ b/UPGRADING @@ -169,6 +169,8 @@ PHP 8.5 UPGRADE NOTES - Enchant: . Added enchant_dict_remove_from_session() to remove a word added to the spellcheck session via enchant_dict_add_to_session(). + . Added enchant_dict_remove() to put a word on the exclusion list and remove + remove it from the session dictionary. - PGSQL: . pg_close_stmt offers an alternative way to close a prepared diff --git a/ext/enchant/enchant.c b/ext/enchant/enchant.c index c003a1287f9d..bcea06a83d7a 100644 --- a/ext/enchant/enchant.c +++ b/ext/enchant/enchant.c @@ -689,6 +689,22 @@ PHP_FUNCTION(enchant_dict_add) } /* }}} */ +PHP_FUNCTION(enchant_dict_remove) +{ + zval *dict; + char *word; + size_t wordlen; + enchant_dict *pdict; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "Op", &dict, enchant_dict_ce, &word, &wordlen) == FAILURE) { + RETURN_THROWS(); + } + + PHP_ENCHANT_GET_DICT; + + enchant_dict_remove(pdict->pdict, word, wordlen); +} + /* {{{ add 'word' to this spell-checking session */ PHP_FUNCTION(enchant_dict_add_to_session) { diff --git a/ext/enchant/enchant.stub.php b/ext/enchant/enchant.stub.php index 7ca966490f3d..eafce22eac7d 100644 --- a/ext/enchant/enchant.stub.php +++ b/ext/enchant/enchant.stub.php @@ -87,6 +87,8 @@ function enchant_dict_suggest(EnchantDictionary $dictionary, string $word): arra function enchant_dict_add(EnchantDictionary $dictionary, string $word): void {} +function enchant_dict_remove(EnchantDictionary $dictionary, string $word): void {} + /** * @alias enchant_dict_add */ diff --git a/ext/enchant/enchant_arginfo.h b/ext/enchant/enchant_arginfo.h index 1b85b7dd48f3..a06f713f9ced 100644 --- a/ext/enchant/enchant_arginfo.h +++ b/ext/enchant/enchant_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: f4705d8708830247ffb55a7bf73bc6e874e12629 */ + * Stub hash: 9dd3fce23840ced1c265f8ec1dd3929298fdfe37 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_enchant_broker_init, 0, 0, EnchantBroker, MAY_BE_FALSE) ZEND_END_ARG_INFO() @@ -75,6 +75,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_enchant_dict_add, 0, 2, IS_VOID, ZEND_ARG_TYPE_INFO(0, word, IS_STRING, 0) ZEND_END_ARG_INFO() +#define arginfo_enchant_dict_remove arginfo_enchant_dict_add + #define arginfo_enchant_dict_add_to_personal arginfo_enchant_dict_add #define arginfo_enchant_dict_add_to_session arginfo_enchant_dict_add @@ -115,6 +117,7 @@ ZEND_FUNCTION(enchant_dict_quick_check); ZEND_FUNCTION(enchant_dict_check); ZEND_FUNCTION(enchant_dict_suggest); ZEND_FUNCTION(enchant_dict_add); +ZEND_FUNCTION(enchant_dict_remove); ZEND_FUNCTION(enchant_dict_add_to_session); ZEND_FUNCTION(enchant_dict_remove_from_session); ZEND_FUNCTION(enchant_dict_is_added); @@ -139,6 +142,7 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(enchant_dict_check, arginfo_enchant_dict_check) ZEND_FE(enchant_dict_suggest, arginfo_enchant_dict_suggest) ZEND_FE(enchant_dict_add, arginfo_enchant_dict_add) + ZEND_FE(enchant_dict_remove, arginfo_enchant_dict_remove) ZEND_RAW_FENTRY("enchant_dict_add_to_personal", zif_enchant_dict_add, arginfo_enchant_dict_add_to_personal, ZEND_ACC_DEPRECATED, NULL, NULL) ZEND_FE(enchant_dict_add_to_session, arginfo_enchant_dict_add_to_session) ZEND_FE(enchant_dict_remove_from_session, arginfo_enchant_dict_remove_from_session) diff --git a/ext/enchant/tests/dict_remove.phpt b/ext/enchant/tests/dict_remove.phpt new file mode 100644 index 000000000000..d2732214194f --- /dev/null +++ b/ext/enchant/tests/dict_remove.phpt @@ -0,0 +1,30 @@ +--TEST-- +enchant_dict_remove() function +--EXTENSIONS-- +enchant +--SKIPIF-- + +--FILE-- + +--EXPECT-- +bool(false) +bool(true) +bool(true) +bool(false) +bool(false)