abies           Wed May 12 09:14:55 2004 EDT

  Modified files:              
    /php-src/ext/interbase      interbase.c 
  Log:
  Made ibase_timefmt() check its args more thoroughly and nuked a pointless malloc()
  
http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.212&r2=1.213&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.212 php-src/ext/interbase/interbase.c:1.213
--- php-src/ext/interbase/interbase.c:1.212     Wed May 12 09:07:35 2004
+++ php-src/ext/interbase/interbase.c   Wed May 12 09:14:55 2004
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: interbase.c,v 1.212 2004/05/12 13:07:35 abies Exp $ */
+/* $Id: interbase.c,v 1.213 2004/05/12 13:14:55 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -30,7 +30,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.212 $"
+#define FILE_REVISION "$Revision: 1.213 $"
 
 #if HAVE_IBASE
 
@@ -1136,34 +1136,18 @@
 #endif
 /* }}} */
 
-#if HAVE_STRFTIME
 /* {{{ proto bool ibase_timefmt(string format [, int type ])
    Sets the format of timestamp, date and time columns returned from queries */
 PHP_FUNCTION(ibase_timefmt)
 {
-       zval ***args;
-       char *fmt = NULL;
-       int type = PHP_IBASE_TIMESTAMP;
-       
-       if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 2) {
-               WRONG_PARAM_COUNT;
-       }
+       char *fmt;
+       int fmt_len;
+       long type = PHP_IBASE_TIMESTAMP;
        
-       args = (zval ***) safe_emalloc(sizeof(zval **), ZEND_NUM_ARGS(), 0);
-       if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
-               efree(args);
+       if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &fmt, 
&fmt_len, &type)) {
                RETURN_FALSE;
        }
 
-       switch (ZEND_NUM_ARGS()) {
-               case 2:
-                       convert_to_long_ex(args[1]);
-                       type = Z_LVAL_PP(args[1]);
-               case 1:
-                       convert_to_string_ex(args[0]);
-                       fmt = Z_STRVAL_PP(args[0]);
-       }
-
        switch (type) {
                case PHP_IBASE_TIMESTAMP:
                        if (IBG(timestampformat)) {
@@ -1183,13 +1167,13 @@
                        }
                        IBG(timeformat) = DL_STRDUP(fmt);
                        break;
+               default:
+                       RETURN_FALSE;
        }
 
-       efree(args);
        RETURN_TRUE;
 }
 /* }}} */
-#endif
 
 /* {{{ proto int ibase_gen_id(string generator [, int increment [, resource 
link_identifier ]])
    Increments the named generator and returns its new value */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to