diff --git a/execute/child.c b/execute/child.c index 53cd31e..f1202d2 100644 --- a/execute/child.c +++ b/execute/child.c @@ -6,7 +6,7 @@ /* By: wonyang +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/01/11 23:33:05 by wonyang #+# #+# */ -/* Updated: 2023/01/16 16:37:51 by wonyang ### ########seoul.kr */ +/* Updated: 2023/01/16 21:18:36 by wonyang ### ########seoul.kr */ /* */ /* ************************************************************************** */ @@ -86,7 +86,7 @@ static pid_t fork_child(t_tnode *cmd_node, int *before_fd) || (tmp != STDIN_FILENO && ft_dup2(tmp, STDIN_FILENO) == ERROR) || ft_dup2(fd[1], STDOUT_FILENO) == ERROR || child_execute(cmd_node) == ERROR) - return (0); + exit(1); } if ((tmp != STDIN_FILENO && close(tmp) == -1) || close(fd[1]) == -1) diff --git a/parsing/wildcard.c b/parsing/wildcard.c index 914fe54..14ed041 100644 --- a/parsing/wildcard.c +++ b/parsing/wildcard.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* wildcard.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jeongmin +#+ +:+ +#+ */ +/* By: wonyang +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/01/13 17:42:37 by jeongmin #+# #+# */ -/* Updated: 2023/01/16 20:55:23 by jeongmin ### ########.fr */ +/* Updated: 2023/01/16 21:51:53 by wonyang ### ########seoul.kr */ /* */ /* ************************************************************************** */ @@ -31,26 +31,26 @@ static t_token *make_node_token(char *line, t_ttype type) return (token); } -static bool match_wcard(char *pattern, char *dname) +static bool match_wcard(char *str, char *dname) { - int len_p; - int len_w; - int nth; + int str_len; + int d_len; + int i; int skip; - nth = 0; - len_p = ft_strlen(pattern); - len_w = ft_strlen(dname); - while (nth < len_p && nth < len_w && (pattern[nth] == dname[nth])) - nth++; - if (len_p == nth) - return (nth == len_w); - if (pattern[nth] == WILDCARD) + i = 0; + str_len = ft_strlen(str); + d_len = ft_strlen(dname); + while (i < str_len && i < d_len && (str[i] == dname[i])) + i++; + if (str_len == i) + return (i == d_len); + if (str[i] == WILDCARD) { skip = 0; - while (skip + nth <= len_w) + while (skip + i <= d_len) { - if (match_wcard(pattern + nth + 1, dname + skip + nth)) + if (match_wcard(str + i + 1, dname + skip + i)) return (true); skip += 1; }