/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* m_loop_next.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ /* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include #include "d_define.h" #include "m_loop_counter.h" #include "m_loop_multis.h" #include "s_struct.h" #include "u_utils.h" char *m_check_multi_backslash(int32_t fd, char line[], t_msh *msh) { if (line[ft_strlen(line) - 1] == '\\') { line = m_counter_line_backslash(fd, 2, line, msh); line = m_check_multi_backslash(fd, line, msh); } return (line); } char *m_check_multi_pipe(int32_t fd, char line[], t_msh *msh) { char *pipe; if ((pipe = ft_strrchr(line, '|')) != NULL) { pipe += 1; while (*pipe != '\0') { if (ft_iswhitespace(*pipe) == FALSE) { return (line); } pipe++; } line = m_counter_line_pipes(fd, 2, line, msh); line = m_check_multi_backslash(fd, line, msh); line = m_check_multi_pipe(fd, line, msh); } return (line); } char *m_check_multi_and(int32_t fd, char line[], t_msh *msh) { char *and; if ((and = ft_strrchr(line, '&')) != NULL && *(and - 1) == '&') { and += 1; while (*and != '\0') { if (ft_iswhitespace(*and) == FALSE) { return (line); } and++; } line = m_counter_line_pipes(fd, 2, line, msh); line = m_check_multi_backslash(fd, line, msh); line = m_check_multi_pipe(fd, line, msh); line = m_check_multi_and(fd, line, msh); } return (line); }