fix infinite loop
This commit is contained in:
@ -6,16 +6,11 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/09 15:26:01 by tomoron #+# #+# */
|
||||
/* Updated: 2024/05/06 10:58:08 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/05/06 16:26:35 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include "minishell.h"
|
||||
|
||||
int is_cmd_char(char c)
|
||||
{
|
||||
return (!ft_isspace(c) && c != '|' && c != '&' && c != '<' && c != '>');
|
||||
}
|
||||
|
||||
int add_home_to_str(char *res)
|
||||
{
|
||||
int i;
|
||||
@ -40,7 +35,7 @@ char *get_token(char **cmd, int quotes[2])
|
||||
while (ft_isspace(**cmd))
|
||||
(*cmd)++;
|
||||
res = ft_calloc(get_token_len(*cmd) + 1, 1);
|
||||
while (res && **cmd && (is_cmd_char(**cmd) || quotes[0] || quotes[1]))
|
||||
while (res && **cmd && (!ft_isspace(**cmd) || quotes[0] || quotes[1]))
|
||||
{
|
||||
if (**cmd == '"' && !quotes[0])
|
||||
quotes[1] = !quotes[1];
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/09 15:24:36 by tomoron #+# #+# */
|
||||
/* Updated: 2024/05/06 10:52:37 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/05/06 16:27:54 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -60,7 +60,7 @@ int get_token_len(char *command)
|
||||
in_quote = 0;
|
||||
in_dquote = 0;
|
||||
res = 0;
|
||||
while (*command && (is_cmd_char(*command) || in_quote || in_dquote))
|
||||
while (*command && (!ft_isspace(*command) || in_quote || in_dquote))
|
||||
{
|
||||
if (*command == '"' && !in_quote)
|
||||
in_dquote = !in_dquote;
|
||||
|
Reference in New Issue
Block a user