diff --git a/42sh/Makefile b/42sh/Makefile index 15ff6d83..b20dd88f 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -13,7 +13,7 @@ NAME = 42sh CC = gcc -FLAGS = -Wall -Wextra -Werror -g +FLAGS = -Wall -Wextra -Werror D_FLAGS = -g DELTA = $$(echo "$$(tput cols)-47"|bc) diff --git a/42sh/src/line-editing/get_touch.c b/42sh/src/line-editing/get_touch.c index eec81a25..14d09512 100644 --- a/42sh/src/line-editing/get_touch.c +++ b/42sh/src/line-editing/get_touch.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/19 16:28:49 by gwojda #+# #+# */ -/* Updated: 2017/02/02 10:38:58 by gwojda ### ########.fr */ +/* Updated: 2017/02/02 11:34:22 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,9 +18,9 @@ static int ft_lecture_3(int ret, char **str, size_t *i) ft_suppr(str, i); else if (ret == TOUCHE_DELETE && (*str) && (*i) < ft_strlen((*str))) ft_del(str, i); - else if (ret == TOUCHE_HOME && *str) + else if (ret == TOUCHE_HOME) ft_home(*str, i); - else if (ret == TOUCHE_END && *str) + else if (ret == TOUCHE_END) ft_end(*str, i); else return (0); diff --git a/42sh/src/line-editing/get_touch_toolz.c b/42sh/src/line-editing/get_touch_toolz.c index beae3600..ae54f960 100644 --- a/42sh/src/line-editing/get_touch_toolz.c +++ b/42sh/src/line-editing/get_touch_toolz.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/19 16:42:54 by gwojda #+# #+# */ -/* Updated: 2017/02/01 16:45:22 by gwojda ### ########.fr */ +/* Updated: 2017/02/02 11:41:52 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,8 +18,10 @@ void ft_history_2(char **str, int ret, t_list_history **head if (*str) { if (*pos) + { --(*pos); - ft_get_beggin_with_curs(*str, pos); + ft_get_beggin_with_curs(*str, pos); + } ft_puttermcaps("cd"); *pos = 0; ft_strdel(str); diff --git a/42sh/src/line-editing/get_touch_toolz_2.c b/42sh/src/line-editing/get_touch_toolz_2.c index ad7d2372..d7c6b2e4 100644 --- a/42sh/src/line-editing/get_touch_toolz_2.c +++ b/42sh/src/line-editing/get_touch_toolz_2.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/19 16:43:58 by gwojda #+# #+# */ -/* Updated: 2017/02/01 15:29:20 by gwojda ### ########.fr */ +/* Updated: 2017/02/02 11:34:34 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,6 +20,8 @@ int ft_put(int nb) void ft_end(char *str, size_t *pos) { + if (!str) + return ; if (*pos) { --(*pos); @@ -35,6 +37,8 @@ void ft_end(char *str, size_t *pos) void ft_home(char *str, size_t *pos) { + if (!str) + return ; if (*pos) { --(*pos); diff --git a/42sh/src/line-editing/toolz_parseur.c b/42sh/src/line-editing/toolz_parseur.c index 50f2c532..adc6b90b 100644 --- a/42sh/src/line-editing/toolz_parseur.c +++ b/42sh/src/line-editing/toolz_parseur.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/16 16:14:46 by gwojda #+# #+# */ -/* Updated: 2017/02/02 11:01:10 by gwojda ### ########.fr */ +/* Updated: 2017/02/02 11:46:55 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -69,10 +69,11 @@ void ft_found_prev_word(char *str, size_t *pos) } (*pos) = (i && str[*pos - i] == '\n') ? *pos - i + 1 : *pos - i; i = 0; - if (str[*pos - 1] == '\n') + if (*pos >= 1 && str[*pos - 1] == '\n') { ft_puttermcaps("cd"); - (*pos) -= 2; + if (*pos >= 2) + (*pos) -= 2; ft_get_beggin(str, pos); ft_current_str(str, *pos); ft_get_next_str(str, pos); @@ -80,12 +81,12 @@ void ft_found_prev_word(char *str, size_t *pos) } else { - if (!(str[*pos] == '\n' || str[*pos] == ' ')) + if (*pos && !(str[*pos] == '\n' || str[*pos] == ' ')) { ft_puttermcaps("le"); --(*pos); } - while (str[*pos - i] == '\n' || str[*pos - i] == ' ') + while (*pos - i && (str[*pos - i] == '\n' || str[*pos - i] == ' ')) { ft_puttermcaps("le"); ++i; @@ -123,7 +124,7 @@ void ft_found_next_word(char *str, size_t *pos) } ft_puttermcaps("cd"); ft_get_next_str(str, pos); - (*pos) += 2; + (*pos) += (*pos) ? 2 : 1; ft_current_str(str, *pos); ft_get_next_str(str, pos); if (!str[*pos])