diff options
author | salad <fmoenne-@student.le-101.fr> | 2020-12-16 13:46:31 +0100 |
---|---|---|
committer | salad <fmoenne-@student.le-101.fr> | 2020-12-16 13:46:31 +0100 |
commit | b96c18b5a12dc3f581ee0050aa48b2b3d7df26ec (patch) | |
tree | 5871c8a1555aa107a00b6a7e7d98210f263d6e3f /src/c_init.c | |
parent | c_keys_next is now c_utils_next (diff) | |
download | 42-minishell-b96c18b5a12dc3f581ee0050aa48b2b3d7df26ec.tar.gz 42-minishell-b96c18b5a12dc3f581ee0050aa48b2b3d7df26ec.tar.bz2 42-minishell-b96c18b5a12dc3f581ee0050aa48b2b3d7df26ec.tar.xz 42-minishell-b96c18b5a12dc3f581ee0050aa48b2b3d7df26ec.tar.zst 42-minishell-b96c18b5a12dc3f581ee0050aa48b2b3d7df26ec.zip |
check for leaks.......again
Diffstat (limited to 'src/c_init.c')
-rw-r--r-- | src/c_init.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/c_init.c b/src/c_init.c index 0001660..59cb5fa 100644 --- a/src/c_init.c +++ b/src/c_init.c @@ -116,28 +116,18 @@ char return (p); } -/* TODO : key_up_down should manage and set the correct key */ - static char *c_process_key(char **line, char *buf, t_caps *tcaps, t_msh *msh) { - char *ptr; - if (ft_isprint(buf[0])) 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); - } - else if (((*((unsigned int *)buf)) == DOWN_K) || + ((*((unsigned int *)buf)) == CTRL_P) || + ((*((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); + tcaps->key = c_set_key(buf); + c_key_up_down(line, tcaps, msh); } else if ((*((unsigned int *)buf)) == DEL_K) { @@ -167,6 +157,8 @@ short msh->sig = 0; tcaps.plen = (unsigned int)m_plen(msh->ps[psx - 1]); *line = NULL; + if (!(*line = ft_calloc(sizeof(char), 1))) + return (-1); if (!(c_get_win_size(&tcaps.ws))) return (-1); while (!(ft_strchr(nread, '\n'))) |