From 7e14f65a8f5c791ac59b2121c3ff7a028f30d562 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Thu, 30 Nov 2017 14:27:11 +0100 Subject: Minor refactoring and clarification --- src/sp_execute.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/sp_execute.c') 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) { } } -static void is_builtin_matching(const char * const filename, char* function_name, - char *param_name, sp_node_t *config) { +static void is_builtin_matching(const char * restrict const filename, + char* restrict function_name, char* restrict param_name, sp_node_t *config) { if (!config || !config->data) { return; } @@ -39,22 +39,22 @@ static void is_builtin_matching(const char * const filename, char* function_name } } +/* This function gets the filename in which `eval()` is called from, + * since it looks like "foo.php(1) : eval()'d code", so we're starting + * from the end of the string until the second closing parenthesis. */ char *get_eval_filename(const char *filename) { - size_t i = strlen(filename) - 1; + size_t i = strlen(filename); int count = 0; char *clean_filename = estrdup(filename); - //ghetto as fuck - //get the filename in which eval() is called from "foo.php(1) : eval()'d code" - while (i) { + while (i--) { if (clean_filename[i] == '(') { if (count == 1) { - clean_filename[i] = 0; - break; + clean_filename[i] = '\0'; + break; } count++; } - i--; } return clean_filename; } -- cgit v1.3