From b07259e037e19ed5f4de0896f8cfc52e0f74d415 Mon Sep 17 00:00:00 2001 From: hugogogo Date: Sat, 24 Jul 2021 11:49:36 +0200 Subject: [PATCH] renomme get next line en ft_gnl --- Makefile | 2 +- includes/{ft_get_next_line.h => ft_gnl.h} | 2 +- includes/libft.h | 63 ++--------------------- srcs/{ft_get_next_line.c => ft_gnl.c} | 15 +++--- 4 files changed, 12 insertions(+), 70 deletions(-) rename includes/{ft_get_next_line.h => ft_gnl.h} (95%) rename srcs/{ft_get_next_line.c => ft_gnl.c} (88%) diff --git a/Makefile b/Makefile index b2a080e..147c2f3 100644 --- a/Makefile +++ b/Makefile @@ -95,7 +95,7 @@ SRCS = ft_memset.c \ ft_arraymap.c \ ft_strmultisplit.c \ \ - ft_get_next_line.c \ + ft_gnl.c \ ft_concat_free.c \ \ ft_printf.c \ diff --git a/includes/ft_get_next_line.h b/includes/ft_gnl.h similarity index 95% rename from includes/ft_get_next_line.h rename to includes/ft_gnl.h index 23f7cc6..6d4dc9e 100644 --- a/includes/ft_get_next_line.h +++ b/includes/ft_gnl.h @@ -24,7 +24,7 @@ typedef struct s_gnlist struct s_gnlist *next; } t_gnlist; -int get_next_line(const int fd, char **line); +int ft_gnl(const int fd, char **line); int multi_fd(int fd, t_gnlist **lst); int free_lst(t_gnlist **lst, int ret); diff --git a/includes/libft.h b/includes/libft.h index 3712b93..18db2c6 100644 --- a/includes/libft.h +++ b/includes/libft.h @@ -12,12 +12,10 @@ #ifndef LIBFT_H # define LIBFT_H -# include -# include -# include -# include "ft_get_next_line.h" +# include // for write +# include // for malloc and free +# include "ft_gnl.h" # include "ft_printf.h" -# include // to use va_arg in ft_printf void *ft_memset(void *b, int c, size_t len); void ft_bzero(void *s, size_t n); @@ -105,65 +103,10 @@ int ft_issort(int *tab, int length, int (*f)(int, int)); int *ft_arraymap(int *tab, int length, int(*f)(int)); void ft_putnbrendl(int n); void ft_putnbrendl_fd(int n, int fd); -int ft_get_next_line(const int fd, char **line); char *ft_concat_free(char *str1, char *str2); int ft_abs(int n); int ft_greater(int a, int b); int ft_smaller(int a, int b); int ft_sign(int i); - - - - - -# include // to use va_arg - -/* -** ft_printf.c -*/ - -char *specifier(char *s); -int ft_expand_star(int nbr, char **string); -int ft_put_word(char *s, char *type, int size); -char *convert_with_flags(char *s, va_list ap, char *type, int *size); -int ft_printf(char *string, ...); - -/* -** ft_next_word.c -*/ - -int width_precision(char *s); -int word_length(char *s); -char *next_word(char **s); - -/* -** ft_convert.c -*/ - -char *conv_i(char c, long int i); -char *conv_u(char c, unsigned long int i); -char *ft_convert(va_list ap, char *type, char **s); - -/* -** ft_flag_transform.c -*/ - -char *precision_int(char *print, int precision); -char *ft_precision(char *s, char *print, char *type); -char *width_flags(char *print, char *s, int width, int zero); -char *ft_width(char *s, char *print, int *size, char *type); -char *ft_flag_transform(char *s, char *print, char *type, int *size); - -/* -** ft_flag_transform_bonus.c -*/ - -char *ft_plus(char *s, char *print, char *type); -char *ft_sharp(char *s, char *print, char *type); -char *ft_sharp_again(char *s, char *print, char *type); -char *ft_space(char *s, char *print, char *type, int *size); - - - #endif diff --git a/srcs/ft_get_next_line.c b/srcs/ft_gnl.c similarity index 88% rename from srcs/ft_get_next_line.c rename to srcs/ft_gnl.c index 8b21774..d13051b 100644 --- a/srcs/ft_get_next_line.c +++ b/srcs/ft_gnl.c @@ -13,7 +13,6 @@ #include "libft.h" /* -** #include //for printf ** #include //for open ** ** int main(int ac, char **av) @@ -24,29 +23,29 @@ ** int ret; ** char *line = NULL; ** -** fd = (int *)malloc(sizeof(int) * ac); +** fd = (int *)ft_calloc(ac, sizeof(int)); ** while (++i <= ac - 1) ** fd[i - 1] = open(av[i], O_RDONLY); ** i = 0; ** while (j < ac - 1) ** { -** if ((ret = get_next_line(fd[i], &line)) > 0) +** if ((ret = ft_gnl(fd[i], &line)) > 0) ** { -** printf(" [fd%i-%i] %s\n", fd[i], ret, line); +** ft_printf(" [fd%i-%i] %s\n", fd[i], ret, line); ** free(line); ** j = 0; ** } ** else if (ret == -1) ** { -** printf("[fd%i-%i] *ERROR*\n", fd[i], ret); +** ft_printf("[fd%i-%i] *ERROR*\n", fd[i], ret); ** free(line); ** j++; ** } ** else if (*line != '\0') -** printf(" [fd%i-%i] %s\n", fd[i], ret, line); +** ft_printf(" [fd%i-%i] %s\n", fd[i], ret, line); ** else ** { -** printf("[fd%i-%i] %s *FINI*\n", fd[i], ret, line); +** ft_printf("[fd%i-%i] %s *FINI*\n", fd[i], ret, line); ** free(line); ** j++; ** } @@ -108,7 +107,7 @@ int multi_fd(int fd, t_gnlist **lst) return (1); } -int get_next_line(const int fd, char **line) +int ft_gnl(const int fd, char **line) { char buf[BUFFER_SIZE + 1]; int ret;