Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add enchant_dict_remove() #17507

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions ext/enchant/enchant.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions ext/enchant/enchant.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
6 changes: 5 additions & 1 deletion ext/enchant/enchant_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions ext/enchant/tests/dict_remove.phpt
Original file line number Diff line number Diff line change
@@ -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)
Loading