srcs a la norme
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/11/13 07:08:40 by lperrey #+# #+# */
|
||||
/* Updated: 2021/11/26 21:27:10 by lperrey ### ########.fr */
|
||||
/* Updated: 2021/12/20 16:45:10 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -148,7 +148,7 @@ static void fill_arr(char const *s, char c, char **str_arr)
|
||||
if (s[i] && (s[i] != c || quote_state))
|
||||
str_arr[arr_i][char_i++] = s[i++];
|
||||
}
|
||||
str_arr[arr_i][char_i] = '\0'; //superflu si ft_calloc
|
||||
str_arr[arr_i][char_i] = '\0';
|
||||
arr_i++;
|
||||
}
|
||||
}
|
||||
@@ -159,7 +159,7 @@ static int quote_state_change(int *quote_state, const char *s)
|
||||
{
|
||||
if (*quote_state == IN_QUOTES)
|
||||
*quote_state = 0;
|
||||
else if (ft_strchr(&s[1], '\'')) // if closed quotes
|
||||
else if (ft_strchr(&s[1], '\''))
|
||||
*quote_state = IN_QUOTES;
|
||||
else
|
||||
return (0);
|
||||
@@ -169,7 +169,7 @@ static int quote_state_change(int *quote_state, const char *s)
|
||||
{
|
||||
if (*quote_state == IN_DQUOTES)
|
||||
*quote_state = 0;
|
||||
else if (ft_strchr(&s[1], '\"')) // if closed quotes
|
||||
else if (ft_strchr(&s[1], '\"'))
|
||||
*quote_state = IN_DQUOTES;
|
||||
else
|
||||
return (0);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/11/13 04:35:06 by lperrey #+# #+# */
|
||||
/* Updated: 2021/11/26 21:27:05 by lperrey ### ########.fr */
|
||||
/* Updated: 2021/12/20 16:29:27 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -44,7 +44,7 @@ static int quote_state_change(int *quote_state, const char *s)
|
||||
{
|
||||
if (*quote_state == IN_QUOTES)
|
||||
*quote_state = 0;
|
||||
else if (ft_strchr(&s[1], '\'')) // if closed quotes
|
||||
else if (ft_strchr(&s[1], '\''))
|
||||
*quote_state = IN_QUOTES;
|
||||
else
|
||||
return (0);
|
||||
@@ -54,7 +54,7 @@ static int quote_state_change(int *quote_state, const char *s)
|
||||
{
|
||||
if (*quote_state == IN_DQUOTES)
|
||||
*quote_state = 0;
|
||||
else if (ft_strchr(&s[1], '\"')) // if closed quotes
|
||||
else if (ft_strchr(&s[1], '\"'))
|
||||
*quote_state = IN_DQUOTES;
|
||||
else
|
||||
return (0);
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/11/26 19:02:27 by lperrey #+# #+# */
|
||||
/* Updated: 2021/11/26 20:48:11 by lperrey ### ########.fr */
|
||||
/* Updated: 2021/12/20 16:48:02 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
int set_last_exit_status(int new_value)
|
||||
int set_last_exit_status(int new_value)
|
||||
{
|
||||
static int last_exit_status = 0;
|
||||
|
||||
@@ -25,13 +25,3 @@ int get_last_exit_status(void)
|
||||
{
|
||||
return (set_last_exit_status(-1));
|
||||
}
|
||||
|
||||
/* void ALT_set_last_exit_status(int new_value, int *set_last_exit_status_ptr)
|
||||
{
|
||||
static int *last_exit_status_ptr = NULL;
|
||||
|
||||
if (set_last_exit_status_ptr)
|
||||
last_exit_status_ptr = set_last_exit_status_ptr;
|
||||
else if (new_value >= 0)
|
||||
*last_exit_status_ptr = new_value;
|
||||
} */
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/10/24 10:52:40 by lperrey #+# #+# */
|
||||
/* Updated: 2021/12/16 16:23:09 by lperrey ### ########.fr */
|
||||
/* Updated: 2021/12/20 16:22:13 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -20,20 +20,14 @@ t_cmd **parsing(t_token *token_list)
|
||||
|
||||
if (!valid_syntax(token_list))
|
||||
return (NULL);
|
||||
|
||||
// 2.9.1 - 1) Save Words
|
||||
save_redirections_words(token_list);
|
||||
// Struct CMD alloc
|
||||
pipeline = pipeline_alloc(1 + count_pipes(token_list));
|
||||
if (!pipeline)
|
||||
return (NULL);
|
||||
// 2.9.1 - 2) Expansion
|
||||
if (!expansions(token_list, pipeline))
|
||||
return (ft_retp_free(NULL, &pipeline, (t_free_f)free_pipeline));
|
||||
// 2.9.1 - 3) Redirection
|
||||
if (!redirections(token_list, pipeline))
|
||||
return (ft_retp_free(NULL, &pipeline, (t_free_f)free_pipeline));
|
||||
// Struct CMD fill
|
||||
if (!pipeline_fill_argv(token_list, pipeline))
|
||||
return (ft_retp_free(NULL, &pipeline, (t_free_f)free_pipeline));
|
||||
return (pipeline);
|
||||
@@ -44,7 +38,7 @@ void save_redirections_words(t_token *t)
|
||||
while (t)
|
||||
{
|
||||
if (t->id == '>' || t->id == T_DGREAT
|
||||
|| t->id == '<' || t->id == T_DLESS)
|
||||
|| t->id == '<' || t->id == T_DLESS)
|
||||
{
|
||||
t = t->next;
|
||||
t->id = T_REDIRECTION_WORD;
|
||||
|
||||
Reference in New Issue
Block a user