merge conflicts

This commit is contained in:
hugogogo
2021-12-10 10:29:45 +01:00
31 changed files with 470 additions and 139 deletions

View File

@@ -6,14 +6,12 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/07 02:01:33 by lperrey #+# #+# */
/* Updated: 2021/12/02 15:50:40 by hulamy ### ########.fr */
/* Updated: 2021/12/10 10:27:50 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
//t_list *ft_lstnew_generic(size_t lst_sizse, size_t content_size);
static t_list *ret_parameter_expansion(char *content, int *i);
t_list *expand_token(char *content)
@@ -101,9 +99,12 @@ static t_list *ret_parameter_expansion(char *content, int *i)
free(tmp);
if (expand->content)
expand->content = ft_strdup(expand->content);
else
expand->content = ft_calloc(1, 1);
if (!expand->content)
return (ft_retp_free(NULL, expand, free));
return (expand);
}
/*
environment variables must be POSIX NAME :
3.235 Name
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html
#tag_03_235
*/

View File

@@ -6,14 +6,12 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/07 02:01:33 by lperrey #+# #+# */
/* Updated: 2021/12/02 15:50:46 by hulamy ### ########.fr */
/* Updated: 2021/12/10 10:27:26 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
//t_list *ft_lstnew_generic(size_t lst_sizse, size_t content_size);
static t_token *insert_tokens(t_token *t, t_token *insert_lst);
int new_token_for_each_field(char **fields, t_token **t)
@@ -27,21 +25,16 @@ int new_token_for_each_field(char **fields, t_token **t)
i = 0;
while (fields[i])
{
if (fields[i][0])
{
insert_lst->next = (t_token *)ft_lstnew_generic(sizeof(t_token), 0);
insert_lst = insert_lst->next;
if (!insert_lst)
{//todo wrap
perror("insert_token_for_each_field() error");
ft_free_2d_arr(fields);
return ((int)ft_lstclear((t_list **)&head.next, NULL));
}
insert_lst->content = fields[i];
insert_lst->id = T_WORD;
insert_lst->next = ft_lstnew_generic(sizeof(t_token), 0);
insert_lst = insert_lst->next;
if (!insert_lst)
{//todo wrap
perror("insert_token_for_each_field() error");
ft_free_2d_arr(fields);
return ((int)ft_lstclear((t_list **)&head.next, NULL));
}
else
free(fields[i]);
insert_lst->content = fields[i];
insert_lst->id = T_WORD;
i++;
}
free(fields);

View File

@@ -18,12 +18,7 @@ char *rejoin_after_expand(t_list *expand_lst)
char *result;
head = expand_lst;
result = ft_calloc(1, 1);
if (!result)
{//todo wrap
perror("rejoin_after_expand() error");
return (ft_lstclear(&head, free));
}
result = NULL;
while (expand_lst)
{
result = ft_strjoinfree_s1(result, expand_lst->content);

View File

@@ -6,13 +6,12 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/07 02:01:33 by lperrey #+# #+# */
/* Updated: 2021/12/02 15:46:31 by hulamy ### ########.fr */
/* Updated: 2021/12/10 10:27:01 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
//t_list *ft_lstnew_generic(size_t lst_sizse, size_t content_size);
t_list *expand_token(char *content);
char *rejoin_after_expand(t_list *expand_lst);
int new_token_for_each_field(char **fields, t_token **t);

View File

@@ -6,7 +6,7 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/24 10:52:40 by lperrey #+# #+# */
/* Updated: 2021/12/05 14:02:10 by hulamy ### ########.fr */
/* Updated: 2021/12/10 10:26:31 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -78,7 +78,7 @@ t_cmd **parsing(t_token *token_list)
// Struct CMD fill
if (!pipeline_fill_argv(token_list, pipeline))
return (ft_retp_free(NULL, &pipeline, (t_free_f)free_pipeline));
// print_pipeline(pipeline);
//print_pipeline(pipeline);
return (pipeline);
}

View File

@@ -6,7 +6,7 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/11 18:46:43 by lperrey #+# #+# */
/* Updated: 2021/12/05 17:42:35 by hulamy ### ########.fr */
/* Updated: 2021/12/10 10:25:54 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -25,9 +25,6 @@ int here_doc(char *delimiter)
and the here-document lines shall not be expanded.
Otherwise, the delimiter shall be the word itself. */
// TODO : A voir si on fait les expansions de variables dans le here_doc.
// implementer une gestion des signaux pour here_doc (verifier comportement bash et doc POSIX).
// Peut-être remplacer gnl() par readline() pour avoir une gestion correct
// du terminal (actuellement l'affichage lors du changement de ligne est foireux).
int here_doc;
int ret;
@@ -101,7 +98,7 @@ static int here_doc_write(char *delimiter, int doc_fd)
ft_putstr_fd(" delimited by end-of-file (wanted `", 2);
ft_putstr_fd(delimiter, 2);
ft_putstr_fd("')\n", 2);
return (-1);
return (0);
}
if (ft_strncmp(line, delimiter, ft_strlen(line) + 1) == 0) // Ou ft_strlen(delimiter) + 1 ? Ça devrais être identique et ça peux se calculer une seul fois.
break ;

View File

@@ -6,7 +6,7 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/11 18:46:43 by lperrey #+# #+# */
/* Updated: 2021/12/05 14:00:22 by hulamy ### ########.fr */
/* Updated: 2021/12/10 10:25:34 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -37,7 +37,7 @@ int redirections(t_token *t, t_cmd **pipeline)
return (0);
}
}
else if (t->id == '|')
if (t->id == '|')
i++;
t = t->next;
}
@@ -72,7 +72,10 @@ static int redirect_cmd_input(t_token *t, t_cmd *cmd)
cmd->error = EXIT_REDIRECTION;
}
else if (cmd->fd_in > EXIT_SIGNAL)
{
cmd->fd_in = 0;
return (0);
}
}
return (1);
}