correct some errors
This commit is contained in:
parent
e062e9e985
commit
fd457ff351
16
src/Makefile
16
src/Makefile
@ -11,18 +11,23 @@
|
|||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
NAME = libft.a
|
NAME = libft.a
|
||||||
|
|
||||||
SOURCES = ft_atoi.c ft_bzero.c ft_calloc.c ft_isalnum.c ft_isalpha.c \
|
SOURCES = 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_lstadd_back.c\
|
ft_isascii.c ft_isdigit.c ft_isprint.c ft_itoa.c ft_memchr.c \
|
||||||
ft_lstadd_front.c ft_lstclear.c ft_lstdelone.c ft_lstiter.c \
|
|
||||||
ft_lstlast.c ft_lstmap.c ft_lstnew.c ft_lstsize.c ft_memchr.c \
|
|
||||||
ft_memcmp.c ft_memcpy.c ft_memmove.c ft_memset.c ft_putchar_fd.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_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_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_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
|
ft_strtrim.c ft_substr.c ft_tolower.c ft_toupper.c
|
||||||
|
|
||||||
|
BONUS_SOURCES = ft_lstadd_back.c ft_lstadd_front.c ft_lstclear.c \
|
||||||
|
ft_lstdelone.c ft_lstiter.c ft_lstlast.c ft_lstmap.c \
|
||||||
|
ft_lstnew.c ft_lstsize.c
|
||||||
|
|
||||||
OBJECTS = $(SOURCES:.c=.o)
|
OBJECTS = $(SOURCES:.c=.o)
|
||||||
|
|
||||||
|
BONUS_OBJECTS = $(BONUS_SOURCES:.c=.o)
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -Wall -Wextra -Werror
|
CFLAGS = -Wall -Wextra -Werror
|
||||||
|
|
||||||
@ -31,11 +36,14 @@ all: $(NAME)
|
|||||||
$(NAME): $(OBJECTS)
|
$(NAME): $(OBJECTS)
|
||||||
$(AR) -r $@ $?
|
$(AR) -r $@ $?
|
||||||
|
|
||||||
|
bonus: $(OBJECTS) $(BONUS_OBJECTS)
|
||||||
|
$(AR) -r $(NAME) $?
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) -c $(CFLAGS) $?
|
$(CC) -c $(CFLAGS) $?
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJECTS) $(BOBJECTS)
|
rm -f $(OBJECTS) $(BONUS_OBJECTS)
|
||||||
|
|
||||||
fclean: clean
|
fclean: clean
|
||||||
rm -f $(NAME)
|
rm -f $(NAME)
|
||||||
|
|||||||
@ -28,7 +28,7 @@ int ft_atoi(const char *nptr)
|
|||||||
nptr++;
|
nptr++;
|
||||||
res = 0;
|
res = 0;
|
||||||
sign = 1;
|
sign = 1;
|
||||||
while (*nptr == '-' || *nptr == '+')
|
if (*nptr == '-' || *nptr == '+')
|
||||||
{
|
{
|
||||||
if (*nptr == '-')
|
if (*nptr == '-')
|
||||||
sign *= -1;
|
sign *= -1;
|
||||||
|
|||||||
@ -17,6 +17,10 @@ void *ft_calloc(size_t nmemb, size_t size)
|
|||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
|
if (nmemb && nmemb > (size_t) -1 / nmemb)
|
||||||
|
{
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
ptr = malloc(nmemb * size);
|
ptr = malloc(nmemb * size);
|
||||||
if (ptr)
|
if (ptr)
|
||||||
ft_bzero(ptr, nmemb * size);
|
ft_bzero(ptr, nmemb * size);
|
||||||
|
|||||||
@ -18,7 +18,7 @@ char *ft_strnstr(const char *big, const char *little, size_t len)
|
|||||||
size_t j;
|
size_t j;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
if (*little == '\0' || len == 0)
|
if (*little == '\0')
|
||||||
return ((char *) big);
|
return ((char *) big);
|
||||||
while (big[i] && i < len)
|
while (big[i] && i < len)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user