pollita         Sat Mar 25 04:37:44 2006 UTC

  Modified files:              
    /php-src/main/streams       streams.c 
  Log:
  Handle converter instantiation errors properly
  
http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.111&r2=1.112&diff_format=u
Index: php-src/main/streams/streams.c
diff -u php-src/main/streams/streams.c:1.111 
php-src/main/streams/streams.c:1.112
--- php-src/main/streams/streams.c:1.111        Fri Mar 24 20:21:48 2006
+++ php-src/main/streams/streams.c      Sat Mar 25 04:37:44 2006
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: streams.c,v 1.111 2006/03/24 20:21:48 pollita Exp $ */
+/* $Id: streams.c,v 1.112 2006/03/25 04:37:44 pollita Exp $ */
 
 #define _GNU_SOURCE
 #include "php.h"
@@ -2277,45 +2277,47 @@
                        UErrorCode status = U_ZERO_ERROR;
 
                        stream->output_encoding = ucnv_open(encoding, &status);
-                       switch (U_FAILURE(status)) {
-                               case U_ZERO_ERROR:
-                                       /* UTODO: (Maybe?) Allow overriding the 
default error handlers on a per-stream basis via context params */
-                                       
zend_set_converter_error_mode(stream->output_encoding, UG(from_u_error_mode));
-                                       
zend_set_converter_subst_char(stream->output_encoding, UG(subst_char), 
UG(subst_char_len));
-                                       break;
-                               case U_MEMORY_ALLOCATION_ERROR:
-                                       php_stream_wrapper_log_error(wrapper, 
options ^ REPORT_ERRORS TSRMLS_CC,
-                                               "Unable to allocate memory for 
unicode output converter: %s", encoding);
-                                       break;
-                               case U_FILE_ACCESS_ERROR:
-                                       php_stream_wrapper_log_error(wrapper, 
options ^ REPORT_ERRORS TSRMLS_CC,
-                                               "Error loading unicode output 
converter: %s", encoding);
-                                       break;
-                               default:
-                                       php_stream_wrapper_log_error(wrapper, 
options ^ REPORT_ERRORS TSRMLS_CC,
-                                               "Unknown error starting unicode 
output converter: %s", encoding);
+                       if (U_FAILURE(status)) {
+                               switch (status) {
+                                       case U_MEMORY_ALLOCATION_ERROR:
+                                               
php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC,
+                                                       "Unable to allocate 
memory for unicode output converter: %s", encoding);
+                                               break;
+                                       case U_FILE_ACCESS_ERROR:
+                                               
php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC,
+                                                       "Error loading unicode 
output converter: %s", encoding);
+                                               break;
+                                       default:
+                                               
php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC,
+                                                       "Unknown error starting 
unicode output converter: %s", encoding);
+                               }
+                       } else {
+                               /* UTODO: (Maybe?) Allow overriding the default 
error handlers on a per-stream basis via context params */
+                               
zend_set_converter_error_mode(stream->output_encoding, UG(from_u_error_mode));
+                               
zend_set_converter_subst_char(stream->output_encoding, UG(subst_char), 
UG(subst_char_len));
                        }
                }
                if (strchr(implicit_mode, 'r') || strchr(implicit_mode, '+')) {
                        char *encoding = (context && context->input_encoding) ? 
context->input_encoding : "utf8";
                        UErrorCode status = U_ZERO_ERROR;
+
                        stream->input_encoding = ucnv_open(encoding, &status);
-                       switch (U_FAILURE(status)) {
-                               case U_ZERO_ERROR:
-                                       /* UTODO: If/When Input error handling 
gets implemented, set the options here */
-                                       break;
-                               case U_MEMORY_ALLOCATION_ERROR:
-                                       php_stream_wrapper_log_error(wrapper, 
options ^ REPORT_ERRORS TSRMLS_CC,
-                                               "Unable to allocate memory for 
unicode input converter: %s", encoding);
-                                       break;
-                               case U_FILE_ACCESS_ERROR:
-                                       php_stream_wrapper_log_error(wrapper, 
options ^ REPORT_ERRORS TSRMLS_CC,
-                                               "Error loading unicode input 
converter: %s", encoding);
-                                       break;
-                               default:
-                                       php_stream_wrapper_log_error(wrapper, 
options ^ REPORT_ERRORS TSRMLS_CC,
-                                               "Unknown error starting unicode 
input converter: %s", encoding);
+                       if (U_FAILURE(status)) {
+                               switch (status) {
+                                       case U_MEMORY_ALLOCATION_ERROR:
+                                               
php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC,
+                                                       "Unable to allocate 
memory for unicode input converter: %s", encoding);
+                                               break;
+                                       case U_FILE_ACCESS_ERROR:
+                                               
php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC,
+                                                       "Error loading unicode 
input converter: %s", encoding);
+                                               break;
+                                       default:
+                                               
php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC,
+                                                       "Unknown error starting 
unicode input converter: %s", encoding);
+                               }
                        }
+                       /* UTODO: If/When Input error handling gets 
implemented, set the options on success */
                }
        }
 



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

Reply via email to