fix invalid read/leaks completion
This commit is contained in:
parent
c8867156c8
commit
5b27418ead
5 changed files with 22 additions and 14 deletions
|
|
@ -6,14 +6,14 @@
|
||||||
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
|
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2016/08/29 21:32:58 by wescande #+# #+# #
|
# Created: 2016/08/29 21:32:58 by wescande #+# #+# #
|
||||||
# Updated: 2017/03/18 14:17:54 by gwojda ### ########.fr #
|
# Updated: 2017/03/19 15:14:11 by gwojda ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
NAME = 42sh
|
NAME = 42sh
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
FLAGS = -Wall -Wextra -Werror -fvisibility=hidden
|
FLAGS = -Wall -Wextra -Werror -g
|
||||||
D_FLAGS = -g
|
D_FLAGS = -g
|
||||||
|
|
||||||
DELTA = $$(echo "$$(tput cols)-47"|bc)
|
DELTA = $$(echo "$$(tput cols)-47"|bc)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/09 16:54:59 by gwojda #+# #+# */
|
/* Created: 2017/03/09 16:54:59 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/18 14:04:24 by gwojda ### ########.fr */
|
/* Updated: 2017/03/19 15:22:06 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -24,6 +24,8 @@ void c_seek_abs_path(t_comp *c, char *current_word)
|
||||||
len = ft_strrchr(c->rcmd, '/') - current_word + 1;
|
len = ft_strrchr(c->rcmd, '/') - current_word + 1;
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
return ;
|
return ;
|
||||||
|
if (c->cpath)
|
||||||
|
ft_strdel(&c->cpath);
|
||||||
c->cpath = ft_strndup(current_word, len);
|
c->cpath = ft_strndup(current_word, len);
|
||||||
if (current_word[0] == '~')
|
if (current_word[0] == '~')
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/10/15 13:27:14 by alao #+# #+# */
|
/* Created: 2016/10/15 13:27:14 by alao #+# #+# */
|
||||||
/* Updated: 2017/03/16 10:20:44 by gwojda ### ########.fr */
|
/* Updated: 2017/03/19 15:34:38 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -21,6 +21,8 @@ static int c_chevron(t_comp *c)
|
||||||
size_t pos;
|
size_t pos;
|
||||||
|
|
||||||
pos = c->ircmd;
|
pos = c->ircmd;
|
||||||
|
if (pos >= ft_strlen(c->rcmd))
|
||||||
|
pos = ft_strlen(c->rcmd) - (ft_strlen(data_singleton()->line.input) - pos);
|
||||||
while (pos)
|
while (pos)
|
||||||
{
|
{
|
||||||
if (c->rcmd[pos] == '<' || c->rcmd[pos] == '>')
|
if (c->rcmd[pos] == '<' || c->rcmd[pos] == '>')
|
||||||
|
|
@ -38,9 +40,12 @@ static int c_chevron(t_comp *c)
|
||||||
|
|
||||||
static char *c_current_words(t_comp *c)
|
static char *c_current_words(t_comp *c)
|
||||||
{
|
{
|
||||||
int pos;
|
size_t pos;
|
||||||
|
|
||||||
pos = c->ircmd;
|
pos = c->ircmd;
|
||||||
|
if (pos >= ft_strlen(c->rcmd))
|
||||||
|
pos = ft_strlen(c->rcmd) -
|
||||||
|
(ft_strlen(data_singleton()->line.input) - pos + 1);
|
||||||
while (pos && c->rcmd[pos] != ' ')
|
while (pos && c->rcmd[pos] != ' ')
|
||||||
--pos;
|
--pos;
|
||||||
if (c->rcmd[pos] == ' ')
|
if (c->rcmd[pos] == ' ')
|
||||||
|
|
@ -57,6 +62,7 @@ int c_matching(t_data *s, t_comp *c)
|
||||||
char *current_word;
|
char *current_word;
|
||||||
|
|
||||||
current_word = c_current_words(c);
|
current_word = c_current_words(c);
|
||||||
|
DG("current_word = %s", current_word);
|
||||||
if (ft_strchr(c->rcmd, '/'))
|
if (ft_strchr(c->rcmd, '/'))
|
||||||
c_seek_abs_path(c, current_word);
|
c_seek_abs_path(c, current_word);
|
||||||
else if (ft_strchr(c->rcmd, '$'))
|
else if (ft_strchr(c->rcmd, '$'))
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/15 12:03:30 by alao #+# #+# */
|
/* Created: 2017/02/15 12:03:30 by alao #+# #+# */
|
||||||
/* Updated: 2017/03/17 12:03:26 by gwojda ### ########.fr */
|
/* Updated: 2017/03/19 15:28:50 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/03 13:10:38 by alao #+# #+# */
|
/* Created: 2017/02/03 13:10:38 by alao #+# #+# */
|
||||||
/* Updated: 2017/03/17 16:48:49 by gwojda ### ########.fr */
|
/* Updated: 2017/03/19 15:18:55 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -105,12 +105,6 @@ int c_keypress(t_comp *c, long int key)
|
||||||
{
|
{
|
||||||
t_clst *ptr;
|
t_clst *ptr;
|
||||||
|
|
||||||
if (key == 27 || key == 127 || key == 2117294875)
|
|
||||||
{
|
|
||||||
c_term_clear(c);
|
|
||||||
c_clear(data_singleton());
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
if (key == 10 || key == 32)
|
if (key == 10 || key == 32)
|
||||||
{
|
{
|
||||||
ptr = c->lst;
|
ptr = c->lst;
|
||||||
|
|
@ -119,10 +113,16 @@ int c_keypress(t_comp *c, long int key)
|
||||||
c_updater(c, ptr->name);
|
c_updater(c, ptr->name);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
if (key == KP_U || key == KP_D || key == KP_L || key == KP_R)
|
else if (key == KP_U || key == KP_D || key == KP_L || key == KP_R)
|
||||||
{
|
{
|
||||||
c_arrow(c, key);
|
c_arrow(c, key);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
else if (!ft_isprint(key))
|
||||||
|
{
|
||||||
|
c_term_clear(c);
|
||||||
|
c_clear(data_singleton());
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
return ((c_rematch(c, key)) ? (0) : (1));
|
return ((c_rematch(c, key)) ? (0) : (1));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue