Skip to content

Commit a4685d8

Browse files
committed
ext/date: Add const qualifiers
1 parent c67e12e commit a4685d8

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

ext/date/php_date.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ static const char *php_date_short_day_name(timelib_sll y, timelib_sll m, timelib
673673
/* }}} */
674674

675675
/* {{{ date_format - (gm)date helper */
676-
static zend_string *date_format(const char *format, size_t format_len, timelib_time *t, bool localtime)
676+
static zend_string *date_format(const char *format, size_t format_len, const timelib_time *t, bool localtime)
677677
{
678678
smart_str string = {0};
679679
size_t i;
@@ -845,7 +845,7 @@ static zend_string *date_format(const char *format, size_t format_len, timelib_t
845845
return string.s;
846846
}
847847

848-
PHPAPI zend_string *php_format_date_obj(const char *format, size_t format_len, php_date_obj *date_obj)
848+
PHPAPI zend_string *php_format_date_obj(const char *format, size_t format_len, const php_date_obj *date_obj)
849849
{
850850
if (!date_obj->time) {
851851
return NULL;
@@ -2807,7 +2807,7 @@ PHP_METHOD(DateTimeImmutable, createFromTimestamp)
28072807
}
28082808
/* }}} */
28092809

2810-
static bool php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht)
2810+
static bool php_date_initialize_from_hash(php_date_obj **dateobj, const HashTable *myht)
28112811
{
28122812
zval *z_date;
28132813
zval *z_timezone_type;
@@ -2948,7 +2948,7 @@ PHP_METHOD(DateTimeImmutable, __serialize)
29482948
}
29492949
/* }}} */
29502950

2951-
static bool date_time_is_internal_property(zend_string *name)
2951+
static bool date_time_is_internal_property(const zend_string *name)
29522952
{
29532953
if (
29542954
zend_string_equals_literal(name, "date") ||
@@ -2960,7 +2960,7 @@ static bool date_time_is_internal_property(zend_string *name)
29602960
return 0;
29612961
}
29622962

2963-
static void restore_custom_datetime_properties(zval *object, HashTable *myht)
2963+
static void restore_custom_datetime_properties(zval *object, const HashTable *myht)
29642964
{
29652965
zend_string *prop_name;
29662966
zval *prop_val;
@@ -3023,7 +3023,7 @@ static void php_do_date_time_wakeup(INTERNAL_FUNCTION_PARAMETERS, const char *cl
30233023
{
30243024
zval *object = ZEND_THIS;
30253025
php_date_obj *dateobj;
3026-
HashTable *myht;
3026+
const HashTable *myht;
30273027

30283028
ZEND_PARSE_PARAMETERS_NONE();
30293029

@@ -3053,7 +3053,7 @@ PHP_METHOD(DateTimeImmutable, __wakeup)
30533053
/* }}} */
30543054

30553055
/* Helper function used to add an associative array of warnings and errors to a zval */
3056-
static void zval_from_error_container(zval *z, timelib_error_container *error) /* {{{ */
3056+
static void zval_from_error_container(zval *z, const timelib_error_container *error) /* {{{ */
30573057
{
30583058
int i;
30593059
zval element;
@@ -3494,7 +3494,7 @@ PHP_METHOD(DateTimeImmutable, sub)
34943494
}
34953495
/* }}} */
34963496

3497-
static void set_timezone_from_timelib_time(php_timezone_obj *tzobj, timelib_time *t)
3497+
static void set_timezone_from_timelib_time(php_timezone_obj *tzobj, const timelib_time *t)
34983498
{
34993499
/* Free abbreviation if already set */
35003500
if (tzobj->initialized && tzobj->type == TIMELIB_ZONETYPE_ABBR) {
@@ -4053,7 +4053,7 @@ PHP_METHOD(DateTimeZone, __construct)
40534053
}
40544054
/* }}} */
40554055

4056-
static bool php_date_timezone_initialize_from_hash(zval **return_value, php_timezone_obj **tzobj, HashTable *myht) /* {{{ */
4056+
static bool php_date_timezone_initialize_from_hash(zval **return_value, php_timezone_obj **tzobj, const HashTable *myht) /* {{{ */
40574057
{
40584058
zval *z_timezone_type;
40594059

@@ -4103,7 +4103,7 @@ PHP_METHOD(DateTimeZone, __wakeup)
41034103
{
41044104
zval *object = ZEND_THIS;
41054105
php_timezone_obj *tzobj;
4106-
HashTable *myht;
4106+
const HashTable *myht;
41074107

41084108
ZEND_PARSE_PARAMETERS_NONE();
41094109

@@ -4138,7 +4138,7 @@ PHP_METHOD(DateTimeZone, __serialize)
41384138
}
41394139
/* }}} */
41404140

4141-
static bool date_timezone_is_internal_property(zend_string *name)
4141+
static bool date_timezone_is_internal_property(const zend_string *name)
41424142
{
41434143
if (
41444144
zend_string_equals_literal(name, "timezone_type") ||
@@ -4149,7 +4149,7 @@ static bool date_timezone_is_internal_property(zend_string *name)
41494149
return 0;
41504150
}
41514151

4152-
static void restore_custom_datetimezone_properties(zval *object, HashTable *myht)
4152+
static void restore_custom_datetimezone_properties(zval *object, const HashTable *myht)
41534153
{
41544154
zend_string *prop_name;
41554155
zval *prop_val;
@@ -4413,7 +4413,7 @@ PHP_FUNCTION(timezone_location_get)
44134413
}
44144414
/* }}} */
44154415

4416-
static bool date_interval_initialize(timelib_rel_time **rt, /*const*/ char *format, size_t format_length) /* {{{ */
4416+
static bool date_interval_initialize(timelib_rel_time **rt, const char *format, size_t format_length) /* {{{ */
44174417
{
44184418
timelib_time *b = NULL, *e = NULL;
44194419
timelib_rel_time *p = NULL;
@@ -4598,10 +4598,10 @@ PHP_METHOD(DateInterval, __construct)
45984598
}
45994599
/* }}} */
46004600

4601-
static void php_date_interval_initialize_from_hash(zval **return_value, php_interval_obj **intobj, HashTable *myht) /* {{{ */
4601+
static void php_date_interval_initialize_from_hash(zval **return_value, php_interval_obj **intobj, const HashTable *myht) /* {{{ */
46024602
{
46034603
/* If we have a date_string, use that instead */
4604-
zval *date_str = zend_hash_str_find(myht, "date_string", strlen("date_string"));
4604+
const zval *date_str = zend_hash_str_find(myht, "date_string", strlen("date_string"));
46054605
if (date_str && Z_TYPE_P(date_str) == IS_STRING) {
46064606
timelib_time *time;
46074607
timelib_error_container *err = NULL;
@@ -4699,7 +4699,7 @@ static void php_date_interval_initialize_from_hash(zval **return_value, php_inte
46994699
PHP_DATE_INTERVAL_READ_PROPERTY("i", i, timelib_sll, -1)
47004700
PHP_DATE_INTERVAL_READ_PROPERTY("s", s, timelib_sll, -1)
47014701
{
4702-
zval *z_arg = zend_hash_str_find(myht, "f", sizeof("f") - 1);
4702+
const zval *z_arg = zend_hash_str_find(myht, "f", sizeof("f") - 1);
47034703
if (z_arg) {
47044704
(*intobj)->diff->us = zend_dval_to_lval(zval_get_double(z_arg) * 1000000.0);
47054705
}
@@ -4714,7 +4714,7 @@ static void php_date_interval_initialize_from_hash(zval **return_value, php_inte
47144714
PHP_DATE_INTERVAL_READ_PROPERTY("have_weekday_relative", have_weekday_relative, unsigned int, 0);
47154715
PHP_DATE_INTERVAL_READ_PROPERTY("have_special_relative", have_special_relative, unsigned int, 0);
47164716
{
4717-
zval *z_arg = zend_hash_str_find(myht, "civil_or_wall", sizeof("civil_or_wall") - 1);
4717+
const zval *z_arg = zend_hash_str_find(myht, "civil_or_wall", sizeof("civil_or_wall") - 1);
47184718
(*intobj)->civil_or_wall = PHP_DATE_CIVIL;
47194719
if (z_arg) {
47204720
zend_long val = zval_get_long(z_arg);
@@ -4761,7 +4761,7 @@ PHP_METHOD(DateInterval, __serialize)
47614761
}
47624762
/* }}} */
47634763

4764-
static bool date_interval_is_internal_property(zend_string *name)
4764+
static bool date_interval_is_internal_property(const zend_string *name)
47654765
{
47664766
if (
47674767
zend_string_equals_literal(name, "date_string") ||
@@ -4781,7 +4781,7 @@ static bool date_interval_is_internal_property(zend_string *name)
47814781
return 0;
47824782
}
47834783

4784-
static void restore_custom_dateinterval_properties(zval *object, HashTable *myht)
4784+
static void restore_custom_dateinterval_properties(zval *object, const HashTable *myht)
47854785
{
47864786
zend_string *prop_name;
47874787
zval *prop_val;
@@ -4818,7 +4818,7 @@ PHP_METHOD(DateInterval, __wakeup)
48184818
{
48194819
zval *object = ZEND_THIS;
48204820
php_interval_obj *intobj;
4821-
HashTable *myht;
4821+
const HashTable *myht;
48224822

48234823
ZEND_PARSE_PARAMETERS_NONE();
48244824

@@ -4910,7 +4910,7 @@ PHP_METHOD(DateInterval, createFromDateString)
49104910
/* }}} */
49114911

49124912
/* {{{ date_interval_format - */
4913-
static zend_string *date_interval_format(char *format, size_t format_len, timelib_rel_time *t)
4913+
static zend_string *date_interval_format(const char *format, size_t format_len, timelib_rel_time *t)
49144914
{
49154915
smart_str string = {0};
49164916
size_t i;
@@ -4984,7 +4984,7 @@ PHP_FUNCTION(date_interval_format)
49844984
{
49854985
zval *object;
49864986
php_interval_obj *diobj;
4987-
char *format;
4987+
const char *format;
49884988
size_t format_len;
49894989

49904990
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &object, date_ce_interval, &format, &format_len) == FAILURE) {
@@ -4997,7 +4997,7 @@ PHP_FUNCTION(date_interval_format)
49974997
}
49984998
/* }}} */
49994999

5000-
static bool date_period_initialize(timelib_time **st, timelib_time **et, timelib_rel_time **d, zend_long *recurrences, /*const*/ char *format, size_t format_length) /* {{{ */
5000+
static bool date_period_initialize(timelib_time **st, timelib_time **et, timelib_rel_time **d, zend_long *recurrences, const char *format, size_t format_length) /* {{{ */
50015001
{
50025002
timelib_time *b = NULL, *e = NULL;
50035003
timelib_rel_time *p = NULL;
@@ -5030,7 +5030,7 @@ static bool date_period_initialize(timelib_time **st, timelib_time **et, timelib
50305030
return retval;
50315031
} /* }}} */
50325032

5033-
static bool date_period_init_iso8601_string(php_period_obj *dpobj, zend_class_entry* base_ce, char *isostr, size_t isostr_len, zend_long options, zend_long *recurrences)
5033+
static bool date_period_init_iso8601_string(php_period_obj *dpobj, zend_class_entry* base_ce, const char *isostr, size_t isostr_len, zend_long options, zend_long *recurrences)
50345034
{
50355035
if (!date_period_initialize(&(dpobj->start), &(dpobj->end), &(dpobj->interval), recurrences, isostr, isostr_len)) {
50365036
return false;
@@ -5291,7 +5291,7 @@ PHP_METHOD(DatePeriod, getIterator)
52915291
zend_create_internal_iterator_zval(return_value, ZEND_THIS);
52925292
}
52935293

5294-
static int check_id_allowed(char *id, zend_long what) /* {{{ */
5294+
static int check_id_allowed(const char *id, zend_long what) /* {{{ */
52955295
{
52965296
if ((what & PHP_DATE_TIMEZONE_GROUP_AFRICA) && strncasecmp(id, "Africa/", 7) == 0) return 1;
52975297
if ((what & PHP_DATE_TIMEZONE_GROUP_AMERICA) && strncasecmp(id, "America/", 8) == 0) return 1;
@@ -5697,7 +5697,7 @@ static void date_period_object_to_hash(php_period_obj *period_obj, HashTable *pr
56975697
zend_hash_str_update(props, "include_end_date", sizeof("include_end_date")-1, &zv);
56985698
}
56995699

5700-
static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, HashTable *myht) /* {{{ */
5700+
static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, const HashTable *myht) /* {{{ */
57015701
{
57025702
zval *ht_entry;
57035703

@@ -5860,7 +5860,7 @@ PHP_METHOD(DatePeriod, __serialize)
58605860
* Common for date_period_read_property(), date_period_write_property(), and
58615861
* restore_custom_dateperiod_properties functions
58625862
*/
5863-
static bool date_period_is_internal_property(zend_string *name)
5863+
static bool date_period_is_internal_property(const zend_string *name)
58645864
{
58655865
if (
58665866
zend_string_equals_literal(name, "start") ||
@@ -5877,7 +5877,7 @@ static bool date_period_is_internal_property(zend_string *name)
58775877
}
58785878
/* }}} */
58795879

5880-
static void restore_custom_dateperiod_properties(zval *object, HashTable *myht)
5880+
static void restore_custom_dateperiod_properties(zval *object, const HashTable *myht)
58815881
{
58825882
zend_string *prop_name;
58835883
zval *prop_val;
@@ -5916,7 +5916,7 @@ PHP_METHOD(DatePeriod, __wakeup)
59165916
{
59175917
zval *object = ZEND_THIS;
59185918
php_period_obj *period_obj;
5919-
HashTable *myht;
5919+
const HashTable *myht;
59205920

59215921
ZEND_PARSE_PARAMETERS_NONE();
59225922

ext/date/php_date.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ PHPAPI int php_idate(char format, time_t ts, bool localtime);
140140

141141
PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, bool gm);
142142
PHPAPI zend_string *php_format_date(const char *format, size_t format_len, time_t ts, bool localtime);
143-
PHPAPI zend_string *php_format_date_obj(const char *format, size_t format_len, php_date_obj *date_obj);
143+
PHPAPI zend_string *php_format_date_obj(const char *format, size_t format_len, const php_date_obj *date_obj);
144144

145145
/* Mechanism to set new TZ database */
146146
PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb);

0 commit comments

Comments
 (0)