diff --git a/Makefile b/Makefile index b158635..220b3a4 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: erey-bet +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/09/27 04:19:30 by erey-bet #+# #+# # -# Updated: 2022/10/14 22:38:25 by erey-bet ### ########.fr # +# Updated: 2022/10/15 15:06:59 by erey-bet ### ########.fr # # # # **************************************************************************** # @@ -18,13 +18,16 @@ ft_substr.c ft_strjoin.c ft_strtrim.c ft_split.c ft_itoa.c ft_strmapi.c \ ft_striteri.c ft_putchar_fd.c ft_putstr_fd.c ft_putendl_fd.c ft_putnbr_fd.c \ ft_get_size.c ft_power.c OBJS = ${SRCS:.c=.o} -BONUS = ft_lstnew.c ft_lstadd_front.c ft_lstsize.c ft_lstlast.c \ +BONUS_SRCS = ft_lstnew.c ft_lstadd_front.c ft_lstsize.c ft_lstlast.c \ ft_lstadd_back.c ft_lstdelone.c ft_lstclear.c ft_lstiter.c ft_lstmap.c -BONUS_OBJS = ${BONUS:.c=.o} +BONUS_OBJS = ${BONUS_SRCS:.c=.o} CC = gcc CFLAGS = -Wall -Wextra -Werror NAME = libft.a +ifdef BONUS + SRCS += ${BONUS_SRCS} +endif all: ${NAME} @@ -42,8 +45,8 @@ fclean: clean re: fclean all -bonus: ${BONUS_OBJS} - ar -rc ${NAME} ${BONUS_OBJS} +bonus: + @make BONUS=1 coffee: @clear diff --git a/ft_atoi.c b/ft_atoi.c index fe22ca5..a723bf6 100644 --- a/ft_atoi.c +++ b/ft_atoi.c @@ -14,8 +14,10 @@ static int ft_isspace(char c) { - return (c == ' ' || c == '\f' - ||c == '\n' || c == '\r' || c == '\t' || c == '\v'); + if (c == ' ' || c == '\f' + ||c == '\n' || c == '\r' || c == '\t' || c == '\v') + return (1); + return (0); } int ft_atoi(const char *nptr) diff --git a/ft_memset.c b/ft_memset.c index 16edf23..5c2adcd 100644 --- a/ft_memset.c +++ b/ft_memset.c @@ -6,11 +6,11 @@ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/09/26 14:46:33 by erey-bet #+# #+# */ -/* Updated: 2022/09/26 16:23:39 by erey-bet ### ########.fr */ +/* Updated: 2022/10/15 23:31:18 by erey-bet ### ########.fr */ /* */ /* ************************************************************************** */ -#include +#include "libft.h" void *ft_memset(void *ptr, int v, size_t count) { diff --git a/ft_putnbr_fd.c b/ft_putnbr_fd.c index 5927b6a..18b3042 100644 --- a/ft_putnbr_fd.c +++ b/ft_putnbr_fd.c @@ -6,7 +6,7 @@ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/05 10:22:16 by erey-bet #+# #+# */ -/* Updated: 2022/10/10 22:49:10 by erey-bet ### ########.fr */ +/* Updated: 2022/10/17 13:50:20 by erey-bet ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,7 @@ void ft_putnbr_fd(int n, int fd) long nl; nl = n; - nl *= (n > 0) - (n < 0); + nl *= ABS(nl); len = ft_get_size(nl); if (n < 0) ft_putchar_fd('-', fd); diff --git a/libft.h b/libft.h index edfd103..5bf1b2a 100644 --- a/libft.h +++ b/libft.h @@ -14,6 +14,7 @@ # define LIBFT_H # include # include +# define ABS(X) (X > 0) - (X < 0) typedef struct s_list {