summaryrefslogtreecommitdiffstats
path: root/src/b_h.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-09-16 21:09:14 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-09-16 21:09:14 +0200
commitc8ba75c31c949d3b5e5ba44e389550ea10096c5d (patch)
tree3fd61cd13f2ba9452c49cc9b48449c2458580454 /src/b_h.c
parentTodo update (diff)
download42-minishell-c8ba75c31c949d3b5e5ba44e389550ea10096c5d.tar.gz
42-minishell-c8ba75c31c949d3b5e5ba44e389550ea10096c5d.tar.bz2
42-minishell-c8ba75c31c949d3b5e5ba44e389550ea10096c5d.tar.xz
42-minishell-c8ba75c31c949d3b5e5ba44e389550ea10096c5d.tar.zst
42-minishell-c8ba75c31c949d3b5e5ba44e389550ea10096c5d.zip
Leak fix
Diffstat (limited to '')
-rw-r--r--src/b_h.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/b_h.c b/src/b_h.c
index c669fa6..3acee67 100644
--- a/src/b_h.c
+++ b/src/b_h.c
@@ -12,22 +12,43 @@
#include <libft.h>
#include <stdint.h>
+#include <stddef.h>
#include <unistd.h>
#include "d_define.h"
+#include "f_fail.h"
#include "s_struct.h"
#include "u_utils.h"
-static void b_print_history_number(const char arg[])
+static void b_print_history(const char arg[], t_msh *msh)
{
+ char *prev_hist;
+ char *tok;
+ uint32_t i;
+
(void)arg;
+ i = 1;
+ if (msh->prev_hist != NULL)
+ {
+ if ((prev_hist = ft_strdup(msh->prev_hist)) == NULL)
+ return ;
+ tok = ft_strtok(prev_hist, "\n");
+ ft_printf("qwqwe\n");
+ while (tok != NULL)
+ {
+ ft_printf("%-5u %s\n", i, tok);
+ i++;
+ tok = ft_strtok(NULL, "\n");
+ }
+ ft_memdel((void*)&prev_hist);
+ }
}
static t_bool b_check_numeric(const char arg[])
{
char *ptr;
- ptr = arg;
+ ptr = (char*)arg;
while (*ptr != C_NUL)
{
if (ft_isdigit(*ptr) == FALSE)
@@ -57,7 +78,7 @@ uint8_t b_h(char *args[], t_msh *msh)
}
else
{
- b_print_history(*args);
+ b_print_history(*args, msh);
}
return (0);
}