summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-10-03 17:15:43 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-10-03 17:15:43 +0200
commitcbea7dd672c5171464bc4cb82080fc728790362e (patch)
tree22a6c2f7141744eecc44156f25bdae5ddc90d59b /src
parentNormed u_vars (diff)
download42-minishell-cbea7dd672c5171464bc4cb82080fc728790362e.tar.gz
42-minishell-cbea7dd672c5171464bc4cb82080fc728790362e.tar.bz2
42-minishell-cbea7dd672c5171464bc4cb82080fc728790362e.tar.xz
42-minishell-cbea7dd672c5171464bc4cb82080fc728790362e.tar.zst
42-minishell-cbea7dd672c5171464bc4cb82080fc728790362e.zip
Normed u_vars_next
Diffstat (limited to 'src')
-rw-r--r--src/u_vars_next.c27
-rw-r--r--src/u_vars_next.h6
2 files changed, 14 insertions, 19 deletions
diff --git a/src/u_vars_next.c b/src/u_vars_next.c
index 2f23667..0eb8f8b 100644
--- a/src/u_vars_next.c
+++ b/src/u_vars_next.c
@@ -21,16 +21,15 @@
#include "u_parse.h"
#include "u_utils.h"
-static int64_t
- u_get_env_var_line(const char varname[], t_msh *msh)
+static int64_t u_get_env_var_line(const char varname[], t_msh *msh)
{
char **env_dup;
int64_t i;
env_dup = u_get_env_var_names(msh);
i = 0;
- while (env_dup[i] != NULL &&
- ft_strncmp(varname, env_dup[i], ft_strlen(env_dup[i]) + 1) != 0)
+ while (env_dup[i] != NULL
+ && ft_strncmp(varname, env_dup[i], ft_strlen(env_dup[i]) + 1) != 0)
{
i++;
}
@@ -42,14 +41,13 @@ static int64_t
return (i);
}
-static t_bool
- u_get_custom_var_existance(const char varname[], t_msh *msh)
+static t_bool u_get_custom_var_existance(const char varname[], t_msh *msh)
{
t_lvars *ptr;
ptr = msh->vars;
- while (ptr &&
- ft_strncmp(varname, ptr->name, ft_strlen(varname) + 1) != 0)
+ while (ptr != NULL
+ && ft_strncmp(varname, ptr->name, ft_strlen(varname) + 1) != 0)
{
ptr = ptr->next;
}
@@ -63,11 +61,6 @@ static t_bool
}
}
-/* static void */
-/* u_newval_subst(char newval_subst[], const char newval[]) */
-/* { */
-/* } */
-
/*
** void
** u_subst_var_value(const char varname[], const char newval[], t_msh *msh);
@@ -79,8 +72,11 @@ static t_bool
** varname[] is added to msh->vars.
*/
-void
- u_subst_var_value(const char varname[], const char newval[], t_msh *msh)
+/*
+** TODO: Handle malloc fail
+*/
+
+void u_subst_var_value(const char varname[], const char newval[], t_msh *msh)
{
char new_line_fmt[ARG_MAX];
int64_t env_line;
@@ -92,7 +88,6 @@ void
if ((msh->envp[env_line] = (char*)malloc((ft_strlen(new_line_fmt) + 1) *
sizeof(char))) == NULL)
{
- /* TODO: Handle this fail */
}
(void)ft_strlcpy(msh->envp[env_line],
new_line_fmt, ft_strlen(new_line_fmt) + 1);
diff --git a/src/u_vars_next.h b/src/u_vars_next.h
index 118451f..979e07a 100644
--- a/src/u_vars_next.h
+++ b/src/u_vars_next.h
@@ -10,10 +10,10 @@
/* */
/* ************************************************************************** */
-#ifndef U_VARS_NEXT_H
-#define U_VARS_NEXT_H
+#ifndef FT_U_VARS_NEXT_H
+# define FT_U_VARS_NEXT_H
-#include "s_struct.h"
+# include "s_struct.h"
void u_subst_var_value(const char varname[],
const char newval[],