update: fixed some issues
This commit is contained in:
parent
1a3253afc8
commit
2b5a62afc8
6 changed files with 40 additions and 24 deletions
|
|
@ -6,9 +6,9 @@ ast_free/ast_free_scripting \
|
||||||
print_ast/ast_print \
|
print_ast/ast_print \
|
||||||
print_ast/ast_print_arithmetic \
|
print_ast/ast_print_arithmetic \
|
||||||
print_ast/ast_print_command \
|
print_ast/ast_print_command \
|
||||||
|
print_ast/ast_print_general \
|
||||||
print_ast/ast_print_global \
|
print_ast/ast_print_global \
|
||||||
print_ast/ast_print_helper_function \
|
print_ast/ast_print_helper_function \
|
||||||
print_ast/ast_print_node \
|
print_ast/ast_print_node \
|
||||||
print_ast/ast_print_redirection \
|
print_ast/ast_print_redirection \
|
||||||
print_ast/ast_print_subshell \
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ast_print_subshell.c :+: :+: :+: */
|
/* ast_print_general.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/07/26 13:07:12 by rparodi #+# #+# */
|
/* Created: 2024/07/26 13:07:12 by rparodi #+# #+# */
|
||||||
/* Updated: 2024/10/14 14:12:49 by maiboyer ### ########.fr */
|
/* Updated: 2024/10/24 22:30:02 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -14,7 +14,9 @@
|
||||||
|
|
||||||
void ast_print_node_file_redirection_heredoc(t_ast_node self)
|
void ast_print_node_file_redirection_heredoc(t_ast_node self)
|
||||||
{
|
{
|
||||||
(void)(self);
|
if (self == NULL || self->kind != AST_HEREDOC_REDIRECTION)
|
||||||
|
return;
|
||||||
|
printf("<<%s", self->data.heredoc_redirection.delimiter);
|
||||||
}
|
}
|
||||||
//{
|
//{
|
||||||
// if (self->data.file_redirection.op == AST_REDIR_HEREDOC)
|
// if (self->data.file_redirection.op == AST_REDIR_HEREDOC)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/09/14 12:26:51 by maiboyer #+# #+# */
|
/* Created: 2024/09/14 12:26:51 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/10/15 21:30:02 by maiboyer ### ########.fr */
|
/* Updated: 2024/10/24 22:48:26 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -21,27 +21,39 @@ t_error _word_handle_star(t_ast_word *word, t_state *state, t_vec_str *out);
|
||||||
t_error list_files_in_current_directory(t_vec_str *out);
|
t_error list_files_in_current_directory(t_vec_str *out);
|
||||||
t_error _word_into_str_inner(struct s_word_str_args args);
|
t_error _word_into_str_inner(struct s_word_str_args args);
|
||||||
|
|
||||||
t_error _word_split_loop(\
|
t_error _word_split_loop_expand(\
|
||||||
bool do_split, t_expandable_str val, t_vec_str *append, t_string *tmp)
|
t_expandable_str val, t_vec_str *append, t_string *tmp)
|
||||||
{
|
{
|
||||||
t_vec_str split;
|
t_vec_str split;
|
||||||
t_str stmp;
|
t_str stmp;
|
||||||
|
|
||||||
if (do_split)
|
|
||||||
{
|
|
||||||
if (val.do_expand)
|
if (val.do_expand)
|
||||||
{
|
{
|
||||||
if (val.value == NULL)
|
if (val.value == NULL)
|
||||||
val.value = "";
|
val.value = "";
|
||||||
if (str_split(val.value, " ", &split))
|
if (str_split(val.value, " \t\n\r\v", &split))
|
||||||
return (ERROR);
|
return (ERROR);
|
||||||
|
if (split.len != 0)
|
||||||
|
{
|
||||||
|
vec_str_push(append, tmp->buf);
|
||||||
|
*tmp = string_new(16);
|
||||||
|
}
|
||||||
while (!vec_str_pop_front(&split, &stmp))
|
while (!vec_str_pop_front(&split, &stmp))
|
||||||
vec_str_push(append, stmp);
|
vec_str_push(append, stmp);
|
||||||
vec_str_free(split);
|
vec_str_free(split);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
vec_str_push(append, str_clone(val.value));
|
string_push(tmp, val.value);
|
||||||
|
return (NO_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
t_error _word_split_loop(\
|
||||||
|
bool do_split, t_expandable_str val, t_vec_str *append, t_string *tmp)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (do_split)
|
||||||
|
return (_word_split_loop_expand(val, append, tmp));
|
||||||
else
|
else
|
||||||
string_push(tmp, val.value);
|
string_push(tmp, val.value);
|
||||||
return (NO_ERROR);
|
return (NO_ERROR);
|
||||||
|
|
@ -60,7 +72,7 @@ t_error _word_split(\
|
||||||
if (_word_split_loop(do_split, res->value.buffer[i++], append, &tmp))
|
if (_word_split_loop(do_split, res->value.buffer[i++], append, &tmp))
|
||||||
return (string_free(tmp), ERROR);
|
return (string_free(tmp), ERROR);
|
||||||
}
|
}
|
||||||
if (!do_split)
|
if (!do_split || tmp.len != 0)
|
||||||
vec_str_push(append, tmp.buf);
|
vec_str_push(append, tmp.buf);
|
||||||
else
|
else
|
||||||
string_free(tmp);
|
string_free(tmp);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/09/14 12:30:09 by maiboyer #+# #+# */
|
/* Created: 2024/09/14 12:30:09 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/10/14 15:07:42 by maiboyer ### ########.fr */
|
/* Updated: 2024/10/24 22:57:49 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -79,6 +79,7 @@ t_error _spawn_cmd_and_run_end(\
|
||||||
bpath = str_clone(info.binary_path);
|
bpath = str_clone(info.binary_path);
|
||||||
if (spawn_process(info, &out->process))
|
if (spawn_process(info, &out->process))
|
||||||
return (close_fd(cmd_pipe.input), out->exit = 127, _err_cmd(bpath));
|
return (close_fd(cmd_pipe.input), out->exit = 127, _err_cmd(bpath));
|
||||||
|
close_fd(cmd_pipe.input);
|
||||||
str_free(bpath);
|
str_free(bpath);
|
||||||
if (cmd_pipe.create_output || cmd_pipe.input != NULL)
|
if (cmd_pipe.create_output || cmd_pipe.input != NULL)
|
||||||
return (out->exit = -1, NO_ERROR);
|
return (out->exit = -1, NO_ERROR);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/09/06 16:31:41 by rparodi #+# #+# */
|
/* Created: 2024/09/06 16:31:41 by rparodi #+# #+# */
|
||||||
/* Updated: 2024/10/14 15:03:01 by maiboyer ### ########.fr */
|
/* Updated: 2024/10/24 22:31:52 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -64,6 +64,7 @@ void exec_shcat(t_state *state)
|
||||||
vec_ast_push(&prog->data.program.body, state->ast);
|
vec_ast_push(&prog->data.program.body, state->ast);
|
||||||
state->ast = prog;
|
state->ast = prog;
|
||||||
}
|
}
|
||||||
|
ast_print(state->ast);
|
||||||
if (state->ast != NULL && run_program(&state->ast->data.program, state,
|
if (state->ast != NULL && run_program(&state->ast->data.program, state,
|
||||||
&prog_res))
|
&prog_res))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue