vlad Wed Aug 13 14:59:44 2003 EDT
Modified files:
/php-src/ext/pspell pspell.c
Log:
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
Index: php-src/ext/pspell/pspell.c
diff -u php-src/ext/pspell/pspell.c:1.35 php-src/ext/pspell/pspell.c:1.36
--- php-src/ext/pspell/pspell.c:1.35 Sat Jul 19 15:23:32 2003
+++ php-src/ext/pspell/pspell.c Wed Aug 13 14:59:44 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pspell.c,v 1.35 2003/07/19 19:23:32 andrey Exp $ */
+/* $Id: pspell.c,v 1.36 2003/08/13 18:59:44 vlad Exp $ */
#define IS_EXT_MODULE
@@ -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 @@
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 @@
}
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 @@
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 @@
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 @@
manager = to_pspell_manager(ret);
ind = zend_list_insert(manager, le_pspell);
-
RETURN_LONG(ind);
}
/* }}} */
@@ -681,8 +736,8 @@
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;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php