felipe Sat Aug 23 16:32:04 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/pspell pspell.c /php-src/ext/pspell/tests 003.phpt 005.phpt Log: MFH: - WS, Cosmetics - Removed unnecessary variables
http://cvs.php.net/viewvc.cgi/php-src/ext/pspell/pspell.c?r1=1.45.2.4.2.7.2.5&r2=1.45.2.4.2.7.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.7.2.5 php-src/ext/pspell/pspell.c:1.45.2.4.2.7.2.6 --- php-src/ext/pspell/pspell.c:1.45.2.4.2.7.2.5 Wed Aug 13 08:08:47 2008 +++ php-src/ext/pspell/pspell.c Sat Aug 23 16:32:04 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pspell.c,v 1.45.2.4.2.7.2.5 2008/08/13 08:08:47 tony2001 Exp $ */ +/* $Id: pspell.c,v 1.45.2.4.2.7.2.6 2008/08/23 16:32:04 felipe Exp $ */ #define IS_EXT_MODULE @@ -307,12 +307,12 @@ /* 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)) { + if (0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) { LONG result; dwLen = sizeof(aspell_dir) - 1; result = RegQueryValueEx(hkey, "", NULL, &dwType, (LPBYTE)&aspell_dir, &dwLen); RegCloseKey(hkey); - if(result == ERROR_SUCCESS) { + 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)); @@ -342,16 +342,16 @@ speed = mode & PSPELL_SPEED_MASK_INTERNAL; /* First check what mode we want (how many suggestions) */ - if(speed == PSPELL_FAST){ + if (speed == PSPELL_FAST) { pspell_config_replace(config, "sug-mode", "fast"); - }else if(speed == PSPELL_NORMAL){ + } else if (speed == PSPELL_NORMAL) { pspell_config_replace(config, "sug-mode", "normal"); - }else if(speed == PSPELL_BAD_SPELLERS){ + } else if (speed == PSPELL_BAD_SPELLERS) { pspell_config_replace(config, "sug-mode", "bad-spellers"); } /* Then we see if run-together words should be treated as valid components */ - if(mode & PSPELL_RUN_TOGETHER){ + if (mode & PSPELL_RUN_TOGETHER) { pspell_config_replace(config, "run-together", "true"); } } @@ -359,8 +359,8 @@ ret = new_pspell_manager(config); delete_pspell_config(config); - 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)); + 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_can_have_error(ret); RETURN_FALSE; } @@ -404,12 +404,12 @@ /* 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)) { + if (0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) { LONG result; dwLen = sizeof(aspell_dir) - 1; result = RegQueryValueEx(hkey, "", NULL, &dwType, (LPBYTE)&aspell_dir, &dwLen); RegCloseKey(hkey); - if(result == ERROR_SUCCESS) { + 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)); @@ -452,16 +452,16 @@ speed = mode & PSPELL_SPEED_MASK_INTERNAL; /* First check what mode we want (how many suggestions) */ - if(speed == PSPELL_FAST){ + if (speed == PSPELL_FAST) { pspell_config_replace(config, "sug-mode", "fast"); - }else if(speed == PSPELL_NORMAL){ + } else if (speed == PSPELL_NORMAL) { pspell_config_replace(config, "sug-mode", "normal"); - }else if(speed == PSPELL_BAD_SPELLERS){ + } else if (speed == PSPELL_BAD_SPELLERS) { pspell_config_replace(config, "sug-mode", "bad-spellers"); } /* Then we see if run-together words should be treated as valid components */ - if(mode & PSPELL_RUN_TOGETHER){ + if (mode & PSPELL_RUN_TOGETHER) { pspell_config_replace(config, "run-together", "true"); } } @@ -469,8 +469,8 @@ ret = new_pspell_manager(config); delete_pspell_config(config); - 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)); + 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_can_have_error(ret); RETURN_FALSE; } @@ -486,8 +486,7 @@ static PHP_FUNCTION(pspell_new_config) { int type, ind; - long conf; - + long conf; PspellCanHaveError *ret; PspellManager *manager; PspellConfig *config; @@ -500,8 +499,8 @@ ret = new_pspell_manager(config); - 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)); + 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_can_have_error(ret); RETURN_FALSE; } @@ -556,14 +555,14 @@ array_init(return_value); wl = pspell_manager_suggest(manager, word); - if(wl){ + if (wl) { PspellStringEmulation *els = pspell_word_list_elements(wl); - while((sug = pspell_string_emulation_next(els)) != 0){ + while ((sug = pspell_string_emulation_next(els)) != 0) { add_next_index_string(return_value,(char *)sug,1); } delete_pspell_string_emulation(els); - }else{ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "PSPELL had a problem. details: %s ", pspell_manager_error_message(manager)); + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "PSPELL had a problem. details: %s", pspell_manager_error_message(manager)); RETURN_FALSE; } } @@ -585,9 +584,9 @@ PSPELL_FETCH_MANAGER; pspell_manager_store_replacement(manager, miss, corr); - if(pspell_manager_error_number(manager) == 0){ + if (pspell_manager_error_number(manager) == 0) { RETURN_TRUE; - }else{ + } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "pspell_store_replacement() gave error: %s", pspell_manager_error_message(manager)); RETURN_FALSE; } @@ -610,14 +609,14 @@ PSPELL_FETCH_MANAGER; /*If the word is empty, we have to return; otherwise we'll segfault! ouch!*/ - if (word_len == 0){ + if (word_len == 0) { RETURN_FALSE; } pspell_manager_add_to_personal(manager, word); - if(pspell_manager_error_number(manager) == 0){ + if (pspell_manager_error_number(manager) == 0) { RETURN_TRUE; - }else{ + } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "pspell_add_to_personal() gave error: %s", pspell_manager_error_message(manager)); RETURN_FALSE; } @@ -640,14 +639,14 @@ PSPELL_FETCH_MANAGER; /*If the word is empty, we have to return; otherwise we'll segfault! ouch!*/ - if (word_len == 0){ + if (word_len == 0) { RETURN_FALSE; } pspell_manager_add_to_session(manager, word); - if(pspell_manager_error_number(manager) == 0){ + if (pspell_manager_error_number(manager) == 0) { RETURN_TRUE; - }else{ + } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "pspell_add_to_session() gave error: %s", pspell_manager_error_message(manager)); RETURN_FALSE; } @@ -669,9 +668,9 @@ PSPELL_FETCH_MANAGER; pspell_manager_clear_session(manager); - if(pspell_manager_error_number(manager) == 0){ + if (pspell_manager_error_number(manager) == 0) { RETURN_TRUE; - }else{ + } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "pspell_clear_session() gave error: %s", pspell_manager_error_message(manager)); RETURN_FALSE; } @@ -694,9 +693,9 @@ pspell_manager_save_all_word_lists(manager); - if(pspell_manager_error_number(manager) == 0){ + if (pspell_manager_error_number(manager) == 0) { RETURN_TRUE; - }else{ + } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "pspell_save_wordlist() gave error: %s", pspell_manager_error_message(manager)); RETURN_FALSE; } @@ -711,7 +710,6 @@ char *language, *spelling = NULL, *jargon = NULL, *encoding = NULL; int language_len, spelling_len = 0, jargon_len = 0, encoding_len = 0; int ind; - PspellConfig *config; #ifdef PHP_WIN32 @@ -733,12 +731,12 @@ /* 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)) { + if (0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) { LONG result; dwLen = sizeof(aspell_dir) - 1; result = RegQueryValueEx(hkey, "", NULL, &dwType, (LPBYTE)&aspell_dir, &dwLen); RegCloseKey(hkey); - if(result == ERROR_SUCCESS) { + 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)); @@ -756,7 +754,7 @@ pspell_config_replace(config, "spelling", spelling); } - if (jargon_len){ + if (jargon_len) { pspell_config_replace(config, "jargon", jargon); } @@ -780,11 +778,8 @@ int type; long conf; zend_bool runtogether; - int argc; - PspellConfig *config; - argc = ZEND_NUM_ARGS(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lb", &conf, &runtogether) == FAILURE) { return; } @@ -803,7 +798,6 @@ { int type; long conf, mode; - PspellConfig *config; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &conf, &mode) == FAILURE) { @@ -813,11 +807,11 @@ PSPELL_FETCH_CONFIG; /* First check what mode we want (how many suggestions) */ - if (mode == PSPELL_FAST){ + if (mode == PSPELL_FAST) { pspell_config_replace(config, "sug-mode", "fast"); - }else if (mode == PSPELL_NORMAL){ + } else if (mode == PSPELL_NORMAL) { pspell_config_replace(config, "sug-mode", "normal"); - }else if (mode == PSPELL_BAD_SPELLERS){ + } else if (mode == PSPELL_BAD_SPELLERS) { pspell_config_replace(config, "sug-mode", "bad-spellers"); } @@ -830,23 +824,16 @@ static PHP_FUNCTION(pspell_config_ignore) { int type; - long conf, pignore; - int argc; - char ignore_str[MAX_LENGTH_OF_LONG + 1]; - long ignore = 0L; - + long conf, ignore = 0L; PspellConfig *config; - argc = ZEND_NUM_ARGS(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &conf, &pignore) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &conf, &ignore) == FAILURE) { return; } PSPELL_FETCH_CONFIG; - ignore = pignore; - snprintf(ignore_str, sizeof(ignore_str), "%ld", ignore); pspell_config_replace(config, "ignore", ignore_str); @@ -913,7 +900,6 @@ long conf; char *repl; int repl_len; - PspellConfig *config; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &conf, &repl, &repl_len) == FAILURE) { @@ -945,7 +931,6 @@ int type; long conf; zend_bool save; - PspellConfig *config; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lb", &conf, &save) == FAILURE) { http://cvs.php.net/viewvc.cgi/php-src/ext/pspell/tests/003.phpt?r1=1.1.2.3&r2=1.1.2.3.2.1&diff_format=u Index: php-src/ext/pspell/tests/003.phpt diff -u php-src/ext/pspell/tests/003.phpt:1.1.2.3 php-src/ext/pspell/tests/003.phpt:1.1.2.3.2.1 --- php-src/ext/pspell/tests/003.phpt:1.1.2.3 Fri Jul 14 16:14:05 2006 +++ php-src/ext/pspell/tests/003.phpt Sat Aug 23 16:32:04 2008 @@ -29,7 +29,7 @@ --EXPECTF-- bool(false) -Warning: pspell_new_config(): PSPELL couldn't open the dictionary. reason: The encoding "b0rked" is not known.%sThis could also mean that the file "%sb0rked.%s" could not be opened for reading or does not exist. in %s003.php on line 9 +Warning: pspell_new_config(): PSPELL couldn't open the dictionary. reason: The encoding "b0rked" is not known. This could also mean that the file "%sb0rked.%s" could not be opened for reading or does not exist. in %s003.php on line 9 Warning: pspell_check(): 0 is not a PSPELL result index in %s003.php on line 10 bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/pspell/tests/005.phpt?r1=1.1.2.1&r2=1.1.2.1.2.1&diff_format=u Index: php-src/ext/pspell/tests/005.phpt diff -u php-src/ext/pspell/tests/005.phpt:1.1.2.1 php-src/ext/pspell/tests/005.phpt:1.1.2.1.2.1 --- php-src/ext/pspell/tests/005.phpt:1.1.2.1 Wed Jun 28 14:36:23 2006 +++ php-src/ext/pspell/tests/005.phpt Sat Aug 23 16:32:04 2008 @@ -33,7 +33,7 @@ unlink("$wordlist.tmp"); ?> --EXPECTF-- -Warning: pspell_new_personal(): PSPELL couldn't open the dictionary. reason: The file "%s005.php" is not in the proper format. in %s005.php on line 5 +Warning: pspell_new_personal(): PSPELL couldn't open the dictionary. reason: The file "%s005.php" is not in the proper format. in %s005.php on line 5 bool(false) bool(true) --
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php