diff options
| author | Ben Fuhrmannek | 2021-08-02 10:42:12 +0200 |
|---|---|---|
| committer | Ben Fuhrmannek | 2021-08-02 10:42:12 +0200 |
| commit | 4cda0120313dfd5d71236f6faf87416e93f5f89c (patch) | |
| tree | 0c2c6d15e8ac5287fb3304f96de719547d9e847a /src/sp_var_value.c | |
| parent | 6c132e6a1d8d339a20282afb5a4af52eb6bce9db (diff) | |
| parent | e62f226c3ed885808c832040872fc2d73ca46dac (diff) | |
Merge branch 'master' of https://github.com/jvoisin/snuffleupagus
Diffstat (limited to 'src/sp_var_value.c')
| -rw-r--r-- | src/sp_var_value.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/sp_var_value.c b/src/sp_var_value.c index b9ac357..fe37f99 100644 --- a/src/sp_var_value.c +++ b/src/sp_var_value.c | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #include "php_snuffleupagus.h" | 1 | #include "php_snuffleupagus.h" |
| 2 | 2 | ||
| 3 | static zval *get_param_var(zend_execute_data *ed, const char *var_name) { | 3 | static zval *get_param_var(const zend_execute_data *const ed, |
| 4 | const char *const var_name, bool print) { | ||
| 4 | unsigned int nb_param = ed->func->common.num_args; | 5 | unsigned int nb_param = ed->func->common.num_args; |
| 5 | 6 | ||
| 6 | for (unsigned int i = 0; i < nb_param; i++) { | 7 | for (unsigned int i = 0; i < nb_param; i++) { |
| @@ -13,11 +14,14 @@ static zval *get_param_var(zend_execute_data *ed, const char *var_name) { | |||
| 13 | if (0 == strcmp(arg_name, var_name)) { | 14 | if (0 == strcmp(arg_name, var_name)) { |
| 14 | return ZEND_CALL_VAR_NUM(ed, i); | 15 | return ZEND_CALL_VAR_NUM(ed, i); |
| 15 | } | 16 | } |
| 17 | if (print == true) { | ||
| 18 | sp_log_warn("config", " - %d parameter's name: '%s'", i, arg_name); | ||
| 19 | } | ||
| 16 | } | 20 | } |
| 17 | return NULL; | 21 | return NULL; |
| 18 | } | 22 | } |
| 19 | 23 | ||
| 20 | static zval *get_local_var(zend_execute_data *ed, const char *var_name) { | 24 | static zval *get_local_var(zend_execute_data *ed, const char *const var_name) { |
| 21 | zend_execute_data *orig_execute_data = ed; | 25 | zend_execute_data *orig_execute_data = ed; |
| 22 | zend_execute_data *current = ed; | 26 | zend_execute_data *current = ed; |
| 23 | 27 | ||
| @@ -48,7 +52,7 @@ static zval *get_local_var(zend_execute_data *ed, const char *var_name) { | |||
| 48 | return NULL; | 52 | return NULL; |
| 49 | } | 53 | } |
| 50 | 54 | ||
| 51 | static zval *get_constant(const char *value) { | 55 | static zval *get_constant(const char *const value) { |
| 52 | zend_string *name = zend_string_init(value, strlen(value), 0); | 56 | zend_string *name = zend_string_init(value, strlen(value), 0); |
| 53 | zval *zvalue = zend_get_constant_ex(name, NULL, ZEND_FETCH_CLASS_SILENT); | 57 | zval *zvalue = zend_get_constant_ex(name, NULL, ZEND_FETCH_CLASS_SILENT); |
| 54 | zend_string_release(name); | 58 | zend_string_release(name); |
| @@ -68,7 +72,7 @@ static zval *get_var_value(zend_execute_data *ed, const char *var_name, | |||
| 68 | } | 72 | } |
| 69 | 73 | ||
| 70 | if (is_param) { | 74 | if (is_param) { |
| 71 | zval *zvalue = get_param_var(ed, var_name); | 75 | zval *zvalue = get_param_var(ed, var_name, false); |
| 72 | if (!zvalue) { | 76 | if (!zvalue) { |
| 73 | char *complete_function_path = get_complete_function_path(ed); | 77 | char *complete_function_path = get_complete_function_path(ed); |
| 74 | sp_log_warn("config", | 78 | sp_log_warn("config", |
| @@ -76,6 +80,7 @@ static zval *get_var_value(zend_execute_data *ed, const char *var_name, | |||
| 76 | "'%s' of the function '%s', but the parameter does " | 80 | "'%s' of the function '%s', but the parameter does " |
| 77 | "not exists.", | 81 | "not exists.", |
| 78 | var_name, complete_function_path); | 82 | var_name, complete_function_path); |
| 83 | get_param_var(ed, var_name, true); | ||
| 79 | efree(complete_function_path); | 84 | efree(complete_function_path); |
| 80 | return NULL; | 85 | return NULL; |
| 81 | } | 86 | } |
| @@ -85,8 +90,8 @@ static zval *get_var_value(zend_execute_data *ed, const char *var_name, | |||
| 85 | } | 90 | } |
| 86 | } | 91 | } |
| 87 | 92 | ||
| 88 | static void *get_entry_hashtable(const HashTable *ht, const char *entry, | 93 | static void *get_entry_hashtable(const HashTable *const ht, |
| 89 | size_t entry_len) { | 94 | const char *const entry, size_t entry_len) { |
| 90 | zval *zvalue = zend_hash_str_find(ht, entry, entry_len); | 95 | zval *zvalue = zend_hash_str_find(ht, entry, entry_len); |
| 91 | 96 | ||
| 92 | if (!zvalue) { | 97 | if (!zvalue) { |
| @@ -104,8 +109,8 @@ static void *get_entry_hashtable(const HashTable *ht, const char *entry, | |||
| 104 | return zvalue; | 109 | return zvalue; |
| 105 | } | 110 | } |
| 106 | 111 | ||
| 107 | static zval *get_array_value(zend_execute_data *ed, zval *zvalue, | 112 | static zval *get_array_value(zend_execute_data *ed, const zval *const zvalue, |
| 108 | const sp_tree *tree) { | 113 | const sp_tree *const tree) { |
| 109 | zval *idx_value = sp_get_var_value(ed, tree->idx, false); | 114 | zval *idx_value = sp_get_var_value(ed, tree->idx, false); |
| 110 | 115 | ||
| 111 | if (!zvalue || !idx_value) { | 116 | if (!zvalue || !idx_value) { |
| @@ -113,7 +118,7 @@ static zval *get_array_value(zend_execute_data *ed, zval *zvalue, | |||
| 113 | } | 118 | } |
| 114 | 119 | ||
| 115 | if (Z_TYPE_P(zvalue) == IS_ARRAY) { | 120 | if (Z_TYPE_P(zvalue) == IS_ARRAY) { |
| 116 | const zend_string *idx = sp_zval_to_zend_string(idx_value); | 121 | const zend_string *const idx = sp_zval_to_zend_string(idx_value); |
| 117 | return get_entry_hashtable(Z_ARRVAL_P(zvalue), ZSTR_VAL(idx), | 122 | return get_entry_hashtable(Z_ARRVAL_P(zvalue), ZSTR_VAL(idx), |
| 118 | ZSTR_LEN(idx)); | 123 | ZSTR_LEN(idx)); |
| 119 | } | 124 | } |
| @@ -123,10 +128,10 @@ static zval *get_array_value(zend_execute_data *ed, zval *zvalue, | |||
| 123 | 128 | ||
| 124 | static zval *get_object_property(zend_execute_data *ed, zval *object, | 129 | static zval *get_object_property(zend_execute_data *ed, zval *object, |
| 125 | const char *property, bool is_param) { | 130 | const char *property, bool is_param) { |
| 126 | char *class_name = object->value.obj->ce->name->val; | 131 | const char *const class_name = object->value.obj->ce->name->val; |
| 127 | HashTable *array = Z_OBJPROP_P(object); | 132 | HashTable *array = Z_OBJPROP_P(object); |
| 128 | zval *zvalue = NULL; | 133 | zval *zvalue = NULL; |
| 129 | zval *property_val = get_var_value(ed, property, is_param); | 134 | const zval *property_val = get_var_value(ed, property, is_param); |
| 130 | size_t len; | 135 | size_t len; |
| 131 | 136 | ||
| 132 | if (property_val) { | 137 | if (property_val) { |
| @@ -156,7 +161,7 @@ static zval *get_object_property(zend_execute_data *ed, zval *object, | |||
| 156 | return zvalue; | 161 | return zvalue; |
| 157 | } | 162 | } |
| 158 | 163 | ||
| 159 | static zend_class_entry *get_class(const char *value) { | 164 | static zend_class_entry *get_class(const char *const value) { |
| 160 | zend_string *name = zend_string_init(value, strlen(value), 0); | 165 | zend_string *name = zend_string_init(value, strlen(value), 0); |
| 161 | zend_class_entry *ce = zend_lookup_class(name); | 166 | zend_class_entry *ce = zend_lookup_class(name); |
| 162 | zend_string_release(name); | 167 | zend_string_release(name); |
| @@ -165,7 +170,7 @@ static zend_class_entry *get_class(const char *value) { | |||
| 165 | 170 | ||
| 166 | static zval *get_unknown_type(const char *restrict value, zval *zvalue, | 171 | static zval *get_unknown_type(const char *restrict value, zval *zvalue, |
| 167 | zend_class_entry *ce, zend_execute_data *ed, | 172 | zend_class_entry *ce, zend_execute_data *ed, |
| 168 | const sp_tree *tree, bool is_param) { | 173 | const sp_tree *const tree, bool is_param) { |
| 169 | if (ce) { | 174 | if (ce) { |
| 170 | zvalue = get_entry_hashtable(&ce->constants_table, value, strlen(value)); | 175 | zvalue = get_entry_hashtable(&ce->constants_table, value, strlen(value)); |
| 171 | ce = NULL; | 176 | ce = NULL; |
