summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsalad <fmoenne-@student.le-101.fr>2020-09-30 18:34:32 +0200
committersalad <fmoenne-@student.le-101.fr>2020-09-30 18:34:32 +0200
commitafa9544b6c00285dd2f77bb1e852d8f0e95d42b6 (patch)
tree96f6194e4667540525911cba051a01001918ee0b /src
parentgnl grand remplacment (diff)
download42-minishell-afa9544b6c00285dd2f77bb1e852d8f0e95d42b6.tar.gz
42-minishell-afa9544b6c00285dd2f77bb1e852d8f0e95d42b6.tar.bz2
42-minishell-afa9544b6c00285dd2f77bb1e852d8f0e95d42b6.tar.xz
42-minishell-afa9544b6c00285dd2f77bb1e852d8f0e95d42b6.tar.zst
42-minishell-afa9544b6c00285dd2f77bb1e852d8f0e95d42b6.zip
call a plumber
Diffstat (limited to 'src')
-rw-r--r--src/c_init.c17
-rw-r--r--src/c_input.c2
-rw-r--r--src/c_utils.c21
-rw-r--r--src/c_utils.h2
4 files changed, 22 insertions, 20 deletions
diff --git a/src/c_init.c b/src/c_init.c
index d78a8f2..d50daf4 100644
--- a/src/c_init.c
+++ b/src/c_init.c
@@ -91,9 +91,11 @@ char
int i;
i = -1;
- if (line == NULL)
+ if (line == NULL || line[0] == '\0')
+ {
if (!(line = ft_calloc(1, sizeof(char))))
return (NULL);
+ }
if (ft_isprint(buf[0]))
{
line = c_insert_char(line, buf[0], tcaps);
@@ -104,11 +106,15 @@ char
{
c_back_slash(&line, ft_strlen(msh->ps[0]), tcaps);
}
+ else if (buf[0] == '\n')
+ {
+ return (c_new_line(line, tcaps, msh));
+ }
else
{
c_read_cap(buf, line, tcaps, msh);
}
- return (ft_strdup(line));
+ return (line);
}
int16_t
@@ -128,7 +134,7 @@ int16_t
tputs(tgetstr("cr", NULL), 1, ft_putchar);
m_prompt_psx(1, msh);
signal(SIGINT, SIG_IGN);
- ft_bzero(nread, 5);
+ ft_bzero(nread, 5);
if (!(c_get_win_size(&tcaps.ws)))
return (-1);
while (!(ft_strchr(nread, '\n')))
@@ -138,11 +144,6 @@ int16_t
return (0);
else
*line = c_process_key(nread, &tcaps, msh);
- if (*line == NULL)
- {
- ft_printf("FUCK");
- return (0);
- }
tputs(tgetstr("ve", NULL), 1, ft_putchar);
}
return (1);
diff --git a/src/c_input.c b/src/c_input.c
index 10451bc..7c6d351 100644
--- a/src/c_input.c
+++ b/src/c_input.c
@@ -105,6 +105,6 @@ int16_t
(void)tcaps;
(void)line;
msh->ret = 130;
- c_new_line(NULL, msh, tcaps);
+ c_new_line(NULL, tcaps, msh);
return (1);
}
diff --git a/src/c_utils.c b/src/c_utils.c
index 8bc940e..78b923a 100644
--- a/src/c_utils.c
+++ b/src/c_utils.c
@@ -30,25 +30,26 @@
** C-c globul pid
*/
-int16_t
- c_new_line(char *line,
- t_msh *msh,
- t_caps *tcaps)
+char
+ *c_new_line(char *line,
+ t_caps *tcaps,
+ t_msh *msh)
{
+ char *ret;
+
+ (void)msh;
+ ret = NULL;
write(1, "\n", 1);
tputs(tgetstr("cr", NULL), 1, ft_putchar);
c_set_term_raw(0);
if (line != NULL)
{
- m_parse_and_run_line(line, msh);
- line = NULL;
- free(line);
+ ret = ft_strdup(line);
+ line[0] = '\0';
}
tcaps->cpos = 0;
tputs(tgetstr("cr", NULL), 1, ft_putchar);
- c_set_term_raw(1);
- m_prompt_psx(1, msh);
- return (1);
+ return (ret);
}
char
diff --git a/src/c_utils.h b/src/c_utils.h
index 9680b90..e6410a3 100644
--- a/src/c_utils.h
+++ b/src/c_utils.h
@@ -15,7 +15,7 @@
#include "s_struct.h"
-int16_t c_new_line(char *line, t_msh *msh, t_caps *tcaps);
+char *c_new_line(char *line, t_caps *tcaps, t_msh *msh);
char *c_insert_char(char *str, char c, t_caps *tcaps);
char *c_delchar(char *str, uint16_t cpos);
int16_t c_redraw_line(char *line, t_caps *tcaps, t_msh *msh);