diff options
| -rw-r--r-- | src/p_args_escape.c | 49 | 
1 files changed, 22 insertions, 27 deletions
| diff --git a/src/p_args_escape.c b/src/p_args_escape.c index de00861..d878004 100644 --- a/src/p_args_escape.c +++ b/src/p_args_escape.c @@ -16,7 +16,10 @@  #include "d_define.h"  #include "u_utils.h" -static t_quote_mode	p_escape_squote(char *ptr, char **p, char word[], t_quote_mode mode) +static t_quote_mode	p_escape_squote(char *ptr, +									char **p, +									char word[], +									t_quote_mode mode)  {  	if (mode == Q_NONE)  	{ @@ -42,7 +45,10 @@ static t_quote_mode	p_escape_squote(char *ptr, char **p, char word[], t_quote_mo  	return (mode);  } -static t_quote_mode	p_escape_dquote(char *ptr, char **p, char word[], t_quote_mode mode) +static t_quote_mode	p_escape_dquote(char *ptr, +									char **p, +									char word[], +									t_quote_mode mode)  {  	if (mode == Q_NONE)  	{ @@ -109,39 +115,28 @@ static void			p_escape_arg(char word[])  	}  } -static void			p_replace_bs(char *ptr) -{ -	char	*head; - -	head = ptr; -	while (*ptr != C_NUL) -	{ -		if (*ptr == C_SUB && *(ptr + 1) == C_SUB) -		{ -			(void)ft_memmove(head + (ptr - head), ptr + 1, -				(ft_strlen(ptr + 1) + 1) * sizeof(char)); -			*ptr = C_BACKS; -		} -		ptr++; -	} -} - -/* -** TODO: escape \ -** TODO: escape $# special vars -** TODO: comments ################ -** TODO: escape my life -*/ -  void				p_args_escape_chars_and_quotes(char *words[])  {  	char	**ptr; +	char	*head; +	char	*rptr;  	ptr = words;  	while (*ptr != NULL)  	{  		p_escape_arg(*ptr); -		p_replace_bs(*ptr); +		rptr = *ptr; +		head = rptr; +		while (*rptr != C_NUL) +		{ +			if (*rptr == C_SUB && *(rptr + 1) == C_SUB) +			{ +				(void)ft_memmove(head + (rptr - head), rptr + 1, +								 (ft_strlen(rptr + 1) + 1) * sizeof(char)); +				*rptr = C_BACKS; +			} +			rptr++; +		}  		ptr++;  	}  } | 
