diff --git a/includes/parsing.h b/includes/parsing.h index 35095fa..5f0a80a 100644 --- a/includes/parsing.h +++ b/includes/parsing.h @@ -6,7 +6,7 @@ /* By: mcomin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/01/30 07:27:45 by mcomin #+# #+# */ -/* Updated: 2026/03/24 03:39:37 by mcomin ### ########.fr */ +/* Updated: 2026/03/24 04:43:26 by mcomin ### ########.fr */ /* */ /* ************************************************************************** */ @@ -56,5 +56,6 @@ int strmatch(char *pattern, char *name); char *get_matching(char *pattern, char **elements); char *get_rand_numbers(int n); char *reload_input_tab(char *input); +int check_count_redir(char *input); #endif \ No newline at end of file diff --git a/src/parse/check.c b/src/parse/check.c index 61e233c..5f3d8e4 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -6,12 +6,31 @@ /* By: mcomin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/03/10 02:59:44 by mcomin #+# #+# */ -/* Updated: 2026/03/24 03:39:57 by mcomin ### ########.fr */ +/* Updated: 2026/03/24 04:44:00 by mcomin ### ########.fr */ /* */ /* ************************************************************************** */ #include "parsing.h" +int check_count_redir(char *input) +{ + int i; + int count; + + i = 0; + count = 0; + while (input[i] == input[0]) + { + count++; + i++; + if (count > 2) + return (-1); + } + if (input[i] != input[0] && input[i] != ' ') + return (-1); + return (i); +} + char *reload_input_tab(char *input) { char *new_input; diff --git a/src/parse/error.c b/src/parse/error.c index 72136b2..12627fb 100644 --- a/src/parse/error.c +++ b/src/parse/error.c @@ -6,7 +6,7 @@ /* By: mcomin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/02/04 01:46:10 by mcomin #+# #+# */ -/* Updated: 2026/03/24 04:06:46 by mcomin ### ########.fr */ +/* Updated: 2026/03/24 04:44:12 by mcomin ### ########.fr */ /* */ /* ************************************************************************** */ @@ -88,19 +88,16 @@ int check_redirections(char *input) { if (!input[i]) break ; - if (is_redir(input + i) && !is_in_quotes(input, i)) + if ((input[i] == '>' || input[i] == '<') && !is_in_quotes(input, i)) { - if ((input[i] == '>' || input[i] == '<') - && input[i] == input[i + 1]) - i += 2; - else - i += 1; + i = check_count_redir(input + i); + if (i == -1) + return (1); while (input[i] && ft_isspace(input[i])) i++; - if (!input[i] || is_redir(input + i) || input[i] == '|') + if (!input[i] || (input[i] == '>' || input[i] == '<') + || input[i] == '|') return (1); - while (input[i] && !ft_isspace(input[i]) && !is_redir(input + i)) - i++; } else i++; diff --git a/test b/test deleted file mode 100644 index 806c4a7..0000000 --- a/test +++ /dev/null @@ -1,9 +0,0 @@ -build -includes -libs -Makefile -minishell -Readme.md -src -test -valgrind_supp