mirror of
https://github.com/php/php-src.git
synced 2025-01-22 11:44:09 +08:00
changes to accomodate win32 build
# I am not sure whether reading from registry, like I do now is a good # idea, but nobody on php-dev has offered any opinion for or against that
This commit is contained in:
parent
5b6e35851d
commit
3aaff90725
@ -45,6 +45,11 @@
|
||||
#define PSPELL_SPEED_MASK_INTERNAL 3L
|
||||
#define PSPELL_RUN_TOGETHER 8L
|
||||
|
||||
/* Largest ignored word can be 999 characters (this seems sane enough),
|
||||
* and it takes 3 bytes to represent that (see pspell_config_ignore)
|
||||
*/
|
||||
#define PSPELL_LARGEST_WORD 3
|
||||
|
||||
/* {{{ pspell_functions[]
|
||||
*/
|
||||
function_entry pspell_functions[] = {
|
||||
@ -117,6 +122,14 @@ PHP_FUNCTION(pspell_new)
|
||||
int argc;
|
||||
int ind;
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
TCHAR aspell_dir[200];
|
||||
TCHAR data_dir[220];
|
||||
TCHAR dict_dir[220];
|
||||
HKEY hkey;
|
||||
DWORD dwType,dwLen;
|
||||
#endif
|
||||
|
||||
PspellCanHaveError *ret;
|
||||
PspellManager *manager;
|
||||
PspellConfig *config;
|
||||
@ -127,6 +140,24 @@ PHP_FUNCTION(pspell_new)
|
||||
}
|
||||
|
||||
config = new_pspell_config();
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
/* If aspell was installed using installer, we should have a key
|
||||
* pointing to the location of the dictionaries
|
||||
*/
|
||||
if(0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) {
|
||||
RegQueryValueEx(hkey, "", NULL, &dwType, (LPBYTE)&aspell_dir, &dwLen);
|
||||
RegCloseKey(hkey);
|
||||
strcpy(data_dir, aspell_dir);
|
||||
strcat(data_dir, "\\data");
|
||||
strcpy(dict_dir, aspell_dir);
|
||||
strcat(dict_dir, "\\dict");
|
||||
|
||||
pspell_config_replace(config, "data-dir", data_dir);
|
||||
pspell_config_replace(config, "dict-dir", dict_dir);
|
||||
}
|
||||
#endif
|
||||
|
||||
convert_to_string_ex(language);
|
||||
pspell_config_replace(config, "language-tag", Z_STRVAL_PP(language));
|
||||
|
||||
@ -194,6 +225,14 @@ PHP_FUNCTION(pspell_new_personal)
|
||||
int argc;
|
||||
int ind;
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
TCHAR aspell_dir[200];
|
||||
TCHAR data_dir[220];
|
||||
TCHAR dict_dir[220];
|
||||
HKEY hkey;
|
||||
DWORD dwType,dwLen;
|
||||
#endif
|
||||
|
||||
PspellCanHaveError *ret;
|
||||
PspellManager *manager;
|
||||
PspellConfig *config;
|
||||
@ -205,6 +244,23 @@ PHP_FUNCTION(pspell_new_personal)
|
||||
|
||||
config = new_pspell_config();
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
/* If aspell was installed using installer, we should have a key
|
||||
* pointing to the location of the dictionaries
|
||||
*/
|
||||
if(0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) {
|
||||
RegQueryValueEx(hkey, "", NULL, &dwType, (LPBYTE)&aspell_dir, &dwLen);
|
||||
RegCloseKey(hkey);
|
||||
strcpy(data_dir, aspell_dir);
|
||||
strcat(data_dir, "\\data");
|
||||
strcpy(dict_dir, aspell_dir);
|
||||
strcat(dict_dir, "\\dict");
|
||||
|
||||
pspell_config_replace(config, "data-dir", data_dir);
|
||||
pspell_config_replace(config, "dict-dir", dict_dir);
|
||||
}
|
||||
#endif
|
||||
|
||||
convert_to_string_ex(personal);
|
||||
|
||||
if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(personal), NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
|
||||
@ -272,7 +328,6 @@ PHP_FUNCTION(pspell_new_personal)
|
||||
|
||||
manager = to_pspell_manager(ret);
|
||||
ind = zend_list_insert(manager, le_pspell);
|
||||
|
||||
RETURN_LONG(ind);
|
||||
}
|
||||
/* }}} */
|
||||
@ -681,8 +736,8 @@ PHP_FUNCTION(pspell_config_ignore)
|
||||
int argc;
|
||||
|
||||
/* Hack. But I cannot imagine any word being more than 999 characters long */
|
||||
int loc = 3;
|
||||
char ignore_str[loc + 1];
|
||||
int loc = PSPELL_LARGEST_WORD;
|
||||
char ignore_str[PSPELL_LARGEST_WORD + 1];
|
||||
long ignore = 0L;
|
||||
|
||||
PspellConfig *config;
|
||||
|
Loading…
Reference in New Issue
Block a user