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);