moriyoshi               Wed Nov  6 11:54:18 2002 EDT

  Modified files:              
    /php4/ext/iconv     iconv.c 
  Log:
  Clean up
  
  
Index: php4/ext/iconv/iconv.c
diff -u php4/ext/iconv/iconv.c:1.62 php4/ext/iconv/iconv.c:1.63
--- php4/ext/iconv/iconv.c:1.62 Wed Nov  6 11:29:16 2002
+++ php4/ext/iconv/iconv.c      Wed Nov  6 11:54:18 2002
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: iconv.c,v 1.62 2002/11/06 16:29:16 moriyoshi Exp $ */
+/* $Id: iconv.c,v 1.63 2002/11/06 16:54:18 moriyoshi Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -197,7 +197,8 @@
        size_t result;
        typedef unsigned int ucs4_t;
 
-       in_size = in_len;
+       *out = NULL;
+       *out_len = 0;
 
        /*
          This is not the right way to get output size...
@@ -208,17 +209,16 @@
        */
        out_size = in_len * sizeof(ucs4_t) + 15;
        out_left = out_size;
-       
+
+       in_size = in_len;
+
        cd = icv_open(out_charset, in_charset);
        
        if (cd == (iconv_t)(-1)) {
-               *out = NULL;
-               *out_len = 0;
                return PHP_ICONV_ERR_UNKNOWN;
        }
 
        out_buffer = (char *) emalloc(out_size + 1);
-       *out = out_buffer;
        out_p = out_buffer;
        
        result = icv(cd, (const char **) &in_p, &in_size, (char **)
@@ -226,15 +226,15 @@
        
        if (result == (size_t)(-1)) {
                efree(out_buffer);
-               *out = NULL;
-               *out_len = 0;
                return PHP_ICONV_ERR_UNKNOWN;
        }
        
        *out_len = out_size - out_left;
        out_buffer[*out_len] = '\0';
+       *out = out_buffer;
+
        icv_close(cd);
-       
+
        return PHP_ICONV_ERR_SUCCESS;
 
 #else
@@ -247,14 +247,15 @@
        size_t bsz, result = 0;
        php_iconv_err_t retval = PHP_ICONV_ERR_SUCCESS;
 
+       *out = NULL;
+       *out_len = 0;
+
        cd = icv_open(out_charset, in_charset);
 
        if (cd == (iconv_t)(-1)) {
                if (errno == EINVAL) {
-                       *out = NULL;
                        return PHP_ICONV_ERR_WRONG_CHARSET;
                } else {
-                       *out = NULL;
                        return PHP_ICONV_ERR_CONVERTER;
                }
        }
@@ -305,8 +306,6 @@
                                /* other error */
                                retval = PHP_ICONV_ERR_UNKNOWN;
                                efree(out_buf);
-                               *out = NULL;
-                               *out_len = 0;
                                return PHP_ICONV_ERR_UNKNOWN;
                }
        }



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

Reply via email to