1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Add enchant_dict_remove() (#17507)

This commit is contained in:
Niels Dossche
2025-02-02 19:14:49 +01:00
committed by GitHub
parent 50ed7b58bf
commit ff80ec70c6
6 changed files with 56 additions and 1 deletions

1
NEWS
View File

@@ -35,6 +35,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,

View File

@@ -205,6 +205,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 it from the session dictionary.
- PGSQL:
. pg_close_stmt offers an alternative way to close a prepared

View File

@@ -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)
{

View File

@@ -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
*/

View File

@@ -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)

View File

@@ -0,0 +1,30 @@
--TEST--
enchant_dict_remove() function
--EXTENSIONS--
enchant
--SKIPIF--
<?php
if (!is_array(enchant_broker_list_dicts(enchant_broker_init()))) die("skip no dictionary installed on this machine");
?>
--FILE--
<?php
$broker = enchant_broker_init();
$dicts = enchant_broker_list_dicts($broker);
$newWord = 'myImaginaryWord';
$requestDict = enchant_broker_request_dict($broker, $dicts[0]['lang_tag']);
var_dump(enchant_dict_check($requestDict, $newWord));
enchant_dict_add($requestDict, $newWord);
var_dump(enchant_dict_check($requestDict, $newWord));
var_dump(enchant_dict_is_added($requestDict, $newWord));
enchant_dict_remove($requestDict, $newWord);
var_dump(enchant_dict_check($requestDict, $newWord));
var_dump(enchant_dict_is_added($requestDict, $newWord));
?>
--EXPECT--
bool(false)
bool(true)
bool(true)
bool(false)
bool(false)