From f88be73e8b1d70b909aed809196b8234ce0897b1 Mon Sep 17 00:00:00 2001 From: Tanguy MAZE Date: Tue, 29 Jan 2019 18:26:04 +0100 Subject: [PATCH] realpath is in added realpath to libft removed local references to realpath --- includes/minishell.h | 4 +-- libft | 2 +- srcs/cmd_cd.c | 4 +-- srcs/ft_realpath.c | 69 -------------------------------------------- 4 files changed, 4 insertions(+), 75 deletions(-) delete mode 100644 srcs/ft_realpath.c diff --git a/includes/minishell.h b/includes/minishell.h index 7ba9f41..8289660 100644 --- a/includes/minishell.h +++ b/includes/minishell.h @@ -6,7 +6,7 @@ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/11/18 13:12:34 by tmaze #+# #+# */ -/* Updated: 2019/01/27 14:43:56 by tmaze ### ########.fr */ +/* Updated: 2019/01/29 18:23:45 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ @@ -47,6 +47,4 @@ int ft_isin(char *str, char c); char *check_path_slash(char *exec); char *check_path_dot(char *exec, t_list *env); -char *ft_realpath(char *r_path, char **a_path); - #endif diff --git a/libft b/libft index 19d3e23..4b44c49 160000 --- a/libft +++ b/libft @@ -1 +1 @@ -Subproject commit 19d3e23b743dc95d0301579d1c5a0b97b36695aa +Subproject commit 4b44c49fc6caa15379cd821f967e53462d4dc837 diff --git a/srcs/cmd_cd.c b/srcs/cmd_cd.c index fd75b72..e6c700b 100644 --- a/srcs/cmd_cd.c +++ b/srcs/cmd_cd.c @@ -6,7 +6,7 @@ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/01/07 16:44:40 by tmaze #+# #+# */ -/* Updated: 2019/01/28 16:53:32 by tmaze ### ########.fr */ +/* Updated: 2019/01/29 16:12:21 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ @@ -53,9 +53,9 @@ int cmd_cd_core(char *path, t_list **env, char opt) { t_envelem *pwd; char *oldpwd; + char *c_path; char *tmp; - opt = '\0'; if (check_path_slash_cd(path) == NULL) { put_error_cd(path, "invalid path"); diff --git a/srcs/ft_realpath.c b/srcs/ft_realpath.c deleted file mode 100644 index 242f97c..0000000 --- a/srcs/ft_realpath.c +++ /dev/null @@ -1,69 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_realpath.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: tmaze +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/01/27 14:42:35 by tmaze #+# #+# */ -/* Updated: 2019/01/28 15:32:44 by tmaze ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "minishell.h" - -char *ft_tabtopath(char **tab_path) -{ - size_t total_size; - size_t i; - char *ret; - - i = 0; - total_size = 0; - while (tab_path[i]) - total_size += ft_strlen(tab_path[i++]); - if ((ret = ft_strnew(total_size + i)) == NULL) - return (NULL); - i = 0; - while (tab_path[i]) - { - ft_strcat(ret, "/"); - ft_strcat(ret, tab_path[i++]); - } - return (ret); -} - -char *ft_realpath(char *r_path, char **a_path) -{ - char **tab_path; - size_t i; - size_t j; - int strcmp; - - i = 0; - if ((tab_path = ft_strsplit(r_path, '/')) == NULL) - return (NULL); - while (tab_path[i]) - { - if ((strcmp = ft_strcmp(tab_path[i], "..")) == 0 - || ft_strcmp(tab_path[i], ".") == 0) - { - j = i; - if (strcmp == 0 && i != 0) - i = i - 1; - ft_strdel(&(tab_path[i])); - if (strcmp == 0 && i != 0) - ft_strdel(&(tab_path[j])); - while (tab_path[++j]) - tab_path[j - ((strcmp == 0 && i != 0) ? 2 : 1)] = tab_path[j]; - if (strcmp == 0 && i != 0) - tab_path[j - 2] = NULL; - tab_path[j - 1] = NULL; - } - else - i++; - } - *a_path = ft_tabtopath(tab_path); - ft_del_words_tables(&tab_path); - return (*a_path); -}