int main(void) { char const *str[] = { "HKWEY", "HKWEY", "WKHYE", "WKHY", "YKHYE" }; t_lst *lst[5]; t_bool result; lst[0] = str_to_lst(str[0]); lst[1] = str_to_lst(str[1]); lst[2] = str_to_lst(str[2]); lst[3] = str_to_lst(str[3]); lst[4] = str_to_lst(str[4]); result = lst_same_contents(lst[0], lst[2], equ) && lst_same_contents(lst[1], lst[0], equ) && !lst_same_contents(lst[0], lst[3], equ) && !lst_same_contents(lst[0], lst[4], equ); f_lstdel(&lst[0], no_destroy); f_lstdel(&lst[1], no_destroy); f_lstdel(&lst[2], no_destroy); f_lstdel(&lst[3], no_destroy); f_lstdel(&lst[4], no_destroy); return (result ? EXIT_SUCCESS : EXIT_FAILURE); }
t_lex *parser(t_lex *lex) { t_lex *cursor; t_detail *det_error; t_lex *sep_error; cursor = lex; det_error = NULL; sep_error = NULL; while (cursor && !det_error) { if (!is_sep(cursor->str)) { if ((cursor->lst = str_to_lst(cursor->str)) == NULL) return (free_all(lex)); det_error = check_cmd_syntax(cursor->lst); if (!det_error && !(det_error = check_redir(cursor->lst))) assign_redir(cursor->lst, NULL, &det_error); } else cursor->lst = NULL; cursor = cursor->next; } if (det_error) return (free_all(lex)); sep_error = check_sep_syntax(lex); return (sep_error ? free_all(lex) : lex); }