diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-08-04 15:52:47 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-08-04 15:52:47 +0200 |
commit | 5cb3373a2e5a5109a5d3b72ef45978b98f885706 (patch) | |
tree | 11a0a6f467da3ddf227d2eaf6824c4509242025e /libft | |
parent | ok nice (diff) | |
parent | $? fix (diff) | |
download | 42-minishell-5cb3373a2e5a5109a5d3b72ef45978b98f885706.tar.gz 42-minishell-5cb3373a2e5a5109a5d3b72ef45978b98f885706.tar.bz2 42-minishell-5cb3373a2e5a5109a5d3b72ef45978b98f885706.tar.xz 42-minishell-5cb3373a2e5a5109a5d3b72ef45978b98f885706.tar.zst 42-minishell-5cb3373a2e5a5109a5d3b72ef45978b98f885706.zip |
Merge branch 'master' into fix-pwd
Diffstat (limited to 'libft')
-rw-r--r-- | libft/Makefile | 18 | ||||
-rw-r--r-- | libft/include/libft.h (renamed from libft/inc/libft.h) | 9 | ||||
-rw-r--r-- | libft/src/ft_strclen.c | 24 | ||||
-rw-r--r-- | libft/src/ft_strlen.c | 2 |
4 files changed, 47 insertions, 6 deletions
diff --git a/libft/Makefile b/libft/Makefile index 6803f66..7b1c22c 100644 --- a/libft/Makefile +++ b/libft/Makefile @@ -3,10 +3,11 @@ default: all #--------------------------------- Shell --------------------------------------# #==============================================================================# SHELL := /bin/sh +OS = $(shell uname) #==============================================================================# #------------------------------ Directories -----------------------------------# #==============================================================================# -INCS_DIR = inc/ +INCS_DIR = include/ SRCS_DIR = src/ OBJS_DIR = obj/ #==============================================================================# @@ -23,6 +24,8 @@ SRCS_NAME += ft_memchr.c SRCS_NAME += ft_memlchr.c SRCS_NAME += ft_memcmp.c SRCS_NAME += ft_strlen.c +SRCS_NAME += ft_strclen.c +SRCS_NAME += ft_strnlen.c SRCS_NAME += ft_isalpha.c SRCS_NAME += ft_isdigit.c SRCS_NAME += ft_isalnum.c @@ -70,7 +73,6 @@ SRCS_NAME += ft_putstr.c SRCS_NAME += ft_putendl.c SRCS_NAME += ft_putnbr.c SRCS_NAME += ft_putnbr_base.c -SRCS_NAME += ft_strnlen.c SRCS_NAME += ft_strcat.c SRCS_NAME += ft_strcmp.c SRCS_NAME += ft_isspace.c @@ -120,9 +122,17 @@ OS = $(shell uname) #==============================================================================# #-------------------------------- Compiler ------------------------------------# #==============================================================================# -CC = clang +ifeq (${OS}, FreeBSD) +CC = /usr/bin/cc +endif +ifeq (${OS}, Linux) +CC = /usr/bin/clang-9 +endif +ifeq (${OS}, Darwin) +CC = clang +endif #------------------------------------------------------------------------------# -CFLAGS = -std=c89 +CFLAGS = -std=c89 CFLAGS += -Wall CFLAGS += -Wextra CFLAGS += -Werror diff --git a/libft/inc/libft.h b/libft/include/libft.h index 5ddb471..0cd5ed1 100644 --- a/libft/inc/libft.h +++ b/libft/include/libft.h @@ -24,6 +24,12 @@ # define BUFFER_SIZE 72 # endif +typedef enum +{ + FALSE, + TRUE +} t_bool; + typedef struct s_list { void *content; @@ -142,9 +148,10 @@ int ft_strcmp(const char *s1, const char *s2); long ft_memlchr(const void *s, int c, size_t n); long ft_strlchr(const char *s, int c); size_t ft_strlen(const char *s); +size_t ft_strclen(const char *s, int c); +size_t ft_strnlen(const char *s, size_t size); size_t ft_strlcpy(char *dst, const char *src, size_t size); size_t ft_strlcat(char *dst, const char *src, size_t size); -size_t ft_strnlen(const char *s, size_t size); double ft_sqrt(double x); /* diff --git a/libft/src/ft_strclen.c b/libft/src/ft_strclen.c new file mode 100644 index 0000000..fe88ca5 --- /dev/null +++ b/libft/src/ft_strclen.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strclen.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:07:12 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:07:12 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include <stddef.h> + +size_t + ft_strclen(const char *s, int c) +{ + const char *ptr; + + ptr = s; + while (ptr != NULL && *ptr != '\0' && *ptr != c) + ptr++; + return (ptr - s); +} diff --git a/libft/src/ft_strlen.c b/libft/src/ft_strlen.c index 90f5110..2b26bf0 100644 --- a/libft/src/ft_strlen.c +++ b/libft/src/ft_strlen.c @@ -18,7 +18,7 @@ size_t const char *ptr; ptr = s; - while (ptr && *ptr) + while (ptr != NULL && *ptr != '\0') ptr++; return (ptr - s); } |