[PHP-CVS] svn: /php/php-src/trunk/ext/date/ php_date.c php_date.h
derick Sat, 10 Apr 2010 20:33:41 + Revision: http://svn.php.net/viewvc?view=revision&revision=297814 Log: - Expose date-extension object creation externally. - Expose DateTime object initialisation externally. Changed paths: U php/php-src/trunk/ext/date/php_date.c U php/php-src/trunk/ext/date/php_date.h Modified: php/php-src/trunk/ext/date/php_date.c === --- php/php-src/trunk/ext/date/php_date.c 2010-04-10 19:43:42 UTC (rev 297813) +++ php/php-src/trunk/ext/date/php_date.c 2010-04-10 20:33:41 UTC (rev 297814) @@ -475,7 +475,6 @@ static char* guess_timezone(const timelib_tzdb *tzdb TSRMLS_DC); static void date_register_classes(TSRMLS_D); -static zval * date_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC); /* }}} */ ZEND_DECLARE_MODULE_GLOBALS(date) @@ -1846,7 +1845,7 @@ /* Create new object */ MAKE_STD_ZVAL(iterator->current); - date_instantiate(date_ce_date, iterator->current TSRMLS_CC); + php_date_instantiate(date_ce_date, iterator->current TSRMLS_CC); newdateobj = (php_date_obj *) zend_object_store_get_object(iterator->current TSRMLS_CC); newdateobj->time = timelib_time_ctor(); *newdateobj->time = *it_time; @@ -2339,7 +2338,7 @@ } /* Advanced Interface */ -static zval * date_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC) +PHPAPI zval *php_date_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC) { Z_TYPE_P(object) = IS_OBJECT; object_init_ex(object, pce); @@ -2359,7 +2358,7 @@ DATEG(last_errors) = last_errors; } -static int date_initialize(php_date_obj *dateobj, /*const*/ char *time_str, int time_str_len, char *format, zval *timezone_object, int ctor TSRMLS_DC) +PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str, int time_str_len, char *format, zval *timezone_object, int ctor TSRMLS_DC) { timelib_time *now; timelib_tzinfo *tzi; @@ -2454,8 +2453,8 @@ RETURN_FALSE; } - date_instantiate(date_ce_date, return_value TSRMLS_CC); - if (!date_initialize(zend_object_store_get_object(return_value TSRMLS_CC), time_str, time_str_len, NULL, timezone_object, 0 TSRMLS_CC)) { + php_date_instantiate(date_ce_date, return_value TSRMLS_CC); + if (!php_date_initialize(zend_object_store_get_object(return_value TSRMLS_CC), time_str, time_str_len, NULL, timezone_object, 0 TSRMLS_CC)) { RETURN_FALSE; } } @@ -2474,8 +2473,8 @@ RETURN_FALSE; } - date_instantiate(date_ce_date, return_value TSRMLS_CC); - if (!date_initialize(zend_object_store_get_object(return_value TSRMLS_CC), time_str, time_str_len, format_str, timezone_object, 0 TSRMLS_CC)) { + php_date_instantiate(date_ce_date, return_value TSRMLS_CC); + if (!php_date_initialize(zend_object_store_get_object(return_value TSRMLS_CC), time_str, time_str_len, format_str, timezone_object, 0 TSRMLS_CC)) { RETURN_FALSE; } } @@ -2493,7 +2492,7 @@ zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC); if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO", &time_str, &time_str_len, &timezone_object, date_ce_timezone)) { - date_initialize(zend_object_store_get_object(getThis() TSRMLS_CC), time_str, time_str_len, NULL, timezone_object, 1 TSRMLS_CC); + php_date_initialize(zend_object_store_get_object(getThis() TSRMLS_CC), time_str, time_str_len, NULL, timezone_object, 1 TSRMLS_CC); } zend_restore_error_handling(&error_handling TSRMLS_CC); } @@ -2520,7 +2519,7 @@ case TIMELIB_ZONETYPE_ABBR: { char *tmp = emalloc(Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 2); snprintf(tmp, Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 2, "%s %s", Z_STRVAL_PP(z_date), Z_STRVAL_PP(z_timezone)); - date_initialize(*dateobj, tmp, Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 1, NULL, NULL, 0 TSRMLS_CC); + php_date_initialize(*dateobj, tmp, Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 1, NULL, NULL, 0 TSRMLS_CC); efree(tmp); return 1; } @@ -2531,12 +2530,12 @@ tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC); ALLOC_INIT_ZVAL(tmp_obj); - tzobj = zend_object_store_get_object(date_instantiate(date_ce_timezone, tmp_obj TSRMLS_CC) T
[PHP-CVS] svn: /php/php-src/trunk/ext/date/ php_date.c php_date.h
derick Wed, 18 Nov 2009 13:24:41 + Revision: http://svn.php.net/viewvc?view=revision&revision=290912 Log: - Fixed the setting of cookies. Changed paths: U php/php-src/trunk/ext/date/php_date.c U php/php-src/trunk/ext/date/php_date.h Modified: php/php-src/trunk/ext/date/php_date.c === --- php/php-src/trunk/ext/date/php_date.c 2009-11-18 13:22:00 UTC (rev 290911) +++ php/php-src/trunk/ext/date/php_date.c 2009-11-18 13:24:41 UTC (rev 290912) @@ -1095,7 +1095,7 @@ #define am_pm_lower_full(s,l) l ? loc_dat->am_pm_name[s] : am_pm_lower_names[s] #define am_pm_upper_full(s,l) l ? loc_dat->am_pm_name[s] : am_pm_upper_names[s] -static char *date_format(char *format, int format_len, int *return_len, timelib_time *t, int localtime, int localized TSRMLS_DC) +static UChar *date_format(char *format, int format_len, int *return_len, timelib_time *t, int localtime, int localized TSRMLS_DC) { smart_strstring = {0}; int i, no_free, length; @@ -1107,7 +1107,7 @@ if (!format_len) { *return_len = 0; - return (char*)eustrdup(EMPTY_STR); + return eustrdup(EMPTY_STR); } loc_dat = date_get_locale_data(UG(default_locale)); @@ -1257,7 +1257,7 @@ } *return_len = string.len / 2; - return string.c; + return (UChar*) string.c; } static void php_date(INTERNAL_FUNCTION_PARAMETERS, int localtime) @@ -1265,7 +1265,7 @@ char *format; int format_len; longts; - char *string; + UChar *string; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &format, &format_len, &ts) == FAILURE) { RETURN_FALSE; @@ -1276,15 +1276,15 @@ string = php_format_date(format, format_len, ts, localtime TSRMLS_CC); - RETVAL_UNICODE((UChar*)string, 0); + RETVAL_UNICODE(string, 0); } /* }}} */ -PHPAPI char *php_format_date(char *format, int format_len, time_t ts, int localtime TSRMLS_DC) /* {{{ */ +PHPAPI UChar *php_format_date(char *format, int format_len, time_t ts, int localtime TSRMLS_DC) /* {{{ */ { timelib_time *t; timelib_tzinfo *tzi; - char *string; + UChar *string; int return_len; t = timelib_time_ctor(); @@ -2181,7 +2181,7 @@ HashTable*props; zval *zv; php_date_obj *dateobj; - char *str; + UChar*str; int return_len; dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); @@ -2195,7 +2195,7 @@ /* first we add the date and time in ISO format */ str = date_format("Y-m-d H:i:s", 12, &return_len, dateobj->time, 1, 0 TSRMLS_CC); MAKE_STD_ZVAL(zv); - ZVAL_UNICODEL(zv, (UChar*) str, return_len - 1, 0); + ZVAL_UNICODEL(zv, str, return_len - 1, 0); zend_hash_update(props, "date", 5, &zv, sizeof(zval), NULL); /* then we add the timezone name (or similar) */ @@ -2841,7 +2841,8 @@ { zval *object; php_date_obj *dateobj; - char *format, *str; + char *format; + UChar*str; int format_len, length; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, date_ce_date, &format, &format_len) == FAILURE) { @@ -2850,7 +2851,7 @@ dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); DATE_CHECK_INITIALIZED(dateobj->time, DateTime); str = date_format(format, format_len, &length, dateobj->time, dateobj->time->is_localtime, 0 TSRMLS_CC); - RETURN_UNICODEL((UChar*) str, length, 0); + RETURN_UNICODEL(str, length, 0); } /* }}} */ @@ -2860,7 +2861,8 @@ { zval *object; php_date_obj *dateobj; - char *format, *str; + char *format; + UChar*str; int format_len, length; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, date_ce_date, &format, &format_len) == FAILURE) { @@ -2869,7 +2871,7 @@ dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); str = date_format(format, format_len, &length, dateobj->time, dateobj->time->is_localtime, 1 TSRMLS_CC); - RETURN_UNICODEL((UChar*)str, length, 0); + RETURN_UNICODEL(str, length, 0); } /* }}} */ @@ -2883,6 +2885,7 @@ char *modify; int modify_len; timelib_time *tmp_time; + struct timelib_error_container *error; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, date_ce_date, &modify, &modify_len) == FAILURE) { RETURN_FALSE; @@ -2890,7 +2893,17 @@ dateobj =