From a905a595d4403aa00a12265473e269d67bcbd5ac Mon Sep 17 00:00:00 2001 From: maix0 Date: Sun, 6 Oct 2024 15:07:57 +0200 Subject: [PATCH] update: fixed some function leaking into the final binary... --- .gitignore | 1 + Makefile | 14 +++++++------- Minishell.mk | 4 ++-- stdme/src/fs/fd.c | 4 +++- stdme/src/fs/file.c | 4 +++- stdme/src/fs/fs_internal.c | 7 ++++--- stdme/src/printf/formatter/utils.c | 4 ++-- 7 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 1ce7dd27..fcfefa56 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,4 @@ parser/split_rust .tree-sitter-sh/src/tree_sitter/ .tree-sitter-sh/src/node-types.json .direnv +minishell_bonus diff --git a/Makefile b/Makefile index 0690d667..1f2efbd8 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # -# Updated: 2024/09/26 18:01:37 by maiboyer ### ########.fr # +# Updated: 2024/10/06 14:58:13 by maiboyer ### ########.fr # # # # **************************************************************************** # @@ -35,11 +35,11 @@ PMAKE = ifndef PMAKE_DISABLE ifeq ($(shell uname), Linux) PMAKE = -j$(shell grep -c ^processor /proc/cpuinfo) - CFLAGS_ADDITIONAL += -DPRINT_BACKTRACE + #CFLAGS_ADDITIONAL += -DPRINT_BACKTRACE endif ifeq ($(shell uname), Darwin) PMAKE = -j$(shell sysctl -n hw.ncpu) - CFLAGS_ADDITIONAL += -DNVALGRIND + #CFLAGS_ADDITIONAL += -DNVALGRIND endif endif @@ -49,12 +49,12 @@ endif # TODO: REMOVE THIS WHEN FINISHING THIS: # CFLAGS_ADDITIONAL += -fsanitize=memory -fno-omit-frame-pointer -fsanitize-memory-track-origins #-fuse-ld=lld -ffunction-sections -fdata-sections -Wl,--allow-multiple # CFLAGS_ADDITIONAL += -O0 -CFLAGS_ADDITIONAL += -Wno-cpp -Wno-type-limits -Wno-unused-command-line-argument -CFLAGS_ADDITIONAL += -gcolumn-info -g3 -CFLAGS_ADDITIONAL += '-DERROR=((void)printf("ERROR HERE: " __FILE__ ":%d in %s\n", __LINE__, __func__), 1)' +# CFLAGS_ADDITIONAL += -Wno-cpp -Wno-type-limits -Wno-unused-command-line-argument + CFLAGS_ADDITIONAL += -gcolumn-info -g3 -fno-builtin +# CFLAGS_ADDITIONAL += '-DERROR=((void)printf("ERROR HERE: " __FILE__ ":%d in %s\n", __LINE__, __func__), 1)' # CFLAGS_ADDITIONAL += -O2 # CFLAGS_ADDITIONAL += -fuse-ld=gold -Wl,--print-symbol-counts -Wl,/tmp/symbols_count.log -# CFLAGS_ADDITIONAL += -fuse-ld=lld -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,-O3 -Wl,--allow-multiple +CFLAGS_ADDITIONAL += -fuse-ld=lld -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,-O3 # CFLAGS_ADDITIONAL += -I$(shell realpath ./includes) -I$(shell realpath ./output/include) export CFLAGS_ADDITIONAL diff --git a/Minishell.mk b/Minishell.mk index 07cb1176..7308cd7a 100644 --- a/Minishell.mk +++ b/Minishell.mk @@ -6,7 +6,7 @@ # By: maiboyer +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2024/04/28 17:28:30 by maiboyer #+# #+# # -# Updated: 2024/10/06 14:33:24 by maiboyer ### ########.fr # +# Updated: 2024/10/06 14:42:55 by maiboyer ### ########.fr # # # # **************************************************************************** # @@ -17,6 +17,7 @@ link_group = -Wl,--start-group $(1) -Wl,--end-group # Variables ANAME = sh BUILD_DIR ?= $(shell realpath ./build/) +NAME = minishell ifeq ($(MAKECMDGOALS), bonus) CFLAGS_ADDITIONAL += -DBONUS=1 @@ -42,7 +43,6 @@ GEN_DIR = output SRC = $(addsuffix .c,$(addprefix $(SRC_DIR)/,$(SRC_FILES)) $(addprefix $(GEN_DIR)/,$(GEN_FILES))) OBJ = $(addsuffix .o,$(addprefix $(BUILD_DIR)/$(ANAME)/,$(SRC_FILES) $(GEN_FILES))) DEP = $(addsuffix .d,$(addprefix $(BUILD_DIR)/$(ANAME)/,$(SRC_FILES) $(GEN_FILES))) -NAME = minishell # Commands CC ?= clang diff --git a/stdme/src/fs/fd.c b/stdme/src/fs/fd.c index c9c4560c..a1cfc0a7 100644 --- a/stdme/src/fs/fd.c +++ b/stdme/src/fs/fd.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/30 16:17:17 by rparodi #+# #+# */ -/* Updated: 2024/08/05 15:19:17 by maiboyer ### ########.fr */ +/* Updated: 2024/10/06 15:05:48 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -82,6 +82,7 @@ t_error write_fd(t_fd *fd, t_u8 *buffer, t_usize size, t_isize *write_count) return (NO_ERROR); } +/* TODO: REMOVE THIS COMMENT SURROUNDING THE FUNCTION t_error stat_fd(t_fd *fd, t_stat *stat) { if (fd == NULL || stat == NULL || fd->fd == -1) @@ -90,6 +91,7 @@ t_error stat_fd(t_fd *fd, t_stat *stat) return (ERROR); return (NO_ERROR); } +*/ void close_fd(t_fd *fd) { diff --git a/stdme/src/fs/file.c b/stdme/src/fs/file.c index 22ede943..94a3cceb 100644 --- a/stdme/src/fs/file.c +++ b/stdme/src/fs/file.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/30 16:26:32 by rparodi #+# #+# */ -/* Updated: 2024/08/05 15:19:21 by maiboyer ### ########.fr */ +/* Updated: 2024/10/06 15:05:57 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,6 +21,7 @@ #include #include +/* TODO: REMOVE THIS COMMENT SURROUNDING THE FUNCTION t_error open_file(t_str name, t_mode mode, t_file **file) { t_file *out; @@ -82,3 +83,4 @@ void close_file(t_file *file) mem_set_zero(slot, sizeof(*slot)); slot->ty = SLOT_UNUSED; } +*/ diff --git a/stdme/src/fs/fs_internal.c b/stdme/src/fs/fs_internal.c index 4ae2e275..1bfda174 100644 --- a/stdme/src/fs/fs_internal.c +++ b/stdme/src/fs/fs_internal.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/19 15:53:50 by maiboyer #+# #+# */ -/* Updated: 2024/08/22 16:23:04 by maiboyer ### ########.fr */ +/* Updated: 2024/10/06 15:02:50 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -57,6 +57,9 @@ __attribute__((destructor(201))) void close_all_slots(void) close_slot(&arr->storage[i++]); } +// This is to remove the f function from being there... +// else if (slot->ty == SLOT_FILE) +// ;//close_file(&slot->slot.file); void close_slot(struct s_file_slot *slot) { if (slot == NULL) @@ -67,8 +70,6 @@ void close_slot(struct s_file_slot *slot) close_fd(&slot->slot.fd); else if (slot->ty == SLOT_DIR) close_dir(&slot->slot.dir); - else if (slot->ty == SLOT_FILE) - close_file(&slot->slot.file); else (void)!write(2, "Unknown SLOT type", 17); mem_set_zero(slot, sizeof(*slot)); diff --git a/stdme/src/printf/formatter/utils.c b/stdme/src/printf/formatter/utils.c index 9f512be4..296db4ca 100644 --- a/stdme/src/printf/formatter/utils.c +++ b/stdme/src/printf/formatter/utils.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/16 17:57:04 by maiboyer #+# #+# */ -/* Updated: 2024/07/30 16:10:07 by rparodi ### ########.fr */ +/* Updated: 2024/10/06 15:04:47 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -35,7 +35,7 @@ bool handle_atoi_stuff(t_const_str fmt, t_usize *c_idx, t_usize *nxt, advance_atoi(fmt, c_idx); c_arg->extra.align = (t_u64)atoi_res; handle_prec_and_align(fmt, c_idx, c_arg); - atoi_res = atoi(&fmt[*c_idx]); + atoi_res = _atoi_printf(&fmt[*c_idx]); if (atoi_res < 0) { *c_idx = *nxt;