From a0ba5acfc412f1e684bf6aa56353d682c715394c Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Fri, 2 Oct 2020 21:12:28 +0200 Subject: Update --- Makefile | 1 + src/p_lblock_next.c | 20 -------------------- src/p_lblock_next.h | 11 +++++------ src/p_subst_home.c | 39 +++++++++++++++++++++++++++++++++++++++ src/p_subst_home.h | 20 ++++++++++++++++++++ src/s_com.c | 1 + 6 files changed, 66 insertions(+), 26 deletions(-) create mode 100644 src/p_subst_home.c create mode 100644 src/p_subst_home.h diff --git a/Makefile b/Makefile index e5dde07..4b77b31 100644 --- a/Makefile +++ b/Makefile @@ -80,6 +80,7 @@ SRCS_NAME += p_lblock_more SRCS_NAME += p_redirs SRCS_NAME += p_redirs_heredoc SRCS_NAME += p_split +SRCS_NAME += p_subst_home SRCS_NAME += u_alias SRCS_NAME += u_parse SRCS_NAME += u_path diff --git a/src/p_lblock_next.c b/src/p_lblock_next.c index 03d7f80..d964f11 100644 --- a/src/p_lblock_next.c +++ b/src/p_lblock_next.c @@ -191,26 +191,6 @@ size_t p_subst_alias(char word[], t_bool reset, t_msh *msh) return (0); } -char **p_subst_home(char *words[], t_msh *msh) -{ - char path[PATH_MAX]; - char **ptr; - - u_get_var_value(path, "$HOME", PATH_MAX, msh); - if (path[0] == C_NUL) - return (words); - ptr = words; - while (*ptr != NULL) - { - if (*ptr[0] == '~') - { - *ptr = ft_strsubst(*ptr, "~", path); - } - ptr++; - } - return (words); -} - static char **p_alloc_rewords(char *words[], int64_t j, t_msh *msh) { char **rewords; diff --git a/src/p_lblock_next.h b/src/p_lblock_next.h index 4ffdfcf..7af7881 100644 --- a/src/p_lblock_next.h +++ b/src/p_lblock_next.h @@ -10,18 +10,17 @@ /* */ /* ************************************************************************** */ -#ifndef P_LCOM_NEXT_H -#define P_LCOM_NEXT_H +#ifndef FT_P_LCOM_NEXT_H +# define FT_P_LCOM_NEXT_H -#include -#include +# include +# include -#include "s_struct.h" +# include "s_struct.h" void p_subst_vars(char word[], t_msh *msh); size_t p_subst_alias(char word[], t_bool reset, t_msh *msh); char **p_subst_args(const char word[], int8_t redir); -char **p_subst_home(char *word[], t_msh *msh); char **p_check_args_equals(char *words[], t_msh *msh); #endif diff --git a/src/p_subst_home.c b/src/p_subst_home.c new file mode 100644 index 0000000..ee9ed42 --- /dev/null +++ b/src/p_subst_home.c @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* p_subst_home.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include +#include + +#include "d_define.h" +#include "s_struct.h" +#include "u_vars.h" + +char **p_subst_home(char *words[], t_msh *msh) +{ + char path[PATH_MAX]; + char **ptr; + + u_get_var_value(path, "$HOME", PATH_MAX, msh); + if (path[0] == C_NUL) + return (words); + ptr = words; + while (*ptr != NULL) + { + if (*ptr[0] == '~') + { + *ptr = ft_strsubst(*ptr, "~", path); + } + ptr++; + } + return (words); +} diff --git a/src/p_subst_home.h b/src/p_subst_home.h new file mode 100644 index 0000000..59f1f00 --- /dev/null +++ b/src/p_subst_home.h @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* p_subst_home.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_P_SUBST_HOME_H +# define FT_P_SUBST_HOME_H + +#include "s_struct.h" + +char **p_subst_home(char *word[], t_msh *msh); + +#endif diff --git a/src/s_com.c b/src/s_com.c index 4f06c84..84e0f35 100644 --- a/src/s_com.c +++ b/src/s_com.c @@ -19,6 +19,7 @@ #include "p_args.h" #include "p_lblock.h" #include "p_lblock_next.h" +#include "p_subst_home.h" #include "p_redirs.h" #include "s_lredir.h" #include "s_struct.h" -- cgit v1.2.3