diff options
| author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-01 18:39:30 +0200 | 
|---|---|---|
| committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-01 18:39:30 +0200 | 
| commit | 93ec22714f7021e874e5418d1f5743ccdd258cdc (patch) | |
| tree | 605a9b5dbcbc5d050bb457fb142dc1c84e1d97bb | |
| parent | Added quotes multiline (diff) | |
| download | 42-minishell-93ec22714f7021e874e5418d1f5743ccdd258cdc.tar.gz 42-minishell-93ec22714f7021e874e5418d1f5743ccdd258cdc.tar.bz2 42-minishell-93ec22714f7021e874e5418d1f5743ccdd258cdc.tar.xz 42-minishell-93ec22714f7021e874e5418d1f5743ccdd258cdc.tar.zst 42-minishell-93ec22714f7021e874e5418d1f5743ccdd258cdc.zip | |
Better, removed debug printf
Diffstat (limited to '')
| -rw-r--r-- | src/m_loop_next.c | 32 | 
1 files changed, 24 insertions, 8 deletions
| diff --git a/src/m_loop_next.c b/src/m_loop_next.c index 22eadba..d6c085e 100644 --- a/src/m_loop_next.c +++ b/src/m_loop_next.c @@ -80,7 +80,6 @@ static char  			ft_strlen(counter_line) + 1);  	}  	ft_memdel((void*)&counter_line); -	ft_printf("[%s]\n", line);  	return (line);  } @@ -142,23 +141,40 @@ char  	return (line);  } -char -	*m_check_multi_quotes(int32_t fd, char line[], t_msh *msh) +static void +	m_set_q_arr(size_t q[], char line[])  {  	char	*ptr; -	size_t	q[2];  	q[0] = 0;  	q[1] = 0;  	ptr = line;  	while (*ptr != C_NULL)  	{ -		if (*ptr == C_SQUOTE && *(ptr - 1) != C_BACKSLASH) -			q[0] += 1; -		else if (*ptr == C_DQUOTE && *(ptr - 1) != C_BACKSLASH) -			q[1] += 1; +		if (*ptr == C_SQUOTE) +		{ +			if (*(ptr - 1) != C_BACKSLASH) +				q[0] += 1; +			else if (*(ptr - 2) == C_BACKSLASH) +				q[0] += 1; +		} +		else if (*ptr == C_DQUOTE) +		{ +			if (*(ptr - 1) != C_BACKSLASH) +				q[1] += 1; +			else if (*(ptr - 2) == C_BACKSLASH) +				q[1] += 1; +		}  		ptr++;  	} +} + +char +	*m_check_multi_quotes(int32_t fd, char line[], t_msh *msh) +{ +	size_t	q[2]; + +	m_set_q_arr(q, line);  	if (q[0] % 2 == 1 || q[1] % 2 == 1)  	{  		line = m_counter_line_quotes(fd, 2, line, msh); | 
