removing the libft of rparodi
This commit is contained in:
parent
0391323626
commit
be6038dcc8
523 changed files with 724 additions and 3336 deletions
11
Makefile
11
Makefile
|
|
@ -6,7 +6,7 @@
|
||||||
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
||||||
# Updated: 2024/11/08 11:45:04 by rparodi ### ########.fr #
|
# Updated: 2024/11/08 19:36:49 by rparodi ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
|
@ -26,15 +26,14 @@ CFLAGS += -g3 -MMD
|
||||||
# CFLAGS += -fsanitize=address
|
# CFLAGS += -fsanitize=address
|
||||||
# CFLAGS += -fsanitize=thread
|
# CFLAGS += -fsanitize=thread
|
||||||
|
|
||||||
INCLUDES = -I ./includes/ -I ./includes/libft/ -I ./minilibx-linux
|
INCLUDES = -I ./includes/ -I ./includes/include/ -I ./minilibx-linux
|
||||||
|
|
||||||
# Paths
|
# Paths
|
||||||
LIBFT_DIR = ./libft
|
LIBFT_DIR = ./libft
|
||||||
LIBFT_PERSONAL_DIR = ./libft_personal
|
|
||||||
MLX_DIR = ./minilibx-linux
|
MLX_DIR = ./minilibx-linux
|
||||||
|
|
||||||
# Library flags
|
# Library flags
|
||||||
LDFLAGS = -L./build -lft -lft_personal -lm
|
LDFLAGS = -L./build -lft -lm
|
||||||
|
|
||||||
# MiniLibX flags for macOS with XQuartz
|
# MiniLibX flags for macOS with XQuartz
|
||||||
MLXFLAGS = -L$(MLX_DIR) -lmlx -L/opt/X11/lib -lX11 -lXext -lXrender -lXrandr -lXi
|
MLXFLAGS = -L$(MLX_DIR) -lmlx -L/opt/X11/lib -lX11 -lXext -lXrender -lXrandr -lXi
|
||||||
|
|
@ -87,13 +86,11 @@ re: header fclean all
|
||||||
# Compile external libraries
|
# Compile external libraries
|
||||||
build/libft.a:
|
build/libft.a:
|
||||||
@make --no-print-directory -C $(LIBFT_DIR)
|
@make --no-print-directory -C $(LIBFT_DIR)
|
||||||
build/libft_personal.a:
|
|
||||||
@make --no-print-directory -C $(LIBFT_PERSONAL_DIR)
|
|
||||||
build/libmlx.a:
|
build/libmlx.a:
|
||||||
@make --no-print-directory -C $(MLX_DIR)
|
@make --no-print-directory -C $(MLX_DIR)
|
||||||
|
|
||||||
# Dependences for all
|
# Dependences for all
|
||||||
$(NAME): $(OBJ) build/libft.a build/libft_personal.a build/libmlx.a
|
$(NAME): $(OBJ) build/libft.a build/libmlx.a
|
||||||
@mkdir -p $(OBJDIRNAME)
|
@mkdir -p $(OBJDIRNAME)
|
||||||
@printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n'
|
@printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n'
|
||||||
@$(CC) $(CFLAGS) $(OBJ) $(LDFLAGS) -o $(NAME)
|
@$(CC) $(CFLAGS) $(OBJ) $(LDFLAGS) -o $(NAME)
|
||||||
|
|
|
||||||
1
includes/include
Symbolic link
1
includes/include
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../libft/include
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
../libft/includes/libft
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
CompilerFlags:
|
|
||||||
Add:
|
|
||||||
- "-xc"
|
|
||||||
- "-I/Users/raphael/Documents/42_cursus/circle0/libft/includes"
|
|
||||||
862
libft/Makefile
862
libft/Makefile
|
|
@ -3,168 +3,742 @@
|
||||||
# ::: :::::::: #
|
# ::: :::::::: #
|
||||||
# Makefile :+: :+: :+: #
|
# Makefile :+: :+: :+: #
|
||||||
# +:+ +:+ +:+ #
|
# +:+ +:+ +:+ #
|
||||||
# By: rparodi <marvin@42.fr> +#+ +:+ +#+ #
|
# By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
# Created: 2023/12/05 09:04:05 by bgoulard #+# #+# #
|
||||||
# Updated: 2024/10/31 23:46:44 by bgoulard ### ########.fr #
|
# Updated: 2024/10/31 23:53:29 by bgoulard ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
# Variables
|
# Colors
|
||||||
|
GRAY = "\\e[90m"
|
||||||
# Name
|
GREEN = "\\e[42m"
|
||||||
NAME = ../build/libft.a
|
RED = "\\e[41m"
|
||||||
|
RESET = "\\e[0m"
|
||||||
|
BOLD = "\\e[1m"
|
||||||
|
|
||||||
# Commands
|
# Commands
|
||||||
CC = cc
|
CC = clang
|
||||||
RM = rm -rf
|
NAME = ft_personal
|
||||||
|
OUTDIR = ../build
|
||||||
|
|
||||||
# Flags
|
TEST_NAME = tests_run
|
||||||
CFLAGS = -Werror -Wextra -Wall
|
AR = ar
|
||||||
CFLAGS += -g3 -MMD
|
COV = llvm-cov
|
||||||
# CFLAGS += -lm
|
PRD = llvm-profdata
|
||||||
|
ECHO = $(shell which echo) -e
|
||||||
|
PRINTF = $(shell which printf)
|
||||||
|
|
||||||
# CFLAGS += -fsanitize=address
|
# Directories
|
||||||
# CFLAGS += -fsanitize=thread
|
|
||||||
|
|
||||||
LDFLAGS = -L.
|
SRC_DIR = src
|
||||||
LDLIBS = -lft
|
BUILD_DIR = ../build/bgoulard
|
||||||
|
TESTS_DIR = tests
|
||||||
|
INC_DIR = include
|
||||||
|
COVERAGE_DIR = coverage
|
||||||
|
|
||||||
INCLUDES = ./includes/libft/
|
FT_MAP_DIR = ft_map
|
||||||
|
FT_LIST_DIR = ft_list
|
||||||
|
FT_STRING_DIR = ft_string
|
||||||
|
FT_VEC_DIR = ft_vector
|
||||||
|
FT_OPTIONAL_DIR = ft_optional
|
||||||
|
FT_ARGS_DIR = ft_args
|
||||||
|
FT_MATH_DIR = ft_math
|
||||||
|
FT_PAIR_DIR = ft_pair
|
||||||
|
|
||||||
# Objects
|
# Counpound directories
|
||||||
OBJDIRNAME = ../build/rparodi
|
|
||||||
OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.c=.o))
|
|
||||||
|
|
||||||
SRC = char/ft_isdigit.c \
|
FT_LIST_LL_DIR = $(FT_LIST_DIR)/ft_ll
|
||||||
char/ft_isalnum.c \
|
FT_LIST_DL_DIR = $(FT_LIST_DIR)/ft_dl
|
||||||
char/ft_isalpha.c \
|
FT_CHR_DIR = $(FT_STRING_DIR)/ft_chr
|
||||||
char/ft_isascii.c \
|
FT_MEM_DIR = $(FT_STRING_DIR)/ft_mem
|
||||||
char/ft_isprint.c \
|
FT_STR_DIR = $(FT_STRING_DIR)/ft_str
|
||||||
char/ft_tolower.c \
|
FT_T_STRING_DIR = $(FT_STRING_DIR)/ft_string
|
||||||
char/ft_toupper.c \
|
|
||||||
convert/ft_atoi.c \
|
|
||||||
convert/ft_atoll.c \
|
|
||||||
convert/ft_itoa.c \
|
|
||||||
list/ft_lstadd_back.c \
|
|
||||||
list/ft_lstadd_front.c \
|
|
||||||
list/ft_lstclear.c \
|
|
||||||
list/ft_lstdelone.c \
|
|
||||||
list/ft_lstiter.c \
|
|
||||||
list/ft_lstlast.c \
|
|
||||||
list/ft_lstmap.c \
|
|
||||||
list/ft_lstnew.c \
|
|
||||||
list/ft_lstsize.c \
|
|
||||||
memory/ft_bzero.c \
|
|
||||||
memory/ft_calloc.c \
|
|
||||||
memory/ft_memchr.c \
|
|
||||||
memory/ft_memcmp.c \
|
|
||||||
memory/ft_memcpy.c \
|
|
||||||
memory/ft_memmove.c \
|
|
||||||
memory/ft_memset.c \
|
|
||||||
print/ft_printf.c \
|
|
||||||
print/ft_put.c \
|
|
||||||
print/ft_putchar_fd.c \
|
|
||||||
print/ft_putendl_fd.c \
|
|
||||||
print/ft_putnbr_fd.c \
|
|
||||||
print/ft_putstr_fd.c \
|
|
||||||
str/ft_split.c \
|
|
||||||
str/ft_strchr.c \
|
|
||||||
str/ft_strcmp.c \
|
|
||||||
str/ft_strcpy.c \
|
|
||||||
str/ft_strdup.c \
|
|
||||||
str/ft_striteri.c \
|
|
||||||
str/ft_strjoin.c \
|
|
||||||
str/ft_strlcat.c \
|
|
||||||
str/ft_strlcpy.c \
|
|
||||||
str/ft_strlen.c \
|
|
||||||
str/ft_strmapi.c \
|
|
||||||
str/ft_strncmp.c \
|
|
||||||
str/ft_strnstr.c \
|
|
||||||
str/ft_strrchr.c \
|
|
||||||
str/ft_strtrim.c \
|
|
||||||
str/ft_substr.c
|
|
||||||
|
|
||||||
# Colors
|
# Compilation flags
|
||||||
GREEN = \033[32m
|
##
|
||||||
GREY = \033[0;90m
|
## To change debug level run make DEBUG_LEVEL=xxx
|
||||||
RED = \033[0;31m
|
##
|
||||||
GOLD = \033[38;5;220m
|
|
||||||
END = \033[0m
|
LDFLAGS =
|
||||||
|
CPPFLAGS = -I$(INC_DIR) -MMD -MP
|
||||||
|
FFLAGS =\
|
||||||
|
-fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined \
|
||||||
|
-fsanitize=leak -fsanitize=pointer-compare \
|
||||||
|
-fsanitize=pointer-subtract \
|
||||||
|
-fsanitize-address-use-after-scope -fsanitize=pointer-overflow
|
||||||
|
CFLAGS =\
|
||||||
|
-Wall -Wextra $(CPPFLAGS) -Werror -fPIC -fdiagnostics-color
|
||||||
|
TEST_FLAGS =\
|
||||||
|
-g2 -DTEST \
|
||||||
|
-fprofile-instr-generate -ftest-coverage -fcoverage-mapping \
|
||||||
|
|
||||||
|
DEBUG_LEVEL =\
|
||||||
|
0
|
||||||
|
DEBUG_FLAGS =\
|
||||||
|
-g2 -DDEBUG $(FFLAGS) -DDEBUG_LEVEL=$(DEBUG_LEVEL)
|
||||||
|
|
||||||
|
# Inner variables
|
||||||
|
|
||||||
|
MAX_FILE_LEN = 0
|
||||||
|
TARGET ?= "ALL"
|
||||||
|
CLOG_FILE = ./compilation.log
|
||||||
|
|
||||||
|
# Check for llvm-cov and llvm-profdata
|
||||||
|
# If not found, use the version 12 if available
|
||||||
|
# If not found, use the version 14 (latest version)
|
||||||
|
ifeq (, $(shell which $(COV) 2> /dev/null))
|
||||||
|
COV = llvm-cov-12
|
||||||
|
ifeq (, $(shell which $(COV) 2> /dev/null))
|
||||||
|
COV = llvm-cov-14
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq (, $(shell which $(PRD) 2> /dev/null))
|
||||||
|
PRD = llvm-profdata-12
|
||||||
|
ifeq (, $(shell which $(PRD) 2> /dev/null))
|
||||||
|
PRD = llvm-profdata-14
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Sources
|
||||||
|
|
||||||
|
FT_PAIR_SRC = \
|
||||||
|
$(FT_PAIR_DIR)/ft_pair_cmp.c \
|
||||||
|
$(FT_PAIR_DIR)/ft_pair_destroy.c \
|
||||||
|
$(FT_PAIR_DIR)/ft_pair_get.c \
|
||||||
|
$(FT_PAIR_DIR)/ft_pair_new.c \
|
||||||
|
$(FT_PAIR_DIR)/ft_pair_set.c \
|
||||||
|
|
||||||
|
FT_MATH_SRC = \
|
||||||
|
$(FT_MATH_DIR)/ft_clamp.c \
|
||||||
|
$(FT_MATH_DIR)/ft_complex.c \
|
||||||
|
$(FT_MATH_DIR)/ft_intrange.c \
|
||||||
|
$(FT_MATH_DIR)/ft_log.c \
|
||||||
|
$(FT_MATH_DIR)/ft_minmax.c \
|
||||||
|
$(FT_MATH_DIR)/ft_sqrt.c \
|
||||||
|
$(FT_MATH_DIR)/ft_pow.c \
|
||||||
|
$(FT_MATH_DIR)/ft_abs.c \
|
||||||
|
$(FT_MATH_DIR)/ft_align.c \
|
||||||
|
$(FT_MATH_DIR)/ft_round.c
|
||||||
|
|
||||||
|
FT_MAP_SRC = \
|
||||||
|
$(FT_MAP_DIR)/ft_map_clear.c \
|
||||||
|
$(FT_MAP_DIR)/ft_map_create.c \
|
||||||
|
$(FT_MAP_DIR)/ft_map_destroy.c \
|
||||||
|
$(FT_MAP_DIR)/ft_map_get.c \
|
||||||
|
$(FT_MAP_DIR)/ft_map_hash.c \
|
||||||
|
$(FT_MAP_DIR)/ft_map_remove.c \
|
||||||
|
$(FT_MAP_DIR)/ft_map_set.c
|
||||||
|
|
||||||
|
FT_LIST_LL_SRC = \
|
||||||
|
$(FT_LIST_LL_DIR)/ft_ll_find.c \
|
||||||
|
$(FT_LIST_LL_DIR)/ft_ll_add.c \
|
||||||
|
$(FT_LIST_LL_DIR)/ft_ll_clear.c \
|
||||||
|
$(FT_LIST_LL_DIR)/ft_ll_delete.c \
|
||||||
|
$(FT_LIST_LL_DIR)/ft_ll_apply.c \
|
||||||
|
$(FT_LIST_LL_DIR)/ft_ll_iterator.c \
|
||||||
|
$(FT_LIST_LL_DIR)/ft_ll_map.c \
|
||||||
|
$(FT_LIST_LL_DIR)/ft_ll_new.c \
|
||||||
|
$(FT_LIST_LL_DIR)/ft_ll_rev.c \
|
||||||
|
$(FT_LIST_LL_DIR)/ft_ll_size.c \
|
||||||
|
$(FT_LIST_LL_DIR)/ft_ll_create.c \
|
||||||
|
$(FT_LIST_LL_DIR)/ft_ll_getters.c \
|
||||||
|
$(FT_LIST_LL_DIR)/ft_ll_pushpop.c \
|
||||||
|
$(FT_LIST_LL_DIR)/ft_ll_sub.c \
|
||||||
|
|
||||||
|
FT_LIST_DL_SRC = \
|
||||||
|
$(FT_LIST_DL_DIR)/ft_dl_apply.c \
|
||||||
|
$(FT_LIST_DL_DIR)/ft_dl_clear.c \
|
||||||
|
$(FT_LIST_DL_DIR)/ft_dl_create.c \
|
||||||
|
$(FT_LIST_DL_DIR)/ft_dl_delete.c \
|
||||||
|
$(FT_LIST_DL_DIR)/ft_dl_getters.c \
|
||||||
|
$(FT_LIST_DL_DIR)/ft_dl_iterator.c \
|
||||||
|
$(FT_LIST_DL_DIR)/ft_dl_pushpop.c \
|
||||||
|
$(FT_LIST_DL_DIR)/ft_dl_size.c \
|
||||||
|
$(FT_LIST_DL_DIR)/ft_dl_sub.c \
|
||||||
|
$(FT_LIST_DL_DIR)/ft_dl_add.c \
|
||||||
|
$(FT_LIST_DL_DIR)/ft_dl_rev.c \
|
||||||
|
$(FT_LIST_DL_DIR)/ft_dl_map.c \
|
||||||
|
$(FT_LIST_DL_DIR)/ft_dl_new.c \
|
||||||
|
$(FT_LIST_DL_DIR)/ft_dl_find.c \
|
||||||
|
|
||||||
|
FT_STR_SRC = \
|
||||||
|
$(FT_STR_DIR)/ft_atof.c \
|
||||||
|
$(FT_STR_DIR)/ft_atoi.c \
|
||||||
|
$(FT_STR_DIR)/ft_atoi_base.c \
|
||||||
|
$(FT_STR_DIR)/ft_itoa.c \
|
||||||
|
$(FT_STR_DIR)/ft_itoa_base.c \
|
||||||
|
$(FT_STR_DIR)/ft_perror.c \
|
||||||
|
$(FT_STR_DIR)/ft_putendl_fd.c \
|
||||||
|
$(FT_STR_DIR)/ft_putnbr_fd.c \
|
||||||
|
$(FT_STR_DIR)/ft_putstr_fd.c \
|
||||||
|
$(FT_STR_DIR)/ft_shift_args.c \
|
||||||
|
$(FT_STR_DIR)/ft_split.c \
|
||||||
|
$(FT_STR_DIR)/ft_splits.c \
|
||||||
|
$(FT_STR_DIR)/ft_str_isalpha.c \
|
||||||
|
$(FT_STR_DIR)/ft_str_isalnum.c \
|
||||||
|
$(FT_STR_DIR)/ft_str_isbool.c \
|
||||||
|
$(FT_STR_DIR)/ft_str_isdigit.c \
|
||||||
|
$(FT_STR_DIR)/ft_str_isfloat.c \
|
||||||
|
$(FT_STR_DIR)/ft_str_ishex.c \
|
||||||
|
$(FT_STR_DIR)/ft_str_isdouble.c \
|
||||||
|
$(FT_STR_DIR)/ft_str_isint.c \
|
||||||
|
$(FT_STR_DIR)/ft_str_islong.c \
|
||||||
|
$(FT_STR_DIR)/ft_str_isnum.c \
|
||||||
|
$(FT_STR_DIR)/ft_str_isoct.c \
|
||||||
|
$(FT_STR_DIR)/ft_str_isvalid.c \
|
||||||
|
$(FT_STR_DIR)/ft_str_replace.c \
|
||||||
|
$(FT_STR_DIR)/ft_strappend_c.c \
|
||||||
|
$(FT_STR_DIR)/ft_strchr.c \
|
||||||
|
$(FT_STR_DIR)/ft_strclen.c \
|
||||||
|
$(FT_STR_DIR)/ft_strcmp.c \
|
||||||
|
$(FT_STR_DIR)/ft_strcnb.c \
|
||||||
|
$(FT_STR_DIR)/ft_strcspn.c \
|
||||||
|
$(FT_STR_DIR)/ft_strdup.c \
|
||||||
|
$(FT_STR_DIR)/ft_strend_with.c \
|
||||||
|
$(FT_STR_DIR)/ft_strerror.c \
|
||||||
|
$(FT_STR_DIR)/ft_striteri.c \
|
||||||
|
$(FT_STR_DIR)/ft_strjoin.c \
|
||||||
|
$(FT_STR_DIR)/ft_strlcat.c \
|
||||||
|
$(FT_STR_DIR)/ft_strlcpy.c \
|
||||||
|
$(FT_STR_DIR)/ft_strlen.c \
|
||||||
|
$(FT_STR_DIR)/ft_strmapi.c \
|
||||||
|
$(FT_STR_DIR)/ft_strncmp.c \
|
||||||
|
$(FT_STR_DIR)/ft_strndup.c \
|
||||||
|
$(FT_STR_DIR)/ft_strnstr.c \
|
||||||
|
$(FT_STR_DIR)/ft_strrchr.c \
|
||||||
|
$(FT_STR_DIR)/ft_strspn.c \
|
||||||
|
$(FT_STR_DIR)/ft_strstart_with.c \
|
||||||
|
$(FT_STR_DIR)/ft_strtok.c \
|
||||||
|
$(FT_STR_DIR)/ft_strtrim.c \
|
||||||
|
$(FT_STR_DIR)/ft_substr.c \
|
||||||
|
$(FT_STR_DIR)/ft_utoa.c \
|
||||||
|
$(FT_STR_DIR)/get_next_line.c \
|
||||||
|
|
||||||
|
FT_T_STRING_SRC = \
|
||||||
|
$(FT_T_STRING_DIR)/ft_string_append.c \
|
||||||
|
$(FT_T_STRING_DIR)/ft_string_new.c \
|
||||||
|
$(FT_T_STRING_DIR)/ft_string_put.c \
|
||||||
|
$(FT_T_STRING_DIR)/ft_string_from.c \
|
||||||
|
$(FT_T_STRING_DIR)/ft_string_clear.c \
|
||||||
|
$(FT_T_STRING_DIR)/ft_string_destroy.c \
|
||||||
|
$(FT_T_STRING_DIR)/ft_string_insert.c \
|
||||||
|
$(FT_T_STRING_DIR)/ft_string_reserve.c \
|
||||||
|
$(FT_T_STRING_DIR)/ft_string_resize.c \
|
||||||
|
$(FT_T_STRING_DIR)/ft_string_shrink.c \
|
||||||
|
$(FT_T_STRING_DIR)/ft_string_substr.c \
|
||||||
|
$(FT_T_STRING_DIR)/ft_string_to_str.c \
|
||||||
|
$(FT_T_STRING_DIR)/ft_string_trim.c \
|
||||||
|
$(FT_T_STRING_DIR)/ft_string_cmp.c \
|
||||||
|
$(FT_T_STRING_DIR)/ft_string_get.c \
|
||||||
|
$(FT_T_STRING_DIR)/ft_string_chr.c \
|
||||||
|
$(FT_T_STRING_DIR)/ft_string_replace.c \
|
||||||
|
$(FT_T_STRING_DIR)/ft_string_set.c
|
||||||
|
|
||||||
|
FT_MEM_SRC = \
|
||||||
|
$(FT_MEM_DIR)/ft_apply_2d.c \
|
||||||
|
$(FT_MEM_DIR)/ft_bzero.c \
|
||||||
|
$(FT_MEM_DIR)/ft_calloc.c \
|
||||||
|
$(FT_MEM_DIR)/ft_fd_to_buff.c \
|
||||||
|
$(FT_MEM_DIR)/ft_free.c \
|
||||||
|
$(FT_MEM_DIR)/ft_free_2d.c \
|
||||||
|
$(FT_MEM_DIR)/ft_len_2d.c \
|
||||||
|
$(FT_MEM_DIR)/ft_malloc.c \
|
||||||
|
$(FT_MEM_DIR)/ft_memchr.c \
|
||||||
|
$(FT_MEM_DIR)/ft_memcmp.c \
|
||||||
|
$(FT_MEM_DIR)/ft_memcpy.c \
|
||||||
|
$(FT_MEM_DIR)/ft_memmap.c \
|
||||||
|
$(FT_MEM_DIR)/ft_memmove.c \
|
||||||
|
$(FT_MEM_DIR)/ft_memset.c \
|
||||||
|
$(FT_MEM_DIR)/ft_qsort.c \
|
||||||
|
$(FT_MEM_DIR)/ft_realloc.c \
|
||||||
|
$(FT_MEM_DIR)/ft_swap.c
|
||||||
|
|
||||||
|
FT_CHR_SRC = \
|
||||||
|
$(FT_CHR_DIR)/ft_isalnum.c \
|
||||||
|
$(FT_CHR_DIR)/ft_isalpha.c \
|
||||||
|
$(FT_CHR_DIR)/ft_isascii.c \
|
||||||
|
$(FT_CHR_DIR)/ft_isdigit.c \
|
||||||
|
$(FT_CHR_DIR)/ft_ishexdigit.c \
|
||||||
|
$(FT_CHR_DIR)/ft_islower.c \
|
||||||
|
$(FT_CHR_DIR)/ft_isoctdigit.c \
|
||||||
|
$(FT_CHR_DIR)/ft_isprint.c \
|
||||||
|
$(FT_CHR_DIR)/ft_isspace.c \
|
||||||
|
$(FT_CHR_DIR)/ft_isupper.c \
|
||||||
|
$(FT_CHR_DIR)/ft_putchar_fd.c \
|
||||||
|
$(FT_CHR_DIR)/ft_tolower.c \
|
||||||
|
$(FT_CHR_DIR)/ft_toupper.c
|
||||||
|
|
||||||
|
FT_VEC_SRC = \
|
||||||
|
$(FT_VEC_DIR)/ft_vec_add.c \
|
||||||
|
$(FT_VEC_DIR)/ft_vec_apply.c \
|
||||||
|
$(FT_VEC_DIR)/ft_vec_at.c \
|
||||||
|
$(FT_VEC_DIR)/ft_vec_cat.c \
|
||||||
|
$(FT_VEC_DIR)/ft_vec_clear.c \
|
||||||
|
$(FT_VEC_DIR)/ft_vec_destroy.c \
|
||||||
|
$(FT_VEC_DIR)/ft_vec_filter.c \
|
||||||
|
$(FT_VEC_DIR)/ft_vec_get.c \
|
||||||
|
$(FT_VEC_DIR)/ft_vec_map.c \
|
||||||
|
$(FT_VEC_DIR)/ft_vec_new.c \
|
||||||
|
$(FT_VEC_DIR)/ft_vec_pop.c \
|
||||||
|
$(FT_VEC_DIR)/ft_vec_remove.c \
|
||||||
|
$(FT_VEC_DIR)/ft_vec_reserve.c \
|
||||||
|
$(FT_VEC_DIR)/ft_vec_reverse.c \
|
||||||
|
$(FT_VEC_DIR)/ft_vec_shift.c \
|
||||||
|
$(FT_VEC_DIR)/ft_vec_shrink.c \
|
||||||
|
$(FT_VEC_DIR)/ft_vec_sort.c \
|
||||||
|
$(FT_VEC_DIR)/ft_vec_swap.c \
|
||||||
|
$(FT_VEC_DIR)/ft_vec_to_array.c
|
||||||
|
|
||||||
|
FT_OPTIONAL_SRC = \
|
||||||
|
$(FT_OPTIONAL_DIR)/ft_optional_chain.c \
|
||||||
|
$(FT_OPTIONAL_DIR)/ft_optional_copy.c \
|
||||||
|
$(FT_OPTIONAL_DIR)/ft_optional_destroy.c \
|
||||||
|
$(FT_OPTIONAL_DIR)/ft_optional_new.c \
|
||||||
|
$(FT_OPTIONAL_DIR)/ft_optional_unwrap.c
|
||||||
|
|
||||||
|
FT_ARGS_SRC = \
|
||||||
|
$(FT_ARGS_DIR)/ft_arg_custom_checker.c \
|
||||||
|
$(FT_ARGS_DIR)/ft_parse_args.c \
|
||||||
|
$(FT_ARGS_DIR)/ft_parse_err.c \
|
||||||
|
$(FT_ARGS_DIR)/ft_parse_opt.c \
|
||||||
|
$(FT_ARGS_DIR)/ft_progname.c \
|
||||||
|
$(FT_ARGS_DIR)/ft_set_opt_args.c \
|
||||||
|
$(FT_ARGS_DIR)/ft_setup_prog.c \
|
||||||
|
$(FT_ARGS_DIR)/ft_version.c
|
||||||
|
|
||||||
|
# Counpound sources
|
||||||
|
|
||||||
|
FT_LIST_SRC = \
|
||||||
|
$(FT_LIST_LL_SRC) \
|
||||||
|
$(FT_LIST_DL_SRC) \
|
||||||
|
|
||||||
|
FT_STRING_SRC = \
|
||||||
|
$(FT_CHR_SRC) \
|
||||||
|
$(FT_MEM_SRC) \
|
||||||
|
$(FT_STR_SRC) \
|
||||||
|
$(FT_T_STRING_SRC)
|
||||||
|
|
||||||
|
# Tests sources
|
||||||
|
|
||||||
|
TESTS_SRC =\
|
||||||
|
$(TESTS_DIR)/ft_args/tests_custom_checker.c \
|
||||||
|
$(TESTS_DIR)/ft_args/tests_optlist.c \
|
||||||
|
$(TESTS_DIR)/ft_args/tests_progname.c \
|
||||||
|
$(TESTS_DIR)/ft_args/tests_version.c \
|
||||||
|
$(TESTS_DIR)/ft_args/tests_setup_prog.c \
|
||||||
|
$(TESTS_DIR)/ft_args/args_tests.c \
|
||||||
|
\
|
||||||
|
$(TESTS_DIR)/ft_list/ll_tests/ll_tests_utils.c \
|
||||||
|
$(TESTS_DIR)/ft_list/ll_tests/ll_list_tests.c \
|
||||||
|
$(TESTS_DIR)/ft_list/ll_tests/tests_list_push.c \
|
||||||
|
$(TESTS_DIR)/ft_list/ll_tests/tests_list_new.c \
|
||||||
|
$(TESTS_DIR)/ft_list/ll_tests/tests_list_map.c \
|
||||||
|
$(TESTS_DIR)/ft_list/ll_tests/tests_list_rev.c \
|
||||||
|
$(TESTS_DIR)/ft_list/ll_tests/tests_list_sizers.c \
|
||||||
|
$(TESTS_DIR)/ft_list/ll_tests/tests_list_apply.c \
|
||||||
|
$(TESTS_DIR)/ft_list/ll_tests/tests_list_iterators.c \
|
||||||
|
$(TESTS_DIR)/ft_list/ll_tests/tests_list_clear.c \
|
||||||
|
$(TESTS_DIR)/ft_list/ll_tests/tests_list_copy.c \
|
||||||
|
$(TESTS_DIR)/ft_list/ll_tests/tests_list_create.c \
|
||||||
|
$(TESTS_DIR)/ft_list/ll_tests/tests_list_deletors.c \
|
||||||
|
$(TESTS_DIR)/ft_list/ll_tests/tests_list_find.c \
|
||||||
|
$(TESTS_DIR)/ft_list/ll_tests/tests_list_get.c \
|
||||||
|
$(TESTS_DIR)/ft_list/ll_tests/tests_list_subrange.c \
|
||||||
|
$(TESTS_DIR)/ft_list/ll_tests/tests_list_add.c \
|
||||||
|
$(TESTS_DIR)/ft_list/dl_tests/dl_tests_utils.c \
|
||||||
|
$(TESTS_DIR)/ft_list/dl_tests/dl_list_tests.c \
|
||||||
|
$(TESTS_DIR)/ft_list/dl_tests/tests_dlist_add.c \
|
||||||
|
$(TESTS_DIR)/ft_list/dl_tests/tests_dlist_clear.c \
|
||||||
|
$(TESTS_DIR)/ft_list/dl_tests/tests_dlist_copy.c \
|
||||||
|
$(TESTS_DIR)/ft_list/dl_tests/tests_dlist_create.c \
|
||||||
|
$(TESTS_DIR)/ft_list/dl_tests/tests_dlist_delete.c \
|
||||||
|
$(TESTS_DIR)/ft_list/dl_tests/tests_dlist_iterators.c \
|
||||||
|
$(TESTS_DIR)/ft_list/dl_tests/tests_dlist_get.c \
|
||||||
|
$(TESTS_DIR)/ft_list/dl_tests/tests_dlist_subrange.c \
|
||||||
|
$(TESTS_DIR)/ft_list/dl_tests/tests_dlist_map.c \
|
||||||
|
$(TESTS_DIR)/ft_list/dl_tests/tests_dlist_new.c \
|
||||||
|
$(TESTS_DIR)/ft_list/dl_tests/tests_dlist_push.c \
|
||||||
|
$(TESTS_DIR)/ft_list/dl_tests/tests_dlist_rev.c \
|
||||||
|
$(TESTS_DIR)/ft_list/dl_tests/tests_dlist_sizers.c \
|
||||||
|
$(TESTS_DIR)/ft_list/dl_tests/tests_dlist_apply.c \
|
||||||
|
$(TESTS_DIR)/ft_list/dl_tests/tests_dlist_find.c \
|
||||||
|
\
|
||||||
|
$(TESTS_DIR)/ft_map/map_tests.c \
|
||||||
|
$(TESTS_DIR)/ft_map/tests_map_remove.c \
|
||||||
|
$(TESTS_DIR)/ft_map/tests_map_hash.c \
|
||||||
|
$(TESTS_DIR)/ft_map/tests_map_create.c \
|
||||||
|
$(TESTS_DIR)/ft_map/tests_map_destroy.c \
|
||||||
|
$(TESTS_DIR)/ft_map/tests_map_set_cmphash.c \
|
||||||
|
$(TESTS_DIR)/ft_map/tests_map_get.c \
|
||||||
|
$(TESTS_DIR)/ft_map/tests_map_size.c \
|
||||||
|
$(TESTS_DIR)/ft_map/tests_map_cappacity.c \
|
||||||
|
$(TESTS_DIR)/ft_map/tests_map_clear.c \
|
||||||
|
$(TESTS_DIR)/ft_map/tests_map_set.c \
|
||||||
|
\
|
||||||
|
$(TESTS_DIR)/ft_math/tests_abs.c \
|
||||||
|
$(TESTS_DIR)/ft_math/tests_align.c \
|
||||||
|
$(TESTS_DIR)/ft_math/tests_clamp.c \
|
||||||
|
$(TESTS_DIR)/ft_math/tests_complex.c \
|
||||||
|
$(TESTS_DIR)/ft_math/tests_intrange.c \
|
||||||
|
$(TESTS_DIR)/ft_math/tests_log.c \
|
||||||
|
$(TESTS_DIR)/ft_math/tests_minmax.c \
|
||||||
|
$(TESTS_DIR)/ft_math/tests_pow.c \
|
||||||
|
$(TESTS_DIR)/ft_math/tests_sqrt.c \
|
||||||
|
$(TESTS_DIR)/ft_math/tests_round.c \
|
||||||
|
$(TESTS_DIR)/ft_math/math_tests.c \
|
||||||
|
\
|
||||||
|
$(TESTS_DIR)/ft_optional/tests_optional_chain.c \
|
||||||
|
$(TESTS_DIR)/ft_optional/tests_optional_copy.c \
|
||||||
|
$(TESTS_DIR)/ft_optional/tests_optional_destroy.c \
|
||||||
|
$(TESTS_DIR)/ft_optional/tests_optional_dup.c \
|
||||||
|
$(TESTS_DIR)/ft_optional/tests_optional_from_val.c \
|
||||||
|
$(TESTS_DIR)/ft_optional/tests_optional_map.c \
|
||||||
|
$(TESTS_DIR)/ft_optional/tests_optional_new.c \
|
||||||
|
$(TESTS_DIR)/ft_optional/tests_optional_unwrap.c \
|
||||||
|
$(TESTS_DIR)/ft_optional/optional_tests.c \
|
||||||
|
\
|
||||||
|
$(TESTS_DIR)/ft_pair/tests_pair_cmp.c \
|
||||||
|
$(TESTS_DIR)/ft_pair/tests_pair_cmp_first.c \
|
||||||
|
$(TESTS_DIR)/ft_pair/tests_pair_cmp_second.c \
|
||||||
|
$(TESTS_DIR)/ft_pair/tests_pair_destroy.c \
|
||||||
|
$(TESTS_DIR)/ft_pair/tests_pair_get_first.c \
|
||||||
|
$(TESTS_DIR)/ft_pair/tests_pair_get_second.c \
|
||||||
|
$(TESTS_DIR)/ft_pair/tests_pair_new.c \
|
||||||
|
$(TESTS_DIR)/ft_pair/tests_pair_set.c \
|
||||||
|
$(TESTS_DIR)/ft_pair/pair_tests.c \
|
||||||
|
\
|
||||||
|
$(TESTS_DIR)/ft_string/ft_char/tests_isalnum.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_char/tests_isalpha.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_char/tests_isascii.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_char/tests_isdigit.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_char/tests_ishexdigit.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_char/tests_isoctdigit.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_char/tests_isspace.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_char/tests_isprint.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_char/tests_puchar.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_char/tests_tolower.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_char/tests_toupper.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_char/ft_char_tests.c \
|
||||||
|
\
|
||||||
|
$(TESTS_DIR)/ft_string/ft_mem/tests_apply_2d.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_mem/tests_bzero.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_mem/tests_calloc.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_mem/tests_fd_to_buff.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_mem/tests_free.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_mem/tests_free_2d.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_mem/tests_len_2d.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_mem/tests_memchr.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_mem/tests_memcmp.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_mem/tests_memcpy.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_mem/tests_memmap.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_mem/tests_memmove.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_mem/tests_memset.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_mem/tests_qsort.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_mem/tests_realloc.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_mem/tests_swap.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_mem/mem_tests.c \
|
||||||
|
\
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_atoi_base.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_atoi.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_atof.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_gnl.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_itoa_base.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_itoa.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_putendl.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_putnbr.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_putstr.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_shift_args.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_split.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_splits.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_str_isalpha.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_str_isalnum.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_str_isdouble.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_str_isdigit.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_str_isbool.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_str_isfloat.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_str_ishex.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_str_isint.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_str_islong.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_str_isnum.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_str_isoct.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_str_isvalid.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strchr.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strclen.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strcmp.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strcnb.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strcspn.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strdup.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strend_with.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_striteri.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strjoin.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strlcat.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strlcpy.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strlen.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strmapi.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strncmp.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strndup.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strnstr.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strrchr.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strspn.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strstart_with.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_str_replace.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_str_replace_chr.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strappend_c.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strtok.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_strtrim.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_substr.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/test_utoa.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_str/str_tests.c \
|
||||||
|
$(TESTS_DIR)/ft_string/string_tests.c \
|
||||||
|
\
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_append.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_append_c.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_append_n.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_append_s.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_append_sn.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_cap.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_chr.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_clear.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_cmp.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_cmp_str.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_destroy.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_from.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_from_c.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_from_n.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_from_s.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_from_sn.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_get.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_insert.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_insert_c.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_insert_n.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_insert_s.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_insert_sn.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_len.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_ncmp.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_ncmp_str.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_new.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_offset.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_put.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_rchr.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_replace.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_replace_chr.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_reserve.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_resize.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_roffset.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_set.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_set_inplace.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_set_n.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_shrink.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_substr.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_to_str.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_trim.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_trim_chr.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/test_trimstr.c \
|
||||||
|
$(TESTS_DIR)/ft_string/ft_string/t_string_tests.c \
|
||||||
|
\
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_add.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_apply.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_at.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_cat.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_clear.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_convert_alloc_array.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_destroy.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_filter.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_from_array.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_from_size.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_get.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_map.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_new.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_pop.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_remove.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_remove_if.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_reserve.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_reverse.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_shift.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_shrink.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_sort.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_swap.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/tests_vec_to_array.c \
|
||||||
|
$(TESTS_DIR)/ft_vector/vector_tests.c \
|
||||||
|
\
|
||||||
|
$(TESTS_DIR)/main_tests.c \
|
||||||
|
$(TESTS_DIR)/lambdas_for_tests.c \
|
||||||
|
$(TESTS_DIR)/tests_utils.c
|
||||||
|
|
||||||
|
# Inner variables for targets
|
||||||
|
|
||||||
|
STABLE = \
|
||||||
|
$(FT_MATH_SRC) \
|
||||||
|
$(FT_LIST_SRC) \
|
||||||
|
$(FT_VEC_SRC) \
|
||||||
|
$(FT_STRING_SRC) \
|
||||||
|
$(FT_MAP_SRC) \
|
||||||
|
$(FT_OPTIONAL_SRC) \
|
||||||
|
$(FT_ARGS_SRC) \
|
||||||
|
$(FT_PAIR_SRC) \
|
||||||
|
|
||||||
|
UNSTABLE = \
|
||||||
|
|
||||||
|
INNER_SRC = \
|
||||||
|
$(STABLE)
|
||||||
|
|
||||||
|
# Check if user wants to compile unstable sources
|
||||||
|
# to compile unstable sources run make with TARGET=UNSTABLE
|
||||||
|
ifeq (UNSTABLE, $(findstring UNSTABLE, $(TARGET)))
|
||||||
|
INNER_SRC += \
|
||||||
|
$(UNSTABLE)
|
||||||
|
endif
|
||||||
|
# Check if user wants to compile all sources
|
||||||
|
# to compile all sources run make with TARGET=ALL
|
||||||
|
ifeq (ALL, $(findstring ALL, $(TARGET)))
|
||||||
|
INNER_SRC = \
|
||||||
|
$(STABLE) \
|
||||||
|
$(UNSTABLE)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Objects creation
|
||||||
|
|
||||||
|
# add prefix to sources to specify the directory src/
|
||||||
|
SRCS = $(addprefix $(SRC_DIR)/, $(INNER_SRC))
|
||||||
|
|
||||||
|
# add prefix to sources to specify the directory build/ for objects
|
||||||
|
OBJ = $(patsubst %.c, %.o, $(addprefix $(BUILD_DIR)/,$(INNER_SRC)))
|
||||||
|
|
||||||
|
# add prefix to sources to specify the directory build/tests/ for test objects
|
||||||
|
TOBJ = $(patsubst %.c, %.o, $(addprefix $(BUILD_DIR)/$(TESTS_DIR)/,$(INNER_SRC)))
|
||||||
|
TOBJ += $(patsubst %.c, %.o, $(addprefix $(BUILD_DIR)/,$(TESTS_SRC)))
|
||||||
|
|
||||||
|
# Inner variables for rules
|
||||||
|
|
||||||
|
# Get the max length of the sources names to align the output
|
||||||
|
MAX_FILE_LEN = $(shell $(PRINTF) "%s\n" $(SRCS) | \
|
||||||
|
awk '{print length}' | sort -n | tail -1)
|
||||||
|
|
||||||
# Rules
|
# Rules
|
||||||
|
|
||||||
# All (make all)
|
# Default rule for objects imported from src/
|
||||||
all: header $(NAME) footer
|
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
|
||||||
|
@$(ECHO) -n $(GRAY) "building from "
|
||||||
lib: $(NAME)
|
@$(PRINTF) "%*s ... "$(RESET) $(MAX_FILE_LEN) $<
|
||||||
|
|
||||||
# Bonus (make bonus)
|
|
||||||
bonus: header $(OBJ) $(LIB_OBJ) footer
|
|
||||||
@mkdir -p $(OBJDIRNAME)
|
|
||||||
@mkdir -p $(OBJDIRNAME)/$(SRCDIRNAME)
|
|
||||||
@printf '$(GREY) Be Carefull ur in $(END)$(GREEN)Debug Mode$(END)\n'
|
|
||||||
@cc $(CFLAGS) -D BONUS=1 -o $(NAME) $(OBJ) $(LIB_OBJ)
|
|
||||||
|
|
||||||
# Clean (make clean)
|
|
||||||
clean:
|
|
||||||
@printf '$(GREY) Removing $(END)$(RED)Objects$(END)\n'
|
|
||||||
@printf '$(GREY) Removing $(END)$(RED)Objects Folder$(END)\n'
|
|
||||||
@$(RM) $(OBJDIRNAME)
|
|
||||||
|
|
||||||
# Clean (make fclean)
|
|
||||||
fclean: clean
|
|
||||||
@printf '$(GREY) Removing $(END)$(RED)Program$(END)\n'
|
|
||||||
@$(RM) $(NAME)
|
|
||||||
@echo ""
|
|
||||||
|
|
||||||
# Restart (make re)
|
|
||||||
re: header fclean all
|
|
||||||
|
|
||||||
# Dependences for all
|
|
||||||
$(NAME): $(OBJ)
|
|
||||||
@mkdir -p $(OBJDIRNAME)
|
|
||||||
@ar rc $(NAME) $(OBJ)
|
|
||||||
@ranlib $(NAME)
|
|
||||||
|
|
||||||
# Creating the objects
|
|
||||||
$(OBJDIRNAME)/%.o: %.c
|
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
@printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n'
|
@( $(CC) $(CFLAGS) -c $< -o $@ 2>> $(CLOG_FILE) && \
|
||||||
@cc $(CFLAGS) -o $@ -c $< -I$(INCLUDES)
|
$(ECHO) $(GREEN) "Success" $(RESET) ) || \
|
||||||
|
$(ECHO) $(RED) "Failed" $(RESET) \
|
||||||
|
$(BOLD) "see:" $(CLOG_FILE) $(RESET)
|
||||||
|
|
||||||
# Header
|
# Rule for tests objects imported from src/
|
||||||
header:
|
$(BUILD_DIR)/$(TESTS_DIR)/%.o: $(SRC_DIR)/%.c
|
||||||
@clear
|
@$(ECHO) -n $(GRAY) "building from " $< "..." $(RESET)
|
||||||
@printf '\n\n'
|
@mkdir -p $(dir $@)
|
||||||
@printf '$(GOLD) ******* ****** ******* $(END)\n'
|
@( $(CC) $(CFLAGS) $(TEST_FLAGS) -c $< -o $@ \
|
||||||
@printf '$(GOLD) ****** *** ******* $(END)\n'
|
2>> $(CLOG_FILE) && \
|
||||||
@printf '$(GOLD) ******* * ******* $(END)\n'
|
$(ECHO) $(GREEN) "Success" $(RESET) ) || \
|
||||||
@printf '$(GOLD) ****** ******* $(END)\n'
|
$(ECHO) $(RED) "Failed" $(RESET) \
|
||||||
@printf '$(GOLD) ******* ******* $(END)\n'
|
$(BOLD) "see:" $(CLOG_FILE) $(RESET)
|
||||||
@printf '$(GOLD) ******************* ******* * $(END)\n'
|
|
||||||
@printf '$(GOLD) ******************* ******* *** $(END)\n'
|
|
||||||
@printf '$(GOLD) ****** ******* ****** $(END)\n'
|
|
||||||
@printf '$(GOLD) ****** $(END)\n'
|
|
||||||
@printf '$(GOLD) ****** $(END)\n'
|
|
||||||
@printf '$(GREY) Made by rparodi$(END)\n\n'
|
|
||||||
|
|
||||||
# Footer
|
# Rule for tests objects imported from tests/
|
||||||
footer:
|
$(BUILD_DIR)/$(TESTS_DIR)/%.o: $(TESTS_DIR)/%.c
|
||||||
@printf "\n"
|
@$(ECHO) -n $(GRAY) "building from " $< "..." $(RESET)
|
||||||
@printf "$(GOLD) ,_ _,$(END)\n"
|
@mkdir -p $(dir $@)
|
||||||
@printf "$(GOLD) | \\___//|$(END)\n"
|
@( $(CC) $(CFLAGS) $(TEST_FLAGS) -c $< -o $@ \
|
||||||
@printf "$(GOLD) |=6 6=|$(END)\n"
|
2>> $(CLOG_FILE) && \
|
||||||
@printf "$(GOLD) \\=._Y_.=/$(END)\n"
|
$(ECHO) $(GREEN) "Success" $(RESET) ) || \
|
||||||
@printf "$(GOLD) ) \` ( ,$(END)\n"
|
$(ECHO) $(RED) "Failed" $(RESET) \
|
||||||
@printf "$(GOLD) / \\ (('$(END)\n"
|
$(BOLD) "see:" $(CLOG_FILE) $(RESET)
|
||||||
@printf "$(GOLD) | | ))$(END)\n"
|
|
||||||
@printf "$(GOLD) /| | | |\\_//$(END)\n"
|
|
||||||
@printf "$(GOLD) \\| |._.| |/-\`$(END)\n"
|
|
||||||
@printf "$(GOLD) '\"' '\"'$(END)\n"
|
|
||||||
@printf ' $(GREY)The compilation is$(END) $(GOLD)finish$(END)\n $(GREY)Have a good $(END)$(GOLD)correction !$(END)\n'
|
|
||||||
|
|
||||||
# Phony
|
# Default rule
|
||||||
.PHONY: all bonus clean fclean re
|
all: $(OUTDIR)/lib$(NAME).a
|
||||||
|
|
||||||
-include ${OBJ:.o=.d}
|
tmp:
|
||||||
|
@echo $(SRCS)
|
||||||
|
|
||||||
|
so: $(OUTDIR)/lib$(NAME).so
|
||||||
|
|
||||||
|
# Rule for shared library
|
||||||
|
$(OUTDIR)/lib$(NAME).so: $(OBJ)
|
||||||
|
@$(ECHO) -n $(GRAY) "Making ... " $(RESET) $(BOLD) \
|
||||||
|
"$(OUTDIR)/lib$(NAME).so" $(RESET) $(GRAY) " ... " $(RESET)
|
||||||
|
@( $(CC) -shared -o $(OUTDIR)/lib$(NAME).so $(OBJ) 2> /dev/null && \
|
||||||
|
$(ECHO) $(GREEN) "Success" $(RESET) && $(RM) $(CLOG_FILE) ) || \
|
||||||
|
$(ECHO) $(RED) "Failed" $(RESET) "see:" $(CLOG_FILE)
|
||||||
|
|
||||||
|
# Rule for static library
|
||||||
|
$(OUTDIR)/lib$(NAME).a: $(OBJ)
|
||||||
|
@$(ECHO) -n $(GRAY) "Making ... " $(RESET) $(BOLD) \
|
||||||
|
"$(OUTDIR)/lib$(NAME).a" $(RESET) $(GRAY) " ... " $(RESET)
|
||||||
|
@( $(AR) -rcs $(OUTDIR)/lib$(NAME).a $(OBJ) 2> /dev/null && \
|
||||||
|
$(ECHO) $(GREEN) "Success" $(RESET) && $(RM) $(CLOG_FILE) ) || \
|
||||||
|
$(ECHO) $(RED) "Failed" $(RESET) "see:" $(CLOG_FILE)
|
||||||
|
|
||||||
|
# Rule to compile and run tests
|
||||||
|
$(TEST_NAME): $(TOBJ)
|
||||||
|
@$(ECHO) -n $(GRAY) "Compiling tests ... " $(RESET)
|
||||||
|
@$(CC) $(CFLAGS) $(TOBJ) -o $(TEST_NAME) $(TEST_FLAGS) \
|
||||||
|
$(LDFLAGS) -lgcov \
|
||||||
|
2>> $(CLOG_FILE) && \
|
||||||
|
$(ECHO) $(GREEN) "Success" $(RESET) || \
|
||||||
|
$(ECHO) $(RED) "Failed" $(RESET)
|
||||||
|
@$(ECHO) -n $(GRAY) "Running tests ... " $(RESET) && \
|
||||||
|
./$(TEST_NAME) && \
|
||||||
|
$(ECHO) $(GREEN) "Success" $(RESET) || \
|
||||||
|
$(ECHO) $(RED) "Failed" $(RESET)
|
||||||
|
|
||||||
|
# Rule to generate coverage using llvm
|
||||||
|
$(COVERAGE_DIR): $(TEST_NAME)
|
||||||
|
@$(ECHO) -n $(GRAY) "Generating profraw ... " $(RESET) && \
|
||||||
|
./$(TEST_NAME) && \
|
||||||
|
$(ECHO) -n $(GRAY) " profdata ... " $(RESET) && \
|
||||||
|
$(PRD) merge -sparse default.profraw -o \
|
||||||
|
$(TEST_NAME).profdata && \
|
||||||
|
$(ECHO) -n $(GRAY) "coverage in html ... " \
|
||||||
|
$(RESET) && \
|
||||||
|
$(COV) show -format=html \
|
||||||
|
-instr-profile=$(TEST_NAME).profdata \
|
||||||
|
-ignore-filename-regex=$(TESTS_DIR)/* \
|
||||||
|
--show-branches=count \
|
||||||
|
./$(TEST_NAME) -output-dir=$(COVERAGE_DIR) > /dev/null && \
|
||||||
|
$(RM) *.profraw *.profdata && \
|
||||||
|
$(ECHO) $(GREEN) "Success" $(RESET) || \
|
||||||
|
$(ECHO) $(RED) "Failed" $(RESET)
|
||||||
|
|
||||||
|
# Rule to compile using debug flags
|
||||||
|
debug:
|
||||||
|
@$(ECHO) $(GRAY) "Compiling debug, flags are" $(RESET) \
|
||||||
|
"$(CFLAGS) $(DEBUG_FLAGS)" $(RESET) && \
|
||||||
|
make --no-print-directory -C . re \
|
||||||
|
CFLAGS="$(CFLAGS) $(DEBUG_FLAGS)" && \
|
||||||
|
make --no-print-directory -C . \
|
||||||
|
so CFLAGS="$(CFLAGS) $(DEBUG_FLAGS)" && \
|
||||||
|
$(ECHO) $(GREEN) "Success" $(RESET) || \
|
||||||
|
$(ECHO) $(RED) "Failed" $(RESET)
|
||||||
|
|
||||||
|
# Rule to clean objects
|
||||||
|
clean:
|
||||||
|
@$(ECHO) -n $(GRAY) "Clean ... " $(RESET) && \
|
||||||
|
( $(RM) -rf $(BUILD_DIR) $(CLOG_FILE) $(TEST_NAME) *.gcov \
|
||||||
|
*.gcno *.gcda 2> /dev/null && \
|
||||||
|
$(ECHO) $(GREEN) "Success" $(RESET) ) || \
|
||||||
|
$(ECHO) $(RED) "Failed" $(RESET)
|
||||||
|
|
||||||
|
# Rule to clean objects and libraries/compiled files
|
||||||
|
fclean: clean
|
||||||
|
@$(ECHO) -n $(GRAY) "FClean ... " $(RESET) && \
|
||||||
|
( $(RM) -rf $(OUTDIR)/lib$(NAME).a l$(OUTDIR)/ib$(NAME).so \
|
||||||
|
$(COVERAGE_DIR) $(TEST_NAME) \
|
||||||
|
*.profraw *.profdata Doxygen 2> /dev/null && \
|
||||||
|
$(ECHO) $(GREEN) "Success" $(RESET) ) || \
|
||||||
|
$(ECHO) $(RED) "Failed" $(RESET)
|
||||||
|
|
||||||
|
# Rule to recompile
|
||||||
|
re: fclean
|
||||||
|
@$(ECHO) -ne $(GRAY) "Recompiling ..." $(RESET) "\n" && \
|
||||||
|
make --no-print-directory all && \
|
||||||
|
$(ECHO) $(GREEN) "Success" $(RESET) || \
|
||||||
|
$(ECHO) $(RED) "Failed" $(RESET)
|
||||||
|
|
||||||
|
-include $(OBJ:.o=.d)
|
||||||
|
|
||||||
|
# rule to force rules to be executed even if files exist
|
||||||
|
.PHONY: re fclean clean
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
This project is your very first project as a student at 42. You will need to recode a few functions of the C standard library as well as some other utility functions that you will use during your whole cursus.
|
|
||||||
##
|
|
||||||
| Keywords | Skills |
|
|
||||||
| ------|-----|
|
|
||||||
| Unix Logic | Algorithms & AI |
|
|
||||||
|| Imperative programming |
|
|
||||||
|| Rigor |
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_isalnum.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/06 12:47:28 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 12:54:42 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Check if the character is alpha-numeric
|
|
||||||
*
|
|
||||||
* @param c the character
|
|
||||||
* @return the character if alphanumeric or 0 if not
|
|
||||||
*/
|
|
||||||
int ft_isalnum(int c)
|
|
||||||
{
|
|
||||||
if (ft_isalpha(c) || ft_isdigit(c))
|
|
||||||
return (c);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_isalpha.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/06 11:58:37 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 12:54:40 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Check if the character is alpha
|
|
||||||
*
|
|
||||||
* @param c the character
|
|
||||||
* @return the character if alpha or 0 if not
|
|
||||||
*/
|
|
||||||
int ft_isalpha(int c)
|
|
||||||
{
|
|
||||||
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
|
|
||||||
return (c);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_isascii.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/06 14:04:26 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 12:49:55 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Check if the character is in the ascii table
|
|
||||||
*
|
|
||||||
* @param c the character
|
|
||||||
* @return the character if in the ascii table or 0 if not
|
|
||||||
*/
|
|
||||||
int ft_isascii(int c)
|
|
||||||
{
|
|
||||||
if (c == 0)
|
|
||||||
return (1);
|
|
||||||
if (c > 0 && c <= 127)
|
|
||||||
return (c);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_isdigit.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/06 12:44:28 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 12:49:05 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Check if the character is alpha numeric
|
|
||||||
*
|
|
||||||
* @param c the character
|
|
||||||
* @return the character if numeric or 0 if not
|
|
||||||
*/
|
|
||||||
int ft_isdigit(int c)
|
|
||||||
{
|
|
||||||
if (c >= '0' && c <= '9')
|
|
||||||
return (c);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_isprint.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/06 14:06:53 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 12:50:37 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Check if the character is printable
|
|
||||||
*
|
|
||||||
* @param c the character
|
|
||||||
* @return the character if can be print or 0 if not
|
|
||||||
*/
|
|
||||||
int ft_isprint(int c)
|
|
||||||
{
|
|
||||||
if (c >= 32 && c <= 126)
|
|
||||||
return (c);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_tolower.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/07 10:38:54 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 12:55:28 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief convert the upper case to lower case
|
|
||||||
*
|
|
||||||
* @param c the character
|
|
||||||
* @return the character to lower case if is on upper
|
|
||||||
*/
|
|
||||||
int ft_tolower(int c)
|
|
||||||
{
|
|
||||||
if (c >= 'A' && c <= 'Z')
|
|
||||||
c += 32;
|
|
||||||
return (c);
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_toupper.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/07 10:44:26 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 12:55:14 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief convert the lower case to upper case
|
|
||||||
*
|
|
||||||
* @param c the character
|
|
||||||
* @return the character to upper case if is on lower
|
|
||||||
*/
|
|
||||||
int ft_toupper(int c)
|
|
||||||
{
|
|
||||||
if (c >= 'a' && c <= 'z')
|
|
||||||
c -= 32;
|
|
||||||
return (c);
|
|
||||||
}
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_atoi.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/08 17:22:41 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 15:16:10 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
static int ft_check_space(int c)
|
|
||||||
{
|
|
||||||
if (c == 32 || (c >= 9 && c <= 13))
|
|
||||||
return (1);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ft_check_sign(const char *nptr, int *i)
|
|
||||||
{
|
|
||||||
while (ft_check_space(nptr[*i]))
|
|
||||||
(*i)++;
|
|
||||||
if (nptr[*i] == '-')
|
|
||||||
{
|
|
||||||
(*i)++;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
else if (nptr[*i] == '+')
|
|
||||||
(*i)++;
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Converts string to integer
|
|
||||||
*
|
|
||||||
* @param nptr the string that will be converted
|
|
||||||
* @return The integer on the string
|
|
||||||
*/
|
|
||||||
int ft_atoi(const char *nptr)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int sign;
|
|
||||||
int number;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
sign = ft_check_sign(nptr, &i);
|
|
||||||
number = 0;
|
|
||||||
while (nptr[i])
|
|
||||||
{
|
|
||||||
if (nptr[i] >= '0' && nptr[i] <= '9')
|
|
||||||
number = (number * 10) + nptr[i] - '0';
|
|
||||||
else
|
|
||||||
break ;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return (sign * number);
|
|
||||||
}
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_atoll.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/10/31 15:12:07 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 15:14:50 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
static int ft_check_space(int c)
|
|
||||||
{
|
|
||||||
if (c == 32 || (c >= 9 && c <= 13))
|
|
||||||
return (1);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ft_check_sign(const char *nptr, size_t *i)
|
|
||||||
{
|
|
||||||
while (ft_check_space(nptr[*i]))
|
|
||||||
(*i)++;
|
|
||||||
if (nptr[*i] == '-')
|
|
||||||
{
|
|
||||||
(*i)++;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
else if (nptr[*i] == '+')
|
|
||||||
(*i)++;
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Converts string to long long integer
|
|
||||||
*
|
|
||||||
* @param nptr the string that will be converted
|
|
||||||
* @return The long long int on the string
|
|
||||||
*/
|
|
||||||
long long int ft_atoll(const char *nptr)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
int sign;
|
|
||||||
long long int number;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
sign = ft_check_sign(nptr, &i);
|
|
||||||
number = 0;
|
|
||||||
while (nptr[i])
|
|
||||||
{
|
|
||||||
if (nptr[i] >= '0' && nptr[i] <= '9')
|
|
||||||
number = (number * 10) + nptr[i] - '0';
|
|
||||||
else
|
|
||||||
break ;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return (sign * number);
|
|
||||||
}
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_itoa.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/09 13:56:30 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 13:02:55 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
static size_t ft_check_sign(char *str, long *nb)
|
|
||||||
{
|
|
||||||
if ((*nb) == 0)
|
|
||||||
str[0] = '0';
|
|
||||||
if ((*nb) < 0)
|
|
||||||
{
|
|
||||||
str[0] = '-';
|
|
||||||
*nb = -*nb;
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Converts integer to string
|
|
||||||
*
|
|
||||||
* @param n the integer that will be converted
|
|
||||||
* @return The string with this integer
|
|
||||||
*/
|
|
||||||
char *ft_itoa(int n)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
size_t modulus;
|
|
||||||
short int maiboyerlpb;
|
|
||||||
char str[13];
|
|
||||||
long nb;
|
|
||||||
|
|
||||||
nb = n;
|
|
||||||
maiboyerlpb = 0;
|
|
||||||
modulus = 1000000000;
|
|
||||||
ft_bzero(str, 13);
|
|
||||||
i = ft_check_sign(str, &nb);
|
|
||||||
while (modulus != 0)
|
|
||||||
{
|
|
||||||
if (nb / modulus != 0 || maiboyerlpb != 0)
|
|
||||||
{
|
|
||||||
str[i++] = (nb / modulus) + 48;
|
|
||||||
maiboyerlpb++;
|
|
||||||
}
|
|
||||||
nb %= modulus;
|
|
||||||
modulus /= 10;
|
|
||||||
}
|
|
||||||
return (ft_strdup(str));
|
|
||||||
}
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* char.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/10/31 14:54:04 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 15:22:26 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#ifndef CHAR_H
|
|
||||||
# define CHAR_H
|
|
||||||
|
|
||||||
# include <stdio.h>
|
|
||||||
# include <string.h>
|
|
||||||
# include <stdlib.h>
|
|
||||||
# include <unistd.h>
|
|
||||||
# include <limits.h>
|
|
||||||
# include <fcntl.h>
|
|
||||||
|
|
||||||
int ft_isalnum(int c);
|
|
||||||
int ft_isalpha(int c);
|
|
||||||
int ft_isascii(int c);
|
|
||||||
int ft_isdigit(int c);
|
|
||||||
int ft_isprint(int c);
|
|
||||||
int ft_tolower(int c);
|
|
||||||
int ft_toupper(int c);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* convert.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/10/31 14:57:24 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 15:27:40 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#ifndef CONVERT_H
|
|
||||||
# define CONVERT_H
|
|
||||||
|
|
||||||
# include <stdio.h>
|
|
||||||
# include <string.h>
|
|
||||||
# include <stdlib.h>
|
|
||||||
# include <unistd.h>
|
|
||||||
# include <limits.h>
|
|
||||||
# include <fcntl.h>
|
|
||||||
|
|
||||||
char *ft_itoa(int n);
|
|
||||||
int ft_atoi(const char *nptr);
|
|
||||||
long long int ft_atoll(const char *nptr);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* libft.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/06 11:14:57 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 15:27:14 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#ifndef LIBFT_H
|
|
||||||
# define LIBFT_H
|
|
||||||
|
|
||||||
# include "char.h"
|
|
||||||
# include "convert.h"
|
|
||||||
# include "list.h"
|
|
||||||
# include "memory.h"
|
|
||||||
# include "print.h"
|
|
||||||
# include "str.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* char.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/10/31 14:54:04 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 15:22:26 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#ifndef CHAR_H
|
|
||||||
# define CHAR_H
|
|
||||||
|
|
||||||
# include <stdio.h>
|
|
||||||
# include <string.h>
|
|
||||||
# include <stdlib.h>
|
|
||||||
# include <unistd.h>
|
|
||||||
# include <limits.h>
|
|
||||||
# include <fcntl.h>
|
|
||||||
|
|
||||||
int ft_isalnum(int c);
|
|
||||||
int ft_isalpha(int c);
|
|
||||||
int ft_isascii(int c);
|
|
||||||
int ft_isdigit(int c);
|
|
||||||
int ft_isprint(int c);
|
|
||||||
int ft_tolower(int c);
|
|
||||||
int ft_toupper(int c);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* convert.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/10/31 14:57:24 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 15:27:40 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#ifndef CONVERT_H
|
|
||||||
# define CONVERT_H
|
|
||||||
|
|
||||||
# include <stdio.h>
|
|
||||||
# include <string.h>
|
|
||||||
# include <stdlib.h>
|
|
||||||
# include <unistd.h>
|
|
||||||
# include <limits.h>
|
|
||||||
# include <fcntl.h>
|
|
||||||
|
|
||||||
char *ft_itoa(int n);
|
|
||||||
int ft_atoi(const char *nptr);
|
|
||||||
long long int ft_atoll(const char *nptr);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* libft.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/06 11:14:57 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 15:27:14 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#ifndef LIBFT_H
|
|
||||||
# define LIBFT_H
|
|
||||||
|
|
||||||
# include "char.h"
|
|
||||||
# include "convert.h"
|
|
||||||
# include "list.h"
|
|
||||||
# include "memory.h"
|
|
||||||
# include "print.h"
|
|
||||||
# include "str.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* list.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/10/31 15:00:12 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 15:27:20 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#ifndef LIST_H
|
|
||||||
# define LIST_H
|
|
||||||
|
|
||||||
# include <stdio.h>
|
|
||||||
# include <string.h>
|
|
||||||
# include <stdlib.h>
|
|
||||||
# include <unistd.h>
|
|
||||||
# include <limits.h>
|
|
||||||
# include <fcntl.h>
|
|
||||||
|
|
||||||
typedef struct s_list
|
|
||||||
{
|
|
||||||
void *content;
|
|
||||||
struct s_list *next;
|
|
||||||
} t_list;
|
|
||||||
|
|
||||||
int ft_lstsize(t_list *lst);
|
|
||||||
t_list *ft_lstlast(t_list *lst);
|
|
||||||
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *));
|
|
||||||
t_list *ft_lstnew(void *content);
|
|
||||||
void ft_lstadd_back(t_list **lst, t_list *new);
|
|
||||||
void ft_lstadd_front(t_list **lst, t_list *new);
|
|
||||||
void ft_lstclear(t_list **lst, void (*del)(void *));
|
|
||||||
void ft_lstdelone(t_list *lst, void (*del)(void *));
|
|
||||||
void ft_lstiter(t_list *lst, void (*f)(void *));
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* memory.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/10/31 15:18:17 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 15:21:00 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#ifndef MEMORY_H
|
|
||||||
# define MEMORY_H
|
|
||||||
|
|
||||||
# include <stdio.h>
|
|
||||||
# include <string.h>
|
|
||||||
# include <stdlib.h>
|
|
||||||
# include <unistd.h>
|
|
||||||
# include <limits.h>
|
|
||||||
# include <fcntl.h>
|
|
||||||
|
|
||||||
int ft_memcmp(const void *s1, const void *s2, size_t n);
|
|
||||||
void *ft_calloc(size_t nmemb, size_t size);
|
|
||||||
void *ft_memchr(const void *s, int c, size_t n);
|
|
||||||
void *ft_memcpy(void *dest, const void *src, size_t n);
|
|
||||||
void *ft_memmove(void *dest, const void *src, size_t n);
|
|
||||||
void *ft_memset(void *s, int c, size_t n);
|
|
||||||
void ft_bzero(void *s, size_t n);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* print.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/10/31 15:07:30 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 15:41:54 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#ifndef PRINT_H
|
|
||||||
# define PRINT_H
|
|
||||||
|
|
||||||
# include <fcntl.h>
|
|
||||||
# include <limits.h>
|
|
||||||
# include <stdarg.h>
|
|
||||||
# include <stdio.h>
|
|
||||||
# include <stdlib.h>
|
|
||||||
# include <string.h>
|
|
||||||
# include <unistd.h>
|
|
||||||
|
|
||||||
int ft_dprintf(int fd, const char *s, ...);
|
|
||||||
int ft_printf(const char *s, ...);
|
|
||||||
void ft_putchar_fd(char c, int fd);
|
|
||||||
void ft_putendl_fd(char *s, int fd);
|
|
||||||
void ft_putnbr_fd(int n, int fd);
|
|
||||||
void ft_putstr_fd(char *s, int fd);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* str.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/10/31 15:04:59 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 17:06:53 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#ifndef STR_H
|
|
||||||
# define STR_H
|
|
||||||
|
|
||||||
# include <stdio.h>
|
|
||||||
# include <string.h>
|
|
||||||
# include <stdlib.h>
|
|
||||||
# include <unistd.h>
|
|
||||||
# include <limits.h>
|
|
||||||
# include <fcntl.h>
|
|
||||||
|
|
||||||
char **ft_split(char const *s, char c);
|
|
||||||
char *ft_strchr(const char *s, int c);
|
|
||||||
char *ft_strcpy(char *dst, const char *src);
|
|
||||||
char *ft_strdup(const char *s);
|
|
||||||
char *ft_strjoin(char const *s1, char const *s2);
|
|
||||||
char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
|
|
||||||
char *ft_strnstr(const char *big, const char *little, size_t len);
|
|
||||||
char *ft_strrchr(const char *s, int c);
|
|
||||||
char *ft_strtrim(char const *s1, char const *set);
|
|
||||||
char *ft_substr(char const *s, unsigned int start, size_t len);
|
|
||||||
int ft_strcmp(const char *s1, const char *s2);
|
|
||||||
int ft_strncmp(const char *s1, const char *s2, size_t n);
|
|
||||||
size_t ft_strlcat(char *dst, const char *src, size_t size);
|
|
||||||
size_t ft_strlcpy(char *dst, const char *src, size_t size);
|
|
||||||
size_t ft_strlen(const char *s);
|
|
||||||
void ft_striteri(char *s, void (*f)(unsigned int, char*));
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* list.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/10/31 15:00:12 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 15:27:20 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#ifndef LIST_H
|
|
||||||
# define LIST_H
|
|
||||||
|
|
||||||
# include <stdio.h>
|
|
||||||
# include <string.h>
|
|
||||||
# include <stdlib.h>
|
|
||||||
# include <unistd.h>
|
|
||||||
# include <limits.h>
|
|
||||||
# include <fcntl.h>
|
|
||||||
|
|
||||||
typedef struct s_list
|
|
||||||
{
|
|
||||||
void *content;
|
|
||||||
struct s_list *next;
|
|
||||||
} t_list;
|
|
||||||
|
|
||||||
int ft_lstsize(t_list *lst);
|
|
||||||
t_list *ft_lstlast(t_list *lst);
|
|
||||||
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *));
|
|
||||||
t_list *ft_lstnew(void *content);
|
|
||||||
void ft_lstadd_back(t_list **lst, t_list *new);
|
|
||||||
void ft_lstadd_front(t_list **lst, t_list *new);
|
|
||||||
void ft_lstclear(t_list **lst, void (*del)(void *));
|
|
||||||
void ft_lstdelone(t_list *lst, void (*del)(void *));
|
|
||||||
void ft_lstiter(t_list *lst, void (*f)(void *));
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* memory.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/10/31 15:18:17 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 15:21:00 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#ifndef MEMORY_H
|
|
||||||
# define MEMORY_H
|
|
||||||
|
|
||||||
# include <stdio.h>
|
|
||||||
# include <string.h>
|
|
||||||
# include <stdlib.h>
|
|
||||||
# include <unistd.h>
|
|
||||||
# include <limits.h>
|
|
||||||
# include <fcntl.h>
|
|
||||||
|
|
||||||
int ft_memcmp(const void *s1, const void *s2, size_t n);
|
|
||||||
void *ft_calloc(size_t nmemb, size_t size);
|
|
||||||
void *ft_memchr(const void *s, int c, size_t n);
|
|
||||||
void *ft_memcpy(void *dest, const void *src, size_t n);
|
|
||||||
void *ft_memmove(void *dest, const void *src, size_t n);
|
|
||||||
void *ft_memset(void *s, int c, size_t n);
|
|
||||||
void ft_bzero(void *s, size_t n);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* print.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/10/31 15:07:30 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 15:41:54 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#ifndef PRINT_H
|
|
||||||
# define PRINT_H
|
|
||||||
|
|
||||||
# include <fcntl.h>
|
|
||||||
# include <limits.h>
|
|
||||||
# include <stdarg.h>
|
|
||||||
# include <stdio.h>
|
|
||||||
# include <stdlib.h>
|
|
||||||
# include <string.h>
|
|
||||||
# include <unistd.h>
|
|
||||||
|
|
||||||
int ft_dprintf(int fd, const char *s, ...);
|
|
||||||
int ft_printf(const char *s, ...);
|
|
||||||
void ft_putchar_fd(char c, int fd);
|
|
||||||
void ft_putendl_fd(char *s, int fd);
|
|
||||||
void ft_putnbr_fd(int n, int fd);
|
|
||||||
void ft_putstr_fd(char *s, int fd);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* str.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/10/31 15:04:59 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 16:15:39 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#ifndef STR_H
|
|
||||||
# define STR_H
|
|
||||||
|
|
||||||
# include <stdio.h>
|
|
||||||
# include <string.h>
|
|
||||||
# include <stdlib.h>
|
|
||||||
# include <unistd.h>
|
|
||||||
# include <limits.h>
|
|
||||||
# include <fcntl.h>
|
|
||||||
|
|
||||||
char **ft_split(char const *s, char c);
|
|
||||||
char *ft_strchr(const char *s, int c);
|
|
||||||
char *ft_strcpy(char *dst, const char *src);
|
|
||||||
char *ft_strdup(const char *s);
|
|
||||||
char *ft_strjoin(char const *s1, char const *s2);
|
|
||||||
char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
|
|
||||||
char *ft_strnstr(const char *big, const char *little, size_t len);
|
|
||||||
char *ft_strrchr(const char *s, int c);
|
|
||||||
char *ft_strtrim(char const *s1, char const *set);
|
|
||||||
char *ft_substr(char const *s, unsigned int start, size_t len);
|
|
||||||
int ft_strncmp(const char *s1, const char *s2, size_t n);
|
|
||||||
size_t ft_strlcat(char *dst, const char *src, size_t size);
|
|
||||||
size_t ft_strlcpy(char *dst, const char *src, size_t size);
|
|
||||||
size_t ft_strlen(const char *s);
|
|
||||||
void ft_striteri(char *s, void (*f)(unsigned int, char*));
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_lstadd_back.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/12 11:39:56 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 17:29:37 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Add the list new to the back of chained list of lst
|
|
||||||
*
|
|
||||||
* @param lst first element of the list
|
|
||||||
* @param new The element to add at the end
|
|
||||||
*/
|
|
||||||
void ft_lstadd_back(t_list **lst, t_list *new)
|
|
||||||
{
|
|
||||||
t_list *tempo;
|
|
||||||
|
|
||||||
if (*lst == NULL)
|
|
||||||
{
|
|
||||||
*lst = new;
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
tempo = *lst;
|
|
||||||
while (tempo->next != NULL)
|
|
||||||
tempo = tempo->next;
|
|
||||||
tempo->next = new;
|
|
||||||
}
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_lstadd_front.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/12 11:40:16 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 17:30:01 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Add the list new to the front of chained list of lst
|
|
||||||
*
|
|
||||||
* @param lst first element of the list
|
|
||||||
* @param new The element to add at the start
|
|
||||||
*/
|
|
||||||
void ft_lstadd_front(t_list **lst, t_list *new)
|
|
||||||
{
|
|
||||||
if (*lst == NULL)
|
|
||||||
{
|
|
||||||
*lst = new;
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
new->next = *lst;
|
|
||||||
*lst = new;
|
|
||||||
}
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_lstclear.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/12 11:40:37 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 17:32:23 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Clear the all list with the function
|
|
||||||
*
|
|
||||||
* @param lst the start of the chained list
|
|
||||||
* @param del the function to clear the list
|
|
||||||
*/
|
|
||||||
void ft_lstclear(t_list **lst, void (*del)(void *))
|
|
||||||
{
|
|
||||||
t_list *tempo;
|
|
||||||
|
|
||||||
while (*lst)
|
|
||||||
{
|
|
||||||
tempo = (*lst)->next;
|
|
||||||
ft_lstdelone(*lst, del);
|
|
||||||
(*lst) = tempo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_lstdelone.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/12 11:42:11 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 17:46:00 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Clear the element of the list with the function
|
|
||||||
*
|
|
||||||
* @param lst the element of the list to be clear
|
|
||||||
* @param del the function to clear the list
|
|
||||||
*/
|
|
||||||
void ft_lstdelone(t_list *lst, void (*del)(void *))
|
|
||||||
{
|
|
||||||
del(lst->content);
|
|
||||||
free(lst);
|
|
||||||
}
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_lstiter.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/12 11:42:24 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 17:46:55 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Apply the function given in arguments at all the element of the list
|
|
||||||
*
|
|
||||||
* @param lst the chained list
|
|
||||||
* @param f the pointer to function
|
|
||||||
*/
|
|
||||||
void ft_lstiter(t_list *lst, void (*f)(void *))
|
|
||||||
{
|
|
||||||
while (lst != NULL)
|
|
||||||
{
|
|
||||||
f(lst->content);
|
|
||||||
lst = lst->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_lstlast.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/12 11:42:54 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 17:48:08 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Found the last element of the chained list
|
|
||||||
*
|
|
||||||
* @param lst the chained list
|
|
||||||
* @return the last element of the chained list
|
|
||||||
*/
|
|
||||||
t_list *ft_lstlast(t_list *lst)
|
|
||||||
{
|
|
||||||
if (lst == NULL)
|
|
||||||
return (lst);
|
|
||||||
while (lst->next != NULL)
|
|
||||||
lst = lst->next;
|
|
||||||
return (lst);
|
|
||||||
}
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_lstmap.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/12 11:43:28 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 17:51:38 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Create an other list from an old one with a function on all element
|
|
||||||
*
|
|
||||||
* @param lst the chained list
|
|
||||||
* @param f the function to function to iterate
|
|
||||||
* @param del The function to delete the old list
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
|
|
||||||
{
|
|
||||||
t_list *tempo;
|
|
||||||
t_list *tempo_content;
|
|
||||||
|
|
||||||
tempo_content = ft_lstnew(f(lst->content));
|
|
||||||
if (!tempo_content)
|
|
||||||
return (NULL);
|
|
||||||
tempo = tempo_content;
|
|
||||||
lst = lst->next;
|
|
||||||
while (lst)
|
|
||||||
{
|
|
||||||
tempo_content = ft_lstnew(f(lst->content));
|
|
||||||
if (!tempo_content)
|
|
||||||
{
|
|
||||||
ft_lstclear(&tempo, del);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
ft_lstadd_back(&tempo, tempo_content);
|
|
||||||
lst = lst->next;
|
|
||||||
}
|
|
||||||
return (tempo);
|
|
||||||
}
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_lstnew.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/12 11:44:02 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 17:52:24 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Allocate a new list with the first element
|
|
||||||
*
|
|
||||||
* @param content the element to give on first element
|
|
||||||
* @return the new list
|
|
||||||
*/
|
|
||||||
t_list *ft_lstnew(void *content)
|
|
||||||
{
|
|
||||||
t_list *to_return;
|
|
||||||
|
|
||||||
to_return = NULL;
|
|
||||||
to_return = (t_list *)malloc(sizeof(t_list));
|
|
||||||
if (!to_return)
|
|
||||||
return (NULL);
|
|
||||||
to_return->content = content;
|
|
||||||
to_return->next = NULL;
|
|
||||||
return (to_return);
|
|
||||||
}
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_lstsize.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/12 11:44:24 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 17:53:11 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Give the size of the chained list
|
|
||||||
*
|
|
||||||
* @param lst the chained list
|
|
||||||
* @return the size of the list
|
|
||||||
*/
|
|
||||||
int ft_lstsize(t_list *lst)
|
|
||||||
{
|
|
||||||
int count;
|
|
||||||
|
|
||||||
count = 0;
|
|
||||||
while (lst != NULL)
|
|
||||||
{
|
|
||||||
lst = lst->next;
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
return (count);
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_bzero.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/07 16:43:13 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 17:54:25 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Sets a block of memory to zero
|
|
||||||
*
|
|
||||||
* @param s Pointer to the memory area to be set at zero
|
|
||||||
* @param n Number of bytes to set to zero
|
|
||||||
*/
|
|
||||||
void ft_bzero(void *s, size_t n)
|
|
||||||
{
|
|
||||||
ft_memset(s, 0, n);
|
|
||||||
}
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_calloc.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/07 16:47:17 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 17:55:30 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Allocates and zeroes memory for an array
|
|
||||||
*
|
|
||||||
* @param nmemb Number of elements to allocate
|
|
||||||
* @param size Size of each element in bytes
|
|
||||||
*/
|
|
||||||
void *ft_calloc(size_t nmemb, size_t size)
|
|
||||||
{
|
|
||||||
size_t total;
|
|
||||||
char *to_return;
|
|
||||||
|
|
||||||
if (nmemb == 0 || size == 0)
|
|
||||||
return ((void *)malloc(1));
|
|
||||||
total = nmemb * size;
|
|
||||||
if (total / nmemb != size && total / size != nmemb)
|
|
||||||
return (NULL);
|
|
||||||
to_return = (char *)malloc(total);
|
|
||||||
if (to_return == NULL)
|
|
||||||
to_return = NULL;
|
|
||||||
else
|
|
||||||
ft_bzero(to_return, total);
|
|
||||||
return (to_return);
|
|
||||||
}
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_memchr.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/07 16:48:30 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 17:59:07 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Scans memory for a byte
|
|
||||||
*
|
|
||||||
* @param s Pointer to the memory area to scan
|
|
||||||
* @param c Byte value to search for
|
|
||||||
* @param n Number of bytes to scan in s
|
|
||||||
*
|
|
||||||
* @return A pointer to the matching byte in memory, or NULL if the byte
|
|
||||||
is not found within the first n bytes
|
|
||||||
*/
|
|
||||||
void *ft_memchr(const void *s, int c, size_t n)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
char *str;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
str = (char *)s;
|
|
||||||
while (i < n)
|
|
||||||
{
|
|
||||||
if ((char)c == str[i])
|
|
||||||
return ((void *)str + i);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_memcmp.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/07 16:49:04 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 17:59:48 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Compares two memory blocks
|
|
||||||
*
|
|
||||||
* @param s1 Pointer to the first memory area
|
|
||||||
* @param s2 Pointer to the second memory area
|
|
||||||
* @param n Number of bytes to compare
|
|
||||||
*
|
|
||||||
* @return An integer indicating the relationship between the two memory areas:
|
|
||||||
* - `< 0` if `s1` is less than `s2`
|
|
||||||
* - `0` if `s1` equals `s2`
|
|
||||||
* - `> 0` if `s1` is greater than `s2`
|
|
||||||
*/
|
|
||||||
int ft_memcmp(const void *s1, const void *s2, size_t n)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
unsigned char *str1;
|
|
||||||
unsigned char *str2;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
str1 = (unsigned char *)s1;
|
|
||||||
str2 = (unsigned char *)s2;
|
|
||||||
while (i < n)
|
|
||||||
{
|
|
||||||
if (str1[i] != str2[i])
|
|
||||||
return (str1[i] - str2[i]);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_memcpy.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/07 16:49:46 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 17:57:31 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Copies memory from source to destination
|
|
||||||
*
|
|
||||||
* @param dest Pointer to the destination memory area
|
|
||||||
* @param src Pointer to the source memory area
|
|
||||||
* @param n Number of bytes to copy from src to dest
|
|
||||||
*
|
|
||||||
* @return A pointer to the destination memory area dest
|
|
||||||
*/
|
|
||||||
void *ft_memcpy(void *dest, const void *src, size_t n)
|
|
||||||
{
|
|
||||||
char *d;
|
|
||||||
const char *s;
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
if (!dest && !src)
|
|
||||||
return (NULL);
|
|
||||||
d = (char *)dest;
|
|
||||||
s = (char *)src;
|
|
||||||
while (i < n)
|
|
||||||
{
|
|
||||||
d[i] = s[i];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return ((void *)d);
|
|
||||||
}
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_memmove.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/07 16:51:35 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 18:15:19 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
char *ft_checks(char *s, char *d, size_t n)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
if (d < s)
|
|
||||||
{
|
|
||||||
while (i < n)
|
|
||||||
{
|
|
||||||
d[i] = s[i];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
i = n;
|
|
||||||
while (i > 0)
|
|
||||||
{
|
|
||||||
i--;
|
|
||||||
d[i] = s[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (d);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Copies memory with overlap handling
|
|
||||||
*
|
|
||||||
* @param dest Pointer to the destination memory area
|
|
||||||
* @param src Pointer to the source memory area
|
|
||||||
* @param n Number of bytes to copy from src to dest
|
|
||||||
*
|
|
||||||
* @return A pointer to the destination memory area dest
|
|
||||||
*/
|
|
||||||
void *ft_memmove(void *dest, const void *src, size_t n)
|
|
||||||
{
|
|
||||||
char *d;
|
|
||||||
char *s;
|
|
||||||
|
|
||||||
if (!dest && !src)
|
|
||||||
return (NULL);
|
|
||||||
d = (char *)dest;
|
|
||||||
s = (char *)src;
|
|
||||||
ft_checks(s, d, n);
|
|
||||||
return (dest);
|
|
||||||
}
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_memset.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/07 16:50:29 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 17:56:59 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Fills a block of memory with a specified byte
|
|
||||||
*
|
|
||||||
* @param s Pointer to the memory area to fill
|
|
||||||
* @param c Byte value to be set in the memory
|
|
||||||
* @param n Number of bytes to be set to the value c
|
|
||||||
*
|
|
||||||
* @return A pointer to the memory area s
|
|
||||||
*/
|
|
||||||
void *ft_memset(void *s, int c, size_t n)
|
|
||||||
{
|
|
||||||
char *str;
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
str = (char *)s;
|
|
||||||
while (i < n)
|
|
||||||
{
|
|
||||||
str[i] = c;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return (str);
|
|
||||||
}
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_printf.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/14 17:27:44 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 18:01:28 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
void _print_char(int fd, char c, int *ret_value);
|
|
||||||
void _print_nbr(int fd, int nb, int *ret_value);
|
|
||||||
void _print_base(\
|
|
||||||
int fd, unsigned long long nbr, int *ret_value, char c);
|
|
||||||
void _print_unsigned(int fd, unsigned int nb, int *ret_value);
|
|
||||||
void _print_str(int fd, char *str, int *ret_value);
|
|
||||||
|
|
||||||
int _check_args(int fd, char c, va_list args, int *ret_value)
|
|
||||||
{
|
|
||||||
if (c == 'c')
|
|
||||||
_print_char(fd, (char)va_arg(args, int), ret_value);
|
|
||||||
else if (c == 's')
|
|
||||||
_print_str(fd, (char *)va_arg(args, char *), ret_value);
|
|
||||||
else if (c == 'i' || c == 'd')
|
|
||||||
_print_nbr(fd, (int)va_arg(args, int), ret_value);
|
|
||||||
else if (c == '%')
|
|
||||||
_print_char(fd, '%', ret_value);
|
|
||||||
else if (c == 'u')
|
|
||||||
_print_unsigned(\
|
|
||||||
fd, (unsigned int)va_arg(args, unsigned int), ret_value);
|
|
||||||
else if (c == 'x')
|
|
||||||
_print_base(fd, (unsigned int)va_arg(args, unsigned int), ret_value, c);
|
|
||||||
else if (c == 'X')
|
|
||||||
_print_base(fd, (unsigned int)va_arg(args, unsigned int), ret_value, c);
|
|
||||||
else if (c == 'p')
|
|
||||||
_print_base(fd, (unsigned long long)va_arg(args, unsigned long long), \
|
|
||||||
ret_value, c);
|
|
||||||
va_end(args);
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Print on a file descriptor
|
|
||||||
*
|
|
||||||
* @param fd the file descriptor
|
|
||||||
* @param s the string
|
|
||||||
* @return the number of character printable
|
|
||||||
*/
|
|
||||||
int ft_dprintf(int fd, const char *s, ...)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
va_list args;
|
|
||||||
char *str;
|
|
||||||
int ret_value;
|
|
||||||
|
|
||||||
ret_value = 0;
|
|
||||||
str = ft_strdup(s);
|
|
||||||
va_start(args, s);
|
|
||||||
i = 0;
|
|
||||||
while (str[i])
|
|
||||||
{
|
|
||||||
if (str[i] == '%')
|
|
||||||
{
|
|
||||||
_check_args(fd, str[i + 1], args, &ret_value);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_print_char(fd, str[i], &ret_value);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
free(str);
|
|
||||||
return (ret_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Print on the standard output
|
|
||||||
*
|
|
||||||
* @param s the string
|
|
||||||
* @return the number of character printable
|
|
||||||
*/
|
|
||||||
int ft_printf(const char *s, ...)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
va_list args;
|
|
||||||
char *str;
|
|
||||||
int ret_value;
|
|
||||||
|
|
||||||
ret_value = 0;
|
|
||||||
str = ft_strdup(s);
|
|
||||||
va_start(args, s);
|
|
||||||
i = 0;
|
|
||||||
while (str[i])
|
|
||||||
{
|
|
||||||
if (str[i] == '%')
|
|
||||||
{
|
|
||||||
_check_args(1, str[i + 1], args, &ret_value);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_print_char(1, str[i], &ret_value);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
free(str);
|
|
||||||
return (ret_value);
|
|
||||||
}
|
|
||||||
|
|
@ -1,97 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_put.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/16 12:13:14 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 16:16:45 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
void _print_char(int fd, char c, int *ret_value);
|
|
||||||
void _print_nbr(int fd, int nb, int *ret_value);
|
|
||||||
void _print_base(\
|
|
||||||
int fd, unsigned long long nbr, int *ret_value, char c);
|
|
||||||
void _print_unsigned(int fd, unsigned int nb, int *ret_value);
|
|
||||||
void _print_str(int fd, char *str, int *ret_value);
|
|
||||||
|
|
||||||
void _print_char(int fd, char c, int *ret_value)
|
|
||||||
{
|
|
||||||
write(fd, &c, 1);
|
|
||||||
(*ret_value)++;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _print_nbr(int fd, int nb, int *ret_value)
|
|
||||||
{
|
|
||||||
if (nb < 0)
|
|
||||||
{
|
|
||||||
if (nb == INT_MIN)
|
|
||||||
{
|
|
||||||
write(1, "-2147483648", 11);
|
|
||||||
*ret_value += 11;
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
nb = -nb;
|
|
||||||
_print_char(fd, '-', ret_value);
|
|
||||||
}
|
|
||||||
if (nb >= 10)
|
|
||||||
{
|
|
||||||
_print_nbr(fd, nb / 10, ret_value);
|
|
||||||
nb = nb % 10;
|
|
||||||
}
|
|
||||||
if (nb < 10)
|
|
||||||
_print_char(fd, nb + 48, ret_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _print_base(\
|
|
||||||
int fd, unsigned long long nbr, int *ret_value, char c)
|
|
||||||
{
|
|
||||||
char base[16];
|
|
||||||
|
|
||||||
if (c == 'x' || c == 'q')
|
|
||||||
ft_strcpy(base, "0123456789abcdef");
|
|
||||||
else if (c == 'X')
|
|
||||||
ft_strcpy(base, "0123456789ABCDEF");
|
|
||||||
else if (c == 'p')
|
|
||||||
{
|
|
||||||
if (nbr != 0)
|
|
||||||
_print_str(fd, "0x", ret_value);
|
|
||||||
else if (nbr == 0)
|
|
||||||
{
|
|
||||||
_print_str(fd, "(nil)", ret_value);
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ft_strcpy(base, "0123456789abcdef");
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
if (c != 'p')
|
|
||||||
{
|
|
||||||
if (nbr >= 16)
|
|
||||||
_print_base(fd, nbr / 16, ret_value, c);
|
|
||||||
_print_char(fd, base[nbr % 16], ret_value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _print_unsigned(int fd, unsigned int nb, int *ret_value)
|
|
||||||
{
|
|
||||||
if (nb >= 10)
|
|
||||||
{
|
|
||||||
_print_unsigned(fd, nb / 10, ret_value);
|
|
||||||
nb = nb % 10;
|
|
||||||
}
|
|
||||||
if (nb < 10)
|
|
||||||
_print_char(fd, nb + 48, ret_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _print_str(int fd, char *str, int *ret_value)
|
|
||||||
{
|
|
||||||
if (!str)
|
|
||||||
*ret_value += write(fd, "(null)", 6);
|
|
||||||
else
|
|
||||||
*ret_value += write(fd, str, ft_strlen(str));
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_putchar_fd.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/09 13:58:22 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 18:02:37 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief print an character on a file descriptor
|
|
||||||
*
|
|
||||||
* @param c the character to print
|
|
||||||
* @param fd the file descriptor
|
|
||||||
*/
|
|
||||||
void ft_putchar_fd(char c, int fd)
|
|
||||||
{
|
|
||||||
write(fd, &c, 1);
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_putendl_fd.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/09 13:59:01 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 18:03:47 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Print a string follow by a new line on a file descriptor
|
|
||||||
*
|
|
||||||
* @param s the string to print
|
|
||||||
* @param fd the file descriptor
|
|
||||||
*/
|
|
||||||
void ft_putendl_fd(char *s, int fd)
|
|
||||||
{
|
|
||||||
ft_putstr_fd(s, fd);
|
|
||||||
ft_putchar_fd('\n', fd);
|
|
||||||
}
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_putnbr_fd.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/09 13:59:18 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 18:04:17 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
static int ft_check_sign(int n, char *str, size_t *i, int fd)
|
|
||||||
{
|
|
||||||
size_t modulus;
|
|
||||||
short int maiboyerlpb;
|
|
||||||
|
|
||||||
maiboyerlpb = 0;
|
|
||||||
modulus = 1000000000;
|
|
||||||
if (n < 0)
|
|
||||||
{
|
|
||||||
n = -n;
|
|
||||||
str[(*i)] = '-';
|
|
||||||
(*i)++;
|
|
||||||
}
|
|
||||||
while (modulus != 0)
|
|
||||||
{
|
|
||||||
if (n / modulus != 0 || maiboyerlpb != 0)
|
|
||||||
{
|
|
||||||
str[(*i)++] = (n / modulus) + 48;
|
|
||||||
maiboyerlpb++;
|
|
||||||
}
|
|
||||||
n %= modulus;
|
|
||||||
modulus /= 10;
|
|
||||||
}
|
|
||||||
ft_putstr_fd(str, fd);
|
|
||||||
return (n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Print a number on a file descriptor
|
|
||||||
*
|
|
||||||
* @param n the number to print
|
|
||||||
* @param fd the file descriptor
|
|
||||||
*/
|
|
||||||
void ft_putnbr_fd(int n, int fd)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
char str[13];
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
ft_bzero(str, 13);
|
|
||||||
if (n == 0)
|
|
||||||
ft_putstr_fd("0", fd);
|
|
||||||
else if (n == -2147483648)
|
|
||||||
ft_putstr_fd("-2147483648", fd);
|
|
||||||
else
|
|
||||||
ft_check_sign(n, str, &i, fd);
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_putstr_fd.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/09 13:58:46 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/10/31 18:05:11 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "libft.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief print a string on a file descriptor
|
|
||||||
*
|
|
||||||
* @param s the string to print
|
|
||||||
* @param fd the file descriptor
|
|
||||||
*/
|
|
||||||
void ft_putstr_fd(char *s, int fd)
|
|
||||||
{
|
|
||||||
write(fd, s, ft_strlen(s));
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue