diff --git a/src/parsing/check_error/check_quote.c b/src/parsing/check_error/check_quote.c index b732784..f3d540b 100644 --- a/src/parsing/check_error/check_quote.c +++ b/src/parsing/check_error/check_quote.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/21 11:59:34 by adjoly #+# #+# */ -/* Updated: 2024/07/16 16:15:41 by adjoly ### ########.fr */ +/* Updated: 2024/07/17 17:14:35 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,6 +15,13 @@ #include "tokenizer.h" #include +char *go_to_nxt_quote(char *rl, t_quote quote_type) +{ + while (*rl && __is_quote(*rl) != quote_type) + rl++; + return (rl); +} + bool watch_quote(char *rl) { char *tmp; @@ -22,10 +29,10 @@ bool watch_quote(char *rl) tmp = rl; while (*tmp) { - if (__is_quote(*tmp) != FALSE) + if (*tmp == DOUBLE || *tmp == SINGLE) { - tmp = search_for_next_quote(tmp + 1, __is_quote(*tmp)); - if (!tmp) + tmp = go_to_nxt_quote(tmp + 1, __is_quote(*tmp)); + if (!*tmp) return (true); } tmp++; @@ -35,7 +42,7 @@ bool watch_quote(char *rl) bool check_quote(char *readline) { - if (watch_quote(readline)) + if (watch_quote(readline)) return (send_error_parsing("quote not closed")); return (false); } diff --git a/src/parsing/is_inquote.c b/src/parsing/is_inquote.c index 04736bd..b9cf4c9 100644 --- a/src/parsing/is_inquote.c +++ b/src/parsing/is_inquote.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/20 20:06:13 by adjoly #+# #+# */ -/* Updated: 2024/07/16 15:55:00 by adjoly ### ########.fr */ +/* Updated: 2024/07/17 16:20:46 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,17 +17,10 @@ char *search_for_next_quote(char *s, t_quote quote_type) { char *tmp; - t_quote o_quote; tmp = s; - if (quote_type == DOUBLE) - o_quote = SINGLE; - else if (quote_type == SINGLE) - o_quote = DOUBLE; - while (*tmp && __is_quote(*tmp) != quote_type && __is_quote(*tmp) != o_quote) + while (*tmp && __is_quote(*tmp) != quote_type) tmp++; - if (__is_quote(*tmp) != quote_type) - return (NULL); return (tmp); } diff --git a/src/parsing/is_quote.c b/src/parsing/is_quote.c index eace2bd..d16223a 100644 --- a/src/parsing/is_quote.c +++ b/src/parsing/is_quote.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/29 13:32:35 by adjoly #+# #+# */ -/* Updated: 2024/06/29 13:32:50 by adjoly ### ########.fr */ +/* Updated: 2024/07/17 17:08:41 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,6 +14,8 @@ t_quote __is_quote(char c) { + if (!c) + return (FALSE); if (c == SINGLE) return (SINGLE); if (c == DOUBLE) diff --git a/src/parsing/split_cmd.c b/src/parsing/split_cmd.c index 549ef7c..d99d87e 100644 --- a/src/parsing/split_cmd.c +++ b/src/parsing/split_cmd.c @@ -6,13 +6,16 @@ /* By: mmoussou + t_cmd *split_cmd(char *cmd_av, t_cmd *cmd) { char **split; @@ -24,5 +27,6 @@ t_cmd *split_cmd(char *cmd_av, t_cmd *cmd) if (!cmd->cmd) return (NULL); cmd->argv = split; + printf("%s\n", cmd->cmd); return (cmd); }