From 56e57dd6e3873ee17021a47990aea3d7e895a3c4 Mon Sep 17 00:00:00 2001 From: Raphael Date: Sat, 17 May 2025 14:43:38 +0200 Subject: [PATCH 01/10] build(09): adding run on ex02 --- cpp09/ex02/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cpp09/ex02/Makefile b/cpp09/ex02/Makefile index 496bedd..443549c 100644 --- a/cpp09/ex02/Makefile +++ b/cpp09/ex02/Makefile @@ -88,6 +88,9 @@ debug: re test: debug @./$(NAME) $(shell shuf -i 1-100000 -n 3000 | tr "\n" " ") +run: re + @./$(NAME) $(shell shuf -i 1-100000 -n 3000 | tr "\n" " ") + # Header header: @clear From 5cedee473692c4bd50b538a2542b0f90bc7f008f Mon Sep 17 00:00:00 2001 From: Raphael Date: Sat, 17 May 2025 14:46:09 +0200 Subject: [PATCH 02/10] build(09): adding run on ex01 --- cpp09/ex01/Makefile | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/cpp09/ex01/Makefile b/cpp09/ex01/Makefile index 8b6e1f2..eebe749 100644 --- a/cpp09/ex01/Makefile +++ b/cpp09/ex01/Makefile @@ -6,7 +6,7 @@ # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # -# Updated: 2025/04/27 18:52:30 by rparodi ### ########.fr # +# Updated: 2025/05/17 14:45:22 by rparodi ### ########.fr # # # # **************************************************************************** # @@ -83,7 +83,7 @@ $(OBJDIRNAME)/%.o: %.cpp @printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n' @$(CXX) $(CXXFLAGS) -o $@ -c $< -test: +test: re @printf '$(GREY) Testing with $(END)$(GOLD)./RPN ""$(END)\n' @./$(NAME) "" @printf '\n' @@ -109,12 +109,8 @@ test: @valgrind ./$(NAME) "1 2 * 2 / 2 * 2 4 - +" 2> /tmp/RPN_test @cat /tmp/RPN_test | rg --color=always "ERROR SUMMARY" -A 10 @printf '$(GREY) Testing with $(END)$(GOLD)./RPN "(1 + 1)"$(END)\n' - @./$(NAME) "(1 + 1)" - @printf '\n' - @printf '$(GREY) MemCheck with $(END)$(GOLD)./RPN "(1 + 1)"$(END)\n' - @valgrind ./$(NAME) "(1 + 1)" 2> /tmp/RPN_test - @cat /tmp/RPN_test | rg --color=always "ERROR SUMMARY" -A 10 +run: test # Header header: @clear From 5edc9a2fa4dffb698a985486520d8e2974a2b1d5 Mon Sep 17 00:00:00 2001 From: Raphael Date: Sun, 18 May 2025 21:35:34 +0200 Subject: [PATCH 03/10] fix(09): checking other month --- cpp09/ex00/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cpp09/ex00/main.cpp b/cpp09/ex00/main.cpp index 1982e94..fe9c851 100644 --- a/cpp09/ex00/main.cpp +++ b/cpp09/ex00/main.cpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/08 12:15:32 by rparodi #+# #+# */ -/* Updated: 2025/05/02 15:22:16 by rparodi ### ########.fr */ +/* Updated: 2025/05/18 21:35:25 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -137,6 +137,8 @@ std::string check_date(std::string name, enum error_code *error_code) { for (int i = 0; i < 4; i++) { if (month == month_30[i] && day > "30") { *error_code = NO_DATE; + } else if (day > "31") { + *error_code = NO_DATE; } } } From 506397a281b6fc2467135de1bad2a50e3445b553 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 5 Jun 2025 18:53:21 +0200 Subject: [PATCH 04/10] build(getter): adding the rules to write auto the input given by the subject --- cpp09/ex00/Makefile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cpp09/ex00/Makefile b/cpp09/ex00/Makefile index f27eb28..5e4816e 100644 --- a/cpp09/ex00/Makefile +++ b/cpp09/ex00/Makefile @@ -6,7 +6,7 @@ # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # -# Updated: 2025/05/02 15:21:09 by rparodi ### ########.fr # +# Updated: 2025/06/05 18:48:32 by rparodi ### ########.fr # # # # **************************************************************************** # @@ -59,6 +59,17 @@ get_db: @cp ./cpp_09/data.csv . &> /dev/null @rm -rf ./cpp_09.tgz ./cpp_09 &> /dev/null @printf '$(GREY)Downloaded $(END)$(GREEN)data.csv$(END)\n' + @echo "date | value" > ./input.txt + @echo "2011-01-03 | 3" >> ./input.txt + @echo "2011-01-03 | 2" >> ./input.txt + @echo "2011-01-03 | 1" >> ./input.txt + @echo "2011-01-03 | 1.2" >> ./input.txt + @echo "2011-01-09 | 1" >> ./input.txt + @echo "2012-01-11 | -1" >> ./input.txt + @echo "2001-42-42" >> ./input.txt + @echo "2012-01-11 | 1" >> ./input.txt + @echo "2012-01-11 | 2147483648" >> ./input.txt + @printf '$(GREY)Writing the example $(END)$(GREEN)input.txt$(END)\n' # Clean (make clean) clean: From c2316b6eaf206a79ca2a6d6c49c87e741fc96df0 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 5 Jun 2025 19:31:43 +0200 Subject: [PATCH 05/10] build(debug/run): improuved some stuff --- cpp09/ex00/Makefile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cpp09/ex00/Makefile b/cpp09/ex00/Makefile index 5e4816e..90dde08 100644 --- a/cpp09/ex00/Makefile +++ b/cpp09/ex00/Makefile @@ -6,7 +6,7 @@ # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # -# Updated: 2025/06/05 18:48:32 by rparodi ### ########.fr # +# Updated: 2025/06/05 19:09:44 by rparodi ### ########.fr # # # # **************************************************************************** # @@ -86,6 +86,9 @@ fclean: clean # Restart (make re) re: header fclean all +run: all + @./$(NAME) ./input.txt + # Dependences for all $(NAME): $(OBJ) @mkdir -p $(OBJDIRNAME) @@ -114,7 +117,7 @@ header: @printf '$(GOLD) ****** $(END)\n' @printf '$(GREY) Made by rparodi$(END)\n\n' -debug: CPPFLAGS += -D DEBUG=1 +debug: CPPFLAGS += -D DEBUG=1 -g debug: re # Footer @@ -147,5 +150,5 @@ clangd: @printf '$(GREY) Now parsing settings is set in $(END)$(GREEN)./.clangd$(END)\n' # Phony -.PHONY: all clean fclean re get_db clangd +.PHONY: all clean fclean re get_db clangd run -include ${OBJ:.o=.d} From 7687cf1568031124d3000755abb40dc03c4fccbf Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 5 Jun 2025 19:32:28 +0200 Subject: [PATCH 06/10] fix(09/01): now handling before the db --- cpp09/ex00/main.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cpp09/ex00/main.cpp b/cpp09/ex00/main.cpp index fe9c851..90dde9d 100644 --- a/cpp09/ex00/main.cpp +++ b/cpp09/ex00/main.cpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/08 12:15:32 by rparodi #+# #+# */ -/* Updated: 2025/05/18 21:35:25 by rparodi ### ########.fr */ +/* Updated: 2025/06/05 19:30:36 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -127,6 +127,10 @@ std::string check_date(std::string name, enum error_code *error_code) { return (name); } std::string day = name.substr(8, 2); + if (year < "2009" || (year == "2009" && month <= "01" && day < "02")) { + *error_code = NO_DATE; + return (name); + } if (day > "28") { if (month == "02" && day == "29") { if ((atoi(year.c_str()) % 4 == 0) && (atoi(year.c_str()) % 100 != 0 || atoi(year.c_str()) % 400 == 0)) @@ -190,7 +194,7 @@ std::mapparse_input(std::string name) { std::string tmpLine; std::string tmpDate; - float tmpValue = 0; + float tmpValue = 0; std::getline(file, tmpLine); if (tmpLine != "date | value") { @@ -217,15 +221,12 @@ std::mapparse_input(std::string name) { } void print_result(std::map input, std::map db) { - std::map::iterator it_input = input.begin(); std::map::iterator it_db = db.begin(); - while (it_input != input.end()) { + for (std::map::iterator it_input = input.begin(); it_input != input.end(); it_input++) { if (it_input->second.reason == NO_ERROR) { - while (it_db != db.end() && it_input->second.date > it_db->first) + while (it_db != db.end() && it_input->second.date > it_db->first) { it_db++; - if (it_db == db.begin()) { - it_db--; } if (it_db == db.end()) { std::cerr << CLR_MAGENTA << it_input->second.date << CLR_RED << " => no data found" << CLR_RESET << std::endl; @@ -257,7 +258,6 @@ void print_result(std::map input, std::map db break; } } - it_input++; } } From b023d3d3750faefc1bef4ecd96c18996be5ff1cc Mon Sep 17 00:00:00 2001 From: Raphael Date: Sat, 7 Jun 2025 16:46:09 +0200 Subject: [PATCH 07/10] fix(09/00): fix the makefile's rule get_db --- cpp09/ex00/Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cpp09/ex00/Makefile b/cpp09/ex00/Makefile index 90dde08..b3f9740 100644 --- a/cpp09/ex00/Makefile +++ b/cpp09/ex00/Makefile @@ -6,7 +6,7 @@ # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # -# Updated: 2025/06/05 19:09:44 by rparodi ### ########.fr # +# Updated: 2025/06/07 16:45:53 by rparodi ### ########.fr # # # # **************************************************************************** # @@ -53,11 +53,11 @@ END = \033[0m all: header $(NAME) footer get_db: - @rm -rf ./cpp_09.tgz ./cpp_09 ./data.csv &> /dev/null - @wget https://cdn.intra.42.fr/document/document/33121/cpp_09.tgz &> /dev/null - @tar -xvf cpp_09.tgz &> /dev/null - @cp ./cpp_09/data.csv . &> /dev/null - @rm -rf ./cpp_09.tgz ./cpp_09 &> /dev/null + @rm -rf ./cpp_09.tgz ./cpp_09 ./data.csv > /dev/null + @wget https://cdn.intra.42.fr/document/document/33121/cpp_09.tgz > /dev/null + @tar -xvf cpp_09.tgz > /dev/null + @cp ./cpp_09/data.csv . > /dev/null + @rm -rf ./cpp_09.tgz ./cpp_09 > /dev/null @printf '$(GREY)Downloaded $(END)$(GREEN)data.csv$(END)\n' @echo "date | value" > ./input.txt @echo "2011-01-03 | 3" >> ./input.txt From d3f6fb1e8f59b62b03ab82fcd0ca62b28bb40ad3 Mon Sep 17 00:00:00 2001 From: Raphael Date: Sun, 8 Jun 2025 16:00:22 +0200 Subject: [PATCH 08/10] fix(09/00): wrong order at each time --- cpp09/ex00/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp09/ex00/main.cpp b/cpp09/ex00/main.cpp index 90dde9d..9a96d3b 100644 --- a/cpp09/ex00/main.cpp +++ b/cpp09/ex00/main.cpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/08 12:15:32 by rparodi #+# #+# */ -/* Updated: 2025/06/05 19:30:36 by rparodi ### ########.fr */ +/* Updated: 2025/06/08 15:59:57 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -133,7 +133,7 @@ std::string check_date(std::string name, enum error_code *error_code) { } if (day > "28") { if (month == "02" && day == "29") { - if ((atoi(year.c_str()) % 4 == 0) && (atoi(year.c_str()) % 100 != 0 || atoi(year.c_str()) % 400 == 0)) + if (!((atoi(year.c_str()) % 4 == 0) && (atoi(year.c_str()) % 100 != 0 || atoi(year.c_str()) % 400 == 0))) *error_code = NO_DATE; } else { From 6246c4b7a8cc4601786aff6a9a2940ede7572a56 Mon Sep 17 00:00:00 2001 From: Raphael Date: Sun, 8 Jun 2025 22:14:46 +0200 Subject: [PATCH 09/10] style(direnv): removing the flake.lock --- flake.lock | 61 ------------------------------------------------------ 1 file changed, 61 deletions(-) delete mode 100644 flake.lock diff --git a/flake.lock b/flake.lock deleted file mode 100644 index bb33fd6..0000000 --- a/flake.lock +++ /dev/null @@ -1,61 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1746328495, - "narHash": "sha256-uKCfuDs7ZM3QpCE/jnfubTg459CnKnJG/LwqEVEdEiw=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "979daf34c8cacebcd917d540070b52a3c2b9b16e", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} From a4b8d55bc4e8bded140b581a08e39529943a0835 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 25 Dec 2025 01:38:39 +0100 Subject: [PATCH 10/10] style(make): using printf for unity w/ macos & linux --- cpp00/ex01/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp00/ex01/Makefile b/cpp00/ex01/Makefile index c5b6a69..06122d1 100644 --- a/cpp00/ex01/Makefile +++ b/cpp00/ex01/Makefile @@ -6,7 +6,7 @@ # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # -# Updated: 2025/02/10 10:02:41 by rparodi ### ########.fr # +# Updated: 2025/10/10 17:59:41 by rparodi ### ########.fr # # # # **************************************************************************** # @@ -113,7 +113,7 @@ footer: @printf ' $(GREY)The compilation is$(END) $(GOLD)finish$(END)\n $(GREY)Have a good $(END)$(GOLD)correction !$(END)\n' clangd: - @echo \ + @printf \ "CompileFlags:\n" \ " Add:\n" \ " - \"-std=c++98 -Wall -Wextra -Werror\"\n" \