summaryrefslogtreecommitdiff
path: root/src/sp_execute.c
diff options
context:
space:
mode:
authorjvoisin2022-06-27 20:12:47 +0200
committerjvoisin2022-06-27 20:12:47 +0200
commit30f1270c26edb6ced469eb302de2fa27befbdbec (patch)
treebd6cc9e15a81c607b8751a36673a99d17f555e07 /src/sp_execute.c
parentaef97b6b5cb130984ead1a0c3fbc3cdc2037320e (diff)
Move compile_file and compile_string to sp_execute.c
Diffstat (limited to '')
-rw-r--r--src/sp_execute.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/sp_execute.c b/src/sp_execute.c
index f1ed8d0..b81f408 100644
--- a/src/sp_execute.c
+++ b/src/sp_execute.c
@@ -286,6 +286,34 @@ static zend_result sp_stream_open(zend_file_handle *handle) {
286 286
287#endif 287#endif
288 288
289ZEND_API zend_op_array* (*orig_zend_compile_file)(zend_file_handle* file_handle,
290 int type) = NULL;
291#if PHP_VERSION_ID >= 80000
292ZEND_API zend_op_array* (*orig_zend_compile_string)(
293 zend_string* source_string, const char* filename) = NULL;
294#else
295ZEND_API zend_op_array* (*orig_zend_compile_string)(zval* source_string,
296 char* filename) = NULL;
297#endif
298
299#if PHP_VERSION_ID >= 80000
300ZEND_API zend_op_array* sp_compile_string(zend_string* source_string,
301 const char* filename) {
302#else
303ZEND_API zend_op_array* sp_compile_string(zval* source_string, char* filename) {
304#endif
305 zend_op_array* opline = orig_zend_compile_string(source_string, filename);
306 sp_sloppy_modify_opcode(opline);
307 return opline;
308}
309
310ZEND_API zend_op_array* sp_compile_file(zend_file_handle* file_handle,
311 int type) {
312 zend_op_array* opline = orig_zend_compile_file(file_handle, type);
313 sp_sloppy_modify_opcode(opline);
314 return opline;
315}
316
289int hook_execute(void) { 317int hook_execute(void) {
290 TSRMLS_FETCH(); 318 TSRMLS_FETCH();
291 319
@@ -309,5 +337,16 @@ int hook_execute(void) {
309 } 337 }
310 } 338 }
311 339
340 if (NULL == orig_zend_compile_file && zend_compile_file != sp_compile_file) {
341 orig_zend_compile_file = zend_compile_file;
342 zend_compile_file = sp_compile_file;
343 }
344
345 if (NULL == orig_zend_compile_string &&
346 zend_compile_string != sp_compile_string) {
347 orig_zend_compile_string = zend_compile_string;
348 zend_compile_string = sp_compile_string;
349 }
350
312 return SUCCESS; 351 return SUCCESS;
313} 352}