From 30f1270c26edb6ced469eb302de2fa27befbdbec Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 27 Jun 2022 20:12:47 +0200 Subject: Move compile_file and compile_string to sp_execute.c --- src/sp_sloppy.c | 41 +---------------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) (limited to 'src/sp_sloppy.c') diff --git a/src/sp_sloppy.c b/src/sp_sloppy.c index fca4be5..2c6ef6a 100644 --- a/src/sp_sloppy.c +++ b/src/sp_sloppy.c @@ -1,16 +1,6 @@ #include "php_snuffleupagus.h" -ZEND_API zend_op_array* (*orig_zend_compile_file)(zend_file_handle* file_handle, - int type) = NULL; -#if PHP_VERSION_ID >= 80000 -ZEND_API zend_op_array* (*orig_zend_compile_string)( - zend_string* source_string, const char* filename) = NULL; -#else -ZEND_API zend_op_array* (*orig_zend_compile_string)(zval* source_string, - char* filename) = NULL; -#endif - -static void modify_opcode(zend_op_array* opline) { +void sp_sloppy_modify_opcode(zend_op_array* opline) { if (NULL != opline) { for (size_t i = 0; i < opline->last; i++) { zend_op* orig_opline = &(opline->opcodes[i]); @@ -25,24 +15,6 @@ static void modify_opcode(zend_op_array* opline) { } } -#if PHP_VERSION_ID >= 80000 -ZEND_API zend_op_array* sp_compile_string(zend_string* source_string, - const char* filename) { -#else -ZEND_API zend_op_array* sp_compile_string(zval* source_string, char* filename) { -#endif - zend_op_array* opline = orig_zend_compile_string(source_string, filename); - modify_opcode(opline); - return opline; -} - -ZEND_API zend_op_array* sp_compile_file(zend_file_handle* file_handle, - int type) { - zend_op_array* opline = orig_zend_compile_file(file_handle, type); - modify_opcode(opline); - return opline; -} - static void array_handler(INTERNAL_FUNCTION_PARAMETERS, const char* name, size_t size, zif_handler orig_handler, const char* spec) { @@ -99,17 +71,6 @@ PHP_FUNCTION(sp_array_keys) { void hook_sloppy() { TSRMLS_FETCH(); - if (NULL == orig_zend_compile_file && zend_compile_file != sp_compile_file) { - orig_zend_compile_file = zend_compile_file; - zend_compile_file = sp_compile_file; - } - - if (NULL == orig_zend_compile_string && - zend_compile_string != sp_compile_string) { - orig_zend_compile_string = zend_compile_string; - zend_compile_string = sp_compile_string; - } - HOOK_FUNCTION("in_array", sp_internal_functions_hook, PHP_FN(sp_in_array)); HOOK_FUNCTION("array_search", sp_internal_functions_hook, PHP_FN(sp_array_search)); -- cgit v1.3