diff options
Diffstat (limited to 'src/b_export_next.c')
-rw-r--r-- | src/b_export_next.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/b_export_next.c b/src/b_export_next.c index 1fc732e..3457f6d 100644 --- a/src/b_export_next.c +++ b/src/b_export_next.c @@ -21,8 +21,7 @@ #include "u_utils.h" #include "u_vars.h" -static char - **b_get_var(const char arg[], t_msh *msh) +static char **b_get_var(const char arg[], t_msh *msh) { size_t len; char **var; @@ -33,18 +32,17 @@ static char while (arg[len] != '=' && arg[len] != '\0') len++; len += 1; - if ((var[FT_VAR_NAME] = (char*)malloc((len + 1) * sizeof(char))) == NULL) + if ((var[B_VAR_NAME] = (char*)malloc((len + 1) * sizeof(char))) == NULL) f_alloc_and_destroy_msh(msh); - var[FT_VAR_NAME][0] = '$'; - ft_strlcpy(var[FT_VAR_NAME] + 1, arg, len); - if ((var[FT_VAR_VAL] = ft_strdup(arg + len)) == NULL) + var[B_VAR_NAME][0] = '$'; + ft_strlcpy(var[B_VAR_NAME] + 1, arg, len); + if ((var[B_VAR_VAL] = ft_strdup(arg + len)) == NULL) f_alloc_and_destroy_msh(msh); - var[FT_VAR_NULL] = NULL; + var[B_VAR_NULL] = NULL; return (var); } -static int64_t - b_is_it_in_env(const char varname[], t_msh *msh) +static int64_t b_is_it_in_env(const char varname[], t_msh *msh) { char **env_dup; size_t i; @@ -64,8 +62,7 @@ static int64_t return (-1); } -static void - b_add_to_env(const char arg[], t_msh *msh) +static void b_add_to_env(const char arg[], t_msh *msh) { size_t i; char **nenvp; @@ -89,8 +86,7 @@ static void msh->envp = nenvp; } -void - b_export_with_equals(const char arg[], t_msh *msh) +void b_export_with_equals(const char arg[], t_msh *msh) { char varval[4096]; char **var; @@ -98,18 +94,18 @@ void varval[0] = C_NUL; var = b_get_var(arg, msh); - if ((env_i = b_is_it_in_env(var[FT_VAR_NAME] + 1, msh)) != -1) + if ((env_i = b_is_it_in_env(var[B_VAR_NAME] + 1, msh)) != -1) { ft_memdel((void*)&msh->envp[env_i]); if ((msh->envp[env_i] = ft_strdup(arg)) == NULL) f_alloc_and_destroy_msh(msh); return ; } - u_get_custom_var(varval, var[FT_VAR_NAME], 4096, msh); + u_get_custom_var(varval, var[B_VAR_NAME], 4096, msh); if (varval[0] != C_NUL) { b_add_to_env(arg, msh); - lvars_delone(&msh->vars, var[FT_VAR_NAME] + 1); + lvars_delone(&msh->vars, var[B_VAR_NAME] + 1); } else { |