diff --git a/42sh/src/history/history.c b/42sh/src/history/history.c index 29fa0548..48be8f6f 100644 --- a/42sh/src/history/history.c +++ b/42sh/src/history/history.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/02 15:22:19 by gwojda #+# #+# */ -/* Updated: 2017/03/17 12:09:42 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 16:05:47 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -39,9 +39,8 @@ int ft_history_down(char **str, size_t *pos) head = head->next; if (!head->str) *str = NULL; - else - if (!(*str = ft_strdup(head->str))) - return (-1); + else if (!(*str = ft_strdup(head->str))) + return (-1); if (*str) ft_current_str(*str, *pos); if (*str) @@ -64,9 +63,8 @@ int ft_history_up(char **str, size_t *pos) head = head->prev; if (!head->str) *str = NULL; - else - if (!(*str = ft_strdup(head->str))) - return (-1); + else if (!(*str = ft_strdup(head->str))) + return (-1); if (*str) ft_current_str(*str, *pos); if (*str) diff --git a/42sh/src/history/surch_in_history.c b/42sh/src/history/surch_in_history.c index d3fbffc7..0920de9c 100644 --- a/42sh/src/history/surch_in_history.c +++ b/42sh/src/history/surch_in_history.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/26 10:43:16 by gwojda #+# #+# */ -/* Updated: 2017/03/17 12:12:19 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 16:06:09 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -52,7 +52,7 @@ static void ft_give_new_prompt(char *str_srch, size_t srch_pos) } static void ft_modify_str(char *str_srch, size_t srch_pos, char **str, - size_t *pos) + size_t *pos) { ft_clear_prompt(pos, srch_pos); data_singleton()->line.is_prompt ? ft_prompt() : ft_putstr("> "); diff --git a/42sh/src/line-editing/get_key.c b/42sh/src/line-editing/get_key.c index 7c974d2c..c99659fc 100644 --- a/42sh/src/line-editing/get_key.c +++ b/42sh/src/line-editing/get_key.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/19 16:28:49 by gwojda #+# #+# */ -/* Updated: 2017/03/17 15:11:10 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 15:54:45 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -81,6 +81,7 @@ int ft_read_stdin(char **input) { if (read_stdin(&ret, &j) < 0) return (-1); + DG("key value hex = %x", ret); if (ft_completion(ret, str, pos)) continue ; while (g_key[j].value && g_key[j].value != ret) diff --git a/42sh/src/line-editing/readline.c b/42sh/src/line-editing/readline.c index cc134418..0b84ab3d 100644 --- a/42sh/src/line-editing/readline.c +++ b/42sh/src/line-editing/readline.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */ -/* Updated: 2017/03/17 14:56:35 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 16:10:40 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,11 +16,12 @@ int readline(int has_prompt, char **input) { int ret; + if (!has_prompt) + data_singleton()->line.prompt_size = 1; if (!SH_IS_INTERACTIVE(data_singleton()->opts)) return ((ret = get_next_line(STDIN, input)) >= 0 ? !ret : ret); readline_init(has_prompt); ret = ft_read_stdin(input); - DG("ret = %s", input); if (ret < 0) return (ret); if (data_singleton()->line.input)