andrei          Wed Jul 12 17:04:14 2006 UTC

  Modified files:              
    /ZendEngine2        zend.c zend.h zend_vm_def.h zend_vm_execute.h 
    /php-src/main       main.c 
  Log:
  Commit Sara's patch for supporting filesystem enccoding in
  include/require.
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend.c?r1=1.363&r2=1.364&diff_format=u
Index: ZendEngine2/zend.c
diff -u ZendEngine2/zend.c:1.363 ZendEngine2/zend.c:1.364
--- ZendEngine2/zend.c:1.363    Wed Jun 28 14:13:13 2006
+++ ZendEngine2/zend.c  Wed Jul 12 17:04:12 2006
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend.c,v 1.363 2006/06/28 14:13:13 andrei Exp $ */
+/* $Id: zend.c,v 1.364 2006/07/12 17:04:12 andrei Exp $ */
 
 #include "zend.h"
 #include "zend_extensions.h"
@@ -55,6 +55,7 @@
 ZEND_API zend_class_entry *zend_standard_class_def = NULL;
 ZEND_API int (*zend_printf)(const char *format, ...);
 ZEND_API zend_write_func_t zend_write;
+ZEND_API int (*zend_path_encode)(char **encpath, int *encpath_len, const UChar 
*path, int path_len TSRMLS_DC);
 ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path);
 ZEND_API int (*zend_stream_open_function)(const char *filename, 
zend_file_handle *handle TSRMLS_DC);
 ZEND_API void (*zend_block_interruptions)(void);
@@ -607,6 +608,21 @@
        }
 }
 
+static int zend_path_encode_wrapper(char **encpath, int *encpath_len, const 
UChar *path, int path_len TSRMLS_DC)
+{
+       UErrorCode status = U_ZERO_ERROR;
+
+       
zend_convert_from_unicode(ZEND_U_CONVERTER(UG(filesystem_encoding_conv)), 
encpath, encpath_len, path, path_len, &status);
+
+       if (U_FAILURE(status)) {
+               efree(*encpath);
+               *encpath = NULL;
+               *encpath_len = 0;
+               return FAILURE;
+       }
+
+       return SUCCESS;
+}
 
 static FILE *zend_fopen_wrapper(const char *filename, char **opened_path)
 {
@@ -990,6 +1006,10 @@
        zend_error_cb = utility_functions->error_function;
        zend_printf = utility_functions->printf_function;
        zend_write = (zend_write_func_t) utility_functions->write_function;
+       zend_path_encode = utility_functions->path_encode_function;
+       if (!zend_path_encode) {
+               zend_path_encode = zend_path_encode_wrapper;
+       }
        zend_fopen = utility_functions->fopen_function;
        if (!zend_fopen) {
                zend_fopen = zend_fopen_wrapper;
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend.h?r1=1.323&r2=1.324&diff_format=u
Index: ZendEngine2/zend.h
diff -u ZendEngine2/zend.h:1.323 ZendEngine2/zend.h:1.324
--- ZendEngine2/zend.h:1.323    Mon Jun 12 17:06:39 2006
+++ ZendEngine2/zend.h  Wed Jul 12 17:04:13 2006
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend.h,v 1.323 2006/06/12 17:06:39 andrei Exp $ */
+/* $Id: zend.h,v 1.324 2006/07/12 17:04:13 andrei Exp $ */
 
 #ifndef ZEND_H
 #define ZEND_H
@@ -410,6 +410,7 @@
        void (*error_function)(int type, const char *error_filename, const uint 
error_lineno, const char *format, va_list args);
        int (*printf_function)(const char *format, ...);
        int (*write_function)(const char *str, uint str_length);
+       int (*path_encode_function)(char **encpath, int *encpath_len, const 
UChar *path, int path_len TSRMLS_DC);
        FILE *(*fopen_function)(const char *filename, char **opened_path);
        void (*message_handler)(long message, void *data);
        void (*block_interruptions)(void);
@@ -555,6 +556,7 @@
 BEGIN_EXTERN_C()
 extern ZEND_API int (*zend_printf)(const char *format, ...);
 extern ZEND_API zend_write_func_t zend_write;
+extern ZEND_API int (*zend_path_encode)(char **encpath, int *encpath_len, 
const UChar *path, int path_len TSRMLS_DC);
 extern ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path);
 extern ZEND_API void (*zend_block_interruptions)(void);
 extern ZEND_API void (*zend_unblock_interruptions)(void);
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_def.h?r1=1.122&r2=1.123&diff_format=u
Index: ZendEngine2/zend_vm_def.h
diff -u ZendEngine2/zend_vm_def.h:1.122 ZendEngine2/zend_vm_def.h:1.123
--- ZendEngine2/zend_vm_def.h:1.122     Tue Jul 11 08:52:44 2006
+++ ZendEngine2/zend_vm_def.h   Wed Jul 12 17:04:13 2006
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_vm_def.h,v 1.122 2006/07/11 08:52:44 dmitry Exp $ */
+/* $Id: zend_vm_def.h,v 1.123 2006/07/12 17:04:13 andrei Exp $ */
 
 /* If you change this file, please regenerate the zend_vm_execute.h and
  * zend_vm_opcodes.h files by running:
@@ -2761,7 +2761,19 @@
                        convert_to_unicode(&tmp_inc_filename);
                        inc_filename = &tmp_inc_filename;
                }
-       } else if (Z_TYPE_P(inc_filename)!=IS_STRING) {
+       } else if (Z_TYPE_P(inc_filename) == IS_UNICODE) {
+               char *encpath;
+               int encpath_len;
+
+               if (FAILURE == zend_path_encode(&encpath, &encpath_len, 
Z_USTRVAL_P(inc_filename), Z_USTRLEN_P(inc_filename) TSRMLS_CC)) {
+                       failure_retval = 0;
+                       zend_error(E_ERROR, "Failure converting '%R' to 
filesystem encoding", IS_UNICODE, Z_USTRVAL_P(inc_filename));
+                       goto skip_compile;
+               }
+
+               ZVAL_STRINGL(&tmp_inc_filename, encpath, encpath_len, 0);
+               inc_filename = &tmp_inc_filename;
+       } else if (Z_TYPE_P(inc_filename) != IS_STRING) {
                tmp_inc_filename = *inc_filename;
                zval_copy_ctor(&tmp_inc_filename);
                convert_to_string(&tmp_inc_filename);
@@ -2824,6 +2836,8 @@
                        break;
                EMPTY_SWITCH_DEFAULT_CASE()
        }
+
+skip_compile:
        if (inc_filename==&tmp_inc_filename) {
                zval_dtor(&tmp_inc_filename);
        }
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_execute.h?r1=1.126&r2=1.127&diff_format=u
Index: ZendEngine2/zend_vm_execute.h
diff -u ZendEngine2/zend_vm_execute.h:1.126 ZendEngine2/zend_vm_execute.h:1.127
--- ZendEngine2/zend_vm_execute.h:1.126 Tue Jul 11 08:52:44 2006
+++ ZendEngine2/zend_vm_execute.h       Wed Jul 12 17:04:13 2006
@@ -1870,7 +1870,19 @@
                        convert_to_unicode(&tmp_inc_filename);
                        inc_filename = &tmp_inc_filename;
                }
-       } else if (Z_TYPE_P(inc_filename)!=IS_STRING) {
+       } else if (Z_TYPE_P(inc_filename) == IS_UNICODE) {
+               char *encpath;
+               int encpath_len;
+
+               if (FAILURE == zend_path_encode(&encpath, &encpath_len, 
Z_USTRVAL_P(inc_filename), Z_USTRLEN_P(inc_filename) TSRMLS_CC)) {
+                       failure_retval = 0;
+                       zend_error(E_ERROR, "Failure converting '%R' to 
filesystem encoding", IS_UNICODE, Z_USTRVAL_P(inc_filename));
+                       goto skip_compile;
+               }
+
+               ZVAL_STRINGL(&tmp_inc_filename, encpath, encpath_len, 0);
+               inc_filename = &tmp_inc_filename;
+       } else if (Z_TYPE_P(inc_filename) != IS_STRING) {
                tmp_inc_filename = *inc_filename;
                zval_copy_ctor(&tmp_inc_filename);
                convert_to_string(&tmp_inc_filename);
@@ -1933,6 +1945,8 @@
                        break;
                EMPTY_SWITCH_DEFAULT_CASE()
        }
+
+skip_compile:
        if (inc_filename==&tmp_inc_filename) {
                zval_dtor(&tmp_inc_filename);
        }
@@ -4436,7 +4450,19 @@
                        convert_to_unicode(&tmp_inc_filename);
                        inc_filename = &tmp_inc_filename;
                }
-       } else if (Z_TYPE_P(inc_filename)!=IS_STRING) {
+       } else if (Z_TYPE_P(inc_filename) == IS_UNICODE) {
+               char *encpath;
+               int encpath_len;
+
+               if (FAILURE == zend_path_encode(&encpath, &encpath_len, 
Z_USTRVAL_P(inc_filename), Z_USTRLEN_P(inc_filename) TSRMLS_CC)) {
+                       failure_retval = 0;
+                       zend_error(E_ERROR, "Failure converting '%R' to 
filesystem encoding", IS_UNICODE, Z_USTRVAL_P(inc_filename));
+                       goto skip_compile;
+               }
+
+               ZVAL_STRINGL(&tmp_inc_filename, encpath, encpath_len, 0);
+               inc_filename = &tmp_inc_filename;
+       } else if (Z_TYPE_P(inc_filename) != IS_STRING) {
                tmp_inc_filename = *inc_filename;
                zval_copy_ctor(&tmp_inc_filename);
                convert_to_string(&tmp_inc_filename);
@@ -4499,6 +4525,8 @@
                        break;
                EMPTY_SWITCH_DEFAULT_CASE()
        }
+
+skip_compile:
        if (inc_filename==&tmp_inc_filename) {
                zval_dtor(&tmp_inc_filename);
        }
@@ -7599,7 +7627,19 @@
                        convert_to_unicode(&tmp_inc_filename);
                        inc_filename = &tmp_inc_filename;
                }
-       } else if (Z_TYPE_P(inc_filename)!=IS_STRING) {
+       } else if (Z_TYPE_P(inc_filename) == IS_UNICODE) {
+               char *encpath;
+               int encpath_len;
+
+               if (FAILURE == zend_path_encode(&encpath, &encpath_len, 
Z_USTRVAL_P(inc_filename), Z_USTRLEN_P(inc_filename) TSRMLS_CC)) {
+                       failure_retval = 0;
+                       zend_error(E_ERROR, "Failure converting '%R' to 
filesystem encoding", IS_UNICODE, Z_USTRVAL_P(inc_filename));
+                       goto skip_compile;
+               }
+
+               ZVAL_STRINGL(&tmp_inc_filename, encpath, encpath_len, 0);
+               inc_filename = &tmp_inc_filename;
+       } else if (Z_TYPE_P(inc_filename) != IS_STRING) {
                tmp_inc_filename = *inc_filename;
                zval_copy_ctor(&tmp_inc_filename);
                convert_to_string(&tmp_inc_filename);
@@ -7662,6 +7702,8 @@
                        break;
                EMPTY_SWITCH_DEFAULT_CASE()
        }
+
+skip_compile:
        if (inc_filename==&tmp_inc_filename) {
                zval_dtor(&tmp_inc_filename);
        }
@@ -20358,7 +20400,19 @@
                        convert_to_unicode(&tmp_inc_filename);
                        inc_filename = &tmp_inc_filename;
                }
-       } else if (Z_TYPE_P(inc_filename)!=IS_STRING) {
+       } else if (Z_TYPE_P(inc_filename) == IS_UNICODE) {
+               char *encpath;
+               int encpath_len;
+
+               if (FAILURE == zend_path_encode(&encpath, &encpath_len, 
Z_USTRVAL_P(inc_filename), Z_USTRLEN_P(inc_filename) TSRMLS_CC)) {
+                       failure_retval = 0;
+                       zend_error(E_ERROR, "Failure converting '%R' to 
filesystem encoding", IS_UNICODE, Z_USTRVAL_P(inc_filename));
+                       goto skip_compile;
+               }
+
+               ZVAL_STRINGL(&tmp_inc_filename, encpath, encpath_len, 0);
+               inc_filename = &tmp_inc_filename;
+       } else if (Z_TYPE_P(inc_filename) != IS_STRING) {
                tmp_inc_filename = *inc_filename;
                zval_copy_ctor(&tmp_inc_filename);
                convert_to_string(&tmp_inc_filename);
@@ -20421,6 +20475,8 @@
                        break;
                EMPTY_SWITCH_DEFAULT_CASE()
        }
+
+skip_compile:
        if (inc_filename==&tmp_inc_filename) {
                zval_dtor(&tmp_inc_filename);
        }
http://cvs.php.net/viewvc.cgi/php-src/main/main.c?r1=1.694&r2=1.695&diff_format=u
Index: php-src/main/main.c
diff -u php-src/main/main.c:1.694 php-src/main/main.c:1.695
--- php-src/main/main.c:1.694   Sat Jun  3 11:19:44 2006
+++ php-src/main/main.c Wed Jul 12 17:04:13 2006
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: main.c,v 1.694 2006/06/03 11:19:44 mike Exp $ */
+/* $Id: main.c,v 1.695 2006/07/12 17:04:13 andrei Exp $ */
 
 /* {{{ includes
  */
@@ -974,6 +974,14 @@
 }
 /* }}} */
 
+/* {{{ php_path_encode_for_zend
+ */
+static int php_path_encode_for_zend(char **encpath, int *encpath_len, const 
UChar *path, int path_len TSRMLS_DC)
+{
+       return php_stream_path_encode(NULL, encpath, encpath_len, path, 
path_len, 0, NULL);
+}
+/* }}} */
+
 /* {{{ php_fopen_wrapper_for_zend
  */
 static FILE *php_fopen_wrapper_for_zend(const char *filename, char 
**opened_path)
@@ -1522,6 +1530,7 @@
        zuf.error_function = php_error_cb;
        zuf.printf_function = php_printf;
        zuf.write_function = php_output_wrapper;
+       zuf.path_encode_function = php_path_encode_for_zend;
        zuf.fopen_function = php_fopen_wrapper_for_zend;
        zuf.message_handler = php_message_handler_for_zend;
        zuf.block_interruptions = sapi_module.block_interruptions;

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

Reply via email to