update: fixed small errors
This commit is contained in:
parent
f5a8c2be04
commit
d97efa87a7
16 changed files with 59 additions and 140 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
SRC_FILES = \
|
SRC_FILES = \
|
||||||
env \
|
|
||||||
_env_norm_helper \
|
_env_norm_helper \
|
||||||
ft_exit \
|
|
||||||
_helper_main \
|
_helper_main \
|
||||||
|
env \
|
||||||
|
ft_exit \
|
||||||
main \
|
main \
|
||||||
signal_handler \
|
signal_handler \
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,11 @@ me_alloc/merge_blocks \
|
||||||
me_alloc/pages \
|
me_alloc/pages \
|
||||||
me_alloc/realloc \
|
me_alloc/realloc \
|
||||||
vg/dummy_block \
|
vg/dummy_block \
|
||||||
|
vg/dummy_mem_status \
|
||||||
vg/dummy_mempool \
|
vg/dummy_mempool \
|
||||||
vg/dummy_mempool_bis \
|
vg/dummy_mempool_bis \
|
||||||
vg/dummy_mem_status \
|
|
||||||
vg/valgrind_block \
|
vg/valgrind_block \
|
||||||
|
vg/valgrind_mem_status \
|
||||||
vg/valgrind_mempool \
|
vg/valgrind_mempool \
|
||||||
vg/valgrind_mempool_bis \
|
vg/valgrind_mempool_bis \
|
||||||
vg/valgrind_mem_status \
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,40 @@
|
||||||
SRC_FILES = \
|
SRC_FILES = \
|
||||||
builtins/cd \
|
_read_dir \
|
||||||
builtins/_debug \
|
builtins/_debug \
|
||||||
|
builtins/cd \
|
||||||
builtins/echo \
|
builtins/echo \
|
||||||
builtins/env \
|
builtins/env \
|
||||||
builtins/exit \
|
builtins/exit \
|
||||||
builtins/export \
|
builtins/export \
|
||||||
builtins/pwd \
|
builtins/pwd \
|
||||||
builtins/unset \
|
builtins/unset \
|
||||||
_read_dir \
|
|
||||||
run_arithmetic/arithmetic \
|
|
||||||
run_arithmetic/arithmetic_operation \
|
|
||||||
run_arithmetic/_get_op \
|
run_arithmetic/_get_op \
|
||||||
run_arithmetic/operator_bis \
|
|
||||||
run_arithmetic/_run_arith \
|
run_arithmetic/_run_arith \
|
||||||
run_arithmetic/_to_ast_node \
|
run_arithmetic/_to_ast_node \
|
||||||
|
run_arithmetic/arithmetic \
|
||||||
|
run_arithmetic/arithmetic_operation \
|
||||||
|
run_arithmetic/operator_bis \
|
||||||
run_ast/_ast_into_str \
|
run_ast/_ast_into_str \
|
||||||
run_ast/_ast_into_str2 \
|
run_ast/_ast_into_str2 \
|
||||||
run_ast/_ast_into_str3 \
|
run_ast/_ast_into_str3 \
|
||||||
run_ast/_ast_into_str4 \
|
run_ast/_ast_into_str4 \
|
||||||
run_ast/_ast_into_str5 \
|
run_ast/_ast_into_str5 \
|
||||||
run_ast/_ast_into_str6 \
|
|
||||||
run_ast/_get_pid \
|
run_ast/_get_pid \
|
||||||
|
run_ast/_run_exit_code \
|
||||||
|
run_ast/_run_exp_operators \
|
||||||
|
run_ast/_spawn_cmd \
|
||||||
|
run_ast/_spawn_cmd_redir_fd \
|
||||||
|
run_ast/_spawn_cmd_redir_heredoc \
|
||||||
run_ast/run_builtins \
|
run_ast/run_builtins \
|
||||||
run_ast/run_builtins2 \
|
run_ast/run_builtins2 \
|
||||||
run_ast/run_cmd_sub \
|
run_ast/run_cmd_sub \
|
||||||
run_ast/run_command \
|
run_ast/run_command \
|
||||||
run_ast/_run_exit_code \
|
|
||||||
run_ast/run_expansion \
|
run_ast/run_expansion \
|
||||||
run_ast/run_expansion_builtin \
|
run_ast/run_expansion_builtin \
|
||||||
run_ast/_run_exp_operators \
|
|
||||||
run_ast/run_list \
|
run_ast/run_list \
|
||||||
run_ast/run_pipeline \
|
run_ast/run_pipeline \
|
||||||
run_ast/run_pipeline_helper \
|
run_ast/run_pipeline_helper \
|
||||||
run_ast/run_program \
|
run_ast/run_program \
|
||||||
run_ast/run_subshell \
|
run_ast/run_subshell \
|
||||||
run_ast/run_words \
|
run_ast/run_words \
|
||||||
run_ast/_spawn_cmd \
|
|
||||||
run_ast/_spawn_cmd_redir_fd \
|
|
||||||
run_ast/_spawn_cmd_redir_heredoc \
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,14 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */
|
/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/10/12 17:51:18 by rparodi ### ########.fr */
|
/* Updated: 2024/10/13 17:24:19 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "exec/builtins.h"
|
#include "exec/builtins.h"
|
||||||
#include "me/convert/str_to_numbers.h"
|
#include "me/convert/str_to_numbers.h"
|
||||||
#include "me/types.h"
|
#include "me/types.h"
|
||||||
|
#include "me/printf/printf.h"
|
||||||
|
|
||||||
t_error builtin_exit__(\
|
t_error builtin_exit__(\
|
||||||
t_state *state, t_builtin_spawn_info info, t_i32 *exit_code)
|
t_state *state, t_builtin_spawn_info info, t_i32 *exit_code)
|
||||||
|
|
@ -23,8 +24,10 @@ t_error builtin_exit__(\
|
||||||
if (info.args.len < 2)
|
if (info.args.len < 2)
|
||||||
actual_exit_code = 0;
|
actual_exit_code = 0;
|
||||||
else if (str_to_i32(info.args.buffer[1], 10, &actual_exit_code))
|
else if (str_to_i32(info.args.buffer[1], 10, &actual_exit_code))
|
||||||
return (\
|
{
|
||||||
printf("info.args.buffer[1] = %s\n", info.args.buffer[1]), ERROR);
|
me_printf_fd(info.stderr, "Error: invalid argument: not a number\n");
|
||||||
|
me_exit(2);
|
||||||
|
}
|
||||||
*exit_code = actual_exit_code;
|
*exit_code = actual_exit_code;
|
||||||
me_exit(actual_exit_code);
|
me_exit(actual_exit_code);
|
||||||
return (NO_ERROR);
|
return (NO_ERROR);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/07 14:13:41 by rparodi #+# #+# */
|
/* Created: 2024/08/07 14:13:41 by rparodi #+# #+# */
|
||||||
/* Updated: 2024/10/12 17:51:18 by rparodi ### ########.fr */
|
/* Updated: 2024/10/13 17:24:39 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -34,7 +34,7 @@ static void _assign_export(t_usize idx, t_str *arg, void *vctx)
|
||||||
ctx = vctx;
|
ctx = vctx;
|
||||||
first_eq = str_find_chr(*arg, '=');
|
first_eq = str_find_chr(*arg, '=');
|
||||||
if (first_eq == NULL || first_eq == *arg)
|
if (first_eq == NULL || first_eq == *arg)
|
||||||
return ;
|
hmap_env_insert(ctx->state->env, *arg, NULL);
|
||||||
key = str_substring(*arg, 0, first_eq - *arg);
|
key = str_substring(*arg, 0, first_eq - *arg);
|
||||||
value = str_substring(first_eq, 1, ~0llu);
|
value = str_substring(first_eq, 1, ~0llu);
|
||||||
if (hmap_env_insert(ctx->state->env, key, value))
|
if (hmap_env_insert(ctx->state->env, key, value))
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/07 13:58:37 by rparodi #+# #+# */
|
/* Created: 2024/08/07 13:58:37 by rparodi #+# #+# */
|
||||||
/* Updated: 2024/10/12 17:51:19 by rparodi ### ########.fr */
|
/* Updated: 2024/10/13 17:22:56 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -29,7 +29,7 @@ t_error builtin_pwd___(\
|
||||||
string_reserve(&s, s.capacity * 3);
|
string_reserve(&s, s.capacity * 3);
|
||||||
else
|
else
|
||||||
return (*exit_code = 1, string_free(s), me_printf_fd(\
|
return (*exit_code = 1, string_free(s), me_printf_fd(\
|
||||||
info.stderr, "cd: Unable to get current directory\n"), NO_ERROR);
|
info.stderr, "pwd: Unable to get current directory\n"), NO_ERROR);
|
||||||
}
|
}
|
||||||
me_printf_fd(info.stdout, "%s\n", s.buf);
|
me_printf_fd(info.stdout, "%s\n", s.buf);
|
||||||
string_free(s);
|
string_free(s);
|
||||||
|
|
|
||||||
|
|
@ -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/12 17:51:23 by rparodi ### ########.fr */
|
/* Updated: 2024/10/13 17:30:06 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ t_error _word_no_quote(t_state *state, t_word_result *res, t_vec_str *append)
|
||||||
return (NO_ERROR);
|
return (NO_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
t_error _word_do_quote(t_state *state, t_word_result *res, t_vec_str *append)
|
t_error _word_pass_quote(t_state *state, t_word_result *res, t_vec_str *append)
|
||||||
{
|
{
|
||||||
t_string tmp;
|
t_string tmp;
|
||||||
t_usize i;
|
t_usize i;
|
||||||
|
|
@ -66,12 +66,7 @@ t_error _word_into_str(t_ast_node self, t_state *state, t_vec_str *append)
|
||||||
return (_word_handle_star(&self->data.word, state, append));
|
return (_word_handle_star(&self->data.word, state, append));
|
||||||
if (run_word(&self->data.word, state, &res))
|
if (run_word(&self->data.word, state, &res))
|
||||||
return (ERROR);
|
return (ERROR);
|
||||||
if (res.kind == AST_WORD_NO_QUOTE)
|
if (_word_pass_quote(state, &res, append))
|
||||||
{
|
|
||||||
if (_word_no_quote(state, &res, append))
|
|
||||||
return (ERROR);
|
|
||||||
}
|
|
||||||
else if (_word_do_quote(state, &res, append))
|
|
||||||
return (ERROR);
|
return (ERROR);
|
||||||
return (vec_estr_free(res.value), NO_ERROR);
|
return (vec_estr_free(res.value), NO_ERROR);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,87 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* _ast_into_str6.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/09/14 12:26:51 by maiboyer #+# #+# */
|
|
||||||
/* Updated: 2024/10/12 17:51:22 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "exec/_run_ast.h"
|
|
||||||
#include "me/string/string.h"
|
|
||||||
#include "me/str/str.h"
|
|
||||||
#include "me/convert/numbers_to_str.h"
|
|
||||||
#include "me/vec/vec_str.h"
|
|
||||||
|
|
||||||
bool _word_is_star(t_ast_word *word);
|
|
||||||
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 _word_into_str_inner3(struct s_word_str_args args)
|
|
||||||
{
|
|
||||||
t_usize j;
|
|
||||||
t_usize len;
|
|
||||||
|
|
||||||
j = 0;
|
|
||||||
while (j + 1 < args.splitted->len)
|
|
||||||
{
|
|
||||||
if (vec_str_pop_front(args.splitted, args.tmp_str))
|
|
||||||
return (vec_estr_free(args.res->value), ERROR);
|
|
||||||
vec_str_push(args.append, *args.tmp_str);
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
len = str_len(args.res->value.buffer[args.i].value);
|
|
||||||
if (len != 0 && str_find_chr(args.ifs,
|
|
||||||
args.res->value.buffer[args.i].value[len - 1]) == NULL)
|
|
||||||
(string_push(args.tmp, *args.tmp_str), str_free(*args.tmp_str));
|
|
||||||
else
|
|
||||||
vec_str_push(args.append, *args.tmp_str);
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
t_error _word_into_str_inner2(struct s_word_str_args args)
|
|
||||||
{
|
|
||||||
t_str ifs;
|
|
||||||
t_str tmp_str;
|
|
||||||
t_vec_str splitted;
|
|
||||||
|
|
||||||
ifs = _get_ifs_value(args.state);
|
|
||||||
if (str_split(args.res->value.buffer[args.i].value, ifs, &splitted))
|
|
||||||
return (vec_estr_free(args.res->value), ERROR);
|
|
||||||
if (!vec_str_pop_front(&splitted, &tmp_str))
|
|
||||||
{
|
|
||||||
if (str_find_chr(ifs,
|
|
||||||
args.res->value.buffer[args.i].value[0]) == NULL)
|
|
||||||
(string_push(args.tmp, tmp_str), str_free(tmp_str));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vec_str_push(args.append, args.tmp->buf);
|
|
||||||
*args.tmp = string_new(64);
|
|
||||||
string_push(args.tmp, tmp_str);
|
|
||||||
str_free(tmp_str);
|
|
||||||
}
|
|
||||||
if (_word_into_str_inner3((struct s_word_str_args){args.i, args.state, \
|
|
||||||
args.tmp, args.res, args.append, &tmp_str, &splitted, ifs}))
|
|
||||||
return (ERROR);
|
|
||||||
}
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
t_error _word_into_str_inner(struct s_word_str_args args)
|
|
||||||
{
|
|
||||||
t_str ifs;
|
|
||||||
|
|
||||||
ifs = _get_ifs_value(args.state);
|
|
||||||
while (ifs != NULL && *ifs != '\0'
|
|
||||||
&& str_find_chr(args.res->value.buffer[args.i].value, *ifs) == NULL)
|
|
||||||
ifs++;
|
|
||||||
if (ifs == NULL || *ifs == '\0')
|
|
||||||
string_push(args.tmp, args.res->value.buffer[args.i].value);
|
|
||||||
else if (_word_into_str_inner2((struct s_word_str_args){args.i, \
|
|
||||||
args.state, args.tmp, args.res, args.append, NULL, NULL, NULL}))
|
|
||||||
return (ERROR);
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
|
|
@ -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/12 17:51:27 by rparodi ### ########.fr */
|
/* Updated: 2024/10/13 17:32:14 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "line/line.h"
|
#include "line/line.h"
|
||||||
#include "me/types.h"
|
#include "me/types.h"
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
t_error _redirection_fd(\
|
t_error _redirection_fd(\
|
||||||
t_spawn_info *info, t_state *state, t_ast_node red);
|
t_spawn_info *info, t_state *state, t_ast_node red);
|
||||||
|
|
@ -70,12 +71,12 @@ t_error _spawn_cmd_and_run_end(\
|
||||||
return (close_fd(cmd_pipe.input), out->exit = 127, ERROR);
|
return (close_fd(cmd_pipe.input), out->exit = 127, ERROR);
|
||||||
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);
|
||||||
if (waitpid(out->process.pid, &status, 0) == -1)
|
if (waitpid(out->process.pid, &status, 0) == -1 && errno != ESRCH)
|
||||||
return (ERROR);
|
return (ERROR);
|
||||||
if (WIFEXITED(status))
|
if (WIFEXITED(status))
|
||||||
out->exit = WEXITSTATUS(status);
|
out->exit = WEXITSTATUS(status);
|
||||||
if (WIFSIGNALED(status))
|
if (WIFSIGNALED(status))
|
||||||
out->exit = WTERMSIG(status);
|
out->exit = WTERMSIG(status) + 128;
|
||||||
state->last_exit = out->exit;
|
state->last_exit = out->exit;
|
||||||
return (NO_ERROR);
|
return (NO_ERROR);
|
||||||
}
|
}
|
||||||
|
|
@ -86,6 +87,8 @@ t_error _spawn_cmd_and_run(t_vec_str args, t_redirections redirs,
|
||||||
t_spawn_info info;
|
t_spawn_info info;
|
||||||
|
|
||||||
info = (t_spawn_info){};
|
info = (t_spawn_info){};
|
||||||
|
for (t_usize i = 0; i < args.len; i++)
|
||||||
|
printf("args[%zu] = %s\n", i, args.buffer[i]);
|
||||||
if (_setup_redirection(&info, state, redirs.cmd_pipe, &redirs.redirections))
|
if (_setup_redirection(&info, state, redirs.cmd_pipe, &redirs.redirections))
|
||||||
return (ERROR);
|
return (ERROR);
|
||||||
redirs.redirections.len = 0;
|
redirs.redirections.len = 0;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/09/14 12:35:02 by maiboyer #+# #+# */
|
/* Created: 2024/09/14 12:35:02 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/10/12 17:51:27 by rparodi ### ########.fr */
|
/* Updated: 2024/10/13 17:24:55 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
#include "me/mem/mem.h"
|
#include "me/mem/mem.h"
|
||||||
#include "me/os/os.h"
|
#include "me/os/os.h"
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
t_error _spawn_info_to_subshell(\
|
t_error _spawn_info_to_subshell(\
|
||||||
t_spawn_info *info, struct s_subshell_info *sinfo)
|
t_spawn_info *info, struct s_subshell_info *sinfo)
|
||||||
|
|
@ -75,13 +76,12 @@ t_error _wait_subshell(\
|
||||||
(dup2(sinfo.stderr->fd, 2), close_fd(sinfo.stderr));
|
(dup2(sinfo.stderr->fd, 2), close_fd(sinfo.stderr));
|
||||||
if (cmd_pipe.create_output || cmd_pipe.input != NULL)
|
if (cmd_pipe.create_output || cmd_pipe.input != NULL)
|
||||||
return (out->stdout = sinfo.ret_stdout, NO_ERROR);
|
return (out->stdout = sinfo.ret_stdout, NO_ERROR);
|
||||||
if (waitpid(forked, &status, 0) == -1)
|
if (waitpid(forked, &status, 0) == -1 && errno != ESRCH)
|
||||||
return (ERROR);
|
return (ERROR);
|
||||||
if (WIFEXITED(status))
|
if (WIFEXITED(status))
|
||||||
out->exit = WEXITSTATUS(status);
|
out->exit = WEXITSTATUS(status);
|
||||||
if (WIFSIGNALED(status))
|
if (WIFSIGNALED(status))
|
||||||
out->exit = WTERMSIG(status);
|
out->exit = WTERMSIG(status) + 130;
|
||||||
printf("out->exit for subshell is %i\n", out->exit);
|
|
||||||
sinfo.state->last_exit = out->exit;
|
sinfo.state->last_exit = out->exit;
|
||||||
return (NO_ERROR);
|
return (NO_ERROR);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@ SRC_FILES = \
|
||||||
line \
|
line \
|
||||||
line_edit_actions \
|
line_edit_actions \
|
||||||
line_edit_actions2 \
|
line_edit_actions2 \
|
||||||
line_editing \
|
|
||||||
line_editing2 \
|
|
||||||
line_edit_mode \
|
line_edit_mode \
|
||||||
line_edit_mode_interal \
|
line_edit_mode_interal \
|
||||||
line_edit_mode_specific_key \
|
line_edit_mode_specific_key \
|
||||||
|
line_editing \
|
||||||
|
line_editing2 \
|
||||||
line_globals \
|
line_globals \
|
||||||
line_history \
|
line_history \
|
||||||
line_internals \
|
line_internals \
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@ passes/paren_to_nquote \
|
||||||
passes/remove_whitespace \
|
passes/remove_whitespace \
|
||||||
passes/split_double_paren \
|
passes/split_double_paren \
|
||||||
passes/verify_invalid_tokens \
|
passes/verify_invalid_tokens \
|
||||||
tokenizer \
|
|
||||||
tokenizer_utils \
|
|
||||||
token_lifetime \
|
token_lifetime \
|
||||||
token_name \
|
token_name \
|
||||||
token_utils \
|
token_utils \
|
||||||
|
tokenizer \
|
||||||
|
tokenizer_utils \
|
||||||
ts_print \
|
ts_print \
|
||||||
yard/yard \
|
yard/yard \
|
||||||
yard/yard_cmd \
|
yard/yard_cmd \
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,10 @@ fs/fs_internal \
|
||||||
fs/getters \
|
fs/getters \
|
||||||
fs/putfd \
|
fs/putfd \
|
||||||
gnl/get_next_line \
|
gnl/get_next_line \
|
||||||
hash/hasher \
|
|
||||||
hash/hash_signed \
|
hash/hash_signed \
|
||||||
hash/hash_str \
|
hash/hash_str \
|
||||||
hash/hash_unsigned \
|
hash/hash_unsigned \
|
||||||
|
hash/hasher \
|
||||||
hash/sip/sip13 \
|
hash/sip/sip13 \
|
||||||
hash/sip/sip_utils \
|
hash/sip/sip_utils \
|
||||||
hash/sip/sip_utils2 \
|
hash/sip/sip_utils2 \
|
||||||
|
|
@ -69,10 +69,6 @@ printf/printf \
|
||||||
printf/printf_fd \
|
printf/printf_fd \
|
||||||
printf/printf_str \
|
printf/printf_str \
|
||||||
printf/vprintf \
|
printf/vprintf \
|
||||||
string/mod \
|
|
||||||
string/string_insert \
|
|
||||||
string/string_remove \
|
|
||||||
string/string_reserve \
|
|
||||||
str/str_clone \
|
str/str_clone \
|
||||||
str/str_compare \
|
str/str_compare \
|
||||||
str/str_find_chr \
|
str/str_find_chr \
|
||||||
|
|
@ -89,6 +85,10 @@ str/str_n_find_str \
|
||||||
str/str_split \
|
str/str_split \
|
||||||
str/str_substring \
|
str/str_substring \
|
||||||
str/str_trim \
|
str/str_trim \
|
||||||
|
string/mod \
|
||||||
|
string/string_insert \
|
||||||
|
string/string_remove \
|
||||||
|
string/string_reserve \
|
||||||
|
|
||||||
GEN_FILES = \
|
GEN_FILES = \
|
||||||
convert/i16_to_str \
|
convert/i16_to_str \
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/07/07 18:01:52 by maiboyer #+# #+# */
|
/* Created: 2024/07/07 18:01:52 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/10/12 17:52:39 by rparodi ### ########.fr */
|
/* Updated: 2024/10/13 17:35:46 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
#include "me/printf/_internal_printf.h"
|
#include "me/printf/_internal_printf.h"
|
||||||
#include "me/string/string.h"
|
#include "me/string/string.h"
|
||||||
#include "me/types.h"
|
#include "me/types.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
void me_printf_append_string(t_const_str to_write, t_usize to_write_len,
|
void me_printf_append_string(t_const_str to_write, t_usize to_write_len,
|
||||||
void *p_args)
|
void *p_args)
|
||||||
|
|
@ -31,6 +32,6 @@ void me_printf_write(t_const_str to_write, \
|
||||||
t_fprintf_arg *arg;
|
t_fprintf_arg *arg;
|
||||||
|
|
||||||
arg = (t_fprintf_arg *)p_args;
|
arg = (t_fprintf_arg *)p_args;
|
||||||
write_fd(arg->fd, (t_u8 *)to_write, to_write_len, NULL);
|
(write_fd(arg->fd, (t_u8 *)to_write, to_write_len, NULL));
|
||||||
arg->total_print += to_write_len;
|
arg->total_print += to_write_len;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/07/05 19:55:09 by maiboyer #+# #+# */
|
/* Created: 2024/07/05 19:55:09 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/10/12 17:52:43 by rparodi ### ########.fr */
|
/* Updated: 2024/10/13 17:42:02 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -18,13 +18,18 @@
|
||||||
|
|
||||||
t_usize me_vprintf_fd(t_fd *fd, t_const_str fmt, va_list *args)
|
t_usize me_vprintf_fd(t_fd *fd, t_const_str fmt, va_list *args)
|
||||||
{
|
{
|
||||||
t_fprintf_arg passthru;
|
t_sprintf_arg passthru;
|
||||||
|
t_string buf;
|
||||||
|
|
||||||
if (fd == NULL || fmt == NULL || args == NULL)
|
if (fd == NULL || fmt == NULL || args == NULL)
|
||||||
return (0);
|
return (0);
|
||||||
passthru.fd = fd;
|
buf = string_new(16);
|
||||||
|
passthru.buffer = &buf;
|
||||||
passthru.total_print = 0;
|
passthru.total_print = 0;
|
||||||
me_printf_str_inner(fmt, &me_printf_write, args, (void *)&passthru);
|
me_printf_str_inner(fmt, &me_printf_append_string, args, (void *)&passthru);
|
||||||
|
if (write_fd(fd, (void *)buf.buf, buf.len, NULL))
|
||||||
|
perror("write");
|
||||||
|
string_free(buf);
|
||||||
return (passthru.total_print);
|
return (passthru.total_print);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/09 14:57:28 by maiboyer #+# #+# */
|
/* Created: 2024/02/09 14:57:28 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/10/12 17:52:44 by rparodi ### ########.fr */
|
/* Updated: 2024/10/13 17:41:28 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue