diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-10-05 16:11:54 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-10-05 16:11:54 +0200 |
commit | ffd4838e8fbaafa80945bcbd74c0dea3ae53105b (patch) | |
tree | f2e35e4a7a6c219d584ed54b2d0580a9e3f7c934 | |
parent | TODO update (diff) | |
download | 42-minishell-ffd4838e8fbaafa80945bcbd74c0dea3ae53105b.tar.gz 42-minishell-ffd4838e8fbaafa80945bcbd74c0dea3ae53105b.tar.bz2 42-minishell-ffd4838e8fbaafa80945bcbd74c0dea3ae53105b.tar.xz 42-minishell-ffd4838e8fbaafa80945bcbd74c0dea3ae53105b.tar.zst 42-minishell-ffd4838e8fbaafa80945bcbd74c0dea3ae53105b.zip |
Fix
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | src/b_exit.c | 4 | ||||
-rw-r--r-- | src/b_h.c | 4 | ||||
-rw-r--r-- | src/e_builtins.c | 2 | ||||
-rw-r--r-- | src/m_loop.c | 2 | ||||
-rw-r--r-- | src/m_loop.h | 2 | ||||
-rw-r--r-- | src/s_struct.h | 2 |
7 files changed, 11 insertions, 7 deletions
@@ -1,4 +1,4 @@ -default: debug +default: asan #==============================================================================# #--------------------------------- SHELL --------------------------------------# #==============================================================================# diff --git a/src/b_exit.c b/src/b_exit.c index 3aef1c1..113313d 100644 --- a/src/b_exit.c +++ b/src/b_exit.c @@ -21,6 +21,10 @@ #include "s_struct.h" #include "u_utils.h" +/* +** TODO: handle non-numeric args[0] +*/ + uint8_t b_exit(char *args[], t_msh *msh) { uint8_t ret; @@ -36,7 +36,7 @@ static uint64_t b_get_total_hist(t_msh *msh) ptr++; } } - ptr = msh->curr_hist; + ptr = msh->curr_hist_ptr; while (*ptr != C_NUL) { if (*ptr == C_LF) @@ -81,7 +81,7 @@ static void b_print_history(uint64_t asked, uint64_t total, t_msh *msh) to_print = (total - asked < 0) ? (0) : (total - asked); i = b_print_prev_history(asked, total, msh); - if ((hist = ft_strdup(msh->curr_hist)) == NULL) + if ((hist = ft_strdup(msh->curr_hist_ptr)) == NULL) return ; tok = ft_strtok(hist, "\n"); while (tok != NULL) diff --git a/src/e_builtins.c b/src/e_builtins.c index 734a317..d08cf63 100644 --- a/src/e_builtins.c +++ b/src/e_builtins.c @@ -81,7 +81,7 @@ static void e_builtin_parent(pid_t pid, else if (bu_id == B_ID_EXIT) { if (msh->fd == STDIN_FILENO) - m_dump_hist(msh); + m_dump_hist(msh->curr_hist_ptr, msh); s_com_destroy(&msh->com); s_line_clear(&msh->curr); s_destroy(msh); diff --git a/src/m_loop.c b/src/m_loop.c index 76ed6e0..ac3ca12 100644 --- a/src/m_loop.c +++ b/src/m_loop.c @@ -125,7 +125,7 @@ uint8_t m_loop(int32_t fd, t_msh *msh) int8_t gnl; gnl = 1; - msh->curr_hist = hist; + msh->curr_hist_ptr = hist; while (gnl > 0) { if (fd == STDIN_FILENO) diff --git a/src/m_loop.h b/src/m_loop.h index 8f28977..1920c41 100644 --- a/src/m_loop.h +++ b/src/m_loop.h @@ -17,7 +17,7 @@ # include "s_struct.h" -void m_dump_hist(t_msh *msh); +void m_dump_hist(char hist[], t_msh *msh); uint8_t m_loop(int32_t fd, t_msh *msh); #endif diff --git a/src/s_struct.h b/src/s_struct.h index cb44d1a..c4ffffe 100644 --- a/src/s_struct.h +++ b/src/s_struct.h @@ -93,7 +93,7 @@ typedef struct s_msh char **argv; char **envp; char *prev_hist; - char *curr_hist; + char *curr_hist_ptr; char ps[4][255]; char env_fork_tmp[128][4096]; char sqb_ref[B_ID_SQB_COUNT][4]; |