diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-07-27 21:19:29 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-07-27 21:19:29 +0200 |
commit | 004eef9a3fd3403d6634ca658336d9a1e9766685 (patch) | |
tree | 571cd00a9719c9174f0e5ad09f57585a6bd87e86 /src | |
parent | I couldn't see shit (diff) | |
download | 42-minishell-004eef9a3fd3403d6634ca658336d9a1e9766685.tar.gz 42-minishell-004eef9a3fd3403d6634ca658336d9a1e9766685.tar.bz2 42-minishell-004eef9a3fd3403d6634ca658336d9a1e9766685.tar.xz 42-minishell-004eef9a3fd3403d6634ca658336d9a1e9766685.tar.zst 42-minishell-004eef9a3fd3403d6634ca658336d9a1e9766685.zip |
In progress
Diffstat (limited to 'src')
-rw-r--r-- | src/b_cd.c | 4 | ||||
-rw-r--r-- | src/p_lcom_next.c | 2 | ||||
-rw-r--r-- | src/u_vars.c | 10 | ||||
-rw-r--r-- | src/u_vars.h | 2 | ||||
-rw-r--r-- | src/u_vars_next.c | 30 | ||||
-rw-r--r-- | src/u_vars_next.h | 21 |
6 files changed, 60 insertions, 9 deletions
@@ -33,7 +33,7 @@ static void if (!ft_strncmp("~/", *path, 2) || !ft_strncmp("~", *path, 2)) { if (!(*path = ft_strsubst(*path, - "~", subst_var_value("$HOME", msh)))) + "~", get_var_value("$HOME", msh)))) { s_destroy(msh); fail_alloc(msh); @@ -55,7 +55,7 @@ uint8_t } else if (argc == 0) { - if (!(path = subst_var_value("$HOME", msh))) + if (!(path = get_var_value("$HOME", msh))) return (1); } else diff --git a/src/p_lcom_next.c b/src/p_lcom_next.c index 94ac9bf..a4fbb61 100644 --- a/src/p_lcom_next.c +++ b/src/p_lcom_next.c @@ -34,7 +34,7 @@ static int8_t varlen += 1; if (!(s_varname = ft_substr(*p_words, (uint32_t)i, varlen - i))) return (-1); - varval = subst_var_value(s_varname, msh); + varval = get_var_value(s_varname, msh); *p_words = ft_strsubst(*p_words, s_varname, varval); ft_memdel((void*)&s_varname); ft_memdel((void*)&varval); diff --git a/src/u_vars.c b/src/u_vars.c index 3f3a1a5..2b7fc4a 100644 --- a/src/u_vars.c +++ b/src/u_vars.c @@ -123,11 +123,11 @@ static char } /* -** char * -** subst_var_value(const char varname[], const t_msh *msh); +** char* +** get_var_value(const char varname[], t_msh *msh); ** ** DESCRIPTION -** The subst_var_value() function returns +** The get_var_value() function returns ** a heap-allocated, null-terminated string ** that may later be free'd containing the ** value of the variable varname[] including @@ -136,8 +136,8 @@ static char */ char - *subst_var_value(const char varname[], - t_msh *msh) + *get_var_value(const char varname[], + t_msh *msh) { /* TODO: check behaviour on empty vars -> "QWE=" */ /* TODO: add support for global variables -> "$hey $nigga..." */ diff --git a/src/u_vars.h b/src/u_vars.h index 686a9b5..cad825c 100644 --- a/src/u_vars.h +++ b/src/u_vars.h @@ -15,7 +15,7 @@ #include "s_struct.h" -char *subst_var_value(const char varname[], +char *get_var_value(const char varname[], t_msh *msh); #endif diff --git a/src/u_vars_next.c b/src/u_vars_next.c new file mode 100644 index 0000000..5626376 --- /dev/null +++ b/src/u_vars_next.c @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* u_vars_next.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include "s_struct.h" +/* +** void +** subst_var_value(const char varname[], t_msh *msh); +** +** DESCRIPTION +** The subst_var_value() changes the msh->envp value +** of the variable varname[]. If varname[] wasn't found +** in msh->envp, varname[] is searched in msh->vars. +*/ + +void + subst_var_value(const char varname[], + t_msh *msh) +{ + (void)varname; + (void)msh; +} diff --git a/src/u_vars_next.h b/src/u_vars_next.h new file mode 100644 index 0000000..1360190 --- /dev/null +++ b/src/u_vars_next.h @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* u_vars_next.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef U_VARS_NEXT_H +#define U_VARS_NEXT_H + +#include "s_struct.h" + +void subst_var_value(const char varname[], + t_msh *msh) + +#endif |