Skip to content
Open
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
91 changes: 42 additions & 49 deletions Zend/zend_ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static inline bool zend_is_whitespace(char c) {
*/
static int zend_remove_ini_entries(zval *el, void *arg) /* {{{ */
{
zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el);
const zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el);
int module_number = *(int *)arg;

return ini_entry->module_number == module_number;
Expand Down Expand Up @@ -70,9 +70,9 @@ static zend_result zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stag
}
ini_entry->value = ini_entry->orig_value;
ini_entry->modifiable = ini_entry->orig_modifiable;
ini_entry->modified = 0;
ini_entry->modified = false;
ini_entry->orig_value = NULL;
ini_entry->orig_modifiable = 0;
ini_entry->orig_modifiable = false;
}
return SUCCESS;
}
Expand All @@ -82,12 +82,12 @@ static void free_ini_entry(zval *zv) /* {{{ */
{
zend_ini_entry *entry = (zend_ini_entry*)Z_PTR_P(zv);

zend_string_release_ex(entry->name, 1);
zend_string_release_ex(entry->name, true);
if (entry->value) {
zend_string_release(entry->value);
}
if (entry->orig_value) {
zend_string_release_ex(entry->orig_value, 1);
zend_string_release_ex(entry->orig_value, true);
}
free(entry);
}
Expand All @@ -103,7 +103,7 @@ ZEND_API void zend_ini_startup(void) /* {{{ */
EG(ini_directives) = registered_zend_ini_directives;
EG(modified_ini_directives) = NULL;
EG(error_reporting_ini_entry) = NULL;
zend_hash_init(registered_zend_ini_directives, 128, NULL, free_ini_entry, 1);
zend_hash_init(registered_zend_ini_directives, 128, NULL, free_ini_entry, true);
}
/* }}} */

Expand Down Expand Up @@ -146,18 +146,18 @@ ZEND_API void zend_ini_deactivate(void) /* {{{ */
static void copy_ini_entry(zval *zv) /* {{{ */
{
zend_ini_entry *old_entry = (zend_ini_entry*)Z_PTR_P(zv);
zend_ini_entry *new_entry = pemalloc(sizeof(zend_ini_entry), 1);
zend_ini_entry *new_entry = pemalloc(sizeof(zend_ini_entry), true);

Z_PTR_P(zv) = new_entry;
memcpy(new_entry, old_entry, sizeof(zend_ini_entry));
if (old_entry->name) {
new_entry->name = zend_string_dup(old_entry->name, 1);
new_entry->name = zend_string_dup(old_entry->name, true);
}
if (old_entry->value) {
new_entry->value = zend_string_dup(old_entry->value, 1);
new_entry->value = zend_string_dup(old_entry->value, true);
}
if (old_entry->orig_value) {
new_entry->orig_value = zend_string_dup(old_entry->orig_value, 1);
new_entry->orig_value = zend_string_dup(old_entry->orig_value, true);
}
}
/* }}} */
Expand All @@ -167,7 +167,7 @@ ZEND_API void zend_copy_ini_directives(void) /* {{{ */
EG(modified_ini_directives) = NULL;
EG(error_reporting_ini_entry) = NULL;
EG(ini_directives) = (HashTable *) malloc(sizeof(HashTable));
zend_hash_init(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, free_ini_entry, 1);
zend_hash_init(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, free_ini_entry, true);
zend_hash_copy(EG(ini_directives), registered_zend_ini_directives, copy_ini_entry);
}
/* }}} */
Expand All @@ -194,7 +194,7 @@ static int ini_key_compare(Bucket *f, Bucket *s) /* {{{ */

ZEND_API void zend_ini_sort_entries(void) /* {{{ */
{
zend_hash_sort(EG(ini_directives), ini_key_compare, 0);
zend_hash_sort(EG(ini_directives), ini_key_compare, false);
}
/* }}} */

Expand Down Expand Up @@ -224,9 +224,9 @@ ZEND_API zend_result zend_register_ini_entries_ex(const zend_ini_entry_def *ini_
#endif

while (ini_entry->name) {
p = pemalloc(sizeof(zend_ini_entry), 1);
p = pemalloc(sizeof(zend_ini_entry), true);
p->def = ini_entry;
p->name = zend_string_init_interned(ini_entry->name, ini_entry->name_length, 1);
p->name = zend_string_init_interned(ini_entry->name, ini_entry->name_length, true);
p->on_modify = ini_entry->on_modify;
p->mh_arg1 = ini_entry->mh_arg1;
p->mh_arg2 = ini_entry->mh_arg2;
Expand All @@ -236,13 +236,13 @@ ZEND_API zend_result zend_register_ini_entries_ex(const zend_ini_entry_def *ini_
p->displayer = ini_entry->displayer;
p->modifiable = ini_entry->modifiable;

p->orig_modifiable = 0;
p->modified = 0;
p->orig_modifiable = false;
p->modified = false;
p->module_number = module_number;

if (zend_hash_add_ptr(directives, p->name, (void*)p) == NULL) {
if (p->name) {
zend_string_release_ex(p->name, 1);
zend_string_release_ex(p->name, true);
}
pefree(p, true);
zend_unregister_ini_entries_ex(module_number, module_type);
Expand All @@ -260,7 +260,7 @@ ZEND_API zend_result zend_register_ini_entries_ex(const zend_ini_entry_def *ini_
}
} else {
p->value = ini_entry->value ?
zend_string_init_interned(ini_entry->value, ini_entry->value_length, 1) : NULL;
zend_string_init_interned(ini_entry->value, ini_entry->value_length, true) : NULL;

if (p->on_modify) {
p->on_modify(p, p->value, p->mh_arg1, p->mh_arg2, p->mh_arg3, ZEND_INI_STAGE_STARTUP);
Expand Down Expand Up @@ -348,7 +348,7 @@ ZEND_API zend_result zend_alter_ini_entry_chars(zend_string *name, const char *v
}
/* }}} */

ZEND_API zend_result zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change) /* {{{ */
ZEND_API zend_result zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, bool force_change) /* {{{ */
{
zend_result ret;
zend_string *new_value;
Expand Down Expand Up @@ -386,12 +386,12 @@ ZEND_API zend_result zend_alter_ini_entry_ex(zend_string *name, zend_string *new

if (!EG(modified_ini_directives)) {
ALLOC_HASHTABLE(EG(modified_ini_directives));
zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, 0);
zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, false);
}
if (!modified) {
ini_entry->orig_value = ini_entry->value;
ini_entry->orig_modifiable = modifiable;
ini_entry->modified = 1;
ini_entry->modified = true;
zend_hash_add_ptr(EG(modified_ini_directives), ini_entry->name, ini_entry);
}

Expand Down Expand Up @@ -428,7 +428,7 @@ ZEND_API zend_result zend_restore_ini_entry(zend_string *name, int stage) /* {{{
}

if (EG(modified_ini_directives)) {
if (zend_restore_ini_entry_cb(ini_entry, stage) == 0) {
if (zend_restore_ini_entry_cb(ini_entry, stage) == SUCCESS) {
zend_hash_del(EG(modified_ini_directives), name);
} else {
return FAILURE;
Expand Down Expand Up @@ -457,7 +457,7 @@ ZEND_API zend_result zend_ini_register_displayer(const char *name, uint32_t name
* Data retrieval
*/

ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, int orig) /* {{{ */
ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, bool orig) /* {{{ */
{
zend_ini_entry *ini_entry;

Expand All @@ -474,7 +474,7 @@ ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, int orig)
}
/* }}} */

ZEND_API double zend_ini_double(const char *name, size_t name_length, int orig) /* {{{ */
ZEND_API double zend_ini_double(const char *name, size_t name_length, bool orig) /* {{{ */
{
zend_ini_entry *ini_entry;

Expand All @@ -491,15 +491,15 @@ ZEND_API double zend_ini_double(const char *name, size_t name_length, int orig)
}
/* }}} */

ZEND_API char *zend_ini_string_ex(const char *name, size_t name_length, int orig, bool *exists) /* {{{ */
ZEND_API char *zend_ini_string_ex(const char *name, size_t name_length, bool orig, bool *exists) /* {{{ */
{
zend_string *str = zend_ini_str_ex(name, name_length, orig, exists);

return str ? ZSTR_VAL(str) : NULL;
}
/* }}} */

ZEND_API char *zend_ini_string(const char *name, size_t name_length, int orig) /* {{{ */
ZEND_API char *zend_ini_string(const char *name, size_t name_length, bool orig) /* {{{ */
{
zend_string *str = zend_ini_str(name, name_length, orig);

Expand Down Expand Up @@ -560,13 +560,13 @@ ZEND_API zend_string *zend_ini_get_value(zend_string *name) /* {{{ */
}
/* }}} */

ZEND_API bool zend_ini_parse_bool(zend_string *str)
ZEND_API bool zend_ini_parse_bool(const zend_string *str)
{
if (zend_string_equals_literal_ci(str, "true")
|| zend_string_equals_literal_ci(str, "yes")
|| zend_string_equals_literal_ci(str, "on")
) {
return 1;
return true;
} else {
return atoi(ZSTR_VAL(str)) != 0;
}
Expand Down Expand Up @@ -610,12 +610,12 @@ static const char *zend_ini_consume_quantity_prefix(const char *const digits, co
return digits_consumed;
}

static zend_ulong zend_ini_parse_quantity_internal(zend_string *value, zend_ini_parse_quantity_signed_result_t signed_result, zend_string **errstr) /* {{{ */
static zend_ulong zend_ini_parse_quantity_internal(const zend_string *value, zend_ini_parse_quantity_signed_result_t signed_result, zend_string **errstr) /* {{{ */
{
char *digits_end = NULL;
char *str = ZSTR_VAL(value);
char *str_end = &str[ZSTR_LEN(value)];
char *digits = str;
const char *str = ZSTR_VAL(value);
const char *str_end = &str[ZSTR_LEN(value)];
const char *digits = str;
bool overflow = false;
zend_ulong factor;
smart_str invalid = {0};
Expand Down Expand Up @@ -844,19 +844,19 @@ static zend_ulong zend_ini_parse_quantity_internal(zend_string *value, zend_ini_
}
/* }}} */

ZEND_API zend_long zend_ini_parse_quantity(zend_string *value, zend_string **errstr) /* {{{ */
ZEND_API zend_long zend_ini_parse_quantity(const zend_string *value, zend_string **errstr) /* {{{ */
{
return (zend_long) zend_ini_parse_quantity_internal(value, ZEND_INI_PARSE_QUANTITY_SIGNED, errstr);
}
/* }}} */

ZEND_API zend_ulong zend_ini_parse_uquantity(zend_string *value, zend_string **errstr) /* {{{ */
ZEND_API zend_ulong zend_ini_parse_uquantity(const zend_string *value, zend_string **errstr) /* {{{ */
{
return zend_ini_parse_quantity_internal(value, ZEND_INI_PARSE_QUANTITY_UNSIGNED, errstr);
}
/* }}} */

ZEND_API zend_long zend_ini_parse_quantity_warn(zend_string *value, zend_string *setting) /* {{{ */
ZEND_API zend_long zend_ini_parse_quantity_warn(const zend_string *value, zend_string *setting) /* {{{ */
{
zend_string *errstr;
zend_long retval = zend_ini_parse_quantity(value, &errstr);
Expand All @@ -870,7 +870,7 @@ ZEND_API zend_long zend_ini_parse_quantity_warn(zend_string *value, zend_string
}
/* }}} */

ZEND_API zend_ulong zend_ini_parse_uquantity_warn(zend_string *value, zend_string *setting) /* {{{ */
ZEND_API zend_ulong zend_ini_parse_uquantity_warn(const zend_string *value, zend_string *setting) /* {{{ */
{
zend_string *errstr;
zend_ulong retval = zend_ini_parse_uquantity(value, &errstr);
Expand All @@ -886,21 +886,14 @@ ZEND_API zend_ulong zend_ini_parse_uquantity_warn(zend_string *value, zend_strin

ZEND_INI_DISP(zend_ini_boolean_displayer_cb) /* {{{ */
{
int value;
zend_string *tmp_value;
bool value;

if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL );
value = zend_ini_parse_bool(ini_entry->orig_value);
} else if (ini_entry->value) {
tmp_value = ini_entry->value;
} else {
tmp_value = NULL;
}

if (tmp_value) {
value = zend_ini_parse_bool(tmp_value);
value = zend_ini_parse_bool(ini_entry->value);
} else {
value = 0;
value = false;
}

if (value) {
Expand All @@ -913,7 +906,7 @@ ZEND_INI_DISP(zend_ini_boolean_displayer_cb) /* {{{ */

ZEND_INI_DISP(zend_ini_color_displayer_cb) /* {{{ */
{
char *value;
const char *value;

if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
value = ZSTR_VAL(ini_entry->orig_value);
Expand All @@ -940,7 +933,7 @@ ZEND_INI_DISP(zend_ini_color_displayer_cb) /* {{{ */

ZEND_INI_DISP(display_link_numbers) /* {{{ */
{
char *value;
const char *value;

if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
value = ZSTR_VAL(ini_entry->orig_value);
Expand Down
22 changes: 11 additions & 11 deletions Zend/zend_ini.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct _zend_ini_entry {

uint8_t modifiable;
uint8_t orig_modifiable;
uint8_t modified;
bool modified;

const zend_ini_entry_def *def;
};
Expand All @@ -82,18 +82,18 @@ ZEND_API void zend_ini_refresh_caches(int stage);
ZEND_API zend_result zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage);
ZEND_API zend_result zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, bool force_change);
ZEND_API zend_result zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage);
ZEND_API zend_result zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change);
ZEND_API zend_result zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, bool force_change);
ZEND_API zend_result zend_restore_ini_entry(zend_string *name, int stage);
ZEND_API void display_ini_entries(zend_module_entry *module);

ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, int orig);
ZEND_API double zend_ini_double(const char *name, size_t name_length, int orig);
ZEND_API char *zend_ini_string(const char *name, size_t name_length, int orig);
ZEND_API char *zend_ini_string_ex(const char *name, size_t name_length, int orig, bool *exists);
ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, bool orig);
ZEND_API double zend_ini_double(const char *name, size_t name_length, bool orig);
ZEND_API char *zend_ini_string(const char *name, size_t name_length, bool orig);
ZEND_API char *zend_ini_string_ex(const char *name, size_t name_length, bool orig, bool *exists);
ZEND_API zend_string *zend_ini_str(const char *name, size_t name_length, bool orig);
ZEND_API zend_string *zend_ini_str_ex(const char *name, size_t name_length, bool orig, bool *exists);
ZEND_API zend_string *zend_ini_get_value(zend_string *name);
ZEND_API bool zend_ini_parse_bool(zend_string *str);
ZEND_API bool zend_ini_parse_bool(const zend_string *str);

/**
* Parses an ini quantity
Expand Down Expand Up @@ -130,16 +130,16 @@ ZEND_API bool zend_ini_parse_bool(zend_string *str);
* In any of these cases an error string is stored in *errstr (caller must
* release it), otherwise *errstr is set to NULL.
*/
ZEND_API zend_long zend_ini_parse_quantity(zend_string *value, zend_string **errstr);
ZEND_API zend_long zend_ini_parse_quantity(const zend_string *value, zend_string **errstr);

/**
* Unsigned variant of zend_ini_parse_quantity
*/
ZEND_API zend_ulong zend_ini_parse_uquantity(zend_string *value, zend_string **errstr);
ZEND_API zend_ulong zend_ini_parse_uquantity(const zend_string *value, zend_string **errstr);

ZEND_API zend_long zend_ini_parse_quantity_warn(zend_string *value, zend_string *setting);
ZEND_API zend_long zend_ini_parse_quantity_warn(const zend_string *value, zend_string *setting);

ZEND_API zend_ulong zend_ini_parse_uquantity_warn(zend_string *value, zend_string *setting);
ZEND_API zend_ulong zend_ini_parse_uquantity_warn(const zend_string *value, zend_string *setting);

ZEND_API zend_result zend_ini_register_displayer(const char *name, uint32_t name_length, void (*displayer)(zend_ini_entry *ini_entry, int type));

Expand Down
Loading