[PHP-CVS] cvs: php-src(PHP_5_2) /ext/pspell pspell.c
tony2001Wed Aug 13 08:09:55 2008 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/pspell pspell.c Log: MFH: fix compile warnings (patch by Phil Oleson) http://cvs.php.net/viewvc.cgi/php-src/ext/pspell/pspell.c?r1=1.45.2.4.2.8&r2=1.45.2.4.2.9&diff_format=u Index: php-src/ext/pspell/pspell.c diff -u php-src/ext/pspell/pspell.c:1.45.2.4.2.8 php-src/ext/pspell/pspell.c:1.45.2.4.2.9 --- php-src/ext/pspell/pspell.c:1.45.2.4.2.8Mon Dec 31 07:20:10 2007 +++ php-src/ext/pspell/pspell.c Wed Aug 13 08:09:55 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: pspell.c,v 1.45.2.4.2.8 2007/12/31 07:20:10 sebastian Exp $ */ +/* $Id: pspell.c,v 1.45.2.4.2.9 2008/08/13 08:09:55 tony2001 Exp $ */ #define IS_EXT_MODULE @@ -251,7 +251,7 @@ if(pspell_error_number(ret) != 0){ php_error_docref(NULL TSRMLS_CC, E_WARNING, "PSPELL couldn't open the dictionary. reason: %s ", pspell_error_message(ret)); - delete_pspell_manager(ret); + delete_pspell_can_have_error(ret); RETURN_FALSE; } @@ -374,7 +374,7 @@ if(pspell_error_number(ret) != 0){ php_error_docref(NULL TSRMLS_CC, E_WARNING, "PSPELL couldn't open the dictionary. reason: %s ", pspell_error_message(ret)); - delete_pspell_manager(ret); + delete_pspell_can_have_error(ret); RETURN_FALSE; } @@ -408,7 +408,7 @@ if(pspell_error_number(ret) != 0){ php_error_docref(NULL TSRMLS_CC, E_WARNING, "PSPELL couldn't open the dictionary. reason: %s ", pspell_error_message(ret)); - delete_pspell_manager(ret); + delete_pspell_can_have_error(ret); RETURN_FALSE; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/pspell pspell.c
stasSat Feb 17 01:45:52 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/pspell pspell.c Log: use safer functions, check error value http://cvs.php.net/viewvc.cgi/php-src/ext/pspell/pspell.c?r1=1.45.2.4.2.5&r2=1.45.2.4.2.6&diff_format=u Index: php-src/ext/pspell/pspell.c diff -u php-src/ext/pspell/pspell.c:1.45.2.4.2.5 php-src/ext/pspell/pspell.c:1.45.2.4.2.6 --- php-src/ext/pspell/pspell.c:1.45.2.4.2.5Tue Jan 16 11:19:10 2007 +++ php-src/ext/pspell/pspell.c Sat Feb 17 01:45:52 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: pspell.c,v 1.45.2.4.2.5 2007/01/16 11:19:10 tony2001 Exp $ */ +/* $Id: pspell.c,v 1.45.2.4.2.6 2007/02/17 01:45:52 stas Exp $ */ #define IS_EXT_MODULE @@ -186,16 +186,19 @@ * pointing to the location of the dictionaries */ if(0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) { + LONG result; dwLen = sizeof(aspell_dir) - 1; - RegQueryValueEx(hkey, "", NULL, &dwType, (LPBYTE)&aspell_dir, &dwLen); + result = 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"); + if(result == ERROR_SUCCESS) { + strlcpy(data_dir, aspell_dir, sizeof(data_dir)); + strlcat(data_dir, "\\data", sizeof(data_dir)); + strlcpy(dict_dir, aspell_dir, sizeof(dict_dir)); + strlcat(dict_dir, "\\dict", sizeof(dict_dir)); - pspell_config_replace(config, "data-dir", data_dir); - pspell_config_replace(config, "dict-dir", dict_dir); + pspell_config_replace(config, "data-dir", data_dir); + pspell_config_replace(config, "dict-dir", dict_dir); + } } #endif @@ -291,16 +294,19 @@ * pointing to the location of the dictionaries */ if(0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) { + LONG result; dwLen = sizeof(aspell_dir) - 1; - RegQueryValueEx(hkey, "", NULL, &dwType, (LPBYTE)&aspell_dir, &dwLen); + result = 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"); + if(result == ERROR_SUCCESS) { + strlcpy(data_dir, aspell_dir, sizeof(data_dir)); + strlcat(data_dir, "\\data", sizeof(data_dir)); + strlcpy(dict_dir, aspell_dir, sizeof(dict_dir)); + strlcat(dict_dir, "\\dict", sizeof(dict_dir)); - pspell_config_replace(config, "data-dir", data_dir); - pspell_config_replace(config, "dict-dir", dict_dir); + pspell_config_replace(config, "data-dir", data_dir); + pspell_config_replace(config, "dict-dir", dict_dir); + } } #endif @@ -649,16 +655,19 @@ * pointing to the location of the dictionaries */ if(0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) { + LONG result; dwLen = sizeof(aspell_dir) - 1; - RegQueryValueEx(hkey, "", NULL, &dwType, (LPBYTE)&aspell_dir, &dwLen); + result = 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"); + if(result == ERROR_SUCCESS) { + strlcpy(data_dir, aspell_dir, sizeof(data_dir)); + strlcat(data_dir, "\\data", sizeof(data_dir)); + strlcpy(dict_dir, aspell_dir, sizeof(dict_dir)); + strlcat(dict_dir, "\\dict", sizeof(dict_dir)); - pspell_config_replace(config, "data-dir", data_dir); - pspell_config_replace(config, "dict-dir", dict_dir); + pspell_config_replace(config, "data-dir", data_dir); + pspell_config_replace(config, "dict-dir", dict_dir); + } } #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/pspell pspell.c
tony2001Tue Jan 16 11:19:10 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/pspell pspell.c Log: MFH http://cvs.php.net/viewvc.cgi/php-src/ext/pspell/pspell.c?r1=1.45.2.4.2.4&r2=1.45.2.4.2.5&diff_format=u Index: php-src/ext/pspell/pspell.c diff -u php-src/ext/pspell/pspell.c:1.45.2.4.2.4 php-src/ext/pspell/pspell.c:1.45.2.4.2.5 --- php-src/ext/pspell/pspell.c:1.45.2.4.2.4Mon Jan 1 09:36:05 2007 +++ php-src/ext/pspell/pspell.c Tue Jan 16 11:19:10 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: pspell.c,v 1.45.2.4.2.4 2007/01/01 09:36:05 sebastian Exp $ */ +/* $Id: pspell.c,v 1.45.2.4.2.5 2007/01/16 11:19:10 tony2001 Exp $ */ #define IS_EXT_MODULE @@ -186,6 +186,7 @@ * pointing to the location of the dictionaries */ if(0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) { + dwLen = sizeof(aspell_dir) - 1; RegQueryValueEx(hkey, "", NULL, &dwType, (LPBYTE)&aspell_dir, &dwLen); RegCloseKey(hkey); strcpy(data_dir, aspell_dir); @@ -247,6 +248,7 @@ if(pspell_error_number(ret) != 0){ php_error_docref(NULL TSRMLS_CC, E_WARNING, "PSPELL couldn't open the dictionary. reason: %s ", pspell_error_message(ret)); + delete_pspell_manager(ret); RETURN_FALSE; } @@ -289,6 +291,7 @@ * pointing to the location of the dictionaries */ if(0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) { + dwLen = sizeof(aspell_dir) - 1; RegQueryValueEx(hkey, "", NULL, &dwType, (LPBYTE)&aspell_dir, &dwLen); RegCloseKey(hkey); strcpy(data_dir, aspell_dir); @@ -304,10 +307,12 @@ convert_to_string_ex(personal); if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(personal), NULL, CHECKUID_CHECK_FILE_AND_DIR))) { + delete_pspell_config(config); RETURN_FALSE; } if (php_check_open_basedir(Z_STRVAL_PP(personal) TSRMLS_CC)) { + delete_pspell_config(config); RETURN_FALSE; } @@ -363,6 +368,7 @@ if(pspell_error_number(ret) != 0){ php_error_docref(NULL TSRMLS_CC, E_WARNING, "PSPELL couldn't open the dictionary. reason: %s ", pspell_error_message(ret)); + delete_pspell_manager(ret); RETURN_FALSE; } @@ -396,6 +402,7 @@ if(pspell_error_number(ret) != 0){ php_error_docref(NULL TSRMLS_CC, E_WARNING, "PSPELL couldn't open the dictionary. reason: %s ", pspell_error_message(ret)); + delete_pspell_manager(ret); RETURN_FALSE; } @@ -641,17 +648,18 @@ /* 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); - } + if(0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) { + dwLen = sizeof(aspell_dir) - 1; + 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); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/pspell pspell.c
tony2001Wed Dec 20 15:12:38 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/pspell pspell.c Log: MFH http://cvs.php.net/viewvc.cgi/php-src/ext/pspell/pspell.c?r1=1.45.2.4.2.2&r2=1.45.2.4.2.3&diff_format=u Index: php-src/ext/pspell/pspell.c diff -u php-src/ext/pspell/pspell.c:1.45.2.4.2.2 php-src/ext/pspell/pspell.c:1.45.2.4.2.3 --- php-src/ext/pspell/pspell.c:1.45.2.4.2.2Mon Aug 14 20:08:18 2006 +++ php-src/ext/pspell/pspell.c Wed Dec 20 15:12:38 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: pspell.c,v 1.45.2.4.2.2 2006/08/14 20:08:18 nlopess Exp $ */ +/* $Id: pspell.c,v 1.45.2.4.2.3 2006/12/20 15:12:38 tony2001 Exp $ */ #define IS_EXT_MODULE @@ -751,8 +751,7 @@ zval **conf, **pignore; int argc; - int loc = PSPELL_LARGEST_WORD; - char ignore_str[PSPELL_LARGEST_WORD + 1]; + char ignore_str[MAX_LENGTH_OF_LONG + 1]; long ignore = 0L; PspellConfig *config; @@ -767,23 +766,9 @@ convert_to_long_ex(pignore); ignore = Z_LVAL_PP(pignore); - /* The following is a very hackish way to convert a long to a string - (actually only the numbers 0-999 will get converted properly, but that should - be sufficient). If anyone knows of a better way to convert an integer to a string, - please, fix it.*/ - ignore_str[loc] = '\0'; - while(ignore > 0){ - if(loc == 0){ - break; - } - ignore_str[--loc] = '0' + (ignore % 10); - ignore /= 10; - } - if(ignore_str[loc] == '\0'){ - ignore_str[--loc] = '0'; - } + sprintf(ignore_str, "%ld", ignore); - pspell_config_replace(config, "ignore", &ignore_str[loc]); + pspell_config_replace(config, "ignore", ignore_str); RETURN_TRUE; } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php