From 8e40323db9715621d8ab45ff6d943c2eeba46ea0 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Mon, 14 Sep 2020 20:48:50 +0200 Subject: Removing path hash table, replacing it by brute force search --- src/eval/exec.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'src/eval/exec.c') diff --git a/src/eval/exec.c b/src/eval/exec.c index e8e13e1..f733c34 100644 --- a/src/eval/exec.c +++ b/src/eval/exec.c @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:06:11 by charles #+# #+# */ -/* Updated: 2020/09/14 17:20:50 by charles ### ########.fr */ +/* Updated: 2020/09/14 19:48:49 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,7 +31,6 @@ int exec_path_check(char *exec_path) return (errorf_ret(127, "%s: %s\n", exec_path, strerror(errno))); if (S_ISDIR(statbuf.st_mode)) return (errorf_ret(126, "%s: Is a directory\n", exec_path)); - // if (!(statbuf.st_mode & 0444)) return (errorf_ret(126, "%s: %s\n", exec_path, strerror(EACCES))); return (0); @@ -45,20 +44,22 @@ int exec_path_check(char *exec_path) ** \return Executable path or NULL if not found or path update error */ -int exec_search_path(t_path path, char *path_var, char *exec_name, char **exec_path) -{ - if (ft_strchr(exec_name, '/') != NULL) // TODO test recursive link - { - *exec_path = exec_name; - return (0); - } - // TODO if PATH contain empty path, consider current directory files as cmd - if ((*exec_path = ft_htget(path, exec_name)) == NULL) - { - if (path_update(path, path_var) == NULL) // optimise by not updating not changed path in ht - return (EVAL_FATAL); // FIXME need to distiguish between malloc error and cmd not found error - if ((*exec_path = ft_htget(path, exec_name)) == NULL) - return (127); - } - return (0); -} +/* int exec_search_path(t_path path, char *path_var, char *exec_name, char **exec_path) */ +/* { */ +/* if (ft_strchr(exec_name, '/') != NULL) // TODO test recursive link */ +/* { */ +/* *exec_path = exec_name; */ +/* return (0); */ +/* } */ +/* if (path_var == NULL) */ +/* return (127); */ +/* // TODO if PATH contain empty path, consider current directory files as cmd */ +/* if ((*exec_path = ft_htget(path, exec_name)) == NULL) */ +/* { */ +/* if (path_update(path, path_var) == NULL) */ +/* return (EVAL_FATAL); */ +/* if ((*exec_path = ft_htget(path, exec_name)) == NULL) */ +/* return (127); */ +/* } */ +/* return (0); */ +/* } */ -- cgit