davidc          Fri Jun 20 20:54:32 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/standard       pack.c 
  Log:
  - New parsing parameter API cleanups
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/pack.c?r1=1.57.2.5.2.6.2.2&r2=1.57.2.5.2.6.2.3&diff_format=u
Index: php-src/ext/standard/pack.c
diff -u php-src/ext/standard/pack.c:1.57.2.5.2.6.2.2 
php-src/ext/standard/pack.c:1.57.2.5.2.6.2.3
--- php-src/ext/standard/pack.c:1.57.2.5.2.6.2.2        Fri Jun 20 14:53:57 2008
+++ php-src/ext/standard/pack.c Fri Jun 20 20:54:32 2008
@@ -15,7 +15,7 @@
    | Author: Chris Schneider <[EMAIL PROTECTED]>                          |
    +----------------------------------------------------------------------+
  */
-/* $Id: pack.c,v 1.57.2.5.2.6.2.2 2008/06/20 14:53:57 felipe Exp $ */
+/* $Id: pack.c,v 1.57.2.5.2.6.2.3 2008/06/20 20:54:32 davidc Exp $ */
 
 #include "php.h"
 
@@ -106,8 +106,8 @@
    Takes one or more arguments and packs them into a binary string according 
to the format argument */
 PHP_FUNCTION(pack)
 {
-       zval ***argv;
-       int argc, i;
+       zval ***argv = NULL;
+       int num_args, i;
        int currentarg;
        char *format;
        int formatlen;
@@ -117,20 +117,10 @@
        int outputpos = 0, outputsize = 0;
        char *output;
 
-       argc = ZEND_NUM_ARGS();
-
-       if (argc < 1) {
-               WRONG_PARAM_COUNT;
-       }
-
-       argv = safe_emalloc(argc, sizeof(zval **), 0);
-
-       if (zend_get_parameters_array_ex(argc, argv) == FAILURE) {
-               efree(argv);
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", &argv, 
&num_args) == FAILURE) {
+               return;
        }
 
-       convert_to_string_ex(argv[0]);
        format = Z_STRVAL_PP(argv[0]);
        formatlen = Z_STRLEN_PP(argv[0]);
 
@@ -178,7 +168,7 @@
                        case 'A': 
                        case 'h': 
                        case 'H':
-                               if (currentarg >= argc) {
+                               if (currentarg >= num_args) {
                                        efree(argv);
                                        efree(formatcodes);
                                        efree(formatargs);
@@ -210,12 +200,12 @@
                        case 'f': 
                        case 'd': 
                                if (arg < 0) {
-                                       arg = argc - currentarg;
+                                       arg = num_args - currentarg;
                                }
 
                                currentarg += arg;
 
-                               if (currentarg > argc) {
+                               if (currentarg > num_args) {
                                        efree(argv);
                                        efree(formatcodes);
                                        efree(formatargs);
@@ -236,8 +226,8 @@
                formatargs[formatcount] = arg;
        }
 
-       if (currentarg < argc) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d arguments 
unused", (argc - currentarg));
+       if (currentarg < num_args) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d arguments 
unused", (num_args - currentarg));
        }
 
        /* Calculate output length and upper bound while processing*/



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

Reply via email to