Re: cvs: pear /PECL/namazu Makefile.in README.en README.ja config.m4 php_namazu.c php_namazu.h php_namazu_globals.h /PECL/namazu/sample form.php
search.php search2.php

From: Date: Wed, 09 Jan 2002 10:17:13 +0000
Subject: Re: cvs: pear /PECL/namazu Makefile.in README.en README.ja config.m4 php_namazu.c php_namazu.h php_namazu_globals.h /PECL/namazu/sample form.php
search.php search2.php
References: 1  Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-1875@lists.php.net to get a copy of this message
On Wed, Jan 09, 2002 at 09:08:40AM -0000, Yasuo Ohgaki wrote : > yohgaki Wed Jan 9 04:08:40 2002 EDT > > Added files: > /pear/PECL/namazu Makefile.in README.en README.ja config.m4 > php_namazu.c php_namazu.h php_namazu_globals.h > /pear/PECL/namazu/sample form.php search.php search2.php > Log: > Fulltext search engine interface. [...] > PHP_FUNCTION(nmz_set_sortorder) > { > zval **arg_order; > > if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg_order) == FAILURE) { > WRONG_PARAM_COUNT; > } > > convert_to_string_ex(arg_order); > if (strcasecmp("ascending", Z_STRVAL_PP(arg_order)) == 0) { > nmz_set_sortorder(ASCENDING); > } else if (strcasecmp("descending", Z_STRVAL_PP(arg_order)) == 0) { > nmz_set_sortorder(DESCENDING); > } else { > php_error(E_WARNING, "Illegal argument"); > RETURN_FALSE; > } > RETURN_TRUE; > } > /* }}} */ Shouldn't we use CONSTANTS here instead of strings? Same goes for sortmethod. NMZ_ASC instead of "ascending" and NMZ_DESC for "descending" (just an example, could be NAMAZU_ASCENDING too ;). > if (Z_TYPE_PP(arg_result) == IS_RESOURCE && Z_LVAL_PP(arg_result) == 0) { > RETURN_FALSE; > } > > ZEND_FETCH_RESOURCE(nmzres, php_nmzresult_t *, arg_result, -1, "Namazu result", > le_nmzres); If you use ZEND_FETCH_RESOURE() it does automatically error cehcking (there's no need for the if's above. > > if (type == 2) { > if (ZEND_NUM_ARGS() != 3 || > zend_get_parameters_ex(3, &arg_result, &arg_row, &arg_field) == FAILURE) { > WRONG_PARAM_COUNT; > } > convert_to_string_ex(arg_field); > } else { > if (ZEND_NUM_ARGS() != 2 || > zend_get_parameters_ex(2, &arg_result, &arg_row) == FAILURE) { > WRONG_PARAM_COUNT; > } > } You might want to switch to zend_parse_parameters() ... (I saw such code multiple times). Also, when using php_error() please always expose the context of the current function, e.g. php_error(E_WARNING, "%s(): illegal foobar '%d'", get_active_function_name(TSRMLS_C), value); - Markus

« previous php.pear.cvs (#1875) next »