summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsalad <fmoenne-@student.le-101.fr>2020-12-15 14:17:51 +0100
committersalad <fmoenne-@student.le-101.fr>2020-12-15 14:17:51 +0100
commit93f307f99188bdba8dc783abb8627d0abb5b871d (patch)
treef0382b1338aec133f76f7d6e5bd84db3ef0d13f3 /src
parentonto something (diff)
download42-minishell-93f307f99188bdba8dc783abb8627d0abb5b871d.tar.gz
42-minishell-93f307f99188bdba8dc783abb8627d0abb5b871d.tar.bz2
42-minishell-93f307f99188bdba8dc783abb8627d0abb5b871d.tar.xz
42-minishell-93f307f99188bdba8dc783abb8627d0abb5b871d.tar.zst
42-minishell-93f307f99188bdba8dc783abb8627d0abb5b871d.zip
noleak ????????????????
Diffstat (limited to 'src')
-rw-r--r--src/c_init.c28
-rw-r--r--src/c_utils.c11
2 files changed, 20 insertions, 19 deletions
diff --git a/src/c_init.c b/src/c_init.c
index b1e9fb2..7fb530f 100644
--- a/src/c_init.c
+++ b/src/c_init.c
@@ -185,45 +185,44 @@ static void
static char
*c_process_key(char **line, char *buf, t_caps *tcaps, t_msh *msh)
{
- static char *line = NULL;
char *ptr;
- if (line == NULL || line == (void*)0x1)
+ if (*line == NULL)
{
- if (!(line = calloc(1, sizeof(char))))
+ if (!(*line = calloc(1, sizeof(char))))
return (NULL);
}
if (ft_isprint(buf[0]))
- c_add_char(&line, buf, tcaps);
+ c_add_char(line, buf, tcaps);
else if (((*((unsigned int *)buf)) == UP_K) ||
((*((unsigned int *)buf)) == CTRL_P))
{
ptr = c_set_ptr(FALSE, -1, msh);
- c_key_up_down(&line, tcaps, ptr);
- c_redraw_line(line, tcaps);
+ c_key_up_down(line, tcaps, ptr);
+ c_redraw_line(*line, tcaps);
}
else if (((*((unsigned int *)buf)) == DOWN_K) ||
((*((unsigned int *)buf)) == CTRL_N))
{
ptr = c_set_ptr(FALSE, 1, msh);
- c_key_up_down(&line, tcaps, ptr);
- c_redraw_line(line, tcaps);
+ c_key_up_down(line, tcaps, ptr);
+ c_redraw_line(*line, tcaps);
}
else if ((*((unsigned int *)buf)) == DEL_K)
{
- c_back_slash(&line, tcaps->plen, tcaps);
+ c_back_slash(line, tcaps->plen, tcaps);
if ((((tcaps->cpos) + tcaps->plen) %
tcaps->ws.ws_col) == 0)
{
return (NULL);
}
- c_redraw_line(line, tcaps);
+ c_redraw_line(*line, tcaps);
}
else if ((*((unsigned int *)buf)) == CTRL_C)
- return (c_ctrl_c(&line, buf, msh));
+ return (c_ctrl_c(line, buf, msh));
else
- c_read_cap(buf, line, tcaps, msh);
- return ((buf[0] == '\n') ? c_new_line(line, tcaps) : NULL);
+ c_read_cap(buf, *line, tcaps, msh);
+ return ((buf[0] == '\n') ? c_new_line(*line, tcaps) : NULL);
}
short
@@ -238,6 +237,7 @@ short
ft_bzero(nread, 4);
msh->sig = 0;
tcaps.plen = (unsigned int)m_plen(msh->ps[psx - 1]);
+ *line = NULL;
if (!(c_get_win_size(&tcaps.ws)))
return (-1);
while (!(ft_strchr(nread, '\n')))
@@ -246,7 +246,7 @@ short
if (!(read(fd, nread, 3)))
return (0);
else
- *line = c_process_key(nread, &tcaps, msh);
+ c_process_key(line, nread, &tcaps, msh);
tputs(tgetstr("ve", NULL), 1, ft_putchar);
}
return (1);
diff --git a/src/c_utils.c b/src/c_utils.c
index 048b845..f5e66fe 100644
--- a/src/c_utils.c
+++ b/src/c_utils.c
@@ -32,11 +32,12 @@ char
write(1, "\n", 1);
tputs(tgetstr("cr", NULL), 1, ft_putchar);
c_set_term_raw(0);
- if (line != NULL)
- {
- ret = ft_strdup(line);
- *line = '\0';
- }
+ (void)line;
+ /* if (line != NULL) */
+ /* { */
+ /* ret = ft_strdup(line); */
+ /* *line = '\0'; */
+ /* } */
tcaps->cpos = 0;
tputs(tgetstr("cr", NULL), 1, ft_putchar);
if (i < tcaps->nlines && tcaps->nlines != 1)