]> granicus.if.org Git - php/commitdiff
Unicode support
authorDmitry Stogov <dmitry@php.net>
Tue, 23 Aug 2005 12:53:31 +0000 (12:53 +0000)
committerDmitry Stogov <dmitry@php.net>
Tue, 23 Aug 2005 12:53:31 +0000 (12:53 +0000)
16 files changed:
Zend/zend_API.c
Zend/zend_API.h
Zend/zend_builtin_functions.c
Zend/zend_exceptions.c
ext/reflection/tests/parameters_001.phpt
ext/standard/dir.c
ext/standard/dns.c
ext/standard/filestat.c
ext/standard/info.c
ext/standard/link.c
ext/standard/string.c
ext/standard/tests/file/userdirstream.phpt
ext/standard/tests/strings/bug24098.phpt
ext/standard/type.c
ext/standard/uniqid.c
unicode-progress.txt

index f4ea75918f07dbc33bd04dd8cde10ac1aaf5bc7f..1eb64bc3d273af3c03030fbb82c5634262e5af95 100644 (file)
@@ -1711,6 +1711,66 @@ ZEND_API int add_property_stringl_ex(zval *arg, char *key, uint key_len, char *s
        return SUCCESS;
 }
 
+ZEND_API int add_property_ascii_string_ex(zval *arg, char *key, uint key_len, char *str, int duplicate TSRMLS_DC)
+{
+       zval *tmp;
+       zval z_key;
+
+       MAKE_STD_ZVAL(tmp);
+       ZVAL_ASCII_STRING(tmp, str, duplicate);
+
+       ZVAL_STRINGL(&z_key, key, key_len-1, 0);
+
+       Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, tmp TSRMLS_CC);
+       zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
+       return SUCCESS;
+}
+
+ZEND_API int add_property_ascii_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, int duplicate TSRMLS_DC)
+{
+       zval *tmp;
+       zval z_key;
+
+       MAKE_STD_ZVAL(tmp);
+       ZVAL_ASCII_STRINGL(tmp, str, length, duplicate);
+
+       ZVAL_STRINGL(&z_key, key, key_len-1, 0);
+
+       Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, tmp TSRMLS_CC);
+       zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
+       return SUCCESS;
+}
+
+ZEND_API int add_property_rt_string_ex(zval *arg, char *key, uint key_len, char *str, int duplicate TSRMLS_DC)
+{
+       zval *tmp;
+       zval z_key;
+
+       MAKE_STD_ZVAL(tmp);
+       ZVAL_RT_STRING(tmp, str, duplicate);
+
+       ZVAL_STRINGL(&z_key, key, key_len-1, 0);
+
+       Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, tmp TSRMLS_CC);
+       zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
+       return SUCCESS;
+}
+
+ZEND_API int add_property_rt_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, int duplicate TSRMLS_DC)
+{
+       zval *tmp;
+       zval z_key;
+
+       MAKE_STD_ZVAL(tmp);
+       ZVAL_RT_STRINGL(tmp, str, length, duplicate);
+
+       ZVAL_STRINGL(&z_key, key, key_len-1, 0);
+
+       Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, tmp TSRMLS_CC);
+       zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
+       return SUCCESS;
+}
+
 ZEND_API int add_property_zval_ex(zval *arg, char *key, uint key_len, zval *value TSRMLS_DC)
 {
        zval z_key;
@@ -2937,6 +2997,50 @@ ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object
        zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);
 }
 
+ZEND_API void zend_update_property_ascii_string(zend_class_entry *scope, zval *object, char *name, int name_length, char *value TSRMLS_DC)
+{
+       zval *tmp;
+       
+       ALLOC_ZVAL(tmp);
+       tmp->is_ref = 0;
+       tmp->refcount = 0;
+       ZVAL_ASCII_STRING(tmp, value, 1);
+       zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);
+}
+
+ZEND_API void zend_update_property_ascii_stringl(zend_class_entry *scope, zval *object, char *name, int name_length, char *value, int value_len TSRMLS_DC)
+{
+       zval *tmp;
+       
+       ALLOC_ZVAL(tmp);
+       tmp->is_ref = 0;
+       tmp->refcount = 0;
+       ZVAL_ASCII_STRINGL(tmp, value, value_len, 1);
+       zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);
+}
+
+ZEND_API void zend_update_property_rt_string(zend_class_entry *scope, zval *object, char *name, int name_length, char *value TSRMLS_DC)
+{
+       zval *tmp;
+       
+       ALLOC_ZVAL(tmp);
+       tmp->is_ref = 0;
+       tmp->refcount = 0;
+       ZVAL_RT_STRING(tmp, value, 1);
+       zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);
+}
+
+ZEND_API void zend_update_property_rt_stringl(zend_class_entry *scope, zval *object, char *name, int name_length, char *value, int value_len TSRMLS_DC)
+{
+       zval *tmp;
+       
+       ALLOC_ZVAL(tmp);
+       tmp->is_ref = 0;
+       tmp->refcount = 0;
+       ZVAL_RT_STRINGL(tmp, value, value_len, 1);
+       zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);
+}
+
 ZEND_API void zend_update_property_unicode(zend_class_entry *scope, zval *object, char *name, int name_length, UChar *value TSRMLS_DC)
 {
        zval *tmp;
index 7514df4f038b8d3909c47ffdaa030fd5e35fa6b1..f1190c5b23c1e72d483ce9a74f8af4a2031b712b 100644 (file)
@@ -228,6 +228,10 @@ ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, c
 ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, char *name, int name_length, double value TSRMLS_DC);
 ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, char *name, int name_length, char *value TSRMLS_DC);
 ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, char *name, int name_length, char *value, int value_length TSRMLS_DC);
+ZEND_API void zend_update_property_ascii_string(zend_class_entry *scope, zval *object, char *name, int name_length, char *value TSRMLS_DC);
+ZEND_API void zend_update_property_ascii_stringl(zend_class_entry *scope, zval *object, char *name, int name_length, char *value, int value_length TSRMLS_DC);
+ZEND_API void zend_update_property_rt_string(zend_class_entry *scope, zval *object, char *name, int name_length, char *value TSRMLS_DC);
+ZEND_API void zend_update_property_rt_stringl(zend_class_entry *scope, zval *object, char *name, int name_length, char *value, int value_length TSRMLS_DC);
 ZEND_API void zend_update_property_unicode(zend_class_entry *scope, zval *object, char *name, int name_length, UChar *value TSRMLS_DC);
 ZEND_API void zend_update_property_unicodel(zend_class_entry *scope, zval *object, char *name, int name_length, UChar *value, int value_length TSRMLS_DC);
 
@@ -306,6 +310,29 @@ ZEND_API int add_assoc_zval_ex(zval *arg, char *key, uint key_len, zval *value);
                add_assoc_stringl_ex(arg, key, key_len, (char*)(str), length, duplicate); \
        }
 
+#define add_assoc_rt_string_ex(arg, key, key_len, str, duplicate) \
+       if (UG(unicode)) { \
+    UErrorCode status = U_ZERO_ERROR; \
+               UChar *u_str; \
+               int32_t u_len; \
+               int length = strlen(str); \
+               zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u_str, &u_len, str, length, &status); \
+               add_assoc_unicodel_ex(arg, key, key_len, u_str, u_len, 0); \
+       } else { \
+               add_assoc_string_ex(arg, key, key_len, (char*)(str), duplicate); \
+       }
+
+#define add_assoc_rt_stringl_ex(arg, key, key_len, str, length, duplicate) \
+       if (UG(unicode)) { \
+    UErrorCode status = U_ZERO_ERROR; \
+               UChar *u_str; \
+               int32_t u_len; \
+               zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u_str, &u_len, str, length, &status); \
+               add_assoc_unicodel_ex(arg, key, key_len, u_str, u_len, 0); \
+       } else { \
+               add_assoc_stringl_ex(arg, key, key_len, (char*)(str), length, duplicate); \
+       }
+
 #define add_assoc_long(__arg, __key, __n) add_assoc_long_ex(__arg, __key, strlen(__key)+1, __n)
 #define add_assoc_null(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key) + 1)
 #define add_assoc_bool(__arg, __key, __b) add_assoc_bool_ex(__arg, __key, strlen(__key)+1, __b)
@@ -316,6 +343,8 @@ ZEND_API int add_assoc_zval_ex(zval *arg, char *key, uint key_len, zval *value);
 #define add_assoc_unicode(__arg, __key, __str, __duplicate) add_assoc_unicode_ex(__arg, __key, strlen(__key)+1, __str, __duplicate)
 #define add_assoc_unicodel(__arg, __key, __str, __length, __duplicate) add_assoc_unicodel_ex(__arg, __key, strlen(__key)+1, __str, __length, __duplicate)
 #define add_assoc_zval(__arg, __key, __value) add_assoc_zval_ex(__arg, __key, strlen(__key)+1, __value)
+#define add_assoc_rt_string(__arg, __key, __str, __duplicate) add_assoc_rt_string_ex(__arg, __key, strlen(__key)+1, __str, __duplicate)
+#define add_assoc_rt_stringl(__arg, __key, __str, __length, __duplicate) add_assoc_rt_stringl_ex(__arg, __key, strlen(__key)+1, __str, __length, __duplicate)
 
 #define add_assoc_text(arg, key, str, duplicate) \
        if (UG(unicode)) { \
@@ -446,6 +475,29 @@ ZEND_API int add_next_index_zval(zval *arg, zval *value);
                add_next_index_stringl(arg, (char*)(str), length, duplicate); \
        }
 
+#define add_next_index_rt_string(arg, str, duplicate) \
+       if (UG(unicode)) { \
+    UErrorCode status = U_ZERO_ERROR; \
+               UChar *u_str; \
+               int32_t u_len; \
+               int length = strlen(str); \
+               zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u_str, &u_len, str, length, &status); \
+               add_next_index_unicodel(arg, u_str, u_len, 0); \
+       } else { \
+               add_next_index_string(arg, (char*)(str), duplicate); \
+       }
+
+#define add_next_index_rt_stringl(arg, str, length, duplicate) \
+       if (UG(unicode)) { \
+    UErrorCode status = U_ZERO_ERROR; \
+               UChar *u_str; \
+               int32_t u_len; \
+               zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u_str, &u_len, str, length, &status); \
+               add_next_index_unicodel(arg, u_str, u_len, 0); \
+       } else { \
+               add_next_index_stringl(arg, (char*)(str), length, duplicate); \
+       }
+
 ZEND_API int add_get_assoc_string_ex(zval *arg, char *key, uint key_len, char *str, void **dest, int duplicate);
 ZEND_API int add_get_assoc_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, void **dest, int duplicate);
 
@@ -469,6 +521,10 @@ ZEND_API int add_property_double_ex(zval *arg, char *key, uint key_len, double d
 ZEND_API int add_property_string_ex(zval *arg, char *key, uint key_len, char *str, int duplicate TSRMLS_DC);
 ZEND_API int add_property_stringl_ex(zval *arg, char *key, uint key_len,  char *str, uint length, int duplicate TSRMLS_DC);
 ZEND_API int add_property_zval_ex(zval *arg, char *key, uint key_len, zval *value TSRMLS_DC);
+ZEND_API int add_property_ascii_string_ex(zval *arg, char *key, uint key_len, char *str, int duplicate TSRMLS_DC);
+ZEND_API int add_property_ascii_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, int duplicate TSRMLS_DC);
+ZEND_API int add_property_rt_string_ex(zval *arg, char *key, uint key_len, char *str, int duplicate TSRMLS_DC);
+ZEND_API int add_property_rt_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, int duplicate TSRMLS_DC);
 
 #define add_property_long(__arg, __key, __n) add_property_long_ex(__arg, __key, strlen(__key)+1, __n TSRMLS_CC)
 #define add_property_null(__arg, __key) add_property_null_ex(__arg, __key, strlen(__key) + 1 TSRMLS_CC)
@@ -477,6 +533,10 @@ ZEND_API int add_property_zval_ex(zval *arg, char *key, uint key_len, zval *valu
 #define add_property_double(__arg, __key, __d) add_property_double_ex(__arg, __key, strlen(__key)+1, __d TSRMLS_CC) 
 #define add_property_string(__arg, __key, __str, __duplicate) add_property_string_ex(__arg, __key, strlen(__key)+1, __str, __duplicate TSRMLS_CC)
 #define add_property_stringl(__arg, __key, __str, __length, __duplicate) add_property_stringl_ex(__arg, __key, strlen(__key)+1, __str, __length, __duplicate TSRMLS_CC)
+#define add_property_ascii_string(__arg, __key, __str, __duplicate) add_property_string_ex(__arg, __key, strlen(__key)+1, __str, __duplicate TSRMLS_CC)
+#define add_property_ascii_stringl(__arg, __key, __str, __length, __duplicate) add_property_stringl_ex(__arg, __key, strlen(__key)+1, __str, __length, __duplicate TSRMLS_CC)
+#define add_property_rt_string(__arg, __key, __str, __duplicate) add_property_ascii_string_ex(__arg, __key, strlen(__key)+1, __str, __duplicate TSRMLS_CC)
+#define add_property_rt_stringl(__arg, __key, __str, __length, __duplicate) add_property_rt_stringl_ex(__arg, __key, strlen(__key)+1, __str, __length, __duplicate TSRMLS_CC)
 #define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key)+1, __value TSRMLS_CC)       
 
 
index 41dbada57a006350fa44973013a71d5ebe2e5339..936dc5de119558f2e8cde1d9de90b8188f9621d4 100644 (file)
@@ -1158,8 +1158,8 @@ ZEND_FUNCTION(get_included_files)
 
        array_init(return_value);
        zend_hash_internal_pointer_reset(&EG(included_files));
-       while (zend_hash_get_current_key(&EG(included_files), &entry, NULL, 1) == HASH_KEY_IS_STRING) {
-               add_next_index_string(return_value, entry, 0);
+       while (zend_hash_get_current_key(&EG(included_files), &entry, NULL, 0) == HASH_KEY_IS_STRING) {
+               add_next_index_rt_string(return_value, entry, 1);
                zend_hash_move_forward(&EG(included_files));
        }
 }
@@ -1979,7 +1979,7 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last TSRML
                if (skip->op_array) {
                        filename = skip->op_array->filename;
                        lineno = skip->opline->lineno;
-                       add_assoc_string_ex(stack_frame, "file", sizeof("file"), filename, 1);
+                       add_assoc_rt_string_ex(stack_frame, "file", sizeof("file"), filename, 1);
                        add_assoc_long_ex(stack_frame, "line", sizeof("line"), lineno);
 
                        /* try to fetch args only if an FCALL was just made - elsewise we're in the middle of a function
@@ -2060,7 +2060,7 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last TSRML
                                   if we have called include in the frame above - this is the file we have included.
                                 */
 
-                               add_next_index_string(arg_array, include_filename, 1);
+                               add_next_index_rt_string(arg_array, include_filename, 1);
                                add_assoc_zval_ex(stack_frame, "args", sizeof("args"), arg_array);
                        }
 
index da2d0d85dd20195237cc3111608cfb1f0e1ac644..2659687db99614bce55d76a4ff11069537395b2f 100644 (file)
@@ -94,7 +94,7 @@ static zend_object_value zend_default_exception_new_ex(zend_class_entry *class_t
        trace->refcount = 0;
        zend_fetch_debug_backtrace(trace, skip_top_traces TSRMLS_CC);
 
-       zend_update_property_string(U_CLASS_ENTRY(default_exception_ce), &obj, "file", sizeof("file")-1, zend_get_executed_filename(TSRMLS_C) TSRMLS_CC);
+       zend_update_property_rt_string(U_CLASS_ENTRY(default_exception_ce), &obj, "file", sizeof("file")-1, zend_get_executed_filename(TSRMLS_C) TSRMLS_CC);
        zend_update_property_long(U_CLASS_ENTRY(default_exception_ce), &obj, "line", sizeof("line")-1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC);
        zend_update_property(U_CLASS_ENTRY(default_exception_ce), &obj, "trace", sizeof("trace")-1, trace TSRMLS_CC);
 
@@ -141,6 +141,14 @@ ZEND_METHOD(exception, __construct)
        if (message) {
                if (message_type == IS_UNICODE) {
                        zend_update_property_unicodel(U_CLASS_ENTRY(default_exception_ce), object, "message", sizeof("message")-1, message, message_len TSRMLS_CC);
+               } else if (UG(unicode)) {
+           UErrorCode status = U_ZERO_ERROR;
+                       UChar *u_str;
+                       int32_t u_len;
+                       
+                       zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u_str, &u_len, message, message_len, &status);
+                       zend_update_property_unicodel(U_CLASS_ENTRY(default_exception_ce), object, "message", sizeof("message")-1, u_str, u_len TSRMLS_CC);
+                       efree(u_str);
                } else {
                        zend_update_property_stringl(U_CLASS_ENTRY(default_exception_ce), object, "message", sizeof("message")-1, message, message_len TSRMLS_CC);
                }
@@ -172,6 +180,14 @@ ZEND_METHOD(error_exception, __construct)
        if (message) {
                if (message_type == IS_UNICODE) {
                        zend_update_property_unicodel(U_CLASS_ENTRY(default_exception_ce), object, "message", sizeof("message")-1, message, message_len TSRMLS_CC);
+               } else if (UG(unicode)) {
+           UErrorCode status = U_ZERO_ERROR;
+                       UChar *u_str;
+                       int32_t u_len;
+                       
+                       zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u_str, &u_len, message, message_len, &status);
+                       zend_update_property_unicodel(U_CLASS_ENTRY(default_exception_ce), object, "message", sizeof("message")-1, u_str, u_len TSRMLS_CC);
+                       efree(u_str);
                } else {
                        zend_update_property_stringl(U_CLASS_ENTRY(default_exception_ce), object, "message", sizeof("message")-1, message, message_len TSRMLS_CC);
                }
@@ -286,12 +302,23 @@ ZEND_METHOD(error_exception, getSeverity)
 
 #define TRACE_APPEND_STRL(val, vallen)                                   \
        {                                                                    \
-           int l = vallen;                                                  \
+               int l = vallen;                                                  \
                *str = (char*)erealloc(*str, *len + l + 1);                      \
                memcpy((*str) + *len, val, l);                                   \
                *len += l;                                                       \
        }
 
+#define TRACE_APPEND_ZVAL(zv) \
+       if (Z_TYPE_P((zv)) == IS_UNICODE) { \
+               zval copy; \
+               int use_copy; \
+               zend_make_printable_zval((zv), &copy, &use_copy); \
+    TRACE_APPEND_STRL(Z_STRVAL(copy), Z_STRLEN(copy)); \
+    zval_dtor(&copy); \
+       } else { \
+               TRACE_APPEND_STRL(Z_STRVAL_P((zv)), Z_STRLEN_P((zv))); \
+       }
+
 #define TRACE_APPEND_STR(val)                                            \
        TRACE_APPEND_STRL(val, sizeof(val)-1)
 
@@ -436,8 +463,9 @@ static int _build_trace_string(zval **frame, int num_args, va_list args, zend_ha
                } else {
                        line = 0;
                }
-               s_tmp = emalloc(Z_STRLEN_PP(file) + MAX_LENGTH_OF_LONG + 2 + 1);
-               sprintf(s_tmp, "%s(%ld): ", Z_STRVAL_PP(file), line);
+               TRACE_APPEND_ZVAL(*file);
+               s_tmp = emalloc(MAX_LENGTH_OF_LONG + 2 + 1);
+               sprintf(s_tmp, "(%ld): ", line);
                TRACE_APPEND_STRL(s_tmp, strlen(s_tmp));
                efree(s_tmp);
        } else {
@@ -646,7 +674,7 @@ ZEND_API zval * zend_throw_exception(zend_class_entry *exception_ce, char *messa
        
 
        if (message) {
-               zend_update_property_string(U_CLASS_ENTRY(default_exception_ce), ex, "message", sizeof("message")-1, message TSRMLS_CC);
+               zend_update_property_rt_string(U_CLASS_ENTRY(default_exception_ce), ex, "message", sizeof("message")-1, message TSRMLS_CC);
        }
        if (code) {
                zend_update_property_long(U_CLASS_ENTRY(default_exception_ce), ex, "code", sizeof("code")-1, code TSRMLS_CC);
@@ -723,7 +751,15 @@ ZEND_API void zend_exception_error(zval *exception TSRMLS_DC)
                file = zend_read_property(U_CLASS_ENTRY(default_exception_ce), exception, "file", sizeof("file")-1, 1 TSRMLS_CC);
                line = zend_read_property(U_CLASS_ENTRY(default_exception_ce), exception, "line", sizeof("line")-1, 1 TSRMLS_CC);
 
-               zend_error_va(E_ERROR, Z_STRVAL_P(file), Z_LVAL_P(line), "Uncaught %R\n  thrown", Z_TYPE_P(str), Z_UNIVAL_P(str));
+               if (Z_TYPE_P(file) == IS_UNICODE) {
+                       zval copy;
+                       int use_copy;
+                       zend_make_printable_zval(file, &copy, &use_copy);
+                       zend_error_va(E_ERROR, Z_STRVAL(copy), Z_LVAL_P(line), "Uncaught %R\n  thrown", Z_TYPE_P(str), Z_UNIVAL_P(str));
+                       zval_dtor(&copy);
+               } else {
+                       zend_error_va(E_ERROR, Z_STRVAL_P(file), Z_LVAL_P(line), "Uncaught %R\n  thrown", Z_TYPE_P(str), Z_UNIVAL_P(str));
+               }
        } else {
                zend_error(E_ERROR, "Uncaught exception '%v'", ce_exception->name);
        }
index 709944677f1b28532cca8679f0b19638ac79adf9..3e0cff13e749a48eee0ae8b2c1dab800f9ebd691 100755 (executable)
@@ -36,3 +36,10 @@ bool(false)
 bool(true)
 string(54) "The parameter specified by its name could not be found"
 ===DONE===
+--UEXPECT--
+int(2)
+int(1)
+bool(false)
+bool(true)
+unicode(54) "The parameter specified by its name could not be found"
+===DONE===
index cc452b5a6201d36f86993605dc462e3152c6d4ee..f250f82e2e69e8ef676685c26d38a98768d685cc 100644 (file)
@@ -201,8 +201,8 @@ static void _php_do_opendir(INTERNAL_FUNCTION_PARAMETERS, int createobject)
        php_set_default_dir(dirp->rsrc_id TSRMLS_CC);
 
        if (createobject) {
-               object_init_ex(return_value, dir_class_entry_ptr);
-               add_property_stringl(return_value, "path", dirname, dir_len, 1);
+               object_init_ex(return_value, U_CLASS_ENTRY(dir_class_entry_ptr));
+               add_property_rt_stringl(return_value, "path", dirname, dir_len, 1);
                add_property_resource(return_value, "handle", dirp->rsrc_id);
                php_stream_auto_cleanup(dirp); /* so we don't get warnings under debug */
        } else {
@@ -318,7 +318,7 @@ PHP_FUNCTION(getcwd)
 #endif
 
        if (ret) {
-               RETURN_STRING(path, 1);
+               RETURN_RT_STRING(path, 1);
        } else {
                RETURN_FALSE;
        }
@@ -349,7 +349,7 @@ PHP_NAMED_FUNCTION(php_if_readdir)
        FETCH_DIRP();
 
        if (php_stream_readdir(dirp, &entry)) {
-               RETURN_STRINGL(entry.d_name, strlen(entry.d_name), 1);
+               RETURN_RT_STRINGL(entry.d_name, strlen(entry.d_name), 1);
        }
        RETURN_FALSE;
 }
@@ -450,7 +450,7 @@ PHP_FUNCTION(glob)
                                continue;
                        }
                }
-               add_next_index_string(return_value, globbuf.gl_pathv[n]+cwd_skip, 1);
+               add_next_index_rt_string(return_value, globbuf.gl_pathv[n]+cwd_skip, 1);
        }
 
        globfree(&globbuf);
@@ -491,7 +491,10 @@ PHP_FUNCTION(scandir)
        array_init(return_value);
 
        for (i = 0; i < n; i++) {
-               add_next_index_string(return_value, namelist[i], 0);
+               add_next_index_rt_string(return_value, namelist[i], 0);
+               if (UG(unicode)) {
+                       efree(namelist[i]);
+               }
        }
 
        if (n) {
index 7e631ff926f70aa545e5aaa624c93b3fa2c289a5..e0de17992a4dac54645e7b508051913b84c412e0 100644 (file)
@@ -142,7 +142,10 @@ PHP_FUNCTION(gethostbyaddr)
 #endif
                RETVAL_FALSE;
        } else {
-               RETVAL_STRING(addr, 0);
+               RETVAL_RT_STRING(addr, 0);
+               if (UG(unicode)) {
+                       efree(addr);
+               }
        }
 }
 /* }}} */
@@ -187,6 +190,7 @@ static char *php_gethostbyaddr(char *ip)
 PHP_FUNCTION(gethostbyname)
 {
        zval **arg;
+       char *tmp;
        
        if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) {
                ZEND_WRONG_PARAM_COUNT();
@@ -194,7 +198,11 @@ PHP_FUNCTION(gethostbyname)
 
        convert_to_string_ex(arg);
 
-       RETVAL_STRING(php_gethostbyname(Z_STRVAL_PP(arg)), 0);
+       tmp = php_gethostbyname(Z_STRVAL_PP(arg));
+       RETVAL_RT_STRING(tmp, 0);
+       if (UG(unicode)) {
+               efree(tmp);
+       }
 }
 /* }}} */
 
@@ -221,7 +229,7 @@ PHP_FUNCTION(gethostbynamel)
 
        for (i = 0 ; hp->h_addr_list[i] != 0 ; i++) {
                in = *(struct in_addr *) hp->h_addr_list[i];
-               add_next_index_string(return_value, inet_ntoa(in), 1);
+               add_next_index_rt_string(return_value, inet_ntoa(in), 1);
        }
 }
 /* }}} */
index 3d628c70425b65391995fcc0141fa2715736ceae..124ccbef5ea8193d5dfcb81bd591e6a3bd8a1b2d 100644 (file)
@@ -658,20 +658,20 @@ PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int typ
 #endif
        case FS_TYPE:
                if (S_ISLNK(ssb.sb.st_mode)) {
-                       RETURN_STRING("link", 1);
+                       RETURN_ASCII_STRING("link", 1);
                }
                switch(ssb.sb.st_mode & S_IFMT) {
-               case S_IFIFO: RETURN_STRING("fifo", 1);
-               case S_IFCHR: RETURN_STRING("char", 1);
-               case S_IFDIR: RETURN_STRING("dir", 1);
-               case S_IFBLK: RETURN_STRING("block", 1);
-               case S_IFREG: RETURN_STRING("file", 1);
+               case S_IFIFO: RETURN_ASCII_STRING("fifo", 1);
+               case S_IFCHR: RETURN_ASCII_STRING("char", 1);
+               case S_IFDIR: RETURN_ASCII_STRING("dir", 1);
+               case S_IFBLK: RETURN_ASCII_STRING("block", 1);
+               case S_IFREG: RETURN_ASCII_STRING("file", 1);
 #if defined(S_IFSOCK) && !defined(ZEND_WIN32)&&!defined(__BEOS__)
-               case S_IFSOCK: RETURN_STRING("socket", 1);
+               case S_IFSOCK: RETURN_ASCII_STRING("socket", 1);
 #endif
                }
                php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unknown file type (%d)", ssb.sb.st_mode&S_IFMT);
-               RETURN_STRING("unknown", 1);
+               RETURN_ASCII_STRING("unknown", 1);
        case FS_IS_W:
                RETURN_BOOL((ssb.sb.st_mode & wmask) != 0);
        case FS_IS_R:
index 00726debaf34824e027e8be9a992de2d14aa5b36..521fd6e1117cbb64c31dc54da7cbae2401084616 100644 (file)
@@ -1011,7 +1011,7 @@ PHP_FUNCTION(phpversion)
        int argc = ZEND_NUM_ARGS();
 
        if (argc == 0) {
-               RETURN_STRING(PHP_VERSION, 1);
+               RETURN_ASCII_STRING(PHP_VERSION, 1);
        } else if (argc == 1 && zend_get_parameters_ex(1, &arg) == SUCCESS) {
                char *version;
                convert_to_string_ex(arg);
@@ -1019,7 +1019,7 @@ PHP_FUNCTION(phpversion)
                if (version == NULL) {
                        RETURN_FALSE;
                }
-               RETURN_STRING(version, 1);
+               RETURN_ASCII_STRING(version, 1);
        } else {
                WRONG_PARAM_COUNT;
        }
@@ -1079,7 +1079,7 @@ PHP_FUNCTION(php_logo_guid)
                WRONG_PARAM_COUNT;
        }
 
-       RETURN_STRING(php_logo_guid(), 0);
+       RETURN_ASCII_STRING(php_logo_guid(), 0);
 }
 /* }}} */
 
@@ -1092,7 +1092,7 @@ PHP_FUNCTION(php_real_logo_guid)
                WRONG_PARAM_COUNT;
        }
 
-       RETURN_STRINGL(PHP_LOGO_GUID, sizeof(PHP_LOGO_GUID)-1, 1);
+       RETURN_ASCII_STRINGL(PHP_LOGO_GUID, sizeof(PHP_LOGO_GUID)-1, 1);
 }
 /* }}} */
 
@@ -1104,7 +1104,7 @@ PHP_FUNCTION(php_egg_logo_guid)
                WRONG_PARAM_COUNT;
        }
 
-       RETURN_STRINGL(PHP_EGG_LOGO_GUID, sizeof(PHP_EGG_LOGO_GUID)-1, 1);
+       RETURN_ASCII_STRINGL(PHP_EGG_LOGO_GUID, sizeof(PHP_EGG_LOGO_GUID)-1, 1);
 }
 /* }}} */
 
@@ -1116,7 +1116,7 @@ PHP_FUNCTION(zend_logo_guid)
                WRONG_PARAM_COUNT;
        }
 
-       RETURN_STRINGL(ZEND_LOGO_GUID, sizeof(ZEND_LOGO_GUID)-1, 1);
+       RETURN_ASCII_STRINGL(ZEND_LOGO_GUID, sizeof(ZEND_LOGO_GUID)-1, 1);
 }
 /* }}} */
 
@@ -1129,7 +1129,7 @@ PHP_FUNCTION(php_sapi_name)
        }
 
        if (sapi_module.name) {
-               RETURN_STRING(sapi_module.name, 1);
+               RETURN_ASCII_STRING(sapi_module.name, 1);
        } else {
                RETURN_FALSE;
        }
@@ -1143,10 +1143,16 @@ PHP_FUNCTION(php_uname)
 {
        char *mode = "a";
        int modelen;
+       char *tmp;
+
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &mode, &modelen) == FAILURE) {
                return;
        }
-       RETURN_STRING(php_get_uname(*mode), 0);
+       tmp = php_get_uname(*mode);
+       RETVAL_RT_STRING(tmp, 0);
+       if (UG(unicode)) {
+               efree(tmp);
+       }
 }
 
 /* }}} */
@@ -1156,7 +1162,7 @@ PHP_FUNCTION(php_uname)
 PHP_FUNCTION(php_ini_scanned_files)
 {
        if (strlen(PHP_CONFIG_FILE_SCAN_DIR) && php_ini_scanned_files) {
-               RETURN_STRING(php_ini_scanned_files, 1);
+               RETURN_RT_STRING(php_ini_scanned_files, 1);
        } else {
                RETURN_FALSE;
        }
index 3297537d044d3f1194cf1471d33ba6b17c3056c0..c790372f09657afb8aaee35ea087cebe2be50646 100644 (file)
@@ -80,7 +80,7 @@ PHP_FUNCTION(readlink)
        /* Append NULL to the end of the string */
        buff[ret] = '\0';
 
-       RETURN_STRING(buff, 1);
+       RETURN_RT_STRING(buff, 1);
 }
 /* }}} */
 
index eaf37fd20728f129e3d2e738c2a5f205ee6ac856..8aecbccc1dc96bce94dc81b40aaca708339ad246 100644 (file)
@@ -1761,14 +1761,17 @@ PHP_FUNCTION(pathinfo)
                ret = estrndup(path, path_len);
                php_dirname(ret, path_len);
                if (*ret) {
-                       add_assoc_string(tmp, "dirname", ret, 1);
+                       add_assoc_rt_string(tmp, "dirname", ret, 1);
                }
                efree(ret);
        }
        
        if ((opt & PHP_PATHINFO_BASENAME) == PHP_PATHINFO_BASENAME) {
                php_basename(path, path_len, NULL, 0, &ret, &ret_len TSRMLS_CC);
-               add_assoc_stringl(tmp, "basename", ret, ret_len, 0);
+               add_assoc_rt_stringl(tmp, "basename", ret, ret_len, 0);
+               if (UG(unicode)) {
+                       efree(ret);
+               }
        }                       
        
        if ((opt & PHP_PATHINFO_EXTENSION) == PHP_PATHINFO_EXTENSION) {
@@ -1785,7 +1788,7 @@ PHP_FUNCTION(pathinfo)
 
                if (p) {
                        idx = p - ret;
-                       add_assoc_stringl(tmp, "extension", ret + idx + 1, ret_len - idx - 1, 1);
+                       add_assoc_rt_stringl(tmp, "extension", ret + idx + 1, ret_len - idx - 1, 1);
                }
 
                if (!have_basename) {
index d457b1988d38ec4645db181e0e5fbc10e16847e0..f857b3c82f1f49dc23baa91569cac871c19a452a 100644 (file)
@@ -49,4 +49,16 @@ array(4) {
   [3]=>
   string(5) "third"
 }
-
+--UEXPECT--
+Opening
+Closing up!
+array(4) {
+  [0]=>
+  unicode(5) "first"
+  [1]=>
+  unicode(6) "fourth"
+  [2]=>
+  unicode(6) "second"
+  [3]=>
+  unicode(5) "third"
+}
index 9ff51a420fd5f4e8d3e85291e141c38d25cf7f71..967da1545008b1e30fc8f61ed1dcdc39b3eb1de6 100644 (file)
@@ -15,3 +15,12 @@ array(3) {
   ["extension"]=>
   string(3) "asa"
 }
+--UEXPECT--
+array(3) {
+  [u"dirname"]=>
+  unicode(1) "/"
+  [u"basename"]=>
+  unicode(8) "dsds.asa"
+  [u"extension"]=>
+  unicode(3) "asa"
+}
index 161ce7f5f007200a61176bd30cfb93c0d7189586..a98d9cf1d694e249c91f635b59b885c26d60a47a 100644 (file)
@@ -33,39 +33,39 @@ PHP_FUNCTION(gettype)
 
        switch (Z_TYPE_PP(arg)) {
                case IS_NULL:
-                       RETVAL_STRING("NULL", 1);
+                       RETVAL_ASCII_STRING("NULL", 1);
                        break;
 
                case IS_BOOL:
-                       RETVAL_STRING("boolean", 1);
+                       RETVAL_ASCII_STRING("boolean", 1);
                        break;
 
                case IS_LONG:
-                       RETVAL_STRING("integer", 1);
+                       RETVAL_ASCII_STRING("integer", 1);
                        break;
 
                case IS_DOUBLE:
-                       RETVAL_STRING("double", 1);
+                       RETVAL_ASCII_STRING("double", 1);
                        break;
        
                case IS_STRING:
-                       RETVAL_STRING("string", 1);
+                       RETVAL_ASCII_STRING("string", 1);
                        break;
        
                case IS_BINARY:
-                       RETVAL_STRING("binary", 1);
+                       RETVAL_ASCII_STRING("binary", 1);
                        break;
 
                case IS_UNICODE:
-                       RETVAL_STRING("unicode", 1);
+                       RETVAL_ASCII_STRING("unicode", 1);
                        break;
 
                case IS_ARRAY:
-                       RETVAL_STRING("array", 1);
+                       RETVAL_ASCII_STRING("array", 1);
                        break;
 
                case IS_OBJECT:
-                       RETVAL_STRING("object", 1);
+                       RETVAL_ASCII_STRING("object", 1);
                /*
                   {
                   char *result;
@@ -84,13 +84,13 @@ PHP_FUNCTION(gettype)
                                char *type_name;
                                type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(arg) TSRMLS_CC);
                                if (type_name) {
-                                       RETVAL_STRING("resource", 1);
+                                       RETVAL_ASCII_STRING("resource", 1);
                                        break;
                                }
                        }
 
                default:
-                       RETVAL_STRING("unknown type", 1);
+                       RETVAL_ASCII_STRING("unknown type", 1);
        }
 }
 /* }}} */
@@ -368,6 +368,15 @@ PHP_FUNCTION(is_numeric)
                        }
                        break;
 
+               case IS_UNICODE:
+                       result = is_numeric_unicode(Z_USTRVAL_PP(arg), Z_USTRLEN_PP(arg), NULL, NULL, 0);
+                       if (result == IS_LONG || result == IS_DOUBLE) {
+                               RETURN_TRUE;
+                       } else {
+                               RETURN_FALSE;
+                       }
+                       break;
+
                default:
                        RETURN_FALSE;
                        break;
index d4f9fe75b37cd2302aef1f8e75deb09a83f95d51..9d692387032ececea739a8c652465c910a366168 100644 (file)
@@ -81,7 +81,7 @@ PHP_FUNCTION(uniqid)
                spprintf(&uniqid, 0, "%s%08x%05x", prefix, sec, usec);
        }
 
-       RETURN_STRING(uniqid, 0);
+       RETURN_RT_STRING(uniqid, 0);
 }
 #endif
 /* }}} */
index a85649fd7dae2f8793550b00e12d50ae0015ea18..9bbd5b5e48b4885291036e00439db0726a5cde06 100644 (file)
@@ -22,9 +22,6 @@ ZE
 --
   Status: In Progress
         debug_backtrace()
-        extension_loaded()
-        get_extension_funcs()
-        get_included_files()
   Completed:
         class_exists()
         create_function()
@@ -33,6 +30,7 @@ ZE
         defined()
         each()
         error_reporting()
+        extension_loaded()
         func_get_arg()
         func_get_args()
         func_num_args()
@@ -45,6 +43,8 @@ ZE
         get_defined_constants()
         get_defined_functions()
         get_defined_vars()
+        get_extension_funcs()
+        get_included_files()
         get_loaded_extensions()
         get_object_vars()
         get_parent_class()