lbarnaud                Tue Oct 21 22:07:30 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/iconv  iconv.c 
  Log:
  MFH: initialize optional vars
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.124.2.8.2.20.2.8&r2=1.124.2.8.2.20.2.9&diff_format=u
Index: php-src/ext/iconv/iconv.c
diff -u php-src/ext/iconv/iconv.c:1.124.2.8.2.20.2.8 
php-src/ext/iconv/iconv.c:1.124.2.8.2.20.2.9
--- php-src/ext/iconv/iconv.c:1.124.2.8.2.20.2.8        Tue Sep 23 15:18:26 2008
+++ php-src/ext/iconv/iconv.c   Tue Oct 21 22:07:30 2008
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: iconv.c,v 1.124.2.8.2.20.2.8 2008/09/23 15:18:26 nlopess Exp $ */
+/* $Id: iconv.c,v 1.124.2.8.2.20.2.9 2008/10/21 22:07:30 lbarnaud Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1873,7 +1873,7 @@
    Returns the character count of str */
 PHP_FUNCTION(iconv_strlen)
 {
-       char *charset;
+       char *charset = ICONVG(internal_encoding);
        int charset_len = 0;
        char *str;
        int str_len; 
@@ -1882,8 +1882,6 @@
 
        unsigned int retval;
 
-       charset = ICONVG(internal_encoding);
-
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s",
                &str, &str_len, &charset, &charset_len) == FAILURE) {
                RETURN_FALSE;
@@ -1908,18 +1906,16 @@
    Returns specified part of a string */
 PHP_FUNCTION(iconv_substr)
 {
-       char *charset;
+       char *charset = ICONVG(internal_encoding);
        int charset_len = 0;
        char *str;
        int str_len; 
-       long offset, length;
+       long offset, length = 0;
 
        php_iconv_err_t err;
 
        smart_str retval = {0};
 
-       charset = ICONVG(internal_encoding);
-
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|ls",
                &str, &str_len, &offset, &length,
                &charset, &charset_len) == FAILURE) {
@@ -1950,21 +1946,18 @@
    Finds position of first occurrence of needle within part of haystack 
beginning with offset */
 PHP_FUNCTION(iconv_strpos)
 {
-       char *charset;
+       char *charset = ICONVG(internal_encoding);
        int charset_len = 0;
        char *haystk;
        int haystk_len; 
        char *ndl;
        int ndl_len;
-       long offset;
+       long offset = 0;
 
        php_iconv_err_t err;
 
        unsigned int retval;
 
-       offset = 0;
-       charset = ICONVG(internal_encoding);
-
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|ls",
                &haystk, &haystk_len, &ndl, &ndl_len,
                &offset, &charset, &charset_len) == FAILURE) {
@@ -2001,7 +1994,7 @@
    Finds position of last occurrence of needle within part of haystack 
beginning with offset */
 PHP_FUNCTION(iconv_strrpos)
 {
-       char *charset;
+       char *charset = ICONVG(internal_encoding);
        int charset_len = 0;
        char *haystk;
        int haystk_len; 
@@ -2012,8 +2005,6 @@
 
        unsigned int retval;
 
-       charset = ICONVG(internal_encoding);
-
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|s",
                &haystk, &haystk_len, &ndl, &ndl_len,
                &charset, &charset_len) == FAILURE) {
@@ -2167,7 +2158,7 @@
 {
        char *encoded_str;
        int encoded_str_len;
-       char *charset;
+       char *charset = ICONVG(internal_encoding);
        int charset_len = 0;
        long mode = 0;
        
@@ -2175,8 +2166,6 @@
 
        php_iconv_err_t err;
 
-       charset = ICONVG(internal_encoding);
-
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls",
                &encoded_str, &encoded_str_len, &mode, &charset, &charset_len) 
== FAILURE) {
 
@@ -2210,14 +2199,12 @@
 {
        const char *encoded_str;
        int encoded_str_len;
-       char *charset;
+       char *charset = ICONVG(internal_encoding);
        int charset_len = 0;
        long mode = 0;
        
        php_iconv_err_t err = PHP_ICONV_ERR_SUCCESS;
 
-       charset = ICONVG(internal_encoding);
-
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls",
                &encoded_str, &encoded_str_len, &mode, &charset, &charset_len) 
== FAILURE) {
 
@@ -2422,7 +2409,7 @@
 PHP_FUNCTION(iconv_get_encoding)
 {
        char *type = "all";
-       int type_len;
+       int type_len = sizeof("all")-1;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &type, 
&type_len) == FAILURE)
                return;



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

Reply via email to