Compare commits

..

No commits in common. "d4cead2b0f4aecca90a384bdd10f44dd95ab8826" and "6ecb66a60ecea865970c74a96bf40d08b7b743d4" have entirely different histories.

8 changed files with 10 additions and 42 deletions

BIN
.cmds.c.swp Normal file

Binary file not shown.

BIN
.env_fill.c.swp Normal file

Binary file not shown.

6
cmds.c
View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/15 14:17:26 by cchauvet #+# #+# */ /* Created: 2023/02/15 14:17:26 by cchauvet #+# #+# */
/* Updated: 2023/02/17 13:09:13 by cchauvet ### ########.fr */ /* Updated: 2023/02/17 13:06:35 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -101,8 +101,10 @@ static int ft_cmds_fill(t_list **cmds, t_list **env, const char *line)
return (0); return (0);
} }
t_list **ft_parse_cmds(char *line, t_list **env, int infile, int outfile) t_list **ft_parse_cmds(char *line, t_list **env)
{ {
int infile;
int outfile;
t_list **cmds; t_list **cmds;
cmds = malloc(sizeof(t_list *)); cmds = malloc(sizeof(t_list *));

31
env.c
View File

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */ /* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/02 14:39:56 by erey-bet #+# #+# */ /* Created: 2023/02/02 14:39:56 by erey-bet #+# #+# */
/* Updated: 2023/02/17 13:05:29 by erey-bet ### ########.fr */ /* Updated: 2023/02/16 16:24:21 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -206,7 +206,6 @@ int set_value_by_key(char *key, char *value, t_list **head)
int create_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) if (set_value_by_key(key, value, head) == 0)
return (0); return (0);
content = ft_calloc(1, sizeof(t_env)); content = ft_calloc(1, sizeof(t_env));
@ -218,25 +217,6 @@ int create_value_by_key(char *key, char *value, t_list **head)
return (0); 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 **init_env(char **env)
{ {
t_list **head; t_list **head;
@ -261,12 +241,3 @@ t_list **init_env(char **env)
} }
return (head); 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);
}*/

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/15 17:52:10 by cchauvet #+# #+# */ /* Created: 2023/02/15 17:52:10 by cchauvet #+# #+# */
/* Updated: 2023/02/17 13:19:09 by cchauvet ### ########.fr */ /* Updated: 2023/02/16 17:52:29 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -33,7 +33,6 @@ static int ft_infile_is_valid(const char *line)
if (tab[i][0] == '<') if (tab[i][0] == '<')
{ {
ft_eprintf("minishell: %s: must be followed by an infile\n", tab[i]); ft_eprintf("minishell: %s: must be followed by an infile\n", tab[i]);
ft_freer_tab_ultimate(1, tab);
return (0); return (0);
} }
ft_freer_tab_ultimate(1, tab); ft_freer_tab_ultimate(1, tab);

4
main.c
View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/16 15:16:14 by cchauvet #+# #+# */ /* Created: 2023/02/16 15:16:14 by cchauvet #+# #+# */
/* Updated: 2023/02/17 13:13:19 by cchauvet ### ########.fr */ /* Updated: 2023/02/17 13:05:54 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -45,7 +45,6 @@ int main(int ac, char **av, char **env)
ft_lstclear(data.env, env_del); ft_lstclear(data.env, env_del);
free(data.env); free(data.env);
free(line); free(line);
return (1);
} }
infile = ft_infile(line); infile = ft_infile(line);
if (infile == -2) if (infile == -2)
@ -54,7 +53,6 @@ int main(int ac, char **av, char **env)
ft_lstclear(data.env, env_del); ft_lstclear(data.env, env_del);
free(data.env); free(data.env);
free(line); free(line);
return (1);
} }
cmds = ft_parse_cmds(line, data.env, infile, outfile); cmds = ft_parse_cmds(line, data.env, infile, outfile);
if (cmds == NULL) if (cmds == NULL)

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/15 18:01:07 by cchauvet #+# #+# */ /* Created: 2023/02/15 18:01:07 by cchauvet #+# #+# */
/* Updated: 2023/02/17 13:19:46 by cchauvet ### ########.fr */ /* Updated: 2023/02/16 17:53:28 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -32,7 +32,6 @@ static int ft_outfile_is_valid(const char *line)
if (tab[i][0] == '>') if (tab[i][0] == '>')
{ {
ft_eprintf("minishell: %s: must be followed by an infile\n", tab[i]); ft_eprintf("minishell: %s: must be followed by an infile\n", tab[i]);
ft_freer_tab_ultimate(1, tab);
return (0); return (0);
} }
ft_freer_tab_ultimate(1, tab); ft_freer_tab_ultimate(1, tab);

View File

@ -71,7 +71,6 @@ static int ft_special_char_dub(const char *str)
} }
i = i + y; i = i + y;
} }
else
i++; i++;
} }
return (0); return (0);