diff --git a/.cmds.c.swp b/.cmds.c.swp deleted file mode 100644 index 295d899..0000000 Binary files a/.cmds.c.swp and /dev/null differ diff --git a/cmds.c b/cmds.c index a91d382..037b60e 100644 --- a/cmds.c +++ b/cmds.c @@ -6,7 +6,7 @@ /* By: cchauvet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/02/02 14:39:56 by erey-bet #+# #+# */ -/* Updated: 2023/02/16 16:24:21 by cchauvet ### ########.fr */ +/* Updated: 2023/02/17 13:05:29 by erey-bet ### ########.fr */ /* */ /* ************************************************************************** */ @@ -205,7 +205,8 @@ int set_value_by_key(char *key, char *value, t_list **head) int create_value_by_key(char *key, char *value, t_list **head) { - t_env *content; + t_env *content; + if (set_value_by_key(key, value, head) == 0) return (0); content = ft_calloc(1, sizeof(t_env)); @@ -217,6 +218,25 @@ int create_value_by_key(char *key, char *value, t_list **head) return (0); } +char **env_to_strs(t_list **head) +{ + t_list *current; + t_env *content; + char **env; + int i; + + current = *head; + env = ft_calloc(ft_lstsize(*head), sizeof(char *)); + i = 0; + while (current->content) + { + content = current->content; + env[i++] = ft_strmerger(3, content->key, "=", content->value); + current = current->next; + } + return (env); +} + t_list **init_env(char **env) { t_list **head; @@ -241,3 +261,12 @@ t_list **init_env(char **env) } return (head); } + +/*int main(int argc, char *argv[], char **env) +{ + t_list **new; + + new = init_env(env); + ft_printf("%S", env_to_strs(new)); + return (0); +}*/ diff --git a/infile.c b/infile.c index c0e09ce..74af6c7 100644 --- a/infile.c +++ b/infile.c @@ -6,7 +6,7 @@ /* By: cchauvet ') { ft_eprintf("minishell: %s: must be followed by an infile\n", tab[i]); + ft_freer_tab_ultimate(1, tab); return (0); } ft_freer_tab_ultimate(1, tab); diff --git a/syntatics.c b/syntatics.c index 067979c..5c7e255 100644 --- a/syntatics.c +++ b/syntatics.c @@ -71,7 +71,8 @@ static int ft_special_char_dub(const char *str) } i = i + y; } - i++; + else + i++; } return (0); }