Merge mandatory and bonus into a single ft_printf, fix edge cases, add README

- Use the flag-aware implementation for both make and make bonus
  (bonus/ moved to src/, _bonus suffix dropped, bonus rule = all)
- Do not treat zero-length output (%s with "", %.0d with 0) as an error
- Return -1 without printing when a % has no conversion ("abc%", "%5")
- Keep field width with '#', '+' and ' '; ignore '0' with '-'
- Fix '#' prefix on zero, '+'/' ' with zero padding, INT_MIN negation UB
- Add README.md required by the subject

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
da7eandClaude Opus 5.5 committed 2026-10-08 22:22:28 +02:00
1 parent b620f5ecdb
commit c8a9ee10cf
24 files changed
+608 -678

No files matched your search

+8 -27
View File
@@ -1,9 +1,7 @@
NAME= libftprintf.a
LIBFT= $(BUILD_DIR)/libft.a
BONUS= $(BUILD_DIR)/libftprintf_bonus.a
SRC_DIR= src
B_SRC_DIR= bonus
INC_DIR= include
LIBFT_DIR= libft
BUILD_DIR= .build
@@ -16,25 +14,13 @@ SRC= $(SRC_DIR)/ft_printf.c \
$(SRC_DIR)/print_pointer.c \
$(SRC_DIR)/print_str.c \
$(SRC_DIR)/print_unsigned.c \
B_SRC= $(B_SRC_DIR)/ft_printf_bonus.c \
$(B_SRC_DIR)/ft_putnbr_base_bonus.c \
$(B_SRC_DIR)/print_char_bonus.c \
$(B_SRC_DIR)/print_hex_bonus.c \
$(B_SRC_DIR)/print_number_bonus.c \
$(B_SRC_DIR)/print_pointer_bonus.c \
$(B_SRC_DIR)/print_str_bonus.c \
$(B_SRC_DIR)/print_unsigned_bonus.c \
$(B_SRC_DIR)/ft_create_arg_bonus.c \
$(B_SRC_DIR)/ft_main_arg_bonus.c \
$(B_SRC_DIR)/ft_parsing_bonus.c \
$(B_SRC_DIR)/utils_flag_bonus.c
$(SRC_DIR)/ft_create_arg.c \
$(SRC_DIR)/ft_main_arg.c \
$(SRC_DIR)/ft_parsing.c \
$(SRC_DIR)/utils_flag.c
OBJ= $(SRC:%.c=$(BUILD_DIR)/%.o)
B_OBJ= $(B_SRC:%.c=$(BUILD_DIR)/%.o)
DEP= $(SRC:%.c=$(BUILD_DIR)/%.d)
B_DEP= $(B_SRC:%.c=$(BUILD_DIR)/%.d)
CC= cc
CFLAGS= -Wall -Wextra -Werror -I$(INC_DIR) -I$(LIBFT_DIR) -MMD -MP
@@ -42,8 +28,7 @@ AR= ar rcs
all: $(NAME)
bonus: $(BONUS)
cp $(BONUS) $(NAME)
bonus: all
$(NAME): $(OBJ) $(LIBFT)
cp $(LIBFT) $(NAME)
@@ -57,20 +42,16 @@ $(LIBFT):
$(MAKE) -C $(LIBFT_DIR)
cp $(LIBFT_DIR)/libft.a $(LIBFT)
$(BONUS): $(B_OBJ) $(LIBFT)
cp $(LIBFT) $(BONUS)
$(AR) $(BONUS) $(B_OBJ)
clean:
rm -f $(OBJ) $(DEP) $(B_OBJ) $(B_DEP)
rm -f $(OBJ) $(DEP)
$(MAKE) -C $(LIBFT_DIR) clean
fclean: clean
rm -f $(NAME) $(BONUS) $(LIBFT)
rm -f $(NAME) $(LIBFT)
$(MAKE) -C $(LIBFT_DIR) fclean
re: fclean all
-include $(DEP) $(B_DEP)
-include $(DEP)
.PHONY: all clean fclean re bonus