diff options
Diffstat (limited to '')
| -rw-r--r-- | src/ft_p_lcom.c | 12 | ||||
| -rw-r--r-- | src/ft_s_lcom.c | 22 | 
2 files changed, 18 insertions, 16 deletions
| diff --git a/src/ft_p_lcom.c b/src/ft_p_lcom.c index 9a4ebad..5890b0f 100644 --- a/src/ft_p_lcom.c +++ b/src/ft_p_lcom.c @@ -16,10 +16,11 @@  #include "ft_s_lcom.h"  #include "ft_s_struct.h" -/* void */ -/* 	ft_check_redir_file() */ -/* { */ -/* } */ +void +	ft_check_redir_file() +{ + +}  static void  	ft_rdr_err_check(char *ptr, @@ -59,7 +60,7 @@ static int8_t  		}  		ptr++;  	} -	*(p_rdrpath) = '\0'; +	*p_rdrpath = '\0';  	return (0);  } @@ -84,6 +85,7 @@ int8_t  		}  		ptr++;  		/* TODO: handle correctly multiples "msh ~> echo qwe > qwe > asd >> zxc > qweasdzxc" */ +		/* hint: bash only handles the last onke */  	}  	if ((*link)->redir != 0)  	{ diff --git a/src/ft_s_lcom.c b/src/ft_s_lcom.c index f469edb..b31f5e5 100644 --- a/src/ft_s_lcom.c +++ b/src/ft_s_lcom.c @@ -29,21 +29,22 @@ static int8_t  		return (-1);  	ft_strlcpy((*lcom)->com, words[0], ft_strlen(words[0]) + 1);  	while(words[i + 1]) +	{ +		if (ft_ischarset("<>", words[i + 1][0])) +			break ;  		i++; +	}  	if (!((*lcom)->args = (char**)malloc((i + 1) * sizeof(char*))))  			return (-1);  	j = 0; -	if (i > 0) +	while (i > 0 && j < i)  	{ -		while (j < i) -		{ -			if (!((*lcom)->args[j] = -				(char*)malloc((ft_strlen(words[j + 1]) + 1) * sizeof(char)))) -				return (-1); -			ft_strlcpy((*lcom)->args[j], words[j + 1], -				ft_strlen(words[j + 1]) + 1); -			j++; -		} +		if (!((*lcom)->args[j] = +			  (char*)malloc((ft_strlen(words[j + 1]) + 1) * sizeof(char)))) +			return (-1); +		ft_strlcpy((*lcom)->args[j], words[j + 1], +				   ft_strlen(words[j + 1]) + 1); +		j++;  	}  	(*lcom)->args[j] = 0;  	return (0); @@ -107,7 +108,6 @@ t_lcom  	link->com = NULL;  	link->args = NULL;  	link->rdrpath = NULL; -	/* TODO: redirections here */  	if (ft_get_redir(word, &link) != 0)  		return (NULL);  	if (!(words = ft_split(word, ' '))) | 
