diff options
| author | jvoisin | 2022-06-27 20:12:47 +0200 |
|---|---|---|
| committer | jvoisin | 2022-06-27 20:12:47 +0200 |
| commit | 30f1270c26edb6ced469eb302de2fa27befbdbec (patch) | |
| tree | bd6cc9e15a81c607b8751a36673a99d17f555e07 /src/sp_sloppy.c | |
| parent | aef97b6b5cb130984ead1a0c3fbc3cdc2037320e (diff) | |
Move compile_file and compile_string to sp_execute.c
Diffstat (limited to 'src/sp_sloppy.c')
| -rw-r--r-- | src/sp_sloppy.c | 41 |
1 files changed, 1 insertions, 40 deletions
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 @@ | |||
| 1 | #include "php_snuffleupagus.h" | 1 | #include "php_snuffleupagus.h" |
| 2 | 2 | ||
| 3 | ZEND_API zend_op_array* (*orig_zend_compile_file)(zend_file_handle* file_handle, | 3 | void sp_sloppy_modify_opcode(zend_op_array* opline) { |
| 4 | int type) = NULL; | ||
| 5 | #if PHP_VERSION_ID >= 80000 | ||
| 6 | ZEND_API zend_op_array* (*orig_zend_compile_string)( | ||
| 7 | zend_string* source_string, const char* filename) = NULL; | ||
| 8 | #else | ||
| 9 | ZEND_API zend_op_array* (*orig_zend_compile_string)(zval* source_string, | ||
| 10 | char* filename) = NULL; | ||
| 11 | #endif | ||
| 12 | |||
| 13 | static void modify_opcode(zend_op_array* opline) { | ||
| 14 | if (NULL != opline) { | 4 | if (NULL != opline) { |
| 15 | for (size_t i = 0; i < opline->last; i++) { | 5 | for (size_t i = 0; i < opline->last; i++) { |
| 16 | zend_op* orig_opline = &(opline->opcodes[i]); | 6 | zend_op* orig_opline = &(opline->opcodes[i]); |
| @@ -25,24 +15,6 @@ static void modify_opcode(zend_op_array* opline) { | |||
| 25 | } | 15 | } |
| 26 | } | 16 | } |
| 27 | 17 | ||
| 28 | #if PHP_VERSION_ID >= 80000 | ||
| 29 | ZEND_API zend_op_array* sp_compile_string(zend_string* source_string, | ||
| 30 | const char* filename) { | ||
| 31 | #else | ||
| 32 | ZEND_API zend_op_array* sp_compile_string(zval* source_string, char* filename) { | ||
| 33 | #endif | ||
| 34 | zend_op_array* opline = orig_zend_compile_string(source_string, filename); | ||
| 35 | modify_opcode(opline); | ||
| 36 | return opline; | ||
| 37 | } | ||
| 38 | |||
| 39 | ZEND_API zend_op_array* sp_compile_file(zend_file_handle* file_handle, | ||
| 40 | int type) { | ||
| 41 | zend_op_array* opline = orig_zend_compile_file(file_handle, type); | ||
| 42 | modify_opcode(opline); | ||
| 43 | return opline; | ||
| 44 | } | ||
| 45 | |||
| 46 | static void array_handler(INTERNAL_FUNCTION_PARAMETERS, const char* name, | 18 | static void array_handler(INTERNAL_FUNCTION_PARAMETERS, const char* name, |
| 47 | size_t size, zif_handler orig_handler, | 19 | size_t size, zif_handler orig_handler, |
| 48 | const char* spec) { | 20 | const char* spec) { |
| @@ -99,17 +71,6 @@ PHP_FUNCTION(sp_array_keys) { | |||
| 99 | void hook_sloppy() { | 71 | void hook_sloppy() { |
| 100 | TSRMLS_FETCH(); | 72 | TSRMLS_FETCH(); |
| 101 | 73 | ||
| 102 | if (NULL == orig_zend_compile_file && zend_compile_file != sp_compile_file) { | ||
| 103 | orig_zend_compile_file = zend_compile_file; | ||
| 104 | zend_compile_file = sp_compile_file; | ||
| 105 | } | ||
| 106 | |||
| 107 | if (NULL == orig_zend_compile_string && | ||
| 108 | zend_compile_string != sp_compile_string) { | ||
| 109 | orig_zend_compile_string = zend_compile_string; | ||
| 110 | zend_compile_string = sp_compile_string; | ||
| 111 | } | ||
| 112 | |||
| 113 | HOOK_FUNCTION("in_array", sp_internal_functions_hook, PHP_FN(sp_in_array)); | 74 | HOOK_FUNCTION("in_array", sp_internal_functions_hook, PHP_FN(sp_in_array)); |
| 114 | HOOK_FUNCTION("array_search", sp_internal_functions_hook, | 75 | HOOK_FUNCTION("array_search", sp_internal_functions_hook, |
| 115 | PHP_FN(sp_array_search)); | 76 | PHP_FN(sp_array_search)); |
