From 1e4185a54483de9971cb44f55f8847bc19b27600 Mon Sep 17 00:00:00 2001 From: maix0 Date: Fri, 11 Oct 2024 22:36:42 +0200 Subject: [PATCH] Fixed issue where '*' would be treated as glob --- Makefile | 8 ++++---- exec/src/run_ast/_ast_into_str.c | 4 ++-- exec/src/run_ast/_ast_into_str5.c | 4 ++-- parser/src/yarn/ast_cmd.c | 10 +++++++--- sources/main.c | 4 +--- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 83d2bc18..1e565578 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # -# Updated: 2024/10/11 10:51:13 by maiboyer ### ########.fr # +# Updated: 2024/10/11 22:24:03 by maiboyer ### ########.fr # # # # **************************************************************************** # @@ -50,9 +50,9 @@ endif # 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 -fno-builtin - CFLAGS_ADDITIONAL += '-DERROR=((void)printf("ERROR HERE: " __FILE__ ":%d in %s\n", __LINE__, __func__), 1)' -CFLAGS_ADDITIONAL += -O2 +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 # CFLAGS_ADDITIONAL += -I$(shell realpath ./includes) -I$(shell realpath ./output/include) diff --git a/exec/src/run_ast/_ast_into_str.c b/exec/src/run_ast/_ast_into_str.c index fd76ee10..6c16724f 100644 --- a/exec/src/run_ast/_ast_into_str.c +++ b/exec/src/run_ast/_ast_into_str.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/09/14 12:26:51 by maiboyer #+# #+# */ -/* Updated: 2024/09/18 22:16:54 by maiboyer ### ########.fr */ +/* Updated: 2024/10/11 22:33:02 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -63,7 +63,7 @@ t_error _word_into_str(t_ast_node self, t_state *state, t_vec_str *append) || self->kind != AST_WORD) return (ERROR); if (_word_is_star(&self->data.word)) - return (_word_handle_star(&self->data.word, state, append)); + return (dprintf(2, "word is star !\n"), _word_handle_star(&self->data.word, state, append)); if (run_word(&self->data.word, state, &res)) return (ERROR); if (res.kind == AST_WORD_NO_QUOTE) diff --git a/exec/src/run_ast/_ast_into_str5.c b/exec/src/run_ast/_ast_into_str5.c index ca548750..1e166985 100644 --- a/exec/src/run_ast/_ast_into_str5.c +++ b/exec/src/run_ast/_ast_into_str5.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/09/14 12:26:51 by maiboyer #+# #+# */ -/* Updated: 2024/10/10 17:44:20 by maiboyer ### ########.fr */ +/* Updated: 2024/10/11 22:36:11 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,7 +20,7 @@ t_error list_files_in_current_directory(t_vec_str *out); bool _word_is_star(t_ast_word *word) { - return (word->kind == AST_WORD_NO_QUOTE && word->inner.len == 1 \ + return (BONUS && word->kind == AST_WORD_NO_QUOTE && word->inner.len == 1 \ && word->inner.buffer[0]->kind == AST_RAW_STRING \ && str_compare("*", word->inner.buffer[0]->data.raw_string.str)); } diff --git a/parser/src/yarn/ast_cmd.c b/parser/src/yarn/ast_cmd.c index d50fa80d..e6b9273f 100644 --- a/parser/src/yarn/ast_cmd.c +++ b/parser/src/yarn/ast_cmd.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/09 12:44:53 by maiboyer #+# #+# */ -/* Updated: 2024/10/11 15:12:36 by maiboyer ### ########.fr */ +/* Updated: 2024/10/11 22:35:33 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -118,9 +118,13 @@ t_error _tok_word_nquote(t_token *tok, t_ast_node *out) t_error _tok_word_squote(t_token *tok, t_ast_node *out) { t_ast_node ret; + t_ast_node tmp; - ret = ast_alloc(AST_RAW_STRING); - ret->data.raw_string.str = (t_str)_token_to_string(tok, false); + ret = ast_alloc(AST_WORD); + tmp = ast_alloc(AST_RAW_STRING); + tmp->data.raw_string.str = (t_str)_token_to_string(tok, false); + vec_ast_push(&ret->data.word.inner, tmp); + ret->data.word.kind = AST_WORD_SINGLE_QUOTE; return (*out = ret, NO_ERROR); } t_error _tok_word_dquote(t_token *tok, t_ast_node *out) diff --git a/sources/main.c b/sources/main.c index ca3af2cd..c87bde71 100644 --- a/sources/main.c +++ b/sources/main.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/28 14:40:38 by rparodi #+# #+# */ -/* Updated: 2024/10/11 16:21:01 by rparodi ### ########.fr */ +/* Updated: 2024/10/11 22:23:14 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -98,8 +98,6 @@ t_error parse_str(t_state *state) if (ast.len != 1) return (ERROR); vec_ast_pop(&ast, &state->ast); - ast_print(state->ast); - printf("\nast\n"); vec_ast_free(ast); return (NO_ERROR); }