summaryrefslogtreecommitdiff
path: root/ext/pspell
diff options
context:
space:
mode:
authorVlad Krupin <vlad@php.net>2003-08-13 18:59:44 +0000
committerVlad Krupin <vlad@php.net>2003-08-13 18:59:44 +0000
commit3aaff90725e830baee9366627086396b448095d8 (patch)
tree8c054cbba0d094325fea5ad560c6b9161a3eab46 /ext/pspell
parent5b6e35851da8e14c14fad13714b6647b5dd67245 (diff)
downloadphp-git-3aaff90725e830baee9366627086396b448095d8.tar.gz
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
Diffstat (limited to 'ext/pspell')
-rw-r--r--ext/pspell/pspell.c61
1 files changed, 58 insertions, 3 deletions
diff --git a/ext/pspell/pspell.c b/ext/pspell/pspell.c
index ec7b8d9bd6..e07b10675e 100644
--- a/ext/pspell/pspell.c
+++ b/ext/pspell/pspell.c
@@ -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;