]> granicus.if.org Git - php/commitdiff
partially ported ext/pspell, should be more for zend_string usage
authorAnatol Belski <ab@php.net>
Tue, 19 Aug 2014 12:28:03 +0000 (14:28 +0200)
committerAnatol Belski <ab@php.net>
Tue, 19 Aug 2014 12:28:03 +0000 (14:28 +0200)
ext/pspell/pspell.c

index 6d1a1026ea16e21782aae19bbf5cdd3c81b820b4..359f02fb15007d99f7b170c9d01213d2750b7fd7 100644 (file)
@@ -265,7 +265,7 @@ static PHP_FUNCTION(pspell_new)
 {
        char *language, *spelling = NULL, *jargon = NULL, *encoding = NULL;
        int language_len, spelling_len = 0, jargon_len = 0, encoding_len = 0;
-       long mode = 0L,  speed = 0L;
+       php_int_t mode = Z_I(0),  speed = Z_I(0);
        int argc = ZEND_NUM_ARGS();
        zval *ind;
 
@@ -281,7 +281,7 @@ static PHP_FUNCTION(pspell_new)
        PspellManager *manager;
        PspellConfig *config;
        
-       if (zend_parse_parameters(argc TSRMLS_CC, "s|sssl", &language, &language_len, &spelling, &spelling_len,
+       if (zend_parse_parameters(argc TSRMLS_CC, "s|sssi", &language, &language_len, &spelling, &spelling_len,
                &jargon, &jargon_len, &encoding, &encoding_len, &mode) == FAILURE) {
                return;
        }
@@ -362,7 +362,7 @@ static PHP_FUNCTION(pspell_new_personal)
 {
        char *personal, *language, *spelling = NULL, *jargon = NULL, *encoding = NULL;
        int personal_len, language_len, spelling_len = 0, jargon_len = 0, encoding_len = 0;
-       long mode = 0L,  speed = 0L;
+       php_int_t mode = Z_I(0),  speed = Z_I(0);
        int argc = ZEND_NUM_ARGS();
        zval *ind;
 
@@ -378,7 +378,7 @@ static PHP_FUNCTION(pspell_new_personal)
        PspellManager *manager;
        PspellConfig *config;
 
-       if (zend_parse_parameters(argc TSRMLS_CC, "ps|sssl", &personal, &personal_len, &language, &language_len, 
+       if (zend_parse_parameters(argc TSRMLS_CC, "ps|sssi", &personal, &personal_len, &language, &language_len, 
                &spelling, &spelling_len, &jargon, &jargon_len, &encoding, &encoding_len, &mode) == FAILURE) {
                return;
        }
@@ -465,13 +465,13 @@ static PHP_FUNCTION(pspell_new_personal)
    Load a dictionary based on the given config */
 static PHP_FUNCTION(pspell_new_config)
 {
-       long conf;      
+       php_int_t conf; 
        zval *ind;
        PspellCanHaveError *ret;
        PspellManager *manager;
        PspellConfig *config;
        
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &conf) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &conf) == FAILURE) {
                return;
        }
 
@@ -496,11 +496,11 @@ static PHP_FUNCTION(pspell_new_config)
 static PHP_FUNCTION(pspell_check)
 {
        int word_len;
-       long scin;
+       php_int_t scin;
        char *word;
        PspellManager *manager;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &scin, &word, &word_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "is", &scin, &word, &word_len) == FAILURE) {
                return;
        }
 
@@ -518,14 +518,14 @@ static PHP_FUNCTION(pspell_check)
    Returns array of suggestions */
 static PHP_FUNCTION(pspell_suggest)
 {
-       long scin;
+       php_int_t scin;
        char *word;
        int word_len;
        PspellManager *manager;
        const PspellWordList *wl;
        const char *sug;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &scin, &word, &word_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "is", &scin, &word, &word_len) == FAILURE) {
                return;
        }
 
@@ -552,11 +552,11 @@ static PHP_FUNCTION(pspell_suggest)
 static PHP_FUNCTION(pspell_store_replacement)
 {
        int miss_len, corr_len;
-       long scin;
+       php_int_t scin;
        char *miss, *corr;
        PspellManager *manager;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lss", &scin, &miss, &miss_len, &corr, &corr_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iss", &scin, &miss, &miss_len, &corr, &corr_len) == FAILURE) {
                return;
        }
 
@@ -577,11 +577,11 @@ static PHP_FUNCTION(pspell_store_replacement)
 static PHP_FUNCTION(pspell_add_to_personal)
 {
        int word_len;
-       long scin;
+       php_int_t scin;
        char *word;
        PspellManager *manager;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &scin, &word, &word_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "is", &scin, &word, &word_len) == FAILURE) {
                return;
        }
 
@@ -607,11 +607,11 @@ static PHP_FUNCTION(pspell_add_to_personal)
 static PHP_FUNCTION(pspell_add_to_session)
 {
        int word_len;
-       long scin;
+       php_int_t scin;
        char *word;
        PspellManager *manager;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &scin, &word, &word_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "is", &scin, &word, &word_len) == FAILURE) {
                return;
        }
 
@@ -636,10 +636,10 @@ static PHP_FUNCTION(pspell_add_to_session)
    Clears the current session */
 static PHP_FUNCTION(pspell_clear_session)
 {
-       long scin;
+       php_int_t scin;
        PspellManager *manager;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &scin) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &scin) == FAILURE) {
                return;
        }
     
@@ -659,10 +659,10 @@ static PHP_FUNCTION(pspell_clear_session)
    Saves the current (personal) wordlist */
 static PHP_FUNCTION(pspell_save_wordlist)
 {
-       long scin;
+       php_int_t scin;
        PspellManager *manager;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &scin) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &scin) == FAILURE) {
                return;
        }
     
@@ -752,11 +752,11 @@ static PHP_FUNCTION(pspell_config_create)
    Consider run-together words as valid components */
 static PHP_FUNCTION(pspell_config_runtogether)
 {
-       long conf;
+       php_int_t conf;
        zend_bool runtogether;
        PspellConfig *config;
        
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lb", &conf, &runtogether) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ib", &conf, &runtogether) == FAILURE) {
                return;
        }
 
@@ -772,10 +772,10 @@ static PHP_FUNCTION(pspell_config_runtogether)
    Select mode for config (PSPELL_FAST, PSPELL_NORMAL or PSPELL_BAD_SPELLERS) */
 static PHP_FUNCTION(pspell_config_mode)
 {
-       long conf, mode;
+       php_int_t conf, mode;
        PspellConfig *config;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &conf, &mode) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ii", &conf, &mode) == FAILURE) {
                return;
        }
 
@@ -799,10 +799,10 @@ static PHP_FUNCTION(pspell_config_mode)
 static PHP_FUNCTION(pspell_config_ignore)
 {
        char ignore_str[MAX_LENGTH_OF_ZEND_INT + 1];    
-       long conf, ignore = 0L;
+       php_int_t conf, ignore = 0L;
        PspellConfig *config;
        
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &conf, &ignore) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ii", &conf, &ignore) == FAILURE) {
                return;
        }
 
@@ -817,12 +817,12 @@ static PHP_FUNCTION(pspell_config_ignore)
 
 static void pspell_config_path(INTERNAL_FUNCTION_PARAMETERS, char *option)
 {
-       long conf;
+       php_int_t conf;
        char *value;
        int value_len;
        PspellConfig *config;
        
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lp", &conf, &value, &value_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ip", &conf, &value, &value_len) == FAILURE) {
                return;
        }
 
@@ -865,12 +865,12 @@ static PHP_FUNCTION(pspell_config_data_dir)
    Use a personal dictionary with replacement pairs for this config */
 static PHP_FUNCTION(pspell_config_repl)
 {
-       long conf;
+       php_int_t conf;
        char *repl;
        int repl_len;
        PspellConfig *config;
        
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lp", &conf, &repl, &repl_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ip", &conf, &repl, &repl_len) == FAILURE) {
                return;
        }
 
@@ -892,11 +892,11 @@ static PHP_FUNCTION(pspell_config_repl)
    Save replacement pairs when personal list is saved for this config */
 static PHP_FUNCTION(pspell_config_save_repl)
 {
-       long conf;
+       php_int_t conf;
        zend_bool save;
        PspellConfig *config;
        
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lb", &conf, &save) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ib", &conf, &save) == FAILURE) {
                return;
        }