diff --git a/.gitignore b/.gitignore index 8213cd9..87fc3b2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,22 +4,18 @@ build/ *.d *.dSYM/ -/Colleen/Colleen -/Grace/Grace -/Sully/Sully +*/Colleen/Colleen +*/Grace/Grace +*/Sully/Sully -Colleen_kid.c -Grace_kid.c -Sully_*.c +Colleen_kid.* +Grace_kid.c* +Sully_*.c* Sully_* *.swp *~ .DS_Store -.idea/ -.vscode/ -# Clang tools .clangd .clang-format -compile_commands.json diff --git a/C/Colleen/Colleen.c b/C/Colleen/Colleen.c index dee8f76..abdec90 100644 --- a/C/Colleen/Colleen.c +++ b/C/Colleen/Colleen.c @@ -10,5 +10,5 @@ const char *get_program(void) { } int main(void) { - printf(get_program(), '\n', '\t', '"', get_program()); + printf(get_program(), 10, 9, 34, get_program()); } diff --git a/C/Grace/Grace.c b/C/Grace/Grace.c new file mode 100644 index 0000000..c78ae51 --- /dev/null +++ b/C/Grace/Grace.c @@ -0,0 +1,14 @@ +#include +#include + +#define TO_WRITE "#include %1$c#include %1$c%1$c#define TO_WRITE %3$c%4$s%3$c%1$c#define NULL_CHECK(ptr){if (ptr == NULL) exit(1);}%1$c#define PROG()int main(void) {%2$cFILE *new_file = fopen(%3$cGrace_kid.c%3$c, %3$cw%3$c);%2$cNULL_CHECK(new_file);%2$cfprintf(new_file, TO_WRITE, 10, 9, 34, TO_WRITE);%2$cfclose(new_file);%2$creturn 0;}%1$c%1$c/**%1$c * @brief Actually the only is to hide this main on a define%1$c *%1$c * @return 0 on success overwise return 1%1$c */%1$c%1$cPROG()%1$c" +#define NULL_CHECK(ptr){if (ptr == NULL) exit(1);} +#define PROG()int main(void) { FILE *new_file = fopen("Grace_kid.c", "w"); NULL_CHECK(new_file); fprintf(new_file, TO_WRITE, 10, 9, 34, TO_WRITE); fclose(new_file); return 0;} + +/** + * @brief Actually the only is to hide this main on a define + * + * @return 0 on success overwise return 1 + */ + +PROG() diff --git a/C/Makefile b/C/Makefile index 353f26f..37425be 100644 --- a/C/Makefile +++ b/C/Makefile @@ -6,7 +6,7 @@ # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # -# Updated: 2026/01/30 16:34:30 by rparodi ### ########.fr # +# Updated: 2026/01/30 23:25:20 by rparodi ### ########.fr # # # # **************************************************************************** # @@ -54,6 +54,8 @@ all: header $(NAME) footer # Exercices ex0: $(COLLEEN) +ex1: $(GRACE) +ex2: $(SULLY) # Dependences for all $(NAME): $(COLLEEN) $(GRACE) $(SULLY) @@ -91,6 +93,31 @@ $(OBJDIRNAME)/%.o: %.c @printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n' @$(CC) $(CFLAGS) -c -o $@ $< +test: test_colleen test_grace test_sully + +test_colleen: $(COLLEEN) + @clear + @rm -rf /tmp/test_colleen.c + @$(COLLEEN) > /tmp/test_colleen.c + @printf '$(GREY)Output of the $(GOLD)Colleen$(END)\n' + @bat -plc /tmp/test_colleen.c + @printf "\n$(GREY)Here's the diff between $(GOLD)$(SRC_COLLEEN) $(GREY)and $(GOLD)/tmp/test_colleen.c$(END)\n" + @diff $(SRC_COLLEEN) /tmp/test_colleen.c | bat -ldiff + +test_grace: $(GRACE) + @$(GRACE) + @printf '\n\n\n$(GREY)Output of the $(GOLD)Grace$(END)\n' + @bat -plc ./Grace_kid.c + @printf "\n$(GREY)Here's the diff between $(GOLD)$(SRC_GRACE) $(GREY)and $(GOLD)Grace_kid.c $(END)\n" + @diff $(SRC_GRACE) ./Grace_kid.c | bat -ldiff + +test_sully: $(SULLY) + @$(SULLY) > /tmp/test_sully.c + @printf '$(GREY)Output of the $(GOLD)Sully$(END)\n' + @bat -plc /tmp/test_sully.c + @printf "\n$(GREY)Here's the diff between $(GOLD)$(SRC_SULLY) $(GREY)and $(GOLD)/tmp/test_sully.c$(END)\n" + @diff $(SRC_SULLY) /tmp/test_sully | bat -ldiff + # Header header: @printf '\n\n' @@ -104,7 +131,7 @@ header: @printf '$(GOLD) ****** ******* ****** $(END)\n' @printf '$(GOLD) ****** $(END)\n' @printf '$(GOLD) ****** $(END)\n' - @printf '$(GREY) Made by glaruell & rparodi$(END)\n\n' + @printf '$(GREY) Made by rparodi$(END)\n\n' # Footer footer: