summaryrefslogtreecommitdiff
path: root/src/sp_utils.c
diff options
context:
space:
mode:
authorjvoisin2017-12-06 13:28:57 +0100
committerjvoisin2017-12-06 13:28:57 +0100
commit75f876fca7587218fdbad9bd10bbe52825591ccc (patch)
tree4ed3febcd8fbe676f5e65237f23e5c71c0546a08 /src/sp_utils.c
parentc5400b2789e6c69bdf245a6f24408c16fc0826fa (diff)
Vastly simplify the dumping of zval in `.dump`
Diffstat (limited to 'src/sp_utils.c')
-rw-r--r--src/sp_utils.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/sp_utils.c b/src/sp_utils.c
index 18f82fe..1ed770b 100644
--- a/src/sp_utils.c
+++ b/src/sp_utils.c
@@ -126,7 +126,7 @@ int sp_log_request(const char* folder, const char* text_repr) {
126 return -1; 126 return -1;
127 } 127 }
128 128
129 fprintf(file, "RULE: %s\n", text_repr); 129 fprintf(file, "RULE: sp.disable_function%s\n", text_repr);
130 130
131 fprintf(file, "FILE: %s:%d\n", current_filename, current_line); 131 fprintf(file, "FILE: %s:%d\n", current_filename, current_line);
132 for (size_t i = 0; i < (sizeof(zones) / sizeof(zones[0])) - 1; i++) { 132 for (size_t i = 0; i < (sizeof(zones) / sizeof(zones[0])) - 1; i++) {
@@ -137,20 +137,15 @@ int sp_log_request(const char* folder, const char* text_repr) {
137 continue; 137 continue;
138 } 138 }
139 139
140 HashTable* ht = Z_ARRVAL(PG(http_globals)[zones[i].key]); 140 const HashTable* const ht = Z_ARRVAL(PG(http_globals)[zones[i].key]);
141 fprintf(file, "%s:", zones[i].str); 141 fprintf(file, "%s:", zones[i].str);
142 ZEND_HASH_FOREACH_STR_KEY_VAL(ht, variable_key, variable_value) { 142 ZEND_HASH_FOREACH_STR_KEY_VAL(ht, variable_key, variable_value) {
143 const char* key = ZSTR_VAL(variable_key); 143 smart_str a = {0};
144 144
145 if (Z_TYPE_INFO_P(variable_value) == IS_LONG) { 145 php_var_export_ex(variable_value, 1, &a);
146 fprintf(file, "%s=%" PRId64 "\n", key, Z_LVAL_P(variable_value)); 146 ZSTR_VAL(a.s)[ZSTR_LEN(a.s)] = '\0';
147 } else if (Z_TYPE_INFO_P(variable_value) == IS_DOUBLE) { 147 fprintf(file, "%s=%s ", ZSTR_VAL(variable_key), ZSTR_VAL(a.s));
148 fprintf(file, "%s=%lf\n", key, Z_DVAL_P(variable_value)); 148 zend_string_release(a.s);
149 } else if (Z_TYPE_INFO_P(variable_value) == IS_ARRAY) {
150 fprintf(file, "%s=array", key);
151 } else {
152 fprintf(file, "%s=%s\n", key, Z_STRVAL_P(variable_value));
153 }
154 } 149 }
155 ZEND_HASH_FOREACH_END(); 150 ZEND_HASH_FOREACH_END();
156 fputs("\n", file); 151 fputs("\n", file);