Skip to content

Commit 9d5f2f1

Browse files
authoredMar 20, 2023
Use new ZSTR_INIT_LITERAL macro (#10879)
1 parent edae243 commit 9d5f2f1

40 files changed

+78
-78
lines changed
 

‎Zend/zend_builtin_functions.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ ZEND_FUNCTION(gc_enable)
110110

111111
ZEND_PARSE_PARAMETERS_NONE();
112112

113-
key = zend_string_init("zend.enable_gc", sizeof("zend.enable_gc")-1, 0);
113+
key = ZSTR_INIT_LITERAL("zend.enable_gc", 0);
114114
zend_alter_ini_entry_chars(key, "1", sizeof("1")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
115115
zend_string_release_ex(key, 0);
116116
}
@@ -123,7 +123,7 @@ ZEND_FUNCTION(gc_disable)
123123

124124
ZEND_PARSE_PARAMETERS_NONE();
125125

126-
key = zend_string_init("zend.enable_gc", sizeof("zend.enable_gc")-1, 0);
126+
key = ZSTR_INIT_LITERAL("zend.enable_gc", 0);
127127
zend_alter_ini_entry_chars(key, "0", sizeof("0")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
128128
zend_string_release_ex(key, 0);
129129
}

‎Zend/zend_compile.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,7 @@ zend_ast *zend_negate_num_string(zend_ast *ast) /* {{{ */
20162016
zval *zv = zend_ast_get_zval(ast);
20172017
if (Z_TYPE_P(zv) == IS_LONG) {
20182018
if (Z_LVAL_P(zv) == 0) {
2019-
ZVAL_NEW_STR(zv, zend_string_init("-0", sizeof("-0")-1, 0));
2019+
ZVAL_NEW_STR(zv, ZSTR_INIT_LITERAL("-0", 0));
20202020
} else {
20212021
ZEND_ASSERT(Z_LVAL_P(zv) > 0);
20222022
Z_LVAL_P(zv) *= -1;
@@ -4221,7 +4221,7 @@ static void zend_compile_assert(znode *result, zend_ast_list *args, zend_string
42214221
/* If the original argument was named, add the new argument as named as well,
42224222
* as mixing named and positional is not allowed. */
42234223
zend_ast *name = zend_ast_create_zval_from_str(
4224-
zend_string_init("description", sizeof("description") - 1, 0));
4224+
ZSTR_INIT_LITERAL("description", 0));
42254225
arg = zend_ast_create(ZEND_AST_NAMED_ARG, name, arg);
42264226
}
42274227
zend_ast_list_add((zend_ast *) args, arg);
@@ -7295,9 +7295,9 @@ static void add_stringable_interface(zend_class_entry *ce) {
72957295
erealloc(ce->interface_names, sizeof(zend_class_name) * ce->num_interfaces);
72967296
// TODO: Add known interned strings instead?
72977297
ce->interface_names[ce->num_interfaces - 1].name =
7298-
zend_string_init("Stringable", sizeof("Stringable") - 1, 0);
7298+
ZSTR_INIT_LITERAL("Stringable", 0);
72997299
ce->interface_names[ce->num_interfaces - 1].lc_name =
7300-
zend_string_init("stringable", sizeof("stringable") - 1, 0);
7300+
ZSTR_INIT_LITERAL("stringable", 0);
73017301
}
73027302

73037303
static zend_string *zend_begin_method_decl(zend_op_array *op_array, zend_string *name, bool has_body) /* {{{ */

‎Zend/zend_enum.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@ void zend_enum_add_interfaces(zend_class_entry *ce)
183183
ce->interface_names = erealloc(ce->interface_names, sizeof(zend_class_name) * ce->num_interfaces);
184184

185185
ce->interface_names[num_interfaces_before].name = zend_string_copy(zend_ce_unit_enum->name);
186-
ce->interface_names[num_interfaces_before].lc_name = zend_string_init("unitenum", sizeof("unitenum") - 1, 0);
186+
ce->interface_names[num_interfaces_before].lc_name = ZSTR_INIT_LITERAL("unitenum", 0);
187187

188188
if (ce->enum_backing_type != IS_UNDEF) {
189189
ce->interface_names[num_interfaces_before + 1].name = zend_string_copy(zend_ce_backed_enum->name);
190-
ce->interface_names[num_interfaces_before + 1].lc_name = zend_string_init("backedenum", sizeof("backedenum") - 1, 0);
190+
ce->interface_names[num_interfaces_before + 1].lc_name = ZSTR_INIT_LITERAL("backedenum", 0);
191191
}
192192

193193
ce->default_object_handlers = &zend_enum_object_handlers;

‎Zend/zend_exceptions.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ ZEND_METHOD(Exception, __toString)
647647
str = ZSTR_EMPTY_ALLOC();
648648

649649
exception = ZEND_THIS;
650-
fname = zend_string_init("gettraceasstring", sizeof("gettraceasstring")-1, 0);
650+
fname = ZSTR_INIT_LITERAL("gettraceasstring", 0);
651651

652652
while (exception && Z_TYPE_P(exception) == IS_OBJECT && instanceof_function(Z_OBJCE_P(exception), zend_ce_throwable)) {
653653
zend_string *prev_str = str;

‎Zend/zend_execute_API.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ ZEND_API zend_string *get_function_or_method_name(const zend_function *func) /*
572572
return zend_create_member_string(func->common.scope->name, func->common.function_name);
573573
}
574574

575-
return func->common.function_name ? zend_string_copy(func->common.function_name) : zend_string_init("main", sizeof("main") - 1, 0);
575+
return func->common.function_name ? zend_string_copy(func->common.function_name) : ZSTR_INIT_LITERAL("main", 0);
576576
}
577577
/* }}} */
578578

‎Zend/zend_language_parser.y

+2-2
Original file line numberDiff line numberDiff line change
@@ -1256,12 +1256,12 @@ inline_function:
12561256
function returns_ref backup_doc_comment '(' parameter_list ')' lexical_vars return_type
12571257
backup_fn_flags '{' inner_statement_list '}' backup_fn_flags
12581258
{ $$ = zend_ast_create_decl(ZEND_AST_CLOSURE, $2 | $13, $1, $3,
1259-
zend_string_init("{closure}", sizeof("{closure}") - 1, 0),
1259+
ZSTR_INIT_LITERAL("{closure}", 0),
12601260
$5, $7, $11, $8, NULL); CG(extra_fn_flags) = $9; }
12611261
| fn returns_ref backup_doc_comment '(' parameter_list ')' return_type
12621262
T_DOUBLE_ARROW backup_fn_flags backup_lex_pos expr backup_fn_flags
12631263
{ $$ = zend_ast_create_decl(ZEND_AST_ARROW_FUNC, $2 | $12, $1, $3,
1264-
zend_string_init("{closure}", sizeof("{closure}") - 1, 0), $5, NULL, $11, $7, NULL);
1264+
ZSTR_INIT_LITERAL("{closure}", 0), $5, NULL, $11, $7, NULL);
12651265
CG(extra_fn_flags) = $9; }
12661266
;
12671267

‎ext/bcmath/bcmath.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ PHP_FUNCTION(bcscale)
633633
RETURN_THROWS();
634634
}
635635

636-
zend_string *ini_name = zend_string_init("bcmath.scale", sizeof("bcmath.scale") - 1, 0);
636+
zend_string *ini_name = ZSTR_INIT_LITERAL("bcmath.scale", 0);
637637
zend_string *new_scale_str = zend_long_to_str(new_scale);
638638
zend_alter_ini_entry(ini_name, new_scale_str, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
639639
zend_string_release(new_scale_str);

‎ext/date/php_date.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,7 @@ static void date_period_it_move_forward(zend_object_iterator *iter)
16501650
}
16511651

16521652
create_date_period_datetime(object->current, object->start_ce, &current_zv);
1653-
zend_string *property_name = zend_string_init("current", sizeof("current") - 1, 0);
1653+
zend_string *property_name = ZSTR_INIT_LITERAL("current", 0);
16541654
zend_std_write_property(&object->std, property_name, &current_zv, NULL);
16551655
zval_ptr_dtor(&current_zv);
16561656
zend_string_release(property_name);

‎ext/dom/php_dom.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /
403403
return debug_info;
404404
}
405405

406-
object_str = zend_string_init("(object value omitted)", sizeof("(object value omitted)")-1, 0);
406+
object_str = ZSTR_INIT_LITERAL("(object value omitted)", 0);
407407

408408
ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(prop_handlers, string_key, entry) {
409409
zval value;

‎ext/fileinfo/libmagic.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -2949,7 +2949,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
29492949
- if (rc == 0) {
29502950
- rc = file_regexec(ms, &rx, fmt, 0, 0, 0);
29512951
- rv = !rc;
2952-
+ pattern = zend_string_init("~%[-0-9\\.]*s~", sizeof("~%[-0-9\\.]*s~") - 1, 0);
2952+
+ pattern = ZSTR_INIT_LITERAL("~%[-0-9\\.]*s~", 0);
29532953
+ if ((pce = pcre_get_compiled_regex_cache_ex(pattern, 0)) == NULL) {
29542954
+ rv = -1;
29552955
+ } else {

‎ext/fileinfo/libmagic/softmagic.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ check_fmt(struct magic_set *ms, const char *fmt)
493493
if (strchr(fmt, '%') == NULL)
494494
return 0;
495495

496-
pattern = zend_string_init("~%[-0-9\\.]*s~", sizeof("~%[-0-9\\.]*s~") - 1, 0);
496+
pattern = ZSTR_INIT_LITERAL("~%[-0-9\\.]*s~", 0);
497497
if ((pce = pcre_get_compiled_regex_cache_ex(pattern, 0)) == NULL) {
498498
rv = -1;
499499
} else {

‎ext/iconv/iconv.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -2236,11 +2236,11 @@ PHP_FUNCTION(iconv_set_encoding)
22362236
}
22372237

22382238
if(zend_string_equals_literal_ci(type, "input_encoding")) {
2239-
name = zend_string_init("iconv.input_encoding", sizeof("iconv.input_encoding") - 1, 0);
2239+
name = ZSTR_INIT_LITERAL("iconv.input_encoding", 0);
22402240
} else if(zend_string_equals_literal_ci(type, "output_encoding")) {
2241-
name = zend_string_init("iconv.output_encoding", sizeof("iconv.output_encoding") - 1, 0);
2241+
name = ZSTR_INIT_LITERAL("iconv.output_encoding", 0);
22422242
} else if(zend_string_equals_literal_ci(type, "internal_encoding")) {
2243-
name = zend_string_init("iconv.internal_encoding", sizeof("iconv.internal_encoding") - 1, 0);
2243+
name = ZSTR_INIT_LITERAL("iconv.internal_encoding", 0);
22442244
} else {
22452245
RETURN_FALSE;
22462246
}

‎ext/imap/php_imap.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ PHP_FUNCTION(imap_append)
822822
}
823823

824824
if (internal_date) {
825-
zend_string *regex = zend_string_init("/[0-3][0-9]-((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec))-[0-9]{4} [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [+-][0-9]{4}/", sizeof("/[0-3][0-9]-((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec))-[0-9]{4} [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [+-][0-9]{4}/") - 1, 0);
825+
zend_string *regex = ZSTR_INIT_LITERAL("/[0-3][0-9]-((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec))-[0-9]{4} [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [+-][0-9]{4}/", 0);
826826
pcre_cache_entry *pce; /* Compiled regex */
827827
zval *subpats = NULL; /* Parts (not used) */
828828
int global = 0;

‎ext/mbstring/mbstring.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ PHP_FUNCTION(mb_language)
12031203
if (name == NULL) {
12041204
RETVAL_STRING((char *)mbfl_no_language2name(MBSTRG(language)));
12051205
} else {
1206-
zend_string *ini_name = zend_string_init("mbstring.language", sizeof("mbstring.language") - 1, 0);
1206+
zend_string *ini_name = ZSTR_INIT_LITERAL("mbstring.language", 0);
12071207
if (FAILURE == zend_alter_ini_entry(ini_name, name, PHP_INI_USER, PHP_INI_STAGE_RUNTIME)) {
12081208
zend_argument_value_error(1, "must be a valid language, \"%s\" given", ZSTR_VAL(name));
12091209
zend_string_release_ex(ini_name, 0);

‎ext/opcache/ZendAccelerator.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2656,7 +2656,7 @@ zend_result accel_activate(INIT_FUNC_ARGS)
26562656
ZCG(root_hash) = buf.st_ino;
26572657
if (sizeof(buf.st_ino) > sizeof(ZCG(root_hash))) {
26582658
if (ZCG(root_hash) != buf.st_ino) {
2659-
zend_string *key = zend_string_init("opcache.enable", sizeof("opcache.enable")-1, 0);
2659+
zend_string *key = ZSTR_INIT_LITERAL("opcache.enable", 0);
26602660
zend_alter_ini_entry_chars(key, "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_RUNTIME);
26612661
zend_string_release_ex(key, 0);
26622662
zend_accel_error(ACCEL_LOG_WARNING, "Can't cache files in chroot() directory with too big inode");
@@ -4479,7 +4479,7 @@ static zend_result accel_preload(const char *config, bool in_child)
44794479
script->ping_auto_globals_mask = ping_auto_globals_mask;
44804480

44814481
/* Store all functions and classes in a single pseudo-file */
4482-
CG(compiled_filename) = zend_string_init("$PRELOAD$", sizeof("$PRELOAD$") - 1, 0);
4482+
CG(compiled_filename) = ZSTR_INIT_LITERAL("$PRELOAD$", 0);
44834483
#if ZEND_USE_ABS_CONST_ADDR
44844484
init_op_array(&script->script.main_op_array, ZEND_USER_FUNCTION, 1);
44854485
#else

‎ext/pdo/pdo_dbh.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ static void pdo_stmt_construct(zend_execute_data *execute_data, pdo_stmt_t *stmt
461461
zend_string *key;
462462

463463
ZVAL_STR(&query_string, stmt->query_string);
464-
key = zend_string_init("queryString", sizeof("queryString") - 1, 0);
464+
key = ZSTR_INIT_LITERAL("queryString", 0);
465465
zend_std_write_property(Z_OBJ_P(object), key, &query_string, NULL);
466466
zend_string_release_ex(key, 0);
467467

‎ext/pdo_dblib/dblib_stmt.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static int pdo_dblib_stmt_describe(pdo_stmt_t *stmt, int colno)
243243
len = snprintf(buf, sizeof(buf), "computed%d", S->computed_column_name_count);
244244
col->name = zend_string_init(buf, len, 0);
245245
} else {
246-
col->name = zend_string_init("computed", strlen("computed"), 0);
246+
col->name = ZSTR_INIT_LITERAL("computed", 0);
247247
}
248248

249249
S->computed_column_name_count++;

‎ext/pdo_firebird/firebird_driver.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ static zend_string* firebird_handle_quoter(pdo_dbh_t *dbh, const zend_string *un
671671
zend_string *quoted_str;
672672

673673
if (ZSTR_LEN(unquoted) == 0) {
674-
return zend_string_init("''", 2, 0);
674+
return ZSTR_INIT_LITERAL("''", 0);
675675
}
676676

677677
/* Firebird only requires single quotes to be doubled if string lengths are used */

‎ext/pdo_mysql/mysql_driver.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ static bool mysql_handle_begin(pdo_dbh_t *dbh)
356356
PDO_DBG_ENTER("mysql_handle_begin");
357357
PDO_DBG_INF_FMT("dbh=%p", dbh);
358358

359-
command = zend_string_init("START TRANSACTION", strlen("START TRANSACTION"), 0);
359+
command = ZSTR_INIT_LITERAL("START TRANSACTION", 0);
360360
return_value = mysql_handle_doer(dbh, command);
361361
zend_string_release_ex(command, 0);
362362
PDO_DBG_RETURN(0 <= return_value);

‎ext/pdo_oci/oci_driver.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ static zend_string* oci_handle_quoter(pdo_dbh_t *dbh, const zend_string *unquote
363363
zend_string *quoted_str;
364364

365365
if (ZSTR_LEN(unquoted) == 0) {
366-
return zend_string_init("''", 2, 0);
366+
return ZSTR_INIT_LITERAL("''", 0);
367367
}
368368

369369
/* count single quotes */

‎ext/phar/phar_object.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */
14351435
}
14361436

14371437
close_fp = 0;
1438-
opened = zend_string_init("[stream]", sizeof("[stream]") - 1, 0);
1438+
opened = ZSTR_INIT_LITERAL("[stream]", 0);
14391439
goto after_open_fp;
14401440
case IS_OBJECT:
14411441
if (instanceof_function(Z_OBJCE_P(value), spl_ce_SplFileInfo)) {

‎ext/phar/stream.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const
8484
return NULL;
8585
}
8686
resource = ecalloc(1, sizeof(php_url));
87-
resource->scheme = zend_string_init("phar", 4, 0);
87+
resource->scheme = ZSTR_INIT_LITERAL("phar", 0);
8888
resource->host = zend_string_init(arch, arch_len, 0);
8989
efree(arch);
9090
resource->path = zend_string_init(entry, entry_len, 0);

‎ext/random/randomizer.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static inline void randomizer_common_init(php_random_randomizer *randomizer, zen
4242
zend_string *mname;
4343
zend_function *generate_method;
4444

45-
mname = zend_string_init("generate", strlen("generate"), 0);
45+
mname = ZSTR_INIT_LITERAL("generate", 0);
4646
generate_method = zend_hash_find_ptr(&engine_object->ce->function_table, mname);
4747
zend_string_release(mname);
4848

0 commit comments

Comments
 (0)