From 0af303d89512878da72696c4d78f9e16ede4f553 Mon Sep 17 00:00:00 2001 From: tomoron Date: Mon, 6 May 2024 16:29:27 +0200 Subject: [PATCH] fix infinite loop --- srcs/parsing.c | 9 ++------- srcs/parsing_var.c | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/srcs/parsing.c b/srcs/parsing.c index ff30538..af29897 100755 --- a/srcs/parsing.c +++ b/srcs/parsing.c @@ -6,16 +6,11 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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]; diff --git a/srcs/parsing_var.c b/srcs/parsing_var.c index 5132404..1a6b04c 100755 --- a/srcs/parsing_var.c +++ b/srcs/parsing_var.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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;