diff options
| author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-08-03 17:26:41 +0200 | 
|---|---|---|
| committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-08-03 17:26:41 +0200 | 
| commit | 1886374416e5dc436db68e3518603258ae32bac0 (patch) | |
| tree | 06a7ae626521205dcbf921ef90f12dda7600cc14 /src | |
| parent | Changed function name (diff) | |
| download | 42-minishell-1886374416e5dc436db68e3518603258ae32bac0.tar.gz 42-minishell-1886374416e5dc436db68e3518603258ae32bac0.tar.bz2 42-minishell-1886374416e5dc436db68e3518603258ae32bac0.tar.xz 42-minishell-1886374416e5dc436db68e3518603258ae32bac0.tar.zst 42-minishell-1886374416e5dc436db68e3518603258ae32bac0.zip | |
Splitted var
Diffstat (limited to '')
| -rw-r--r-- | src/b_export.c | 1 | ||||
| -rw-r--r-- | src/b_export_next.c | 31 | ||||
| -rw-r--r-- | src/b_export_next.h | 7 | 
3 files changed, 36 insertions, 3 deletions
| diff --git a/src/b_export.c b/src/b_export.c index fc1657e..7aeed93 100644 --- a/src/b_export.c +++ b/src/b_export.c @@ -89,7 +89,6 @@ uint8_t  	const uint64_t	argc = u_builtins_get_argc((const char**)args);  	char			**ptr;  	char			*varval; -	/* char			*varname; */  	char			fmt[255];  	t_bool			next;  	uint8_t			r; diff --git a/src/b_export_next.c b/src/b_export_next.c index 2641f65..f0bb804 100644 --- a/src/b_export_next.c +++ b/src/b_export_next.c @@ -11,13 +11,40 @@  /* ************************************************************************** */  #include <libft.h> +#include <stdlib.h> +#include "b_export_next.h" +#include "f_fail.h"  #include "s_struct.h" +static char +	**b_get_var(const char arg[], +				t_msh *msh) +{ +	size_t	len; +	char	**var; + +	if ((var = (char**)malloc(3 * sizeof(char*))) == NULL) +		f_fail_alloc_and_destroy(msh); +	len = 0; +	while (arg[len] != '=' && arg[len] != '\0') +		len++; +	len += 1; +	if ((var[FT_VAR_NAME] = (char*)malloc((len) * sizeof(char))) == NULL) +		f_fail_alloc_and_destroy(msh); +	ft_strlcpy(var[FT_VAR_NAME], arg, len); +	if ((var[FT_VAR_VAL] = ft_strdup(arg + len)) == NULL) +		f_fail_alloc_and_destroy(msh); +	var[FT_VAR_NULL] = NULL; +	return (var); +} +  void  	b_export_with_equals(const char arg[],  						t_msh *msh)  { -	(void)arg; -	(void)msh; +	char	**var; + +	var = b_get_var(arg, msh); +	ft_delwords(var);  } diff --git a/src/b_export_next.h b/src/b_export_next.h index 8df8746..c9d53ea 100644 --- a/src/b_export_next.h +++ b/src/b_export_next.h @@ -15,6 +15,13 @@  #include "s_struct.h" +enum +{ +	FT_VAR_NAME, +	FT_VAR_VAL, +	FT_VAR_NULL +}; +  void	b_export_with_equals(const char arg[], t_msh *msh);  #endif | 
