Skip to content

Use new ZSTR_INIT_LITERAL macro #10879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Zend/zend_builtin_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ ZEND_FUNCTION(gc_enable)

ZEND_PARSE_PARAMETERS_NONE();

key = zend_string_init("zend.enable_gc", sizeof("zend.enable_gc")-1, 0);
key = ZSTR_INIT_LITERAL("zend.enable_gc", 0);
zend_alter_ini_entry_chars(key, "1", sizeof("1")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
zend_string_release_ex(key, 0);
}
Expand All @@ -123,7 +123,7 @@ ZEND_FUNCTION(gc_disable)

ZEND_PARSE_PARAMETERS_NONE();

key = zend_string_init("zend.enable_gc", sizeof("zend.enable_gc")-1, 0);
key = ZSTR_INIT_LITERAL("zend.enable_gc", 0);
zend_alter_ini_entry_chars(key, "0", sizeof("0")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
zend_string_release_ex(key, 0);
}
Expand Down
8 changes: 4 additions & 4 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,7 @@ zend_ast *zend_negate_num_string(zend_ast *ast) /* {{{ */
zval *zv = zend_ast_get_zval(ast);
if (Z_TYPE_P(zv) == IS_LONG) {
if (Z_LVAL_P(zv) == 0) {
ZVAL_NEW_STR(zv, zend_string_init("-0", sizeof("-0")-1, 0));
ZVAL_NEW_STR(zv, ZSTR_INIT_LITERAL("-0", 0));
} else {
ZEND_ASSERT(Z_LVAL_P(zv) > 0);
Z_LVAL_P(zv) *= -1;
Expand Down Expand Up @@ -4221,7 +4221,7 @@ static void zend_compile_assert(znode *result, zend_ast_list *args, zend_string
/* If the original argument was named, add the new argument as named as well,
* as mixing named and positional is not allowed. */
zend_ast *name = zend_ast_create_zval_from_str(
zend_string_init("description", sizeof("description") - 1, 0));
ZSTR_INIT_LITERAL("description", 0));
arg = zend_ast_create(ZEND_AST_NAMED_ARG, name, arg);
}
zend_ast_list_add((zend_ast *) args, arg);
Expand Down Expand Up @@ -7295,9 +7295,9 @@ static void add_stringable_interface(zend_class_entry *ce) {
erealloc(ce->interface_names, sizeof(zend_class_name) * ce->num_interfaces);
// TODO: Add known interned strings instead?
ce->interface_names[ce->num_interfaces - 1].name =
zend_string_init("Stringable", sizeof("Stringable") - 1, 0);
ZSTR_INIT_LITERAL("Stringable", 0);
ce->interface_names[ce->num_interfaces - 1].lc_name =
zend_string_init("stringable", sizeof("stringable") - 1, 0);
ZSTR_INIT_LITERAL("stringable", 0);
}

static zend_string *zend_begin_method_decl(zend_op_array *op_array, zend_string *name, bool has_body) /* {{{ */
Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ void zend_enum_add_interfaces(zend_class_entry *ce)
ce->interface_names = erealloc(ce->interface_names, sizeof(zend_class_name) * ce->num_interfaces);

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

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

ce->default_object_handlers = &zend_enum_object_handlers;
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ ZEND_METHOD(Exception, __toString)
str = ZSTR_EMPTY_ALLOC();

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

while (exception && Z_TYPE_P(exception) == IS_OBJECT && instanceof_function(Z_OBJCE_P(exception), zend_ce_throwable)) {
zend_string *prev_str = str;
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_execute_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ ZEND_API zend_string *get_function_or_method_name(const zend_function *func) /*
return zend_create_member_string(func->common.scope->name, func->common.function_name);
}

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

Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_language_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -1256,12 +1256,12 @@ inline_function:
function returns_ref backup_doc_comment '(' parameter_list ')' lexical_vars return_type
backup_fn_flags '{' inner_statement_list '}' backup_fn_flags
{ $$ = zend_ast_create_decl(ZEND_AST_CLOSURE, $2 | $13, $1, $3,
zend_string_init("{closure}", sizeof("{closure}") - 1, 0),
ZSTR_INIT_LITERAL("{closure}", 0),
$5, $7, $11, $8, NULL); CG(extra_fn_flags) = $9; }
| fn returns_ref backup_doc_comment '(' parameter_list ')' return_type
T_DOUBLE_ARROW backup_fn_flags backup_lex_pos expr backup_fn_flags
{ $$ = zend_ast_create_decl(ZEND_AST_ARROW_FUNC, $2 | $12, $1, $3,
zend_string_init("{closure}", sizeof("{closure}") - 1, 0), $5, NULL, $11, $7, NULL);
ZSTR_INIT_LITERAL("{closure}", 0), $5, NULL, $11, $7, NULL);
CG(extra_fn_flags) = $9; }
;

Expand Down
2 changes: 1 addition & 1 deletion ext/bcmath/bcmath.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ PHP_FUNCTION(bcscale)
RETURN_THROWS();
}

zend_string *ini_name = zend_string_init("bcmath.scale", sizeof("bcmath.scale") - 1, 0);
zend_string *ini_name = ZSTR_INIT_LITERAL("bcmath.scale", 0);
zend_string *new_scale_str = zend_long_to_str(new_scale);
zend_alter_ini_entry(ini_name, new_scale_str, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
zend_string_release(new_scale_str);
Expand Down
2 changes: 1 addition & 1 deletion ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,7 @@ static void date_period_it_move_forward(zend_object_iterator *iter)
}

create_date_period_datetime(object->current, object->start_ce, &current_zv);
zend_string *property_name = zend_string_init("current", sizeof("current") - 1, 0);
zend_string *property_name = ZSTR_INIT_LITERAL("current", 0);
zend_std_write_property(&object->std, property_name, &current_zv, NULL);
zval_ptr_dtor(&current_zv);
zend_string_release(property_name);
Expand Down
2 changes: 1 addition & 1 deletion ext/dom/php_dom.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /
return debug_info;
}

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

ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(prop_handlers, string_key, entry) {
zval value;
Expand Down
2 changes: 1 addition & 1 deletion ext/fileinfo/libmagic.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2949,7 +2949,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
- if (rc == 0) {
- rc = file_regexec(ms, &rx, fmt, 0, 0, 0);
- rv = !rc;
+ pattern = zend_string_init("~%[-0-9\\.]*s~", sizeof("~%[-0-9\\.]*s~") - 1, 0);
+ pattern = ZSTR_INIT_LITERAL("~%[-0-9\\.]*s~", 0);
+ if ((pce = pcre_get_compiled_regex_cache_ex(pattern, 0)) == NULL) {
+ rv = -1;
+ } else {
Expand Down
2 changes: 1 addition & 1 deletion ext/fileinfo/libmagic/softmagic.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ check_fmt(struct magic_set *ms, const char *fmt)
if (strchr(fmt, '%') == NULL)
return 0;

pattern = zend_string_init("~%[-0-9\\.]*s~", sizeof("~%[-0-9\\.]*s~") - 1, 0);
pattern = ZSTR_INIT_LITERAL("~%[-0-9\\.]*s~", 0);
if ((pce = pcre_get_compiled_regex_cache_ex(pattern, 0)) == NULL) {
rv = -1;
} else {
Expand Down
6 changes: 3 additions & 3 deletions ext/iconv/iconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2236,11 +2236,11 @@ PHP_FUNCTION(iconv_set_encoding)
}

if(zend_string_equals_literal_ci(type, "input_encoding")) {
name = zend_string_init("iconv.input_encoding", sizeof("iconv.input_encoding") - 1, 0);
name = ZSTR_INIT_LITERAL("iconv.input_encoding", 0);
} else if(zend_string_equals_literal_ci(type, "output_encoding")) {
name = zend_string_init("iconv.output_encoding", sizeof("iconv.output_encoding") - 1, 0);
name = ZSTR_INIT_LITERAL("iconv.output_encoding", 0);
} else if(zend_string_equals_literal_ci(type, "internal_encoding")) {
name = zend_string_init("iconv.internal_encoding", sizeof("iconv.internal_encoding") - 1, 0);
name = ZSTR_INIT_LITERAL("iconv.internal_encoding", 0);
} else {
RETURN_FALSE;
}
Expand Down
2 changes: 1 addition & 1 deletion ext/imap/php_imap.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ PHP_FUNCTION(imap_append)
}

if (internal_date) {
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);
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);
pcre_cache_entry *pce; /* Compiled regex */
zval *subpats = NULL; /* Parts (not used) */
int global = 0;
Expand Down
2 changes: 1 addition & 1 deletion ext/mbstring/mbstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ PHP_FUNCTION(mb_language)
if (name == NULL) {
RETVAL_STRING((char *)mbfl_no_language2name(MBSTRG(language)));
} else {
zend_string *ini_name = zend_string_init("mbstring.language", sizeof("mbstring.language") - 1, 0);
zend_string *ini_name = ZSTR_INIT_LITERAL("mbstring.language", 0);
if (FAILURE == zend_alter_ini_entry(ini_name, name, PHP_INI_USER, PHP_INI_STAGE_RUNTIME)) {
zend_argument_value_error(1, "must be a valid language, \"%s\" given", ZSTR_VAL(name));
zend_string_release_ex(ini_name, 0);
Expand Down
4 changes: 2 additions & 2 deletions ext/opcache/ZendAccelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -2656,7 +2656,7 @@ zend_result accel_activate(INIT_FUNC_ARGS)
ZCG(root_hash) = buf.st_ino;
if (sizeof(buf.st_ino) > sizeof(ZCG(root_hash))) {
if (ZCG(root_hash) != buf.st_ino) {
zend_string *key = zend_string_init("opcache.enable", sizeof("opcache.enable")-1, 0);
zend_string *key = ZSTR_INIT_LITERAL("opcache.enable", 0);
zend_alter_ini_entry_chars(key, "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_RUNTIME);
zend_string_release_ex(key, 0);
zend_accel_error(ACCEL_LOG_WARNING, "Can't cache files in chroot() directory with too big inode");
Expand Down Expand Up @@ -4479,7 +4479,7 @@ static zend_result accel_preload(const char *config, bool in_child)
script->ping_auto_globals_mask = ping_auto_globals_mask;

/* Store all functions and classes in a single pseudo-file */
CG(compiled_filename) = zend_string_init("$PRELOAD$", sizeof("$PRELOAD$") - 1, 0);
CG(compiled_filename) = ZSTR_INIT_LITERAL("$PRELOAD$", 0);
#if ZEND_USE_ABS_CONST_ADDR
init_op_array(&script->script.main_op_array, ZEND_USER_FUNCTION, 1);
#else
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo/pdo_dbh.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ static void pdo_stmt_construct(zend_execute_data *execute_data, pdo_stmt_t *stmt
zend_string *key;

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

Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_dblib/dblib_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ static int pdo_dblib_stmt_describe(pdo_stmt_t *stmt, int colno)
len = snprintf(buf, sizeof(buf), "computed%d", S->computed_column_name_count);
col->name = zend_string_init(buf, len, 0);
} else {
col->name = zend_string_init("computed", strlen("computed"), 0);
col->name = ZSTR_INIT_LITERAL("computed", 0);
}

S->computed_column_name_count++;
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_firebird/firebird_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ static zend_string* firebird_handle_quoter(pdo_dbh_t *dbh, const zend_string *un
zend_string *quoted_str;

if (ZSTR_LEN(unquoted) == 0) {
return zend_string_init("''", 2, 0);
return ZSTR_INIT_LITERAL("''", 0);
}

/* Firebird only requires single quotes to be doubled if string lengths are used */
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_mysql/mysql_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ static bool mysql_handle_begin(pdo_dbh_t *dbh)
PDO_DBG_ENTER("mysql_handle_begin");
PDO_DBG_INF_FMT("dbh=%p", dbh);

command = zend_string_init("START TRANSACTION", strlen("START TRANSACTION"), 0);
command = ZSTR_INIT_LITERAL("START TRANSACTION", 0);
return_value = mysql_handle_doer(dbh, command);
zend_string_release_ex(command, 0);
PDO_DBG_RETURN(0 <= return_value);
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_oci/oci_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ static zend_string* oci_handle_quoter(pdo_dbh_t *dbh, const zend_string *unquote
zend_string *quoted_str;

if (ZSTR_LEN(unquoted) == 0) {
return zend_string_init("''", 2, 0);
return ZSTR_INIT_LITERAL("''", 0);
}

/* count single quotes */
Expand Down
2 changes: 1 addition & 1 deletion ext/phar/phar_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */
}

close_fp = 0;
opened = zend_string_init("[stream]", sizeof("[stream]") - 1, 0);
opened = ZSTR_INIT_LITERAL("[stream]", 0);
goto after_open_fp;
case IS_OBJECT:
if (instanceof_function(Z_OBJCE_P(value), spl_ce_SplFileInfo)) {
Expand Down
2 changes: 1 addition & 1 deletion ext/phar/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const
return NULL;
}
resource = ecalloc(1, sizeof(php_url));
resource->scheme = zend_string_init("phar", 4, 0);
resource->scheme = ZSTR_INIT_LITERAL("phar", 0);
resource->host = zend_string_init(arch, arch_len, 0);
efree(arch);
resource->path = zend_string_init(entry, entry_len, 0);
Expand Down
2 changes: 1 addition & 1 deletion ext/random/randomizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static inline void randomizer_common_init(php_random_randomizer *randomizer, zen
zend_string *mname;
zend_function *generate_method;

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

Expand Down
Loading