From 9d46cee03958b9bb5490030f3dc5273ad41db868 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 30 Jan 2026 20:21:43 +0100 Subject: [PATCH 01/10] refactor(Colleen): replacing the char given by number --- C/Colleen/Colleen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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()); } From c960cd6f326d1bf60928db8f3917ed736a812c3d Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 30 Jan 2026 22:18:00 +0100 Subject: [PATCH 02/10] build: adding rules ex1/ex2 to the Makefile --- C/Makefile | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/C/Makefile b/C/Makefile index 353f26f..c1600fe 100644 --- a/C/Makefile +++ b/C/Makefile @@ -91,6 +91,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$(RESET)\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$(RESET)\n' + @diff $(SRC_COLLEEN) /tmp/test_colleen.c | bat -ldiff + +test_grace: $(GRACE) + @$(GRACE) > /tmp/test_grace.c + @printf '\n\n\n$(GREY)Output of the $(GOLD)Grace$(RESET)\n' + @bat -plc /tmp/test_grace.c + @printf '\n$(GREY)Here's the diff between $(GOLD)$(SRC_GRACE) $(GREY)and $(GOLD)/tmp/test_grace.c$(RESET)\n' + @diff $(SRC_GRACE) /tmp/test_grace | bat -ldiff + +test_sully: $(SULLY) + @$(SULLY) > /tmp/test_sully.c + @printf '$(GREY)Output of the $(GOLD)Sully$(RESET)\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$(RESET)\n' + @diff $(SRC_SULLY) /tmp/test_sully | bat -ldiff + # Header header: @printf '\n\n' @@ -104,7 +129,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: From 98639235c059e5519ab9cc392e654a8d7ef8a426 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 30 Jan 2026 22:18:11 +0100 Subject: [PATCH 03/10] build: adding rules ex1/ex2 to the Makefile --- C/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/C/Makefile b/C/Makefile index c1600fe..303180b 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 22:16:49 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) From 93dcdf949176c1411730c6b955fe8c0475eb8e93 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 30 Jan 2026 22:22:42 +0100 Subject: [PATCH 04/10] test: adding rules to test all exectuable --- C/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/C/Makefile b/C/Makefile index 303180b..cad2b8e 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 22:16:49 by rparodi ### ########.fr # +# Updated: 2026/01/30 22:22:14 by rparodi ### ########.fr # # # # **************************************************************************** # @@ -101,21 +101,21 @@ test_colleen: $(COLLEEN) @$(COLLEEN) > /tmp/test_colleen.c @printf '$(GREY)Output of the $(GOLD)Colleen$(RESET)\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$(RESET)\n' + @printf "\n$(GREY)Here's the diff between $(GOLD)$(SRC_COLLEEN) $(GREY)and $(GOLD)/tmp/test_colleen.c$(RESET)\n" @diff $(SRC_COLLEEN) /tmp/test_colleen.c | bat -ldiff test_grace: $(GRACE) @$(GRACE) > /tmp/test_grace.c @printf '\n\n\n$(GREY)Output of the $(GOLD)Grace$(RESET)\n' @bat -plc /tmp/test_grace.c - @printf '\n$(GREY)Here's the diff between $(GOLD)$(SRC_GRACE) $(GREY)and $(GOLD)/tmp/test_grace.c$(RESET)\n' + @printf "\n$(GREY)Here's the diff between $(GOLD)$(SRC_GRACE) $(GREY)and $(GOLD)/tmp/test_grace.c$(RESET)\n" @diff $(SRC_GRACE) /tmp/test_grace | bat -ldiff test_sully: $(SULLY) @$(SULLY) > /tmp/test_sully.c @printf '$(GREY)Output of the $(GOLD)Sully$(RESET)\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$(RESET)\n' + @printf "\n$(GREY)Here's the diff between $(GOLD)$(SRC_SULLY) $(GREY)and $(GOLD)/tmp/test_sully.c$(RESET)\n" @diff $(SRC_SULLY) /tmp/test_sully | bat -ldiff # Header From 18023110343c2736c18c7ab03048e7d8c38ad4e3 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 30 Jan 2026 22:25:55 +0100 Subject: [PATCH 05/10] core(git/ignore): adding the gitignore to all executable --- .gitignore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 8213cd9..ccf0dc7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,9 +4,9 @@ build/ *.d *.dSYM/ -/Colleen/Colleen -/Grace/Grace -/Sully/Sully +*/Colleen/Colleen +*/Grace/Grace +*/Sully/Sully Colleen_kid.c Grace_kid.c From e0880b7172d8fa43a6a9f2d3c49154e6d52ffff1 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 30 Jan 2026 22:36:34 +0100 Subject: [PATCH 06/10] core(git/ignore): adding all the file generated --- .gitignore | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index ccf0dc7..87fc3b2 100644 --- a/.gitignore +++ b/.gitignore @@ -8,18 +8,14 @@ build/ */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 From d1dc95871402a71ccc92e6d19b7fe762d470252c Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 30 Jan 2026 23:30:12 +0100 Subject: [PATCH 07/10] feat(Grace): adding the code --- C/Grace/Grace.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 C/Grace/Grace.c diff --git a/C/Grace/Grace.c b/C/Grace/Grace.c new file mode 100644 index 0000000..8e09724 --- /dev/null +++ b/C/Grace/Grace.c @@ -0,0 +1,17 @@ +#include + +/* + * Grace - Autoreproduction sans main + */ + +#define OPEN_FILE FILE *kid = fopen("Grace_kid.c", "w"); if (!kid) return; +#define WRITE_CODE fprintf(kid, CODE, 10, 9, 34, CODE); fclose(kid); +#define CODE "#include %1$c%1$c/*%1$c * Grace - Autoreproduction sans main%1$c */%1$c%1$c#define OPEN_FILE FILE *kid = fopen(%3$cGrace_kid.c%3$c, %3$cw%3$c); if (!kid) return;%1$c#define WRITE_CODE fprintf(kid, CODE, 10, 9, 34, CODE); fclose(kid);%1$c%1$c#define CODE %3$c%4$s%3$c%1$c%1$c#define MAIN OPEN_FILE WRITE_CODE%1$c%1$cvoid __attribute__((constructor)) grace(void) {%1$c%2$cMAIN%1$c}%1$c%1$cint main(void) { return 0; }%1$c" + +#define MAIN OPEN_FILE WRITE_CODE + +void __attribute__((constructor)) grace(void) { + MAIN +} + +int main(void) { return 0; } From de9fd295d8776c813ee7b5a5e92f2815e44c257b Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 30 Jan 2026 23:31:42 +0100 Subject: [PATCH 08/10] test(test/Grace): adding the grace test corrected --- C/Makefile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/C/Makefile b/C/Makefile index cad2b8e..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 22:22:14 by rparodi ### ########.fr # +# Updated: 2026/01/30 23:25:20 by rparodi ### ########.fr # # # # **************************************************************************** # @@ -99,23 +99,23 @@ test_colleen: $(COLLEEN) @clear @rm -rf /tmp/test_colleen.c @$(COLLEEN) > /tmp/test_colleen.c - @printf '$(GREY)Output of the $(GOLD)Colleen$(RESET)\n' + @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$(RESET)\n" + @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) > /tmp/test_grace.c - @printf '\n\n\n$(GREY)Output of the $(GOLD)Grace$(RESET)\n' - @bat -plc /tmp/test_grace.c - @printf "\n$(GREY)Here's the diff between $(GOLD)$(SRC_GRACE) $(GREY)and $(GOLD)/tmp/test_grace.c$(RESET)\n" - @diff $(SRC_GRACE) /tmp/test_grace | bat -ldiff + @$(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$(RESET)\n' + @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$(RESET)\n" + @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 From 4fb3dac7f3fd78948f80916bdcb642e19727aa1f Mon Sep 17 00:00:00 2001 From: Raphael Date: Sat, 31 Jan 2026 13:06:58 +0100 Subject: [PATCH 09/10] feat(grace): adding a working version --- C/Grace/Grace.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/C/Grace/Grace.c b/C/Grace/Grace.c index 8e09724..8044462 100644 --- a/C/Grace/Grace.c +++ b/C/Grace/Grace.c @@ -1,17 +1,12 @@ #include -/* - * Grace - Autoreproduction sans main +#define TO_WRITE "#include %1$c%1$c#define TO_WRITE %3$c%4$s%3$c%1$c#define PROG()int main(void) {%2$cFILE *new_file = fopen(%3$cGrace_kid.c%3$c, %3$cw%3$c);%2$cif (new_file == NULL)%2$c%2$creturn 1;%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 PROG()int main(void) { FILE *new_file = fopen("Grace_kid.c", "w"); if (new_file == NULL) return 1; 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 */ -#define OPEN_FILE FILE *kid = fopen("Grace_kid.c", "w"); if (!kid) return; -#define WRITE_CODE fprintf(kid, CODE, 10, 9, 34, CODE); fclose(kid); -#define CODE "#include %1$c%1$c/*%1$c * Grace - Autoreproduction sans main%1$c */%1$c%1$c#define OPEN_FILE FILE *kid = fopen(%3$cGrace_kid.c%3$c, %3$cw%3$c); if (!kid) return;%1$c#define WRITE_CODE fprintf(kid, CODE, 10, 9, 34, CODE); fclose(kid);%1$c%1$c#define CODE %3$c%4$s%3$c%1$c%1$c#define MAIN OPEN_FILE WRITE_CODE%1$c%1$cvoid __attribute__((constructor)) grace(void) {%1$c%2$cMAIN%1$c}%1$c%1$cint main(void) { return 0; }%1$c" - -#define MAIN OPEN_FILE WRITE_CODE - -void __attribute__((constructor)) grace(void) { - MAIN -} - -int main(void) { return 0; } +PROG() From d36e5ddf1d60f3179a4858a4bf1f94770762b55c Mon Sep 17 00:00:00 2001 From: Raphael Date: Sat, 31 Jan 2026 13:44:51 +0100 Subject: [PATCH 10/10] feat(Grace): adding the 3rd define --- C/Grace/Grace.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/C/Grace/Grace.c b/C/Grace/Grace.c index 8044462..c78ae51 100644 --- a/C/Grace/Grace.c +++ b/C/Grace/Grace.c @@ -1,7 +1,9 @@ #include +#include -#define TO_WRITE "#include %1$c%1$c#define TO_WRITE %3$c%4$s%3$c%1$c#define PROG()int main(void) {%2$cFILE *new_file = fopen(%3$cGrace_kid.c%3$c, %3$cw%3$c);%2$cif (new_file == NULL)%2$c%2$creturn 1;%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 PROG()int main(void) { FILE *new_file = fopen("Grace_kid.c", "w"); if (new_file == NULL) return 1; fprintf(new_file, TO_WRITE, 10, 9, 34, TO_WRITE); fclose(new_file); return 0;} +#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