]> granicus.if.org Git - php/commitdiff
Fixed get_debug_info
authorXinchen Hui <laruence@php.net>
Sat, 28 Jun 2014 15:30:46 +0000 (23:30 +0800)
committerXinchen Hui <laruence@php.net>
Sat, 28 Jun 2014 15:30:46 +0000 (23:30 +0800)
ext/intl/breakiterator/breakiterator_class.cpp
ext/intl/calendar/calendar_class.cpp
ext/intl/timezone/timezone_class.cpp

index 73d4b7550fb5e4b28d006e101a741ce74d9dcd0b..ecaf503565aea765df49e2ba616e1c7571531856 100644 (file)
@@ -135,34 +135,39 @@ static zend_object *BreakIterator_clone_obj(zval *object TSRMLS_DC)
 /* {{{ get_debug_info handler for BreakIterator */
 static HashTable *BreakIterator_get_debug_info(zval *object, int *is_temp TSRMLS_DC)
 {
-       zval                                    zv;
+       zval val;
+       HashTable *debug_info;
        BreakIterator_object    *bio;
        const BreakIterator             *biter;
 
        *is_temp = 1;
 
-       array_init_size(&zv, 8);
+       ALLOC_HASHTABLE(debug_info);
+       zend_hash_init(debug_info, 8, NULL, ZVAL_PTR_DTOR, 0);
 
        bio  = Z_INTL_BREAKITERATOR_P(object);
        biter = bio->biter;
 
        if (biter == NULL) {
-               add_assoc_bool_ex(&zv, "valid", sizeof("valid") - 1, 0);
-               return Z_ARRVAL(zv);
+               ZVAL_FALSE(&val);
+               zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &val);
+               return debug_info;
        }
-       add_assoc_bool_ex(&zv, "valid", sizeof("valid") - 1, 1);
+       ZVAL_TRUE(&val);
+       zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &val);
 
        if (Z_ISUNDEF(bio->text)) {
-               add_assoc_null_ex(&zv, "text", sizeof("text") - 1);
+               ZVAL_NULL(&val);
+               zend_hash_str_update(debug_info, "text", sizeof("text") - 1, &val);
        } else {
                Z_TRY_ADDREF(bio->text);
-               add_assoc_zval_ex(&zv, "text", sizeof("text") - 1, &bio->text);
+               zend_hash_str_update(debug_info, "text", sizeof("text") - 1, &bio->text);
        }
 
-       add_assoc_string_ex(&zv, "type", sizeof("type") - 1,
-                       const_cast<char*>(typeid(*biter).name()));
+       ZVAL_STRING(&val, const_cast<char*>(typeid(*biter).name()));
+       zend_hash_str_update(debug_info, "type", sizeof("type") - 1, &bio->text);
 
-       return Z_ARRVAL(zv);
+       return debug_info;
 }
 /* }}} */
 
index e5d1ecd70586a3ee3ac1db8097734aa5db00abfd..a62ad7b9d9e822e9c457109705ea2450001773de 100644 (file)
@@ -150,47 +150,53 @@ static HashTable *Calendar_get_debug_info(zval *object, int *is_temp TSRMLS_DC)
                                        zfields;
        Calendar_object *co;
        const Calendar  *cal;
+       HashTable               *debug_info;
        
        *is_temp = 1;
 
-       array_init_size(&zv, 8);
+       ALLOC_HASHTABLE(debug_info);
+       zend_hash_init(debug_info, 8, NULL, ZVAL_PTR_DTOR, 0);
 
        co  = Z_INTL_CALENDAR_P(object);
        cal = co->ucal;
 
        if (cal == NULL) {
-               add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 0);
-               return Z_ARRVAL(zv);
+               ZVAL_FALSE(&zv);
+               zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &zv);
+               return debug_info;
        }
+       ZVAL_TRUE(&zv);
+       zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &zv);
 
-       add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 1);
-
-       add_assoc_string_ex(&zv, "type", sizeof("type"),
-               const_cast<char*>(cal->getType()));
-
+       ZVAL_STRING(&zv, const_cast<char*>(cal->getType()));
+       zend_hash_str_update(debug_info, "type", sizeof("type") - 1, &zv);
        {
                zval               ztz,
                                           ztz_debug;
                int                        is_tmp;
-               HashTable          *debug_info;
+               HashTable          *debug_info_tz;
 
                timezone_object_construct(&cal->getTimeZone(), &ztz , 0 TSRMLS_CC);
                debug_info = Z_OBJ_HANDLER(ztz, get_debug_info)(&ztz, &is_tmp TSRMLS_CC);
                assert(is_tmp == 1);
 
-               zend_hash_copy(Z_ARRVAL(ztz_debug), debug_info, NULL);
-               add_assoc_zval_ex(&zv, "timeZone", sizeof("timeZone") - 1, &ztz_debug);
+               array_init(&ztz_debug);
+               zend_hash_copy(Z_ARRVAL(ztz_debug), debug_info_tz, zval_add_ref);
+               zend_hash_destroy(debug_info_tz);
+               FREE_HASHTABLE(debug_info_tz);
+
+               zend_hash_str_update(debug_info, "timeZone", sizeof("timeZone") - 1, &ztz_debug);
        }
 
        {
                UErrorCode      uec             = U_ZERO_ERROR;
                Locale          locale  = cal->getLocale(ULOC_VALID_LOCALE, uec);
                if (U_SUCCESS(uec)) {
-                       add_assoc_string_ex(&zv, "locale", sizeof("locale") - 1,
-                               const_cast<char*>(locale.getName()));
+                       ZVAL_STRING(&zv, const_cast<char*>(locale.getName()));
+                       zend_hash_str_update(debug_info, "locale", sizeof("locale") - 1, &zv);
                } else {
-                       add_assoc_string_ex(&zv, "locale", sizeof("locale") - 1,
-                               const_cast<char*>(u_errorName(uec)));
+                       ZVAL_STRING(&zv, const_cast<char*>(u_errorName(uec)));
+                       zend_hash_str_update(debug_info, "locale", sizeof("locale") - 1, &zv);
                }
        }
 
@@ -209,9 +215,9 @@ static HashTable *Calendar_get_debug_info(zval *object, int *is_temp TSRMLS_DC)
                }
        }
 
-       add_assoc_zval_ex(&zv, "fields", sizeof("fields") - 1, &zfields);
+       zend_hash_str_update(debug_info, "fields", sizeof("fields") - 1, &zfields);
 
-       return Z_ARRVAL(zv);
+       return debug_info;
 }
 /* }}} */
 
index 585c0ce48a38691c93f5d5c73721001e8a70417d..be30c2d541fb26d53b50f9d5a414136a8efc418a 100644 (file)
@@ -293,44 +293,50 @@ static HashTable *TimeZone_get_debug_info(zval *object, int *is_temp TSRMLS_DC)
        UnicodeString   ustr;
        char                    *str;
        int                             str_len;
+       HashTable               *debug_info;
        UErrorCode              uec = U_ZERO_ERROR;
 
        *is_temp = 1;
        
-       array_init_size(&zv, 4);
+       ALLOC_HASHTABLE(debug_info);
+       zend_hash_init(debug_info, 8, NULL, ZVAL_PTR_DTOR, 0);
 
        to = Z_INTL_TIMEZONE_P(object);
        tz = to->utimezone;
 
        if (tz == NULL) {
-               add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 0);
-               return Z_ARRVAL(zv);
+               ZVAL_FALSE(&zv);
+               zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &zv);
+               return debug_info;
        }
 
-       add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 1);
+       ZVAL_TRUE(&zv);
+       zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &zv);
 
        tz->getID(ustr);
        intl_convert_utf16_to_utf8(&str, &str_len,
                ustr.getBuffer(), ustr.length(), &uec);
        if (U_FAILURE(uec)) {
-               return Z_ARRVAL(zv);
+               return debug_info;
        }
+       ZVAL_STRINGL(&zv, str, str_len);
+       zend_hash_str_update(debug_info, "id", sizeof("id") - 1, &zv);
        // TODO: avoid reallocation ???
-       add_assoc_stringl_ex(&zv, "id", sizeof("id"), str, str_len);
        efree(str);
 
        int32_t rawOffset, dstOffset;
        UDate now = Calendar::getNow();
        tz->getOffset(now, FALSE, rawOffset, dstOffset, uec);
        if (U_FAILURE(uec)) {
-               return Z_ARRVAL(zv);
+               return debug_info;
        }
        
-       add_assoc_long_ex(&zv, "rawOffset", sizeof("rawOffset"), (long)rawOffset);
-       add_assoc_long_ex(&zv, "currentOffset", sizeof("currentOffset"),
-               (long)(rawOffset + dstOffset));
+       ZVAL_LONG(&zv, (long)rawOffset);
+       zend_hash_str_update(debug_info,"rawOffset", sizeof("rawOffset") - 1, &zv); 
+       ZVAL_LONG(&zv, (long)(rawOffset + dstOffset));
+       zend_hash_str_update(debug_info,"currentOffset", sizeof("currentOffset") - 1, &zv); 
 
-       return Z_ARRVAL(zv);
+       return debug_info;
 }
 /* }}} */