├── Makefile ├── README.md ├── include ├── checker.h ├── data_struct.h ├── initialize.h ├── operator.h └── push_swap.h ├── lib ├── libft │ ├── Makefile │ ├── include │ │ └── libft.h │ └── src │ │ ├── ft_atoi.c │ │ ├── ft_bzero.c │ │ ├── ft_calloc.c │ │ ├── ft_isalnum.c │ │ ├── ft_isalpha.c │ │ ├── ft_isascii.c │ │ ├── ft_isdigit.c │ │ ├── ft_isprint.c │ │ ├── ft_itoa.c │ │ ├── ft_memchr.c │ │ ├── ft_memcmp.c │ │ ├── ft_memcpy.c │ │ ├── ft_memmove.c │ │ ├── ft_memset.c │ │ ├── ft_putchar_fd.c │ │ ├── ft_putendl_fd.c │ │ ├── ft_putnbr_fd.c │ │ ├── ft_putstr_fd.c │ │ ├── ft_split.c │ │ ├── ft_strchr.c │ │ ├── ft_strdup.c │ │ ├── ft_striteri.c │ │ ├── ft_strjoin.c │ │ ├── ft_strlcat.c │ │ ├── ft_strlcpy.c │ │ ├── ft_strlen.c │ │ ├── ft_strmapi.c │ │ ├── ft_strncmp.c │ │ ├── ft_strnstr.c │ │ ├── ft_strrchr.c │ │ ├── ft_strtrim.c │ │ ├── ft_substr.c │ │ ├── ft_tolower.c │ │ └── ft_toupper.c └── libgnl │ ├── Makefile │ ├── README.md │ ├── include │ └── get_next_line.h │ └── src │ ├── get_next_line.c │ └── get_next_line_utils.c ├── push_swap_tester ├── Makefile ├── README.md ├── push_swap_tester.bash └── random_numbers.cpp ├── run_visualizer.bash ├── srcs ├── data_struct_src │ └── list_utils.c ├── initalize_src │ ├── check.c │ ├── error_exit.c │ ├── init.c │ └── quick_sort.c ├── operator_src │ ├── operator_p.c │ ├── operator_r.c │ ├── operator_rr.c │ ├── operator_s.c │ └── pop_push_swap_rotate.c └── visualizer_src │ └── visualizer.c └── tags /Makefile: -------------------------------------------------------------------------------- 1 | # **************************************************************************** # 2 | # # 3 | # ::: :::::::: # 4 | # Makefile :+: :+: :+: # 5 | # +:+ +:+ +:+ # 6 | # By: mher +#+ +:+ +#+ # 7 | # +#+#+#+#+#+ +#+ # 8 | # Created: 2022/04/13 11:24:10 by mher #+# #+# # 9 | # Updated: 2022/04/23 01:02:30 by mher ### ########.fr # 10 | # # 11 | # **************************************************************************** # 12 | 13 | NAME = visualizer 14 | 15 | CC = gcc -fsanitize=address -g3 16 | CFLAGS = -Wall -Wextra -Werror 17 | 18 | FT_DIR = ./lib/Libft 19 | GNL_DIR = ./lib/libgnl 20 | TESTER_DIR = ./push_swap_tester 21 | FT = ft 22 | GNL = gnl 23 | 24 | 25 | INCLUDE = -I./include 26 | 27 | DATA_STRUCT_DIR = ./srcs/data_struct_src 28 | DATA_STRUCT_SRC = \ 29 | $(DATA_STRUCT_DIR)/list_utils.c \ 30 | 31 | OPERATOR_DIR = ./srcs/operator_src 32 | OPERATOR_SRC = \ 33 | $(OPERATOR_DIR)/operator_s.c \ 34 | $(OPERATOR_DIR)/operator_p.c \ 35 | $(OPERATOR_DIR)/operator_r.c \ 36 | $(OPERATOR_DIR)/operator_rr.c \ 37 | $(OPERATOR_DIR)/pop_push_swap_rotate.c \ 38 | 39 | INITALIZE_DIR = ./srcs/initalize_src 40 | INITALIZE_SRC = \ 41 | $(INITALIZE_DIR)/init.c \ 42 | $(INITALIZE_DIR)/check.c \ 43 | $(INITALIZE_DIR)/quick_sort.c \ 44 | $(INITALIZE_DIR)/error_exit.c \ 45 | 46 | VISUALIZER_DIR = ./srcs/visualizer_src 47 | VISUALIZER_SRC = \ 48 | $(OPERATOR_SRC) \ 49 | $(DATA_STRUCT_SRC) \ 50 | $(INITALIZE_SRC) \ 51 | $(VISUALIZER_DIR)/visualizer.c \ 52 | 53 | 54 | PUSH_SWAP_OBJ = $(PUSH_SWAP_SRC:.c=.o) 55 | VISUALIZER_OBJ = $(VISUALIZER_SRC:.c=.o) 56 | 57 | all: $(NAME) 58 | 59 | $(NAME) : $(VISUALIZER_OBJ) 60 | $(MAKE) -C $(FT_DIR) 61 | $(MAKE) -C $(GNL_DIR) 62 | $(MAKE) -C $(TESTER_DIR) 63 | @$(CC) $(CFLAGS) -o $@ $^ \ 64 | -L$(FT_DIR) -l$(FT) \ 65 | -L$(GNL_DIR) -l$(GNL) 66 | 67 | %.o: %.c 68 | @$(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $^ 69 | 70 | clean: 71 | $(MAKE) clean -C $(FT_DIR) 72 | $(MAKE) clean -C $(GNL_DIR) 73 | @rm -f $(VISUALIZER_OBJ) 74 | rm -f push_swap_out 75 | 76 | fclean: clean 77 | $(MAKE) fclean -C $(FT_DIR) 78 | $(MAKE) fclean -C $(GNL_DIR) 79 | $(MAKE) fclean -C $(TESTER_DIR) 80 | @rm -f $(NAME) 81 | 82 | re: fclean all 83 | 84 | .PHONY: all clean fclean re 85 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # push_swap_visualizer 2 | 3 | ## Note 4 | 5 | - push_swap 보너스 과제인 checker 프로그램을 응용해서 만든 간단한 push_swap_visualizer 프로그램입니다. 6 | - 인자로 들어가는 난수는 minckim님의 [push_swap_tester](https://github.com/minckim42/push_swap_tester) repo에 있는 random_numbers 프로그램을 사용 했습니다. 7 | - 오류나 버그, 궁금한점은 슬랙 DM 혹은 메일로 연락 주세요! 8 | - 수정이나 배포는 자유 입니다! 9 | 10 | ## Directory 11 | ``` 12 | | 13 | |- [ push_swap ] (Your push_swap dir) 14 | | |- Makefile 15 | | 16 | |- [ push_swap_visuzlizer ] 17 | | |- run_visualizer.bash 18 | | |- push_swap_tester (push_swap_tester by minckim) 19 | | |- Makefile 20 | | 21 | ``` 22 | 23 | ## Usage 24 | 25 | - push_swap 디렉토리 명이 ```push_swap```이 아니면 bash 파일에 적힌 ```push_swap``` 경로를 본인의 디렉토리로 교체하거나 디렉토리명을 ```push_swap```으로 바꿔주세요. 26 | - push_swap 디렉토리와 push_swap_visualizer 디렉토리 에서 각각 ```make``` 를 실행시켜주세요. 27 | - cd push_swap_visualizer 28 | - ./run_visualizer.bash <숫자 개수> 29 | - <숫자 개수> 를 입력 하지 않은 경우 기본값으로 10 이 들어가게 됩니다. 30 | - 프로그램이 실행된 후 ```\n``` 을 입력 할때마다 하나의 연산을 수행하게 됩니다. 31 | 32 | ## Example 33 | ``` 34 | ./run_visualizer.bash 35 | ``` 36 | 37 | ``` 38 | ./run_visualizer.bash 30 39 | ``` 40 | -------------------------------------------------------------------------------- /include/checker.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* checker.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/04/15 18:18:22 by mher #+# #+# */ 9 | /* Updated: 2022/04/16 02:58:28 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef CHECKER_H 14 | # define CHECKER_H 15 | 16 | # include "data_struct.h" 17 | # include "operator.h" 18 | # include "initialize.h" 19 | # include "../lib/libgnl/include/get_next_line.h" 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /include/data_struct.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* data_struct.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/04/15 16:28:10 by mher #+# #+# */ 9 | /* Updated: 2022/04/22 15:46:50 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef DATA_STRUCT_H 14 | # define DATA_STRUCT_H 15 | 16 | # include 17 | 18 | typedef struct s_list 19 | { 20 | int data; 21 | struct s_list *prev; 22 | struct s_list *next; 23 | } t_list; 24 | 25 | typedef struct s_stack 26 | { 27 | int size; 28 | t_list *head; 29 | } t_stack; 30 | 31 | typedef struct s_info 32 | { 33 | int total_size; 34 | int max; 35 | int min; 36 | int f_pivot; 37 | int s_pivot; 38 | t_stack a; 39 | t_stack b; 40 | } t_info; 41 | 42 | typedef struct s_op 43 | { 44 | int r; 45 | int rr; 46 | } t_op; 47 | 48 | typedef struct s_rotate 49 | { 50 | t_op a; 51 | t_op b; 52 | } t_rotate; 53 | 54 | t_list *ft_lstnew(int data); 55 | t_list *ft_lstlast(t_list *lst); 56 | t_list *ft_lstlast_cnt(t_list *lst, int cnt); 57 | void ft_lstadd_back(t_list **lst, t_list *new_lst); 58 | void ft_lstadd_front(t_list **lst, t_list *new_lst); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /include/initialize.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* initialize.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/04/15 18:18:22 by mher #+# #+# */ 9 | /* Updated: 2022/04/22 15:46:02 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef INITIALIZE_H 14 | # define INITIALIZE_H 15 | 16 | # include 17 | # include 18 | # include "data_struct.h" 19 | # include "../lib/libft/include/libft.h" 20 | 21 | char *get_line_num(int argc, char **argv); 22 | int *get_nums(char *line, t_info *info); 23 | void init_stack(t_info *info, int *nums); 24 | void init_pivot(t_info *info, int *nums); 25 | void check_dup(int *nums, int size); 26 | int check_ascending(t_info *info, int *nums); 27 | int check_num_atoi(const char *str); 28 | void quick_sort(int *arr, int start, int end); 29 | void error_exit(const char *msg); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /include/operator.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* operator.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/04/15 16:19:05 by mher #+# #+# */ 9 | /* Updated: 2022/04/16 19:06:06 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef OPERATOR_H 14 | # define OPERATOR_H 15 | 16 | # include "unistd.h" 17 | # include "data_struct.h" 18 | 19 | void swap_stack(t_stack *stack); 20 | t_list *pop_stack(t_stack *stack); 21 | void push_stack(t_stack *dest, t_stack *from); 22 | void rotate_stack(t_stack *stack); 23 | void reverse_rotate_stack(t_stack *stack); 24 | void sa(t_info *info, char flag); 25 | void sb(t_info *info, char flag); 26 | void ss(t_info *info, char flag); 27 | void pa(t_info *info, char flag); 28 | void pb(t_info *info, char flag); 29 | void ra(t_info *info, char flag); 30 | void rb(t_info *info, char flag); 31 | void rr(t_info *info, char flag); 32 | void rra(t_info *info, char flag); 33 | void rrb(t_info *info, char flag); 34 | void rrr(t_info *info, char flag); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /include/push_swap.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* push_swap.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/04/03 17:12:01 by mher #+# #+# */ 9 | /* Updated: 2022/04/15 19:26:45 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef PUSH_SWAP_H 14 | # define PUSH_SWAP_H 15 | 16 | # include "data_struct.h" 17 | # include "operator.h" 18 | # include "initialize.h" 19 | 20 | void push_swap(t_info *info); 21 | void pb_smaller_than_pivot(t_info *info, int pivot); 22 | void pb_leave_three(t_info *info); 23 | void set_rotate_position(t_info *info, t_rotate rotate); 24 | t_rotate get_min_rotate_cnt(t_info *info); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /lib/libft/Makefile: -------------------------------------------------------------------------------- 1 | # **************************************************************************** # 2 | # # 3 | # ::: :::::::: # 4 | # Makefile :+: :+: :+: # 5 | # +:+ +:+ +:+ # 6 | # By: mher +#+ +:+ +#+ # 7 | # +#+#+#+#+#+ +#+ # 8 | # Created: 2021/11/19 13:44:52 by mher #+# #+# # 9 | # Updated: 2022/04/20 03:02:33 by mher ### ########.fr # 10 | # # 11 | # **************************************************************************** # 12 | 13 | NAME = libft.a 14 | 15 | CC = gcc 16 | CFLAGS = -Wall -Wextra -Werror 17 | 18 | INCLUDE = -I./include 19 | 20 | SRC_DIR = ./src 21 | SRC = \ 22 | $(SRC_DIR)/ft_atoi.c \ 23 | $(SRC_DIR)/ft_bzero.c \ 24 | $(SRC_DIR)/ft_calloc.c \ 25 | $(SRC_DIR)/ft_isalnum.c \ 26 | $(SRC_DIR)/ft_isalpha.c \ 27 | $(SRC_DIR)/ft_isascii.c \ 28 | $(SRC_DIR)/ft_isdigit.c \ 29 | $(SRC_DIR)/ft_isprint.c \ 30 | $(SRC_DIR)/ft_itoa.c \ 31 | $(SRC_DIR)/ft_memchr.c \ 32 | $(SRC_DIR)/ft_memcmp.c \ 33 | $(SRC_DIR)/ft_memcpy.c \ 34 | $(SRC_DIR)/ft_memmove.c \ 35 | $(SRC_DIR)/ft_memset.c \ 36 | $(SRC_DIR)/ft_putchar_fd.c \ 37 | $(SRC_DIR)/ft_putendl_fd.c \ 38 | $(SRC_DIR)/ft_putnbr_fd.c \ 39 | $(SRC_DIR)/ft_putstr_fd.c \ 40 | $(SRC_DIR)/ft_split.c \ 41 | $(SRC_DIR)/ft_strchr.c \ 42 | $(SRC_DIR)/ft_strdup.c \ 43 | $(SRC_DIR)/ft_strjoin.c \ 44 | $(SRC_DIR)/ft_strlcat.c \ 45 | $(SRC_DIR)/ft_strlcpy.c \ 46 | $(SRC_DIR)/ft_strlen.c \ 47 | $(SRC_DIR)/ft_strmapi.c \ 48 | $(SRC_DIR)/ft_strncmp.c \ 49 | $(SRC_DIR)/ft_strnstr.c \ 50 | $(SRC_DIR)/ft_strrchr.c \ 51 | $(SRC_DIR)/ft_strtrim.c \ 52 | $(SRC_DIR)/ft_substr.c \ 53 | $(SRC_DIR)/ft_tolower.c \ 54 | $(SRC_DIR)/ft_striteri.c \ 55 | $(SRC_DIR)/ft_toupper.c 56 | 57 | OBJ = $(SRC:.c=.o) 58 | 59 | $(NAME): $(OBJ) 60 | 61 | bonus: $(OBJ) 62 | 63 | %.o : %.c 64 | @$(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $^ 65 | @ar crsu $(NAME) $@ 66 | 67 | all: $(NAME) 68 | 69 | clean: 70 | @rm -f $(OBJ) 71 | 72 | fclean: clean 73 | @rm -f $(NAME) 74 | 75 | re: fclean all 76 | 77 | .PHONY: all clean fclean re 78 | -------------------------------------------------------------------------------- /lib/libft/include/libft.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* libft.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/16 14:45:24 by mher #+# #+# */ 9 | /* Updated: 2022/04/16 01:31:29 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef LIBFT_H 14 | # define LIBFT_H 15 | 16 | # include 17 | # include 18 | 19 | int ft_atoi(const char *str); 20 | void ft_bzero(void *s, size_t n); 21 | void *ft_calloc(size_t count, size_t size); 22 | int ft_isalnum(int c); 23 | int ft_isalpha(int c); 24 | int ft_isascii(int c); 25 | int ft_isdigit(int c); 26 | int ft_isprint(int c); 27 | char *ft_itoa(int n); 28 | void *ft_memchr(const void *s, int c, size_t n); 29 | int ft_memcmp(const void *s1, const void *s2, size_t n); 30 | void *ft_memcpy(void *dst, const void *src, size_t n); 31 | void *ft_memmove(void *dst, const void *src, size_t len); 32 | void *ft_memset(void *b, int c, size_t len); 33 | void ft_putchar_fd(char c, int fd); 34 | void ft_putendl_fd(char *s, int fd); 35 | void ft_putnbr_fd(int n, int fd); 36 | void ft_putstr_fd(char *s, int fd); 37 | char **ft_split(char const *s, char c); 38 | char *ft_strchr(const char *s, int c); 39 | char *ft_strdup(const char *s1); 40 | char *ft_strjoin(char const *s1, char const *s2); 41 | size_t ft_strlcat(char *dst, const char *src, size_t size); 42 | size_t ft_strlcpy(char *dst, const char *src, size_t size); 43 | size_t ft_strlen(const char *s); 44 | char *ft_strmapi(char const *s, char (*f)(unsigned int, char)); 45 | int ft_strncmp(const char *s1, const char *s2, size_t n); 46 | char *ft_strnstr(const char *haystack, const char *needle, 47 | size_t len); 48 | char *ft_strrchr(const char *s, int c); 49 | char *ft_strtrim(char const *s1, char const *set); 50 | char *ft_substr(char const *s, unsigned int start, size_t len); 51 | int ft_tolower(int c); 52 | int ft_toupper(int c); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /lib/libft/src/ft_atoi.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_atoi.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/19 12:41:40 by mher #+# #+# */ 9 | /* Updated: 2021/11/27 15:08:52 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_atoi(const char *str) 16 | { 17 | long ret; 18 | int sign; 19 | 20 | ret = 0; 21 | sign = 1; 22 | while (*str == ' ' || (9 <= *str && *str <= 13)) 23 | ++str; 24 | if (*str == '+' || *str == '-') 25 | if (*str++ == '-') 26 | sign *= -1; 27 | while ('0' <= *str && *str <= '9') 28 | { 29 | ret = ret * 10 + (*str++ - '0'); 30 | if (ret < 0) 31 | return ((sign + 1) / -2); 32 | } 33 | return (sign * ret); 34 | } 35 | -------------------------------------------------------------------------------- /lib/libft/src/ft_bzero.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_bzero.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/17 10:58:51 by mher #+# #+# */ 9 | /* Updated: 2021/11/17 10:59:56 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void ft_bzero(void *s, size_t n) 16 | { 17 | ft_memset(s, 0, n); 18 | } 19 | -------------------------------------------------------------------------------- /lib/libft/src/ft_calloc.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_calloc.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/19 16:41:24 by mher #+# #+# */ 9 | /* Updated: 2021/11/21 14:38:50 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void *ft_calloc(size_t count, size_t size) 16 | { 17 | void *ret; 18 | 19 | ret = (void *)malloc(count * size); 20 | if (!ret) 21 | return (0); 22 | ft_bzero(ret, (count * size)); 23 | return (ret); 24 | } 25 | -------------------------------------------------------------------------------- /lib/libft/src/ft_isalnum.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_isalnum.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/16 14:36:50 by mher #+# #+# */ 9 | /* Updated: 2021/11/16 15:32:17 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_isalnum(int c) 16 | { 17 | return (ft_isalpha(c) || ft_isdigit(c)); 18 | } 19 | -------------------------------------------------------------------------------- /lib/libft/src/ft_isalpha.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_isalpha.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/16 14:19:57 by mher #+# #+# */ 9 | /* Updated: 2021/11/23 18:12:25 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_isalpha(int c) 16 | { 17 | return (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')); 18 | } 19 | -------------------------------------------------------------------------------- /lib/libft/src/ft_isascii.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_isascii.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/16 15:44:30 by mher #+# #+# */ 9 | /* Updated: 2021/11/16 15:46:06 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_isascii(int c) 16 | { 17 | return (0 <= c && c <= 127); 18 | } 19 | -------------------------------------------------------------------------------- /lib/libft/src/ft_isdigit.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_isdigit.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/16 14:26:00 by mher #+# #+# */ 9 | /* Updated: 2021/11/16 15:32:37 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_isdigit(int c) 16 | { 17 | return ('0' <= c && c <= '9'); 18 | } 19 | -------------------------------------------------------------------------------- /lib/libft/src/ft_isprint.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_isprint.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/16 15:54:14 by mher #+# #+# */ 9 | /* Updated: 2021/11/17 11:43:13 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_isprint(int c) 16 | { 17 | return (32 <= c && c <= 126); 18 | } 19 | -------------------------------------------------------------------------------- /lib/libft/src/ft_itoa.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_itoa.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/19 16:42:32 by mher #+# #+# */ 9 | /* Updated: 2021/11/21 15:38:21 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | static int ft_abs(int n) 16 | { 17 | if (n < 0) 18 | return (-n); 19 | return (n); 20 | } 21 | 22 | static int ft_get_num_len(int n) 23 | { 24 | int len; 25 | 26 | len = 0; 27 | if (n <= 0) 28 | len = 1; 29 | while (n != 0) 30 | { 31 | n /= 10; 32 | ++len; 33 | } 34 | return (len); 35 | } 36 | 37 | char *ft_itoa(int n) 38 | { 39 | int len; 40 | int sign; 41 | char *ret; 42 | 43 | sign = 1; 44 | if (n < 0) 45 | sign = -1; 46 | len = ft_get_num_len(n); 47 | ret = (char *)malloc(sizeof(char) * (len + 1)); 48 | if (!ret) 49 | return (0); 50 | ret[len--] = 0; 51 | while (len >= 0) 52 | { 53 | ret[len--] = ft_abs(n % 10) + '0'; 54 | n = ft_abs(n / 10); 55 | } 56 | if (sign == -1) 57 | ret[0] = '-'; 58 | return (ret); 59 | } 60 | -------------------------------------------------------------------------------- /lib/libft/src/ft_memchr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_memchr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/19 16:38:10 by mher #+# #+# */ 9 | /* Updated: 2021/11/19 16:38:16 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void *ft_memchr(const void *s, int c, size_t n) 16 | { 17 | while (n--) 18 | { 19 | if (*(unsigned char *)s == (unsigned char)c) 20 | return ((void *)s); 21 | ++s; 22 | } 23 | return (0); 24 | } 25 | -------------------------------------------------------------------------------- /lib/libft/src/ft_memcmp.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_memcmp.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/19 16:40:28 by mher #+# #+# */ 9 | /* Updated: 2021/11/19 16:40:30 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_memcmp(const void *s1, const void *s2, size_t n) 16 | { 17 | unsigned char *new_s1; 18 | unsigned char *new_s2; 19 | 20 | new_s1 = (unsigned char *)s1; 21 | new_s2 = (unsigned char *)s2; 22 | while (n--) 23 | { 24 | if (*new_s1 != *new_s2) 25 | return (*new_s1 - *new_s2); 26 | ++new_s1; 27 | ++new_s2; 28 | } 29 | return (0); 30 | } 31 | -------------------------------------------------------------------------------- /lib/libft/src/ft_memcpy.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_memcpy.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/17 11:00:34 by mher #+# #+# */ 9 | /* Updated: 2021/11/24 15:38:02 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void *ft_memcpy(void *dst, const void *src, size_t n) 16 | { 17 | unsigned char *new_dst; 18 | unsigned char *new_src; 19 | 20 | new_dst = (unsigned char *)dst; 21 | new_src = (unsigned char *)src; 22 | if (dst == src) 23 | return (dst); 24 | while (n--) 25 | *new_dst++ = *new_src++; 26 | return (dst); 27 | } 28 | -------------------------------------------------------------------------------- /lib/libft/src/ft_memmove.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_memmove.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/17 11:44:29 by mher #+# #+# */ 9 | /* Updated: 2021/11/24 15:58:00 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void *ft_memmove(void *dst, const void *src, size_t len) 16 | { 17 | unsigned char *new_dst; 18 | unsigned char *new_src; 19 | 20 | new_dst = (unsigned char *)dst; 21 | new_src = (unsigned char *)src; 22 | if (dst == src || len == 0) 23 | return (dst); 24 | if (dst < src) 25 | while (len--) 26 | *new_dst++ = *new_src++; 27 | else 28 | while (len--) 29 | *(new_dst + len) = *(new_src + len); 30 | return (dst); 31 | } 32 | -------------------------------------------------------------------------------- /lib/libft/src/ft_memset.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_memset.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/27 18:30:41 by mher #+# #+# */ 9 | /* Updated: 2021/11/27 18:30:55 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void *ft_memset(void *b, int c, size_t len) 16 | { 17 | unsigned char *new_b; 18 | unsigned char new_c; 19 | 20 | new_b = (unsigned char *)b; 21 | new_c = (unsigned char)c; 22 | while (len--) 23 | *new_b++ = new_c; 24 | return (b); 25 | } 26 | -------------------------------------------------------------------------------- /lib/libft/src/ft_putchar_fd.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putchar_fd.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/19 16:43:03 by mher #+# #+# */ 9 | /* Updated: 2021/11/19 16:43:04 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void ft_putchar_fd(char c, int fd) 16 | { 17 | if (fd < 0) 18 | return ; 19 | write(fd, &c, 1); 20 | } 21 | -------------------------------------------------------------------------------- /lib/libft/src/ft_putendl_fd.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putendl_fd.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/19 16:43:21 by mher #+# #+# */ 9 | /* Updated: 2021/11/19 16:43:22 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void ft_putendl_fd(char *s, int fd) 16 | { 17 | if (!s || fd < 0) 18 | return ; 19 | write(fd, s, ft_strlen(s)); 20 | write(fd, "\n", 1); 21 | } 22 | -------------------------------------------------------------------------------- /lib/libft/src/ft_putnbr_fd.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putnbr_fd.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/19 16:43:30 by mher #+# #+# */ 9 | /* Updated: 2021/11/21 14:24:46 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | static void ft_print_nbr(int n, int fd) 16 | { 17 | if (n > 9) 18 | ft_print_nbr(n / 10, fd); 19 | write(fd, &"0123456789"[n % 10], 1); 20 | } 21 | 22 | void ft_putnbr_fd(int n, int fd) 23 | { 24 | if (fd < 0) 25 | return ; 26 | if (n == -2147483648) 27 | { 28 | write(fd, "-2147483648", 11); 29 | return ; 30 | } 31 | if (n < 0) 32 | { 33 | write(fd, "-", 1); 34 | n *= -1; 35 | } 36 | ft_print_nbr(n, fd); 37 | } 38 | -------------------------------------------------------------------------------- /lib/libft/src/ft_putstr_fd.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putstr_fd.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/19 16:43:13 by mher #+# #+# */ 9 | /* Updated: 2021/11/19 16:43:14 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void ft_putstr_fd(char *s, int fd) 16 | { 17 | if (!s || fd < 0) 18 | return ; 19 | write(fd, s, ft_strlen(s)); 20 | } 21 | -------------------------------------------------------------------------------- /lib/libft/src/ft_split.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_split.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/19 16:42:23 by mher #+# #+# */ 9 | /* Updated: 2021/11/30 15:56:06 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | static char **ft_malloc_error(char **ret) 16 | { 17 | unsigned int i; 18 | 19 | i = 0; 20 | while (ret[i]) 21 | { 22 | free(ret[i]); 23 | ++i; 24 | } 25 | free(ret); 26 | return (0); 27 | } 28 | 29 | static size_t ft_get_word_cnt(const char *s, char c) 30 | { 31 | size_t cnt; 32 | 33 | cnt = 0; 34 | while (*s) 35 | { 36 | if (*s != c) 37 | { 38 | ++cnt; 39 | while (*s && *s != c) 40 | ++s; 41 | if (!*s) 42 | break ; 43 | } 44 | ++s; 45 | } 46 | return (cnt); 47 | } 48 | 49 | static size_t ft_get_word_len(const char *s, char c) 50 | { 51 | size_t i; 52 | 53 | i = 0; 54 | while (*s && *s != c) 55 | { 56 | ++s; 57 | ++i; 58 | } 59 | return (i); 60 | } 61 | 62 | char **ft_split(char const *s, char c) 63 | { 64 | char **ret; 65 | size_t word_len; 66 | size_t i; 67 | 68 | if (!s) 69 | return (0); 70 | ret = (char **)malloc(sizeof(char *) * (ft_get_word_cnt(s, c) + 1)); 71 | if (!ret) 72 | return (0); 73 | i = 0; 74 | while (*s) 75 | { 76 | if (*s != c) 77 | { 78 | word_len = ft_get_word_len(s, c); 79 | ret[i] = (char *)malloc(word_len + 1); 80 | if (!ret[i]) 81 | return (ft_malloc_error(ret)); 82 | ft_strlcpy(ret[i++], s, word_len + 1); 83 | s += word_len - 1; 84 | } 85 | ++s; 86 | } 87 | ret[i] = 0; 88 | return (ret); 89 | } 90 | -------------------------------------------------------------------------------- /lib/libft/src/ft_strchr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strchr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/17 16:41:02 by mher #+# #+# */ 9 | /* Updated: 2021/11/19 13:55:15 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | char *ft_strchr(const char *s, int c) 16 | { 17 | while (*s) 18 | { 19 | if (*s == (char)c) 20 | return ((char *)s); 21 | ++s; 22 | } 23 | if (*s == (char)c) 24 | return ((char *)s); 25 | return (0); 26 | } 27 | -------------------------------------------------------------------------------- /lib/libft/src/ft_strdup.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strdup.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/19 16:13:31 by mher #+# #+# */ 9 | /* Updated: 2021/11/25 14:32:30 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | char *ft_strdup(const char *s1) 16 | { 17 | size_t len; 18 | char *ret; 19 | char *tmp; 20 | 21 | len = ft_strlen(s1); 22 | ret = (char *)malloc(sizeof(char) * (len + 1)); 23 | if (!ret) 24 | return (0); 25 | tmp = ret; 26 | while (len--) 27 | { 28 | *tmp = *s1; 29 | ++tmp; 30 | ++s1; 31 | } 32 | *tmp = 0; 33 | return (ret); 34 | } 35 | -------------------------------------------------------------------------------- /lib/libft/src/ft_striteri.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_striteri.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/19 12:52:32 by mher #+# #+# */ 9 | /* Updated: 2021/11/19 16:42:53 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void ft_striteri(char *s, void (*f)(unsigned int, char*)) 16 | { 17 | unsigned int i; 18 | 19 | i = 0; 20 | if (!s || !f) 21 | return ; 22 | while (*s) 23 | { 24 | f(i, s); 25 | ++s; 26 | ++i; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/libft/src/ft_strjoin.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strjoin.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/19 16:42:05 by mher #+# #+# */ 9 | /* Updated: 2021/12/09 13:04:24 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | char *ft_strjoin(char const *s1, char const *s2) 16 | { 17 | char *ret; 18 | size_t s1_len; 19 | size_t s2_len; 20 | 21 | if (!s1 && !s2) 22 | return (0); 23 | else if (!s1) 24 | return (ft_strdup(s2)); 25 | else if (!s2) 26 | return (ft_strdup(s1)); 27 | s1_len = ft_strlen(s1); 28 | s2_len = ft_strlen(s2); 29 | ret = (char *)malloc(sizeof(char) * (s1_len + s2_len + 1)); 30 | if (!ret) 31 | return (0); 32 | ft_strlcpy(ret, s1, s1_len + 1); 33 | ft_strlcpy(ret + s1_len, s2, s2_len + 1); 34 | return (ret); 35 | } 36 | -------------------------------------------------------------------------------- /lib/libft/src/ft_strlcat.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strlcat.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/17 16:17:22 by mher #+# #+# */ 9 | /* Updated: 2021/11/24 18:13:04 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | size_t ft_strlcat(char *dst, const char *src, size_t dstsize) 16 | { 17 | size_t i; 18 | 19 | i = 0; 20 | while (*dst && i < dstsize) 21 | { 22 | ++i; 23 | ++dst; 24 | } 25 | while (*src && i + 1 < dstsize) 26 | { 27 | *dst = *src; 28 | ++dst; 29 | ++src; 30 | ++i; 31 | } 32 | if (i < dstsize) 33 | *dst = 0; 34 | while (*src) 35 | { 36 | ++i; 37 | ++src; 38 | } 39 | return (i); 40 | } 41 | -------------------------------------------------------------------------------- /lib/libft/src/ft_strlcpy.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strlcpy.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/17 14:40:28 by mher #+# #+# */ 9 | /* Updated: 2021/11/24 16:21:21 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | size_t ft_strlcpy(char *dest, const char *src, size_t destsize) 16 | { 17 | size_t i; 18 | size_t src_len; 19 | 20 | i = 0; 21 | src_len = ft_strlen(src); 22 | if (destsize == 0) 23 | return (src_len); 24 | while (src[i] && i < (destsize - 1)) 25 | { 26 | dest[i] = src[i]; 27 | ++i; 28 | } 29 | dest[i] = 0; 30 | return (src_len); 31 | } 32 | -------------------------------------------------------------------------------- /lib/libft/src/ft_strlen.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strlen.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/17 10:26:09 by mher #+# #+# */ 9 | /* Updated: 2021/11/18 14:09:15 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | size_t ft_strlen(const char *s) 16 | { 17 | size_t i; 18 | 19 | i = 0; 20 | while (*s) 21 | { 22 | ++i; 23 | ++s; 24 | } 25 | return (i); 26 | } 27 | -------------------------------------------------------------------------------- /lib/libft/src/ft_strmapi.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strmapi.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/19 16:42:43 by mher #+# #+# */ 9 | /* Updated: 2021/11/19 16:42:44 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) 16 | { 17 | char *ret; 18 | unsigned int len; 19 | unsigned int i; 20 | 21 | if (!s || !f) 22 | return (0); 23 | len = ft_strlen(s); 24 | ret = (char *)malloc(sizeof(char) * (len + 1)); 25 | if (!ret) 26 | return (0); 27 | i = 0; 28 | while (s[i]) 29 | { 30 | ret[i] = f(i, s[i]); 31 | ++i; 32 | } 33 | ret[i] = 0; 34 | return (ret); 35 | } 36 | -------------------------------------------------------------------------------- /lib/libft/src/ft_strncmp.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strncmp.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/17 20:10:33 by mher #+# #+# */ 9 | /* Updated: 2021/11/19 14:18:29 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_strncmp(const char *s1, const char *s2, size_t n) 16 | { 17 | unsigned char *t1; 18 | unsigned char *t2; 19 | 20 | t1 = (unsigned char *)s1; 21 | t2 = (unsigned char *)s2; 22 | while (n-- > 0) 23 | { 24 | if (*t1 != *t2 || !*t1 || !*t2) 25 | return (*t1 - *t2); 26 | ++t1; 27 | ++t2; 28 | } 29 | return (0); 30 | } 31 | -------------------------------------------------------------------------------- /lib/libft/src/ft_strnstr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strnstr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/19 16:40:41 by mher #+# #+# */ 9 | /* Updated: 2021/11/19 16:40:53 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | char *ft_strnstr(const char *haystack, const char *needle, size_t len) 16 | { 17 | size_t h_len; 18 | size_t n_len; 19 | size_t size; 20 | 21 | if (!*needle) 22 | return ((char *)haystack); 23 | h_len = ft_strlen(haystack); 24 | n_len = ft_strlen(needle); 25 | if (h_len < n_len || len < n_len) 26 | return (0); 27 | if (h_len > len) 28 | size = len; 29 | else 30 | size = h_len; 31 | while (size-- >= n_len) 32 | { 33 | if (ft_memcmp(haystack, needle, n_len) == 0) 34 | return ((char *)haystack); 35 | ++haystack; 36 | } 37 | return (0); 38 | } 39 | -------------------------------------------------------------------------------- /lib/libft/src/ft_strrchr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strrchr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/17 18:03:10 by mher #+# #+# */ 9 | /* Updated: 2021/11/19 14:09:51 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | char *ft_strrchr(const char *s, int c) 16 | { 17 | char *ret; 18 | 19 | ret = 0; 20 | while (*s) 21 | { 22 | if (*s == (char)c) 23 | ret = (char *)s; 24 | ++s; 25 | } 26 | if (*s == (char)c) 27 | ret = (char *)s; 28 | return (ret); 29 | } 30 | -------------------------------------------------------------------------------- /lib/libft/src/ft_strtrim.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strtrim.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/19 16:42:12 by mher #+# #+# */ 9 | /* Updated: 2021/11/21 14:30:18 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | char *ft_strtrim(char const *s1, char const *set) 16 | { 17 | char *start; 18 | char *end; 19 | char *ret; 20 | 21 | if (!s1) 22 | return (0); 23 | if (!set) 24 | return (ft_strdup(s1)); 25 | start = (char *)s1; 26 | while (*start && ft_strchr(set, *start)) 27 | ++start; 28 | end = (char *)s1 + ft_strlen(s1); 29 | while (end > start && ft_strchr(set, *(end - 1))) 30 | --end; 31 | ret = (char *)malloc(sizeof(char) * (end - start + 1)); 32 | if (!ret) 33 | return (0); 34 | ft_strlcpy(ret, start, end - start + 1); 35 | return (ret); 36 | } 37 | -------------------------------------------------------------------------------- /lib/libft/src/ft_substr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_substr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/19 16:41:51 by mher #+# #+# */ 9 | /* Updated: 2021/11/27 20:27:01 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | char *ft_substr(char const *s, unsigned int start, size_t len) 16 | { 17 | char *substr; 18 | size_t tmp_len; 19 | 20 | if (!s) 21 | return (0); 22 | if ((unsigned int)ft_strlen(s) < start) 23 | return (ft_strdup("")); 24 | tmp_len = ft_strlen(s + start); 25 | if (tmp_len < len) 26 | len = tmp_len; 27 | substr = (char *)malloc(sizeof(char) * (len + 1)); 28 | if (!substr) 29 | return (0); 30 | ft_strlcpy(substr, s + start, len + 1); 31 | return (substr); 32 | } 33 | -------------------------------------------------------------------------------- /lib/libft/src/ft_tolower.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_tolower.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/17 16:38:35 by mher #+# #+# */ 9 | /* Updated: 2021/11/17 16:40:49 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_tolower(int c) 16 | { 17 | if ('A' <= c && c <= 'Z') 18 | return (c - 'A' + 'a'); 19 | return (c); 20 | } 21 | -------------------------------------------------------------------------------- /lib/libft/src/ft_toupper.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_toupper.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/11/17 16:24:53 by mher #+# #+# */ 9 | /* Updated: 2021/11/17 16:37:53 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_toupper(int c) 16 | { 17 | if ('a' <= c && c <= 'z') 18 | return (c - 'a' + 'A'); 19 | return (c); 20 | } 21 | -------------------------------------------------------------------------------- /lib/libgnl/Makefile: -------------------------------------------------------------------------------- 1 | # **************************************************************************** # 2 | # # 3 | # ::: :::::::: # 4 | # Makefile :+: :+: :+: # 5 | # +:+ +:+ +:+ # 6 | # By: mher +#+ +:+ +#+ # 7 | # +#+#+#+#+#+ +#+ # 8 | # Created: 2022/03/26 18:07:13 by mher #+# #+# # 9 | # Updated: 2022/04/20 03:02:45 by mher ### ########.fr # 10 | # # 11 | # **************************************************************************** # 12 | 13 | NAME = libgnl.a 14 | 15 | CC = gcc 16 | CFLAGS = -Wall -Wextra -Werror 17 | 18 | INCLUDE = -I./include 19 | 20 | SRC_DIR = ./src 21 | SRC = \ 22 | $(SRC_DIR)/get_next_line.c\ 23 | $(SRC_DIR)/get_next_line_utils.c\ 24 | 25 | OBJ = $(SRC:.c=.o) 26 | 27 | $(NAME): $(OBJ) 28 | 29 | %.o: %.c 30 | @$(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $^ 31 | @ar crsu $(NAME) $@ 32 | 33 | all: $(NAME) 34 | 35 | clean: 36 | @rm -f $(OBJ) 37 | 38 | fclean: clean 39 | @rm -f $(NAME) 40 | 41 | re: clean all 42 | 43 | .PHONY: all clean fclean re 44 | -------------------------------------------------------------------------------- /lib/libgnl/README.md: -------------------------------------------------------------------------------- 1 | # Get Next Line 2 | 3 | ## Reading a line on a fd is way too tedious 4 | 5 | Summary: The aim of this project is to make you code a function that returns a line, 6 | read from a file descriptor. 7 | 8 | Get Next Line 정리 - [notion](https://mher9804.notion.site/get-next-line-926d59c2dd0d4a9383e3641e7b99ea0a) 9 | -------------------------------------------------------------------------------- /lib/libgnl/include/get_next_line.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* get_next_line.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/06 16:32:44 by mher #+# #+# */ 9 | /* Updated: 2022/04/19 18:02:42 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef GET_NEXT_LINE_BONUS_H 14 | # define GET_NEXT_LINE_BONUS_H 15 | 16 | # include 17 | # include 18 | 19 | # ifndef BUFFER_SIZE 20 | # define BUFFER_SIZE 4096 21 | # endif 22 | 23 | 24 | typedef struct s_fd_lst 25 | { 26 | int fd; 27 | char *keep; 28 | struct s_fd_lst *prev; 29 | struct s_fd_lst *next; 30 | } t_fd_lst; 31 | 32 | char *get_line(char *keep); 33 | char *read_file(int fd, char *keep); 34 | t_fd_lst *find_fd(int fd, t_fd_lst *head); 35 | char *gnl_or_del(t_fd_lst **fd_lst); 36 | char *get_next_line(int fd); 37 | 38 | size_t ft_strlen(const char *s); 39 | size_t ft_strlcpy(char *dst, const char *src, size_t size); 40 | char *ft_strchr(const char *s, int c); 41 | char *ft_strdup(const char *s1); 42 | char *ft_strjoin(char const *s1, char const *s2); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /lib/libgnl/src/get_next_line.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* get_next_line.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/06 15:31:47 by mher #+# #+# */ 9 | /* Updated: 2022/04/19 18:01:12 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "get_next_line.h" 14 | 15 | char *get_line(char *keep) 16 | { 17 | char *line; 18 | size_t i; 19 | 20 | i = 0; 21 | while (keep[i] != '\n' && keep[i]) 22 | ++i; 23 | if (keep[i] == '\n') 24 | ++i; 25 | line = (char *)malloc(sizeof(char) * (i + 1)); 26 | if (!line) 27 | { 28 | free(keep); 29 | keep = 0; 30 | return (0); 31 | } 32 | i = 0; 33 | while (keep[i] != '\n' && keep[i]) 34 | { 35 | line[i] = keep[i]; 36 | i++; 37 | } 38 | if (keep[i] == '\n') 39 | line[i++] = '\n'; 40 | line[i] = 0; 41 | return (line); 42 | } 43 | 44 | char *read_file(int fd, char *keep) 45 | { 46 | char *buff; 47 | char *temp; 48 | ssize_t read_size; 49 | 50 | buff = (char *)malloc(sizeof(char) * (BUFFER_SIZE + 1)); 51 | if (!buff) 52 | return (0); 53 | read_size = read(fd, buff, BUFFER_SIZE); 54 | while (read_size > 0) 55 | { 56 | buff[read_size] = '\0'; 57 | temp = keep; 58 | keep = ft_strjoin(temp, buff); 59 | free(temp); 60 | temp = 0; 61 | if (ft_strchr(keep, '\n') || !keep) 62 | break ; 63 | read_size = read(fd, buff, BUFFER_SIZE); 64 | } 65 | free(buff); 66 | buff = 0; 67 | if (read_size < 0) 68 | return (0); 69 | return (keep); 70 | } 71 | 72 | t_fd_lst *find_fd(int fd, t_fd_lst *head) 73 | { 74 | t_fd_lst *temp; 75 | 76 | temp = head->next; 77 | while (temp) 78 | { 79 | if (temp->fd == fd) 80 | return (temp); 81 | temp = temp->next; 82 | } 83 | temp = (t_fd_lst *)malloc(sizeof(t_fd_lst)); 84 | if (!temp) 85 | return (0); 86 | temp->fd = fd; 87 | temp->keep = 0; 88 | temp->prev = head; 89 | temp->next = head->next; 90 | if (head->next) 91 | head->next->prev = temp; 92 | head->next = temp; 93 | return (temp); 94 | } 95 | 96 | char *gnl_or_del(t_fd_lst **fd_lst) 97 | { 98 | char *line; 99 | char *temp; 100 | 101 | if ((*fd_lst)->keep) 102 | { 103 | line = get_line((*fd_lst)->keep); 104 | if (!line) 105 | return (0); 106 | temp = (*fd_lst)->keep; 107 | (*fd_lst)->keep = ft_strdup(temp + ft_strlen(line)); 108 | free(temp); 109 | temp = 0; 110 | if (!((*fd_lst)->keep)) 111 | return (0); 112 | return (line); 113 | } 114 | else 115 | { 116 | (*fd_lst)->prev->next = (*fd_lst)->next; 117 | if ((*fd_lst)->next) 118 | (*fd_lst)->next->prev = (*fd_lst)->prev; 119 | free(*fd_lst); 120 | *fd_lst = 0; 121 | return (0); 122 | } 123 | } 124 | 125 | char *get_next_line(int fd) 126 | { 127 | static t_fd_lst head; 128 | t_fd_lst *fd_lst; 129 | 130 | if (fd < 0 || BUFFER_SIZE < 1) 131 | return (0); 132 | fd_lst = find_fd(fd, &head); 133 | if (!fd_lst) 134 | return (0); 135 | fd_lst->keep = read_file(fd, fd_lst->keep); 136 | //read_file에서 buff 할당실패 || keep 할당 실패 137 | if (!(fd_lst->keep)) 138 | return (gnl_or_del(&fd_lst)); 139 | //read_file에서 empty_file || eof를 만난후 다시 읽은 경우 keep에 '\0' free 140 | if (!*(fd_lst->keep)) 141 | { 142 | free(fd_lst->keep); 143 | fd_lst->keep = 0; 144 | return (gnl_or_del(&fd_lst)); 145 | } 146 | //read_file에서 한줄을 잘 읽고 keep에 문자열이 저장된경우 147 | return (gnl_or_del(&fd_lst)); 148 | } 149 | -------------------------------------------------------------------------------- /lib/libgnl/src/get_next_line_utils.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* get_next_line_utils.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/06 16:39:24 by mher #+# #+# */ 9 | /* Updated: 2022/04/19 18:01:38 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "get_next_line.h" 14 | 15 | size_t ft_strlen(const char *s) 16 | { 17 | size_t i; 18 | 19 | i = 0; 20 | while (*s) 21 | { 22 | ++i; 23 | ++s; 24 | } 25 | return (i); 26 | } 27 | 28 | size_t ft_strlcpy(char *dest, const char *src, size_t destsize) 29 | { 30 | size_t i; 31 | size_t src_len; 32 | 33 | i = 0; 34 | src_len = ft_strlen(src); 35 | if (destsize == 0) 36 | return (src_len); 37 | while (src[i] && i < (destsize - 1)) 38 | { 39 | dest[i] = src[i]; 40 | ++i; 41 | } 42 | dest[i] = 0; 43 | return (src_len); 44 | } 45 | 46 | char *ft_strchr(const char *s, int c) 47 | { 48 | while (*s) 49 | { 50 | if (*s == (char)c) 51 | return ((char *)s); 52 | ++s; 53 | } 54 | if (*s == (char)c) 55 | return ((char *)s); 56 | return (0); 57 | } 58 | 59 | char *ft_strdup(const char *s1) 60 | { 61 | size_t len; 62 | char *ret; 63 | char *tmp; 64 | 65 | len = ft_strlen(s1); 66 | ret = (char *)malloc(sizeof(char) * (len + 1)); 67 | if (!ret) 68 | return (0); 69 | tmp = ret; 70 | while (len--) 71 | { 72 | *tmp = *s1; 73 | ++tmp; 74 | ++s1; 75 | } 76 | *tmp = 0; 77 | return (ret); 78 | } 79 | 80 | char *ft_strjoin(char const *s1, char const *s2) 81 | { 82 | char *ret; 83 | size_t s1_len; 84 | size_t s2_len; 85 | 86 | if (!s1 && !s2) 87 | return (0); 88 | else if (!s1) 89 | return (ft_strdup(s2)); 90 | else if (!s2) 91 | return (ft_strdup(s1)); 92 | s1_len = ft_strlen(s1); 93 | s2_len = ft_strlen(s2); 94 | ret = (char *)malloc(sizeof(char) * (s1_len + s2_len + 1)); 95 | if (!ret) 96 | return (0); 97 | ft_strlcpy(ret, s1, s1_len + 1); 98 | ft_strlcpy(ret + s1_len, s2, s2_len + 1); 99 | return (ret); 100 | } 101 | -------------------------------------------------------------------------------- /push_swap_tester/Makefile: -------------------------------------------------------------------------------- 1 | # **************************************************************************** # 2 | # # 3 | # ::: :::::::: # 4 | # Makefile :+: :+: :+: # 5 | # +:+ +:+ +:+ # 6 | # By: minckim +#+ +:+ +#+ # 7 | # +#+#+#+#+#+ +#+ # 8 | # Created: 2021/03/09 02:28:13 by minckim #+# #+# # 9 | # Updated: 2021/03/12 15:47:28 by minckim ### ########.fr # 10 | # # 11 | # **************************************************************************** # 12 | 13 | all : name 14 | 15 | name : random_numbers 16 | 17 | random_numbers : random_numbers.cpp 18 | clang++ random_numbers.cpp --std=c++11 -o random_numbers 19 | 20 | fclean: 21 | rm -rf random_numbers -------------------------------------------------------------------------------- /push_swap_tester/README.md: -------------------------------------------------------------------------------- 1 | # push_swap_tester 2 | --- 3 | # Directory 4 | ``` 5 | | 6 | |- [ push_swap ] 7 | | |- Makefile (Your push_swap Makefile) 8 | |- checker_linux (or checker_Mac) 9 | | 10 | |- [ push_swap_tester ] 11 | | |- push_swap_tester.bash 12 | | |- random_numbers.cpp 13 | | |- Makefile 14 | | 15 | ``` 16 | # Note 17 | ### 한국어 18 | - 운영체제가 리눅스라면 ```push_swap_tester.bash```에서 ```OS``` 변수의 값을 ```linux```로 변경해주세요. ```checker_Mac(or linux)```는 ```push_swap``` 디렉토리에 있어야 합니다. 자체 제작한 checker를 사용하는 경우에는 ```OS``` 부분을 모두 주석처리 해주세요. 19 | ```bash 20 | #============================================================================== 21 | # OS 22 | 23 | # OS="Mac" 24 | # OS="linux" 25 | 26 | #============================================================================== 27 | ``` 28 | - push_swap 프로젝트 디렉토리 명이 ```push_swap```이 아니면 bash 파일에 적힌 ```push_swap``` 경로를 여러분의 디렉토리로 교체하거나 디렉토리명을 ```push_swap```으로 바꾸세요. 29 | - 제가 이메일을 잘 확인하지 않는 관계로, 개선사항이나 오류 보고는 슬랙(minckim)으로 해주세요. 제 개인 연락처를 알고계신다면 그냥 카카오톡이나 문자, 전화도 상관없습니다. 30 | - 지지고 볶고 마음대로 하십시오. 왜냐하면 업데이트를 장담할 수 없기 때문에ㅎㅎ;; 출처만 남겨주세요. 31 | - random_numbers.cpp 를 컴파일해서 임의의 숫자 조합을 만들어낼 수 있습니다. 32 | - ```<숫자 범위 최솟값>```과 ```<숫자 범위 최댓값>```은 선택적인 인자입니다. 기본값은 ```0 ~ (<요소 개수> - 1)``` 입니다. 33 | ``` 34 | bash 35 | clang++ random_numbers.cpp -o random_numbers 36 | export ARG=$(./random_numbers <요소 개수> [숫자 범위의 최솟값] [숫자 범위의 최댓값]) 37 | /push_swap $ARG | /checker $ARG 38 | /push_swap $ARG | wc-l 39 | ``` 40 | 41 | - 사용례 42 | ``` 43 | bash 44 | clang++ random_numbers.cpp -o random_numbers 45 | export ARG=$(./random_numbers 100 1) 46 | ../push_swap/push_swap $ARG | ../push_swap/checker $ARG 47 | ../push_swap/push_swap $ARG | wc -l 48 | ``` 49 | ### English 50 | - If the operating system is Linux, please change the value of variable ```OS``` to ```linux``` from push_swap_tester.bash file. ```checker_Mac(or linux)``` should be in the directory ```push_swap```. 51 | - If the name of your push_swap project directory is not ```push_swap```, replace the push_swap path written in the bash file with your directory, or change the name of your directroy to ```push_swap```. 52 | - I don't check my e-mail very well, so please report improvements or errors with Slack(minckim). If you know my personal contact information, I don't mind just Kakao Talk, text message, or phone calls. 53 | - You can make random numbers with random_numbers.cpp. 54 | - `````` and `````` is optional argument. Default is ```0 ~ ( - 1)```. 55 | ``` 56 | bash 57 | clang++ random_numbers.cpp -o random_numbers 58 | export ARG=$(./random_numbers [range min] [range max]) 59 | /push_swap $ARG | /checker $ARG 60 | /push_swap $ARG | wc-l 61 | ``` 62 | 63 | - example 64 | ``` 65 | bash 66 | clang++ random_numbers.cpp -o random_numbers 67 | export ARG=$(./random_numbers 100 1) 68 | ../push_swap/push_swap $ARG | ../push_swap/checker $ARG 69 | ../push_swap/push_swap $ARG | wc -l 70 | ``` 71 | # Install & run 72 | ``` 73 | git clone git@github.com:minckim42/push_swap_tester.git 74 | cd push_swap_tester 75 | ./push_swap_tester.bash 76 | ``` 77 | # Update 78 | - 2021-07-20: 79 | - 오류를 표준출력에 출력하는 경우에 나타내는 실패 메시지를 수정함. 왜 실패인지 모르겠다는 제보가 종종 있어서 수정함. 80 | - checker가 과제에서 기본으로 제공되는 것으로 변경된 것을 반영함. 르포에 checker를 포함하지는 않음. 81 | - Readme 업데이트 82 | - 2021-07-05: 83 | - 테스트케이스의 자잘한 오타 수정. int형 최댓값 잘못 적음ㅎㅎ;; (21474''3647 -> 21474'8'3647) (제보: hyeonsok) 84 | - 2021-03-22: 85 | - 오류가 발생하는 경우(Error를 출력해야 하는 경우)표준출력이 아닌 표준오류에 출력해야 통과되도록 함 86 | - makefile 메시지 감춤 87 | - bash 파일에 적힌 디렉토리 구조가 잘못되어 있었는데, 올바르게 고침 88 | - 2021-03-15: birthday 89 | -------------------------------------------------------------------------------- /push_swap_tester/push_swap_tester.bash: -------------------------------------------------------------------------------- 1 | # **************************************************************************** # 2 | # # 3 | # ::: :::::::: # 4 | # push_swap_tester.bash :+: :+: :+: # 5 | # +:+ +:+ +:+ # 6 | # By: minckim +#+ +:+ +#+ # 7 | # +#+#+#+#+#+ +#+ # 8 | # Created: 2021/03/14 18:07:27 by minckim #+# #+# # 9 | # Updated: 2021/11/29 15:27:28 by minckim ### ########.fr # 10 | # # 11 | # **************************************************************************** # 12 | 13 | #!/bin/bash 14 | 15 | #============================================================================== 16 | # Directroy 17 | 18 | # |- [ push_swap ] 19 | # |- Makefile (Your push_swap Makefile) 20 | # |- checker_linux (or checker_Mac) 21 | # |- [ push_swap_tester ] 22 | # |- push_swap_tester.bash 23 | # |- random_numbers.cpp 24 | # |- Makefile 25 | 26 | #============================================================================== 27 | # push_swap directory 28 | 29 | PUSHSWAP_DIR=../push_swap 30 | 31 | #============================================================================== 32 | # OS 33 | 34 | OS="Mac" 35 | # OS="linux" 36 | 37 | #============================================================================== 38 | 39 | # 40 | # 41 | # 42 | # 여백의 미 43 | # 44 | # 45 | # 46 | 47 | #============================================================================== 48 | # Colors 49 | BLACK=$'\033[0;30m' 50 | RED=$'\033[0;31m' 51 | GREEN=$'\033[0;32m' 52 | YELLOW=$'\033[0;33m' 53 | BLUE=$'\033[0;34m' 54 | PURPLE=$'\033[0;35m' 55 | CYAN=$'\033[0;36m' 56 | WHITE=$'\033[0;39m' 57 | 58 | #============================================================================== 59 | # Path 60 | PUSHSWAP=$PUSHSWAP_DIR/push_swap 61 | if [[ $OS = "linux" ]] 62 | then 63 | CHECKER=$PUSHSWAP_DIR/checker_linux 64 | elif [[ $OS = "Mac" ]] 65 | then 66 | CHECKER=$PUSHSWAP_DIR/checker_Mac 67 | else 68 | CHECKER=$PUSHSWAP_DIR/checker 69 | fi 70 | TESTER=./random_numbers 71 | 72 | #============================================================================== 73 | # Functions 74 | 75 | BORDER_LINE="------------------------------------" 76 | 77 | # parameters: 78 | # $1 : number of args 79 | function print_arguments(){ 80 | if [ $1 -ge 32 ] 81 | then 82 | echo " Arguments : "$1" elements" 83 | else 84 | echo " Arguments : $2 $3 $4 $5 $6" 85 | fi 86 | } 87 | 88 | 89 | # parameters: 90 | # $1 : result 91 | # $2 : to be displayed 92 | function print_display(){ 93 | if [[ "$1" = "PASS" ]] 94 | then 95 | echo " Display : "$GREEN$2$WHITE 96 | else 97 | echo " Display : "$RED$2$WHITE 98 | fi 99 | } 100 | 101 | 102 | # parameters: 103 | # $1 : answer to print 104 | function print_result(){ 105 | if [ $1 == "FAIL" ] 106 | then 107 | echo " Result : "$RED"FAIL"$WHITE 108 | echo $RED$BORDER_LINE$WHITE 109 | else 110 | echo " Result : "$GREEN"PASS"$WHITE 111 | echo $GREEN$BORDER_LINE$WHITE 112 | fi 113 | } 114 | 115 | 116 | # parameters: 117 | # $1 : arg1 118 | # $2 : arg2 119 | # $3 : arg3 120 | function test_error(){ 121 | print_arguments 3 $1 $2 $3 122 | ARG="$1 $2 $3" 123 | # ANS_OUT=$(echo "" | $CHECKER $ARG 2>/dev/null) 124 | ANS_OUT=$(echo "" | $CHECKER $ARG 2>/dev/null) 125 | ANS_ERR=$(echo "" | $CHECKER $ARG 2>&1 > /dev/null) 126 | if [ ! -z $ANS_OUT ] 127 | then 128 | # echo "Display : "$RED$ANS_OUT$WHITE"(Standard out)" 129 | print_display FAIL $ANS_OUT"(Error should be displayed on stderr.)" 130 | print_result "FAIL" 131 | elif [[ "Error" = "$ANS_ERR" ]] 132 | then 133 | print_display PASS $ANS_ERR 134 | print_result "PASS" 135 | else 136 | print_display FAIL $ANS_ERR 137 | print_result "FAIL" 138 | fi 139 | } 140 | 141 | # parameters: 142 | # $1 : number of args 143 | # $2 : arg1 144 | # $3 : arg2 145 | # $4 : arg3 146 | # $5 : arg4 147 | # $6 : arg5 148 | function test(){ 149 | if [[ $1 -le 3 ]] 150 | then 151 | ARG="$2 $3 $4 $5 $6" 152 | else 153 | ARG=$($TESTER $1 1) 154 | fi 155 | print_arguments $1 $ARG 156 | SCORE=-1 157 | 158 | ANS=$($PUSHSWAP $ARG | $CHECKER $ARG) 159 | INS=$($PUSHSWAP $ARG | wc -l) 160 | 161 | 162 | RESULT="PASS" 163 | if [[ ! "$ANS" = "OK" ]] 164 | then 165 | RESULT="FAIL" 166 | fi 167 | 168 | if [[ "$RESULT" = "PASS" ]] 169 | then 170 | print_display PASS $ANS 171 | else 172 | print_display FAIL $ANS 173 | fi 174 | 175 | 176 | INS_RESULT="PASS" 177 | if [[ $1 -eq 3 ]] 178 | then 179 | if [[ $INS -gt 3 ]] 180 | then 181 | INS_RESULT="FAIL" 182 | fi 183 | elif [[ $1 -eq 5 ]] 184 | then 185 | if [[ $INS -gt 12 ]] 186 | then 187 | INS_RESULT="FAIL" 188 | fi 189 | elif [[ $1 -eq 100 ]] 190 | then 191 | if [[ $INS -le 700 ]] 192 | then 193 | SCORE="5" 194 | elif [[ $INS -le 900 ]] 195 | then 196 | SCORE="4" 197 | elif [[ $INS -le 1100 ]] 198 | then 199 | SCORE="3" 200 | elif [[ $INS -le 1300 ]] 201 | then 202 | SCORE="2" 203 | elif [[ $INS -le 1500 ]] 204 | then 205 | SCORE="1" 206 | else 207 | SCORE="0" 208 | INS_RESULT="FAIL" 209 | fi 210 | elif [[ $1 -eq 500 ]] 211 | then 212 | if [[ $INS -le 5500 ]] 213 | then 214 | SCORE="5" 215 | elif [[ $INS -le 7000 ]] 216 | then 217 | SCORE="4" 218 | elif [[ $INS -le 8500 ]] 219 | then 220 | SCORE="3" 221 | elif [[ $INS -le 10000 ]] 222 | then 223 | SCORE="2" 224 | elif [[ $INS -le 11500 ]] 225 | then 226 | SCORE="1" 227 | else 228 | SCORE="0" 229 | INS_RESULT="FAIL" 230 | fi 231 | fi 232 | 233 | if [[ "$INS_RESULT" = "PASS" ]] 234 | then 235 | if [[ $SCORE -ne -1 ]] 236 | then 237 | if [[ $SCORE -eq 5 ]] 238 | then 239 | echo " Score : "$GREEN$SCORE$WHITE 240 | echo "Instructions : "$GREEN$INS$WHITE 241 | elif [[ $SCORE -ge 1 ]] 242 | then 243 | echo " Score : "$YELLOW$SCORE$WHITE 244 | echo "Instructions : "$YELLO$INS$WHITE 245 | else 246 | echo " Score : "$RED$SCORE$WHITE 247 | echo "Instructions : "$RED$INS$WHITE 248 | fi 249 | else 250 | if [[ "$INS_RESULT" = "PASS" ]] 251 | then 252 | echo "Instructions : "$GREEN$INS$WHITE 253 | else 254 | echo "Instructions : "$RED$INS$WHITE 255 | fi 256 | fi 257 | fi 258 | 259 | 260 | if [[ $INS_RESULT = "FAIL" ]] 261 | then 262 | RESULT="FAIL" 263 | fi 264 | 265 | print_result $RESULT 266 | } 267 | 268 | function run_non_arg_test(){ 269 | echo "$CHECKER (with no argument): " 270 | ANS="$($CHECKER)" 271 | if [ -z $ANS ] 272 | then 273 | print_display PASS $ANS 274 | print_result PASS 275 | else 276 | print_display FAIL $ANS 277 | print_result FAIL 278 | fi 279 | echo "$PUSHSWAP (with no argument): " 280 | ANS="$($PUSHSWAP)" 281 | if [ -z $ANS ] 282 | then 283 | print_display PASS $ANS 284 | print_result PASS 285 | else 286 | print_display FAIL $ANS 287 | print_result FAIL 288 | fi 289 | } 290 | 291 | #============================================================================== 292 | # makefile 293 | 294 | # random numbers 295 | echo "Building random number creator..." 296 | if [[ -z $(make 2>&1 > /dev/null) ]] 297 | then 298 | echo $GREEN" Building Successs!"$WHITE 299 | else 300 | echo $RED" Building Failed!"$WHITE 301 | exit 1 302 | fi 303 | 304 | # push_swap 305 | echo "Building push_swap..." 306 | if [[ -z $(make -C $PUSHSWAP_DIR 2>&1 > /dev/null) ]] 307 | then 308 | echo $GREEN" Building Successs!"$WHITE 309 | else 310 | echo $RED" Building Failed!"$WHITE 311 | exit 1 312 | fi 313 | echo $GREEN$BORDER_LINE$WHITE 314 | 315 | #============================================================================== 316 | # TEST START 317 | 318 | # no arg test 319 | run_non_arg_test 320 | 321 | # duplicates 322 | test_error 1 2 2 323 | test_error 2 2 1 324 | test_error 2 1 2 325 | test_error a 1 2 326 | test_error 1 a 2 327 | test_error 1 2 a 328 | test_error 1 2 2147483648 329 | test_error 1 2 -2147483649 330 | # negative numbers, near overflow 331 | test 3 1 -5 2 332 | test 3 1 -2147483648 2 333 | test 3 2147483647 2 1 334 | # # 3 elements 335 | test 3 2 0 1 336 | test 3 1 2 3 337 | test 3 1 3 2 338 | test 3 2 1 3 339 | test 3 2 3 1 340 | test 3 3 1 2 341 | test 3 3 2 1 342 | # 4 elements 343 | test 4 344 | test 4 345 | test 4 346 | test 4 347 | test 4 348 | # 5 elements 349 | test 5 350 | test 5 351 | test 5 352 | test 5 353 | test 5 354 | test 5 355 | test 5 356 | # 100 elements 357 | test 100 358 | test 100 359 | test 100 360 | test 100 361 | test 100 362 | test 100 363 | # 500 elements 364 | test 500 365 | test 500 366 | test 500 367 | test 500 368 | test 500 369 | test 500 370 | 371 | rm $TESTER -------------------------------------------------------------------------------- /push_swap_tester/random_numbers.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* random_numbers.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: minckim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/03/07 01:27:52 by minckim #+# #+# */ 9 | /* Updated: 2021/03/30 04:28:35 by minckim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | int myrandom(long min, long max) 20 | { 21 | std::random_device random_device; 22 | std::mt19937 generator(random_device()); 23 | std::uniform_int_distribution distribute(min, max); 24 | return distribute(generator); 25 | } 26 | 27 | void random_number_vector(std::vector& v, int size, int min = 1, int max = 1) 28 | { 29 | if (min > max) 30 | std::swap(min, max); 31 | if (max + 1 - min < size) 32 | max = min + size - 1; 33 | 34 | std::vector v_tmp; 35 | v_tmp.reserve(max - min + 1); 36 | for (int i = min ; i <= max ; i++) 37 | v_tmp.push_back(i); 38 | for (int i = 0 ; i < max - min + 1 ; i++) 39 | std::swap(v_tmp[i], v_tmp[myrandom(0, max - min)]); 40 | for (int i = 0 ; i < size ; i++) 41 | v.push_back(v_tmp[i]); 42 | } 43 | 44 | int main(int argc, char** argv) 45 | { 46 | std::vector v; 47 | 48 | int size; 49 | int min; 50 | int max; 51 | if (argc < 2) 52 | { 53 | std::cout << "Usage: " << argv[0] << " [min] [max]\n" 54 | << "- and is optional arguments.\n" 55 | << "- Default value of and is 1. But must be defined.\n" 56 | << "- If ( - ) is less than , would be changed to fit the \n" 57 | << "- To set ARG:\n\n" 58 | << " $ export ARG=\"$(" << argv[0] << " [min] [max])\"\n\n" 59 | << "- By: minckim \n"; 60 | return 1; 61 | } 62 | try 63 | { 64 | size = atoi(argv[1]); 65 | if (argc >= 3) 66 | min = atoi(argv[2]); 67 | else 68 | min = 0; 69 | if (argc >= 4) 70 | { 71 | max = atoi(argv[3]); 72 | max = max > min + size - 1 ? max : min + size - 1; 73 | } 74 | else 75 | max = min + size - 1; 76 | } 77 | catch(const std::exception& e) 78 | { 79 | std::cout << e.what() << '\n'; 80 | return 1; 81 | } 82 | random_number_vector(v, size, min, max); 83 | for (int i : v) 84 | { 85 | std::cout << i << " "; 86 | } 87 | return 0; 88 | } -------------------------------------------------------------------------------- /run_visualizer.bash: -------------------------------------------------------------------------------- 1 | # **************************************************************************** # 2 | # # 3 | # ::: :::::::: # 4 | # run_visualizer.bash :+: :+: :+: # 5 | # +:+ +:+ +:+ # 6 | # By: mher +#+ +:+ +#+ # 7 | # +#+#+#+#+#+ +#+ # 8 | # Created: 2022/04/20 00:29:53 by mher #+# #+# # 9 | # Updated: 2022/04/20 22:14:38 by mher ### ########.fr # 10 | # # 11 | # **************************************************************************** # 12 | 13 | #!/bin/bash 14 | 15 | #============================================================================== 16 | # Directroy 17 | 18 | # |- [ push_swap ] (Your push_swap dir) 19 | # | |- Makefile 20 | # |- [ push_swap_visuzlizer ] 21 | # |- run_visualizer.bash 22 | # |- push_swap_tester (push_swap_tester by minckim) 23 | # |- Makefile 24 | 25 | #============================================================================== 26 | # path 27 | 28 | PUSH_SWAP_DIR=../push_swap 29 | 30 | TESTER_DIR=./push_swap_tester 31 | 32 | #============================================================================== 33 | # set ARG 34 | 35 | if [ $1 ] 36 | then 37 | export ARG=$($TESTER_DIR/random_numbers $1 1) 38 | else 39 | export ARG=$($TESTER_DIR/random_numbers 10 1) 40 | fi 41 | 42 | #============================================================================== 43 | # run 44 | 45 | $PUSH_SWAP_DIR/push_swap $ARG > push_swap_out 46 | 47 | ./visualizer $ARG 48 | -------------------------------------------------------------------------------- /srcs/data_struct_src/list_utils.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* list_utils.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/04/12 23:31:31 by mher #+# #+# */ 9 | /* Updated: 2022/04/22 15:49:26 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "../../include/data_struct.h" 14 | 15 | t_list *ft_lstnew(int data) 16 | { 17 | t_list *new_list; 18 | 19 | new_list = (t_list *)malloc(sizeof(t_list)); 20 | if (!new_list) 21 | return (0); 22 | new_list->data = data; 23 | new_list->next = 0; 24 | new_list->prev = 0; 25 | return (new_list); 26 | } 27 | 28 | t_list *ft_lstlast(t_list *lst) 29 | { 30 | if (!lst) 31 | return (0); 32 | while (lst->next) 33 | lst = lst->next; 34 | return (lst); 35 | } 36 | 37 | t_list *ft_lstlast_cnt(t_list *lst, int cnt) 38 | { 39 | int i; 40 | 41 | i = 0; 42 | if (!lst) 43 | return (0); 44 | while (i < cnt) 45 | { 46 | lst = lst->next; 47 | i++; 48 | } 49 | return (lst); 50 | } 51 | 52 | void ft_lstadd_back(t_list **lst, t_list *new_list) 53 | { 54 | t_list *last; 55 | 56 | if (!lst || !new_list) 57 | return ; 58 | if (!*lst) 59 | { 60 | *lst = new_list; 61 | return ; 62 | } 63 | last = ft_lstlast(*lst); 64 | last->next = new_list; 65 | new_list->prev = last; 66 | } 67 | 68 | void ft_lstadd_front(t_list **lst, t_list *new_list) 69 | { 70 | if (!lst || !new_list) 71 | return ; 72 | new_list->next = *lst; 73 | (*lst)->prev = new_list; 74 | *lst = new_list; 75 | } 76 | -------------------------------------------------------------------------------- /srcs/initalize_src/check.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* check.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/04/13 22:02:44 by mher #+# #+# */ 9 | /* Updated: 2022/04/22 15:49:40 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "../../include/initialize.h" 14 | 15 | void check_dup(int *nums, int size) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (i + 1 < size) 21 | { 22 | if (nums[i] == nums[i + 1]) 23 | error_exit("Error\n"); 24 | ++i; 25 | } 26 | } 27 | 28 | int check_ascending(t_info *info, int *nums) 29 | { 30 | int i; 31 | int cnt; 32 | t_list *cur; 33 | 34 | i = 0; 35 | cnt = 0; 36 | cur = info->a.head; 37 | while (i < info->total_size) 38 | { 39 | if (cur->data == nums[i]) 40 | ++cnt; 41 | cur = cur->next; 42 | ++i; 43 | } 44 | if (cnt == info->total_size) 45 | return (1); 46 | return (0); 47 | } 48 | 49 | int check_num_atoi(const char *str) 50 | { 51 | long ret; 52 | int sign; 53 | const char *tmp; 54 | 55 | ret = 0; 56 | sign = 1; 57 | while (*str == ' ' || (9 <= *str && *str <= 13)) 58 | ++str; 59 | if (*str == '+' || *str == '-') 60 | if (*str++ == '-') 61 | sign *= -1; 62 | tmp = str; 63 | while (*tmp) 64 | { 65 | if (*tmp < '0' || '9' < *tmp) 66 | error_exit("Error\n"); 67 | ++tmp; 68 | } 69 | while ('0' <= *str && *str <= '9') 70 | { 71 | ret = (ret * 10) + ((*str++ - '0') * sign); 72 | if (ret < INT_MIN || INT_MAX < ret) 73 | error_exit("Error\n"); 74 | } 75 | return (ret); 76 | } 77 | -------------------------------------------------------------------------------- /srcs/initalize_src/error_exit.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* error_exit.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/04/13 00:31:04 by mher #+# #+# */ 9 | /* Updated: 2022/04/22 15:49:55 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "../../include/initialize.h" 14 | 15 | void error_exit(const char *msg) 16 | { 17 | while (*msg) 18 | write(2, msg++, 1); 19 | exit(1); 20 | } 21 | -------------------------------------------------------------------------------- /srcs/initalize_src/init.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* init.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/04/12 16:52:56 by mher #+# #+# */ 9 | /* Updated: 2022/04/22 15:50:18 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "../../include/initialize.h" 14 | 15 | char *get_line_num(int argc, char **argv) 16 | { 17 | int i; 18 | char *tmp; 19 | char *line; 20 | 21 | i = 1; 22 | tmp = 0; 23 | line = 0; 24 | while (i < argc) 25 | { 26 | if (*argv[i] == 0) 27 | error_exit("Error\n"); 28 | tmp = ft_strjoin(line, argv[i]); 29 | if (!tmp) 30 | error_exit("Error\n"); 31 | free(line); 32 | line = tmp; 33 | tmp = ft_strjoin(line, " "); 34 | if (!tmp) 35 | error_exit("Error\n"); 36 | free(line); 37 | line = tmp; 38 | ++i; 39 | } 40 | return (line); 41 | } 42 | 43 | int *get_nums(char *line, t_info *info) 44 | { 45 | int i; 46 | char **strs; 47 | int *nums; 48 | 49 | i = 0; 50 | strs = ft_split(line, ' '); 51 | if (!strs) 52 | error_exit("Error\n"); 53 | while (strs[i]) 54 | ++i; 55 | info->total_size = i; 56 | nums = (int *)malloc(info->total_size * sizeof(int)); 57 | if (!nums) 58 | error_exit("Error\n"); 59 | i = 0; 60 | while (strs[i]) 61 | { 62 | nums[i] = check_num_atoi(strs[i]); 63 | ++i; 64 | } 65 | i = 0; 66 | while (strs[i]) 67 | free(strs[i++]); 68 | free(strs); 69 | return (nums); 70 | } 71 | 72 | void init_stack(t_info *info, int *nums) 73 | { 74 | t_list *tmp; 75 | 76 | info->a.size = 0; 77 | info->b.size = 0; 78 | info->a.head = ft_lstnew(nums[info->a.size++]); 79 | while (info->a.size < info->total_size) 80 | { 81 | tmp = ft_lstnew(nums[info->a.size]); 82 | if (!tmp) 83 | error_exit("Error\n"); 84 | ft_lstadd_back(&info->a.head, tmp); 85 | info->a.size++; 86 | } 87 | tmp = ft_lstlast(info->a.head); 88 | info->a.head->prev = tmp; 89 | tmp->next = info->a.head; 90 | } 91 | 92 | void init_pivot(t_info *info, int *nums) 93 | { 94 | int size; 95 | 96 | size = info->total_size; 97 | info->min = nums[0]; 98 | info->max = nums[size - 1]; 99 | info->f_pivot = nums[size * 1 / 3]; 100 | info->s_pivot = nums[size * 2 / 3]; 101 | } 102 | -------------------------------------------------------------------------------- /srcs/initalize_src/quick_sort.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* quick_sort.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/04/12 01:46:25 by mher #+# #+# */ 9 | /* Updated: 2022/04/13 12:13:06 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | static void swap(int *a, int *b) 14 | { 15 | int tmp; 16 | 17 | tmp = *a; 18 | *a = *b; 19 | *b = tmp; 20 | } 21 | 22 | void quick_sort(int *arr, int start, int end) 23 | { 24 | int pivot; 25 | int i; 26 | int j; 27 | 28 | pivot = start; 29 | i = pivot + 1; 30 | j = end; 31 | if (start >= end) 32 | return ; 33 | while (i <= j) 34 | { 35 | while (i <= end && arr[i] <= arr[pivot]) 36 | i++; 37 | while (j > start && arr[j] >= arr[pivot]) 38 | j--; 39 | if (i > j) 40 | swap(&arr[j], &arr[pivot]); 41 | else 42 | swap(&arr[i], &arr[j]); 43 | } 44 | quick_sort(arr, start, j - 1); 45 | quick_sort(arr, j + 1, end); 46 | } 47 | -------------------------------------------------------------------------------- /srcs/operator_src/operator_p.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* operator_p.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/04/13 00:18:52 by mher #+# #+# */ 9 | /* Updated: 2022/04/22 15:50:46 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "../../include/operator.h" 14 | 15 | void pa(t_info *info, char flag) 16 | { 17 | if (flag == 'p') 18 | write(1, "pa\n", 3); 19 | push_stack(&info->a, &info->b); 20 | } 21 | 22 | void pb(t_info *info, char flag) 23 | { 24 | if (flag == 'p') 25 | write(1, "pb\n", 3); 26 | push_stack(&info->b, &info->a); 27 | } 28 | -------------------------------------------------------------------------------- /srcs/operator_src/operator_r.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* operator_r.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/04/13 00:19:35 by mher #+# #+# */ 9 | /* Updated: 2022/04/22 15:51:03 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "../../include/operator.h" 14 | 15 | void ra(t_info *info, char flag) 16 | { 17 | if (flag == 'p') 18 | write(1, "ra\n", 3); 19 | rotate_stack(&info->a); 20 | } 21 | 22 | void rb(t_info *info, char flag) 23 | { 24 | if (flag == 'p') 25 | write(1, "rb\n", 3); 26 | rotate_stack(&info->b); 27 | } 28 | 29 | void rr(t_info *info, char flag) 30 | { 31 | if (flag == 'p') 32 | write(1, "rr\n", 3); 33 | rotate_stack(&info->a); 34 | rotate_stack(&info->b); 35 | } 36 | -------------------------------------------------------------------------------- /srcs/operator_src/operator_rr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* operator_rr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/04/06 16:14:30 by mher #+# #+# */ 9 | /* Updated: 2022/04/22 15:51:14 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "../../include/operator.h" 14 | 15 | void rra(t_info *info, char flag) 16 | { 17 | if (flag == 'p') 18 | write(1, "rra\n", 4); 19 | reverse_rotate_stack(&info->a); 20 | } 21 | 22 | void rrb(t_info *info, char flag) 23 | { 24 | if (flag == 'p') 25 | write(1, "rrb\n", 4); 26 | reverse_rotate_stack(&info->b); 27 | } 28 | 29 | void rrr(t_info *info, char flag) 30 | { 31 | if (flag == 'p') 32 | write(1, "rrr\n", 4); 33 | reverse_rotate_stack(&info->a); 34 | reverse_rotate_stack(&info->b); 35 | } 36 | -------------------------------------------------------------------------------- /srcs/operator_src/operator_s.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* operator_s.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/04/13 00:18:11 by mher #+# #+# */ 9 | /* Updated: 2022/04/22 15:51:23 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "../../include/operator.h" 14 | 15 | void sa(t_info *info, char flag) 16 | { 17 | if (flag == 'p') 18 | write(1, "sa\n", 3); 19 | swap_stack(&info->a); 20 | } 21 | 22 | void sb(t_info *info, char flag) 23 | { 24 | if (flag == 'p') 25 | write(1, "sb\n", 3); 26 | swap_stack(&info->b); 27 | } 28 | 29 | void ss(t_info *info, char flag) 30 | { 31 | if (flag == 'p') 32 | write(1, "ss\n", 3); 33 | swap_stack(&info->a); 34 | swap_stack(&info->b); 35 | } 36 | -------------------------------------------------------------------------------- /srcs/operator_src/pop_push_swap_rotate.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* pop_push_swap_rotate.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/04/13 00:16:34 by mher #+# #+# */ 9 | /* Updated: 2022/04/22 15:51:34 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "../../include/operator.h" 14 | 15 | void swap_stack(t_stack *stack) 16 | { 17 | int tmp; 18 | 19 | if (stack->size < 2) 20 | return ; 21 | tmp = stack->head->data; 22 | stack->head->data = stack->head->next->data; 23 | stack->head->next->data = tmp; 24 | } 25 | 26 | void push_stack(t_stack *dest, t_stack *from) 27 | { 28 | t_list *tmp; 29 | 30 | if (from->size == 0) 31 | return ; 32 | if (dest->size == 0) 33 | { 34 | dest->head = pop_stack(from); 35 | dest->size++; 36 | return ; 37 | } 38 | ft_lstadd_front(&dest->head, pop_stack(from)); 39 | tmp = ft_lstlast_cnt(dest->head, dest->size); 40 | dest->head->prev = tmp; 41 | tmp->next = dest->head; 42 | dest->size++; 43 | } 44 | 45 | t_list *pop_stack(t_stack *stack) 46 | { 47 | t_list *pop; 48 | 49 | pop = stack->head; 50 | if (stack->size == 1) 51 | { 52 | stack->head = 0; 53 | } 54 | else if (stack->size == 2) 55 | { 56 | stack->head = stack->head->next; 57 | } 58 | else 59 | { 60 | stack->head->prev->next = stack->head->next; 61 | stack->head->next->prev = stack->head->prev; 62 | stack->head = stack->head->next; 63 | } 64 | stack->size--; 65 | pop->next = 0; 66 | pop->prev = 0; 67 | return (pop); 68 | } 69 | 70 | void rotate_stack(t_stack *stack) 71 | { 72 | if (stack->size < 2) 73 | return ; 74 | stack->head = stack->head->next; 75 | } 76 | 77 | void reverse_rotate_stack(t_stack *stack) 78 | { 79 | if (stack->size < 2) 80 | return ; 81 | stack->head = stack->head->prev; 82 | } 83 | -------------------------------------------------------------------------------- /srcs/visualizer_src/visualizer.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* visualizer.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mher +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/04/15 18:53:03 by mher #+# #+# */ 9 | /* Updated: 2022/04/23 01:17:32 by mher ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "../../include/checker.h" 14 | #include 15 | 16 | static void run_op(t_info *info, char *op) 17 | { 18 | if (!ft_strncmp(op, "sa\n", 3)) 19 | sa(info, 'p'); 20 | else if (!ft_strncmp(op, "sb\n", 3)) 21 | sb(info, 'p'); 22 | else if (!ft_strncmp(op, "ss\n", 3)) 23 | ss(info, 'p'); 24 | else if (!ft_strncmp(op, "pa\n", 3)) 25 | pa(info, 'p'); 26 | else if (!ft_strncmp(op, "pb\n", 3)) 27 | pb(info, 'p'); 28 | else if (!ft_strncmp(op, "ra\n", 3)) 29 | ra(info, 'p'); 30 | else if (!ft_strncmp(op, "rb\n", 3)) 31 | rb(info, 'p'); 32 | else if (!ft_strncmp(op, "rr\n", 3)) 33 | rr(info, 'p'); 34 | else if (!ft_strncmp(op, "rra\n", 4)) 35 | rra(info, 'p'); 36 | else if (!ft_strncmp(op, "rrb\n", 4)) 37 | rrb(info, 'p'); 38 | else if (!ft_strncmp(op, "rrr\n", 4)) 39 | rrr(info, 'p'); 40 | else 41 | error_exit("Error\n"); 42 | } 43 | 44 | static void braker(void) 45 | { 46 | char *brake; 47 | 48 | while(1) 49 | { 50 | brake = get_next_line(STDIN_FILENO); 51 | if (!ft_strncmp(brake, "\n", 1)) 52 | return ; 53 | } 54 | } 55 | 56 | static void padding_buff(char *buff, int *bf_cnt, int cnt, char c) 57 | { 58 | while (cnt) 59 | { 60 | buff[*bf_cnt] = c; 61 | cnt--; 62 | (*bf_cnt)++; 63 | } 64 | } 65 | 66 | static void visualizer_buffer(const t_info *info) 67 | { 68 | int i; 69 | t_list *a_cur; 70 | t_list *b_cur; 71 | char *buff; 72 | int bf_cnt; 73 | 74 | i = 0; 75 | bf_cnt = 0; 76 | a_cur = info->a.head; 77 | b_cur = info->b.head; 78 | buff = (char *)malloc(info->max * 2 * info->total_size); 79 | ft_bzero(buff, info->max * 2 * info->total_size); 80 | while (i < info->total_size) 81 | { 82 | if (0 < info->a.size && i < info->a.size) 83 | padding_buff(buff, &bf_cnt, a_cur->data, '-'); 84 | if (info->a.size > i) 85 | padding_buff(buff, &bf_cnt, info->max - a_cur->data, ' '); 86 | else 87 | padding_buff(buff, &bf_cnt, info->max, ' '); 88 | padding_buff(buff, &bf_cnt, 1, '|'); 89 | if (0 < info->b.size && i < info->b.size) 90 | padding_buff(buff, &bf_cnt, b_cur->data, '-'); 91 | padding_buff(buff, &bf_cnt, 1, '\n'); 92 | if (1 < info->a.size) 93 | a_cur = a_cur->next; 94 | if (1 < info->b.size) 95 | b_cur = b_cur->next; 96 | i++; 97 | } 98 | system("clear"); 99 | write(1, buff, bf_cnt); 100 | free(buff); 101 | } 102 | 103 | static void checker(t_info *info) 104 | { 105 | char *op; 106 | int fd; 107 | int cnt; 108 | 109 | op = 0; 110 | cnt = 0; 111 | fd = open("push_swap_out", O_RDONLY); 112 | if (fd < 0) 113 | error_exit("Error: file open\n"); 114 | while (1) 115 | { 116 | //visualizer(info); 117 | visualizer_buffer(info); 118 | op = get_next_line(fd); 119 | if (!op) 120 | break ; 121 | run_op(info, op); 122 | braker(); 123 | free(op); 124 | ++cnt; 125 | } 126 | close(fd); 127 | } 128 | 129 | int main(int argc, char **argv) 130 | { 131 | t_info info; 132 | char *line; 133 | int *nums; 134 | 135 | if (argc < 2) 136 | return (0); 137 | line = get_line_num(argc, argv); 138 | nums = get_nums(line, &info); 139 | init_stack(&info, nums); 140 | quick_sort(nums, 0, info.total_size - 1); 141 | check_dup(nums, info.total_size); 142 | init_pivot(&info, nums); 143 | checker(&info); 144 | if (info.b.size == 0 && check_ascending(&info, nums)) 145 | write(1, "OK\n", 3); 146 | else 147 | write(1, "KO\n", 3); 148 | exit(0); 149 | } 150 | -------------------------------------------------------------------------------- /tags: -------------------------------------------------------------------------------- 1 | !_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ 2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ 3 | !_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ 4 | !_TAG_PROGRAM_NAME Exuberant Ctags // 5 | !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ 6 | !_TAG_PROGRAM_VERSION 5.8 // 7 | BUFFER_SIZE lib/libgnl/include/get_next_line.h /^# define BUFFER_SIZE /;" d 8 | CC Makefile /^CC = gcc$/;" m 9 | CC lib/libft/Makefile /^CC = gcc$/;" m 10 | CC lib/libgnl/Makefile /^CC = gcc$/;" m 11 | CFLAGS Makefile /^CFLAGS = -Wall -Wextra -Werror$/;" m 12 | CFLAGS lib/libft/Makefile /^CFLAGS = -Wall -Wextra -Werror$/;" m 13 | CFLAGS lib/libgnl/Makefile /^CFLAGS = -Wall -Wextra -Werror$/;" m 14 | CHECKER_H include/checker.h /^# define CHECKER_H$/;" d 15 | DATA_STRUCT_DIR Makefile /^DATA_STRUCT_DIR = .\/srcs\/data_struct_src$/;" m 16 | DATA_STRUCT_H include/data_struct.h /^# define DATA_STRUCT_H$/;" d 17 | DATA_STRUCT_SRC Makefile /^DATA_STRUCT_SRC = \\$/;" m 18 | FT Makefile /^FT = ft$/;" m 19 | FT_DIR Makefile /^FT_DIR = .\/lib\/Libft$/;" m 20 | GET_NEXT_LINE_BONUS_H lib/libgnl/include/get_next_line.h /^# define GET_NEXT_LINE_BONUS_H$/;" d 21 | GNL Makefile /^GNL = gnl$/;" m 22 | GNL_DIR Makefile /^GNL_DIR = .\/lib\/libgnl $/;" m 23 | INCLUDE Makefile /^INCLUDE = -I.\/include$/;" m 24 | INCLUDE lib/libft/Makefile /^INCLUDE = -I.\/include$/;" m 25 | INCLUDE lib/libgnl/Makefile /^INCLUDE = -I.\/include$/;" m 26 | INITALIZE_DIR Makefile /^INITALIZE_DIR = .\/srcs\/initalize_src$/;" m 27 | INITALIZE_SRC Makefile /^INITALIZE_SRC = \\$/;" m 28 | INITIALIZE_H include/initialize.h /^# define INITIALIZE_H$/;" d 29 | LIBFT_H lib/libft/include/libft.h /^# define LIBFT_H$/;" d 30 | NAME Makefile /^NAME = visualizer$/;" m 31 | NAME lib/libft/Makefile /^NAME = libft.a$/;" m 32 | NAME lib/libgnl/Makefile /^NAME = libgnl.a$/;" m 33 | OBJ lib/libft/Makefile /^OBJ = $(SRC:.c=.o)$/;" m 34 | OBJ lib/libgnl/Makefile /^OBJ = $(SRC:.c=.o)$/;" m 35 | OPERATOR_DIR Makefile /^OPERATOR_DIR = .\/srcs\/operator_src$/;" m 36 | OPERATOR_H include/operator.h /^# define OPERATOR_H$/;" d 37 | OPERATOR_SRC Makefile /^OPERATOR_SRC = \\$/;" m 38 | PUSH_SWAP_H include/push_swap.h /^# define PUSH_SWAP_H$/;" d 39 | PUSH_SWAP_OBJ Makefile /^PUSH_SWAP_OBJ = $(PUSH_SWAP_SRC:.c=.o)$/;" m 40 | SRC lib/libft/Makefile /^SRC = \\$/;" m 41 | SRC lib/libgnl/Makefile /^SRC = \\$/;" m 42 | SRC_DIR lib/libft/Makefile /^SRC_DIR = .\/src$/;" m 43 | SRC_DIR lib/libgnl/Makefile /^SRC_DIR = .\/src$/;" m 44 | TESTER_DIR Makefile /^TESTER_DIR = .\/push_swap_tester $/;" m 45 | VISUALIZER_DIR Makefile /^VISUALIZER_DIR = .\/srcs\/visualizer_src$/;" m 46 | VISUALIZER_OBJ Makefile /^VISUALIZER_OBJ = $(VISUALIZER_SRC:.c=.o)$/;" m 47 | VISUALIZER_SRC Makefile /^VISUALIZER_SRC = \\$/;" m 48 | a include/data_struct.h /^ t_op a;$/;" m struct:s_rotate 49 | a include/data_struct.h /^ t_stack a;$/;" m struct:s_info 50 | b include/data_struct.h /^ t_op b;$/;" m struct:s_rotate 51 | b include/data_struct.h /^ t_stack b;$/;" m struct:s_info 52 | braker srcs/visualizer_src/visualizer.c /^static void braker(void)$/;" f file: 53 | check_ascending srcs/initalize_src/check.c /^int check_ascending(t_info *info, int *nums)$/;" f 54 | check_dup srcs/initalize_src/check.c /^void check_dup(int *nums, int size)$/;" f 55 | check_num_atoi srcs/initalize_src/check.c /^int check_num_atoi(const char *str)$/;" f 56 | checker srcs/visualizer_src/visualizer.c /^static void checker(t_info *info)$/;" f file: 57 | data include/data_struct.h /^ int data;$/;" m struct:s_list 58 | error_exit srcs/initalize_src/error_exit.c /^void error_exit(const char *msg)$/;" f 59 | f_pivot include/data_struct.h /^ int f_pivot;$/;" m struct:s_info 60 | fd lib/libgnl/include/get_next_line.h /^ int fd;$/;" m struct:s_fd_lst 61 | find_fd lib/libgnl/src/get_next_line.c /^t_fd_lst *find_fd(int fd, t_fd_lst *head)$/;" f 62 | ft_abs lib/libft/src/ft_itoa.c /^static int ft_abs(int n)$/;" f file: 63 | ft_atoi lib/libft/src/ft_atoi.c /^int ft_atoi(const char *str)$/;" f 64 | ft_bzero lib/libft/src/ft_bzero.c /^void ft_bzero(void *s, size_t n)$/;" f 65 | ft_calloc lib/libft/src/ft_calloc.c /^void *ft_calloc(size_t count, size_t size)$/;" f 66 | ft_get_num_len lib/libft/src/ft_itoa.c /^static int ft_get_num_len(int n)$/;" f file: 67 | ft_get_word_cnt lib/libft/src/ft_split.c /^static size_t ft_get_word_cnt(const char *s, char c)$/;" f file: 68 | ft_get_word_len lib/libft/src/ft_split.c /^static size_t ft_get_word_len(const char *s, char c)$/;" f file: 69 | ft_isalnum lib/libft/src/ft_isalnum.c /^int ft_isalnum(int c)$/;" f 70 | ft_isalpha lib/libft/src/ft_isalpha.c /^int ft_isalpha(int c)$/;" f 71 | ft_isascii lib/libft/src/ft_isascii.c /^int ft_isascii(int c)$/;" f 72 | ft_isdigit lib/libft/src/ft_isdigit.c /^int ft_isdigit(int c)$/;" f 73 | ft_isprint lib/libft/src/ft_isprint.c /^int ft_isprint(int c)$/;" f 74 | ft_itoa lib/libft/src/ft_itoa.c /^char *ft_itoa(int n)$/;" f 75 | ft_lstadd_back srcs/data_struct_src/list_utils.c /^void ft_lstadd_back(t_list **lst, t_list *new)$/;" f 76 | ft_lstadd_front srcs/data_struct_src/list_utils.c /^void ft_lstadd_front(t_list **lst, t_list *new)$/;" f 77 | ft_lstlast srcs/data_struct_src/list_utils.c /^t_list *ft_lstlast(t_list *lst)$/;" f 78 | ft_lstlast_cnt srcs/data_struct_src/list_utils.c /^t_list *ft_lstlast_cnt(t_list *lst, int cnt)$/;" f 79 | ft_lstnew srcs/data_struct_src/list_utils.c /^t_list *ft_lstnew(int data)$/;" f 80 | ft_malloc_error lib/libft/src/ft_split.c /^static char **ft_malloc_error(char **ret)$/;" f file: 81 | ft_memchr lib/libft/src/ft_memchr.c /^void *ft_memchr(const void *s, int c, size_t n)$/;" f 82 | ft_memcmp lib/libft/src/ft_memcmp.c /^int ft_memcmp(const void *s1, const void *s2, size_t n)$/;" f 83 | ft_memcpy lib/libft/src/ft_memcpy.c /^void *ft_memcpy(void *dst, const void *src, size_t n)$/;" f 84 | ft_memmove lib/libft/src/ft_memmove.c /^void *ft_memmove(void *dst, const void *src, size_t len)$/;" f 85 | ft_memset lib/libft/src/ft_memset.c /^void *ft_memset(void *b, int c, size_t len)$/;" f 86 | ft_print_nbr lib/libft/src/ft_putnbr_fd.c /^static void ft_print_nbr(int n, int fd)$/;" f file: 87 | ft_putchar_fd lib/libft/src/ft_putchar_fd.c /^void ft_putchar_fd(char c, int fd)$/;" f 88 | ft_putendl_fd lib/libft/src/ft_putendl_fd.c /^void ft_putendl_fd(char *s, int fd)$/;" f 89 | ft_putnbr_fd lib/libft/src/ft_putnbr_fd.c /^void ft_putnbr_fd(int n, int fd)$/;" f 90 | ft_putstr_fd lib/libft/src/ft_putstr_fd.c /^void ft_putstr_fd(char *s, int fd)$/;" f 91 | ft_split lib/libft/src/ft_split.c /^char **ft_split(char const *s, char c)$/;" f 92 | ft_strchr lib/libft/src/ft_strchr.c /^char *ft_strchr(const char *s, int c)$/;" f 93 | ft_strchr lib/libgnl/src/get_next_line_utils.c /^char *ft_strchr(const char *s, int c)$/;" f 94 | ft_strdup lib/libft/src/ft_strdup.c /^char *ft_strdup(const char *s1)$/;" f 95 | ft_strdup lib/libgnl/src/get_next_line_utils.c /^char *ft_strdup(const char *s1)$/;" f 96 | ft_striteri lib/libft/src/ft_striteri.c /^void ft_striteri(char *s, void (*f)(unsigned int, char*))$/;" f 97 | ft_strjoin lib/libft/src/ft_strjoin.c /^char *ft_strjoin(char const *s1, char const *s2)$/;" f 98 | ft_strjoin lib/libgnl/src/get_next_line_utils.c /^char *ft_strjoin(char const *s1, char const *s2)$/;" f 99 | ft_strlcat lib/libft/src/ft_strlcat.c /^size_t ft_strlcat(char *dst, const char *src, size_t dstsize)$/;" f 100 | ft_strlcpy lib/libft/src/ft_strlcpy.c /^size_t ft_strlcpy(char *dest, const char *src, size_t destsize)$/;" f 101 | ft_strlcpy lib/libgnl/src/get_next_line_utils.c /^size_t ft_strlcpy(char *dest, const char *src, size_t destsize)$/;" f 102 | ft_strlen lib/libft/src/ft_strlen.c /^size_t ft_strlen(const char *s)$/;" f 103 | ft_strlen lib/libgnl/src/get_next_line_utils.c /^size_t ft_strlen(const char *s)$/;" f 104 | ft_strmapi lib/libft/src/ft_strmapi.c /^char *ft_strmapi(char const *s, char (*f)(unsigned int, char))$/;" f 105 | ft_strncmp lib/libft/src/ft_strncmp.c /^int ft_strncmp(const char *s1, const char *s2, size_t n)$/;" f 106 | ft_strnstr lib/libft/src/ft_strnstr.c /^char *ft_strnstr(const char *haystack, const char *needle, size_t len)$/;" f 107 | ft_strrchr lib/libft/src/ft_strrchr.c /^char *ft_strrchr(const char *s, int c)$/;" f 108 | ft_strtrim lib/libft/src/ft_strtrim.c /^char *ft_strtrim(char const *s1, char const *set)$/;" f 109 | ft_substr lib/libft/src/ft_substr.c /^char *ft_substr(char const *s, unsigned int start, size_t len)$/;" f 110 | ft_tolower lib/libft/src/ft_tolower.c /^int ft_tolower(int c)$/;" f 111 | ft_toupper lib/libft/src/ft_toupper.c /^int ft_toupper(int c)$/;" f 112 | get_line lib/libgnl/src/get_next_line.c /^char *get_line(char *keep)$/;" f 113 | get_line_num srcs/initalize_src/init.c /^char *get_line_num(int argc, char **argv)$/;" f 114 | get_next_line lib/libgnl/src/get_next_line.c /^char *get_next_line(int fd)$/;" f 115 | get_nums srcs/initalize_src/init.c /^int *get_nums(char *line, t_info *info)$/;" f 116 | gnl_or_del lib/libgnl/src/get_next_line.c /^char *gnl_or_del(t_fd_lst **fd_lst)$/;" f 117 | head include/data_struct.h /^ t_list *head;$/;" m struct:s_stack 118 | init_pivot srcs/initalize_src/init.c /^void init_pivot(t_info *info, int *nums)$/;" f 119 | init_stack srcs/initalize_src/init.c /^void init_stack(t_info *info, int *nums)$/;" f 120 | keep lib/libgnl/include/get_next_line.h /^ char *keep;$/;" m struct:s_fd_lst 121 | main push_swap_tester/random_numbers.cpp /^int main(int argc, char** argv)$/;" f 122 | main srcs/visualizer_src/visualizer.c /^int main(int argc, char **argv)$/;" f 123 | max include/data_struct.h /^ int max;$/;" m struct:s_info 124 | min include/data_struct.h /^ int min;$/;" m struct:s_info 125 | myrandom push_swap_tester/random_numbers.cpp /^int myrandom(long min, long max)$/;" f 126 | next include/data_struct.h /^ struct s_list *next;$/;" m struct:s_list typeref:struct:s_list::s_list 127 | next lib/libgnl/include/get_next_line.h /^ struct s_fd_lst *next;$/;" m struct:s_fd_lst typeref:struct:s_fd_lst::s_fd_lst 128 | pa srcs/operator_src/operator_p.c /^void pa(t_info *info, char flag)$/;" f 129 | pb srcs/operator_src/operator_p.c /^void pb(t_info *info, char flag)$/;" f 130 | pop_stack srcs/operator_src/pop_push_swap_rotate.c /^t_list *pop_stack(t_stack *stack)$/;" f 131 | prev include/data_struct.h /^ struct s_list *prev;$/;" m struct:s_list typeref:struct:s_list::s_list 132 | prev lib/libgnl/include/get_next_line.h /^ struct s_fd_lst *prev;$/;" m struct:s_fd_lst typeref:struct:s_fd_lst::s_fd_lst 133 | print_arguments push_swap_tester/push_swap_tester.bash /^function print_arguments(){$/;" f 134 | print_display push_swap_tester/push_swap_tester.bash /^function print_display(){$/;" f 135 | print_result push_swap_tester/push_swap_tester.bash /^function print_result(){$/;" f 136 | print_space srcs/visualizer_src/visualizer.c /^static void print_space(int cnt)$/;" f file: 137 | print_stick srcs/visualizer_src/visualizer.c /^static void print_stick(int cnt)$/;" f file: 138 | push_stack srcs/operator_src/pop_push_swap_rotate.c /^void push_stack(t_stack *dest, t_stack *from)$/;" f 139 | quick_sort srcs/initalize_src/quick_sort.c /^void quick_sort(int *arr, int start, int end)$/;" f 140 | r include/data_struct.h /^ int r;$/;" m struct:s_op 141 | ra srcs/operator_src/operator_r.c /^void ra(t_info *info, char flag)$/;" f 142 | random_number_vector push_swap_tester/random_numbers.cpp /^void random_number_vector(std::vector& v, int size, int min = 1, int max = 1)$/;" f 143 | rb srcs/operator_src/operator_r.c /^void rb(t_info *info, char flag)$/;" f 144 | read_file lib/libgnl/src/get_next_line.c /^char *read_file(int fd, char *keep)$/;" f 145 | reverse_rotate_stack srcs/operator_src/pop_push_swap_rotate.c /^void reverse_rotate_stack(t_stack *stack)$/;" f 146 | rotate_stack srcs/operator_src/pop_push_swap_rotate.c /^void rotate_stack(t_stack *stack)$/;" f 147 | rr include/data_struct.h /^ int rr;$/;" m struct:s_op 148 | rr srcs/operator_src/operator_r.c /^void rr(t_info *info, char flag)$/;" f 149 | rra srcs/operator_src/operator_rr.c /^void rra(t_info *info, char flag)$/;" f 150 | rrb srcs/operator_src/operator_rr.c /^void rrb(t_info *info, char flag)$/;" f 151 | rrr srcs/operator_src/operator_rr.c /^void rrr(t_info *info, char flag)$/;" f 152 | run_non_arg_test push_swap_tester/push_swap_tester.bash /^function run_non_arg_test(){$/;" f 153 | run_op srcs/visualizer_src/visualizer.c /^static void run_op(t_info *info, char *op)$/;" f file: 154 | s_fd_lst lib/libgnl/include/get_next_line.h /^typedef struct s_fd_lst$/;" s 155 | s_info include/data_struct.h /^typedef struct s_info$/;" s 156 | s_list include/data_struct.h /^typedef struct s_list$/;" s 157 | s_op include/data_struct.h /^typedef struct s_op$/;" s 158 | s_pivot include/data_struct.h /^ int s_pivot;$/;" m struct:s_info 159 | s_rotate include/data_struct.h /^typedef struct s_rotate$/;" s 160 | s_stack include/data_struct.h /^typedef struct s_stack$/;" s 161 | sa srcs/operator_src/operator_s.c /^void sa(t_info *info, char flag)$/;" f 162 | sb srcs/operator_src/operator_s.c /^void sb(t_info *info, char flag)$/;" f 163 | size include/data_struct.h /^ int size;$/;" m struct:s_stack 164 | ss srcs/operator_src/operator_s.c /^void ss(t_info *info, char flag)$/;" f 165 | swap srcs/initalize_src/quick_sort.c /^static void swap(int *a, int *b)$/;" f file: 166 | swap_stack srcs/operator_src/pop_push_swap_rotate.c /^void swap_stack(t_stack *stack)$/;" f 167 | t_fd_lst lib/libgnl/include/get_next_line.h /^} t_fd_lst;$/;" t typeref:struct:s_fd_lst 168 | t_info include/data_struct.h /^} t_info;$/;" t typeref:struct:s_info 169 | t_list include/data_struct.h /^} t_list;$/;" t typeref:struct:s_list 170 | t_op include/data_struct.h /^} t_op;$/;" t typeref:struct:s_op 171 | t_rotate include/data_struct.h /^} t_rotate;$/;" t typeref:struct:s_rotate 172 | t_stack include/data_struct.h /^} t_stack;$/;" t typeref:struct:s_stack 173 | test push_swap_tester/push_swap_tester.bash /^function test(){$/;" f 174 | test_error push_swap_tester/push_swap_tester.bash /^function test_error(){$/;" f 175 | total_size include/data_struct.h /^ int total_size;$/;" m struct:s_info 176 | visualizer srcs/visualizer_src/visualizer.c /^static void visualizer(const t_info *info)$/;" f file: 177 | --------------------------------------------------------------------------------