Fixed issue where '*' would be treated as glob

This commit is contained in:
maix0 2024-10-11 22:36:42 +02:00
parent baa9af918f
commit 1e4185a544
5 changed files with 16 additions and 14 deletions

View file

@ -6,7 +6,7 @@
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# 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)

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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)

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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));
}

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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)

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}