Skip to content

Commit e6ae5c3

Browse files
author
Brian France
committed
Added two new functions to set the dict-dir and data-dir options.
1 parent 8b97d9d commit e6ae5c3

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

ext/pspell/php_pspell.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ PHP_FUNCTION(pspell_config_runtogether);
4141
PHP_FUNCTION(pspell_config_mode);
4242
PHP_FUNCTION(pspell_config_ignore);
4343
PHP_FUNCTION(pspell_config_personal);
44+
PHP_FUNCTION(pspell_config_dict_dir);
45+
PHP_FUNCTION(pspell_config_data_dir);
4446
PHP_FUNCTION(pspell_config_repl);
4547
PHP_FUNCTION(pspell_config_save_repl);
4648
#else

ext/pspell/pspell.c

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ function_entry pspell_functions[] = {
6868
PHP_FE(pspell_config_mode, NULL)
6969
PHP_FE(pspell_config_ignore, NULL)
7070
PHP_FE(pspell_config_personal, NULL)
71+
PHP_FE(pspell_config_dict_dir, NULL)
72+
PHP_FE(pspell_config_data_dir, NULL)
7173
PHP_FE(pspell_config_repl, NULL)
7274
PHP_FE(pspell_config_save_repl, NULL)
7375
{NULL, NULL, NULL}
@@ -803,18 +805,15 @@ PHP_FUNCTION(pspell_config_ignore)
803805
}
804806
/* }}} */
805807

806-
/* {{{ proto bool pspell_config_personal(int conf, string personal)
807-
Use a personal dictionary for this config */
808-
PHP_FUNCTION(pspell_config_personal)
809-
{
808+
static int pspell_config_path( INTERNAL_FUNCTION_PARAMETERS, char *option ) {
810809
int type;
811-
zval **sccin, **personal;
810+
zval **sccin, **value;
812811
int argc;
813812

814813
PspellConfig *config;
815814

816815
argc = ZEND_NUM_ARGS();
817-
if (argc != 2 || zend_get_parameters_ex(argc,&sccin,&personal) == FAILURE) {
816+
if (argc != 2 || zend_get_parameters_ex(argc,&sccin,&value) == FAILURE) {
818817
WRONG_PARAM_COUNT;
819818
}
820819

@@ -825,20 +824,45 @@ PHP_FUNCTION(pspell_config_personal)
825824
RETURN_FALSE;
826825
}
827826

828-
convert_to_string_ex(personal);
827+
convert_to_string_ex(value);
829828

830-
if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(personal), NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
829+
if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(value), NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
831830
RETURN_FALSE;
832831
}
833832

834-
if (php_check_open_basedir(Z_STRVAL_PP(personal) TSRMLS_CC)) {
833+
if (php_check_open_basedir(Z_STRVAL_PP(value) TSRMLS_CC)) {
835834
RETURN_FALSE;
836835
}
837836

838-
pspell_config_replace(config, "personal", Z_STRVAL_PP(personal));
837+
pspell_config_replace(config, option, Z_STRVAL_PP(value));
839838

840839
RETURN_TRUE;
841840
}
841+
842+
/* {{{ proto bool pspell_config_personal(int conf, string personal)
843+
Use a personal dictionary for this config */
844+
PHP_FUNCTION(pspell_config_personal)
845+
{
846+
pspell_config_path( INTERNAL_FUNCTION_PARAM_PASSTHRU, "personal");
847+
}
848+
/* }}} */
849+
850+
/* {{{ proto bool pspell_config_dict_dir(int conf, string directory)
851+
852+
location of the main word list */
853+
PHP_FUNCTION(pspell_config_dict_dir)
854+
{
855+
pspell_config_path( INTERNAL_FUNCTION_PARAM_PASSTHRU, "dict-dir");
856+
}
857+
858+
/* }}} */
859+
860+
/* {{{ proto bool pspell_config_data_dir(int conf, string directory)
861+
location of language data files */
862+
PHP_FUNCTION(pspell_config_data_dir)
863+
{
864+
pspell_config_path( INTERNAL_FUNCTION_PARAM_PASSTHRU, "data-dir");
865+
}
842866
/* }}} */
843867

844868
/* {{{ proto bool pspell_config_repl(int conf, string repl)

0 commit comments

Comments
 (0)