summaryrefslogtreecommitdiff
path: root/src/sp_execute.c
diff options
context:
space:
mode:
authorjvoisin2017-11-30 14:27:11 +0100
committerjvoisin2017-11-30 14:27:11 +0100
commit7e14f65a8f5c791ac59b2121c3ff7a028f30d562 (patch)
treec6be72bc6734089ac659db0a561586adc5373c11 /src/sp_execute.c
parent4f1dc0debc8eb7be9d1ed498f0b8dd64021662e7 (diff)
Minor refactoring and clarification
Diffstat (limited to 'src/sp_execute.c')
-rw-r--r--src/sp_execute.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/sp_execute.c b/src/sp_execute.c
index 086d769..cd9ee99 100644
--- a/src/sp_execute.c
+++ b/src/sp_execute.c
@@ -28,8 +28,8 @@ ZEND_COLD static inline void terminate_if_writable(const char *filename) {
28 } 28 }
29} 29}
30 30
31static void is_builtin_matching(const char * const filename, char* function_name, 31static void is_builtin_matching(const char * restrict const filename,
32 char *param_name, sp_node_t *config) { 32 char* restrict function_name, char* restrict param_name, sp_node_t *config) {
33 if (!config || !config->data) { 33 if (!config || !config->data) {
34 return; 34 return;
35 } 35 }
@@ -39,22 +39,22 @@ static void is_builtin_matching(const char * const filename, char* function_name
39 } 39 }
40} 40}
41 41
42/* This function gets the filename in which `eval()` is called from,
43 * since it looks like "foo.php(1) : eval()'d code", so we're starting
44 * from the end of the string until the second closing parenthesis. */
42char *get_eval_filename(const char *filename) { 45char *get_eval_filename(const char *filename) {
43 size_t i = strlen(filename) - 1; 46 size_t i = strlen(filename);
44 int count = 0; 47 int count = 0;
45 char *clean_filename = estrdup(filename); 48 char *clean_filename = estrdup(filename);
46 49
47 //ghetto as fuck 50 while (i--) {
48 //get the filename in which eval() is called from "foo.php(1) : eval()'d code"
49 while (i) {
50 if (clean_filename[i] == '(') { 51 if (clean_filename[i] == '(') {
51 if (count == 1) { 52 if (count == 1) {
52 clean_filename[i] = 0; 53 clean_filename[i] = '\0';
53 break; 54 break;
54 } 55 }
55 count++; 56 count++;
56 } 57 }
57 i--;
58 } 58 }
59 return clean_filename; 59 return clean_filename;
60} 60}