From 934991beb44a07baf25ae47db7ef5dd717c266b5 Mon Sep 17 00:00:00 2001 From: gwojda Date: Fri, 17 Mar 2017 10:52:01 +0100 Subject: [PATCH] change ret line editing --- 42sh/src/history/history.c | 10 +++++----- 42sh/src/history/history_parsing.c | 6 +++--- 42sh/src/history/surch_in_history.c | 4 ++-- 42sh/src/line-editing/completion.c | 4 ++-- 42sh/src/line-editing/control_features.c | 8 ++++---- 42sh/src/line-editing/copy_cut_paste.c | 12 ++++++------ 42sh/src/line-editing/get_key.c | 6 +++--- 42sh/src/line-editing/home_end.c | 10 +++++----- 42sh/src/line-editing/move_left_and_right.c | 12 ++++++------ 42sh/src/line-editing/move_to_word.c | 12 ++++++------ 42sh/src/line-editing/move_up_and_down.c | 10 +++++----- 42sh/src/line-editing/print_and_del.c | 12 ++++++------ 42sh/src/line-editing/queue.c | 10 +++++----- 42sh/src/line-editing/readline.c | 4 ++-- 42sh/src/main/main.c | 2 +- 15 files changed, 61 insertions(+), 61 deletions(-) diff --git a/42sh/src/history/history.c b/42sh/src/history/history.c index 2ec071d1..c901b8fc 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/16 17:00:08 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 10:48:21 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,7 +33,7 @@ int ft_history_down(void) head = data_singleton()->line.list_cur; if (!head) - return (1); + return (0); ft_clear_before_history(&STR); if (head->next) head = head->next; @@ -49,7 +49,7 @@ int ft_history_down(void) else POS = 0; data_singleton()->line.list_cur = head; - return (1); + return (0); } int ft_history_up(void) @@ -58,7 +58,7 @@ int ft_history_up(void) head = data_singleton()->line.list_cur; if (!head) - return (1); + return (0); ft_clear_before_history(&STR); if (head->prev) head = head->prev; @@ -74,5 +74,5 @@ int ft_history_up(void) else POS = 0; data_singleton()->line.list_cur = head; - return (1); + return (0); } diff --git a/42sh/src/history/history_parsing.c b/42sh/src/history/history_parsing.c index 5775a7d7..85dc9ef5 100644 --- a/42sh/src/history/history_parsing.c +++ b/42sh/src/history/history_parsing.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/25 11:39:47 by gwojda #+# #+# */ -/* Updated: 2017/03/16 17:09:02 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 10:48:34 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -68,7 +68,7 @@ int ft_history_parsing(int has_prompt, char **input) i = 0; boolean = 0; if (!STR) - return (1); + return (0); while (STR && STR[i]) { if (STR[i] == '!') @@ -83,5 +83,5 @@ int ft_history_parsing(int has_prompt, char **input) } if (boolean) return (readline(has_prompt, input)); - return (1); + return (0); } diff --git a/42sh/src/history/surch_in_history.c b/42sh/src/history/surch_in_history.c index 5269be4b..cbbea74e 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/16 17:12:05 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 10:48:06 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -92,5 +92,5 @@ int ft_surch_in_history(void) break ; } ft_modify_str(str_srch, srch_pos); - return (1); + return (0); } diff --git a/42sh/src/line-editing/completion.c b/42sh/src/line-editing/completion.c index 15828894..b9d12e3a 100644 --- a/42sh/src/line-editing/completion.c +++ b/42sh/src/line-editing/completion.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/03 14:15:55 by gwojda #+# #+# */ -/* Updated: 2017/03/16 10:33:10 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 10:45:06 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -53,5 +53,5 @@ int ft_completion(int ret) ft_putnc('\b', right); POS = ft_strleni_w(STR, pos_tmp, '\n') - right; } - return (1); + return (0); } diff --git a/42sh/src/line-editing/control_features.c b/42sh/src/line-editing/control_features.c index a4b3094d..2298d32f 100644 --- a/42sh/src/line-editing/control_features.c +++ b/42sh/src/line-editing/control_features.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/02 15:17:28 by gwojda #+# #+# */ -/* Updated: 2017/03/16 16:45:43 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 10:45:20 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,7 +19,7 @@ int ft_buff_f6(void) ret = 0; if (read(0, &ret, sizeof(int)) < 0) return (-1); - return (1); + return (0); } int ft_control_d(void) @@ -34,7 +34,7 @@ int ft_control_d(void) ft_del(); else ft_puttermcaps("bl"); - return (1); + return (0); } int ft_control_c(void) @@ -55,5 +55,5 @@ int ft_control_l(void) ft_prompt(); ft_strdel(&STR); POS = 0; - return (1); + return (0); } diff --git a/42sh/src/line-editing/copy_cut_paste.c b/42sh/src/line-editing/copy_cut_paste.c index bc8417af..97808ebc 100644 --- a/42sh/src/line-editing/copy_cut_paste.c +++ b/42sh/src/line-editing/copy_cut_paste.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/19 12:45:06 by gwojda #+# #+# */ -/* Updated: 2017/03/16 17:12:40 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 10:45:37 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -47,7 +47,7 @@ int ft_v(void) i = -1; tmp_pos = POS; if (!STR || !tmp) - return (1); + return (0); while (tmp[++i]) if (!(STR = ft_realloc_imput(STR, tmp[i], POS + i))) return (-1); @@ -60,7 +60,7 @@ int ft_v(void) ft_get_next_str(STR, &POS); ft_putnc('\b', POS - tmp_pos); POS = tmp_pos; - return (1); + return (0); } int ft_x(void) @@ -70,7 +70,7 @@ int ft_x(void) tmp = &data_singleton()->line.copy_tmp; if (!STR) - return (1); + return (0); if (*tmp) ft_strdel(tmp); if (!(*tmp = ft_strdupi_space(&STR[POS]))) @@ -83,7 +83,7 @@ int ft_x(void) --i; } ft_puttermcaps("cd"); - return (1); + return (0); } int ft_c(void) @@ -97,5 +97,5 @@ int ft_c(void) ft_strdel(tmp); if (!(*tmp = ft_strdupi_space(STR + POS))) return (-1); - return (1); + return (0); } diff --git a/42sh/src/line-editing/get_key.c b/42sh/src/line-editing/get_key.c index ee87225b..065754f0 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/16 17:13:48 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 10:49:59 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -69,7 +69,7 @@ int ft_read_stdin(char **input) ++j; if (g_key[j].value) { - if ((ret = g_key[j].f()) != 1) + if ((ret = g_key[j].f())) return (ret); } else if (ft_isprint(ret)) @@ -77,7 +77,7 @@ int ft_read_stdin(char **input) else if (ret == 10) { *input = STR; - return (1); + return (0); } else if (ft_isascii(ret) == 0) ft_read_it(ret, &POS, &STR); diff --git a/42sh/src/line-editing/home_end.c b/42sh/src/line-editing/home_end.c index a1d1b55e..b9dff034 100644 --- a/42sh/src/line-editing/home_end.c +++ b/42sh/src/line-editing/home_end.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/14 11:13:24 by gwojda #+# #+# */ -/* Updated: 2017/03/16 17:14:07 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 10:46:05 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,7 +15,7 @@ int ft_end(void) { if (!STR) - return (1); + return (0); if (POS) { --POS; @@ -27,13 +27,13 @@ int ft_end(void) ft_get_beggin(STR, &POS); ft_current_str(STR, POS); ft_get_next_str(STR, &POS); - return (1); + return (0); } int ft_home(void) { if (!STR) - return (1); + return (0); if (POS) { --POS; @@ -49,5 +49,5 @@ int ft_home(void) if (!STR[POS]) --POS; ft_get_beggin_with_curs(STR, &POS); - return (1); + return (0); } diff --git a/42sh/src/line-editing/move_left_and_right.c b/42sh/src/line-editing/move_left_and_right.c index ab7d69b5..70055250 100644 --- a/42sh/src/line-editing/move_left_and_right.c +++ b/42sh/src/line-editing/move_left_and_right.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/19 16:43:58 by gwojda #+# #+# */ -/* Updated: 2017/03/16 17:15:21 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 10:46:27 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,7 @@ int ft_move_right(void) size_t tmp; if (ft_strlen(STR) <= POS) - return (1); + return (0); if (STR[POS] == '\n') { if (POS) @@ -37,20 +37,20 @@ int ft_move_right(void) ft_putchar(STR[POS]); ++POS; } - return (1); + return (0); } int ft_move_left(void) { if (!POS) - return (1); + return (0); if (STR[POS - 1] == '\n') { if (POS - 1 == 0) { ft_puttermcaps("cd"); --POS; - return (1); + return (0); } ft_puttermcaps("cd"); POS -= 2; @@ -66,5 +66,5 @@ int ft_move_left(void) ft_puttermcaps("le"); --POS; } - return (1); + return (0); } diff --git a/42sh/src/line-editing/move_to_word.c b/42sh/src/line-editing/move_to_word.c index 6a8559e4..cf68ec30 100644 --- a/42sh/src/line-editing/move_to_word.c +++ b/42sh/src/line-editing/move_to_word.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/14 11:12:09 by gwojda #+# #+# */ -/* Updated: 2017/03/16 16:48:48 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 10:46:44 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -61,7 +61,7 @@ int ft_found_prev_word(void) i = 0; if (!POS || !STR) - return (1); + return (0); ft_init_prev_word(&POS, STR); if (POS >= 1 && STR[POS - 1] == '\n') { @@ -69,7 +69,7 @@ int ft_found_prev_word(void) { ft_puttermcaps("cd"); --POS; - return (1); + return (0); } ft_puttermcaps("cd"); POS -= 2; @@ -82,7 +82,7 @@ int ft_found_prev_word(void) } else ft_found_prev_word_2(i, STR, &POS); - return (1); + return (0); } static void ft_found_next_word_2(void) @@ -108,7 +108,7 @@ int ft_found_next_word(void) i = 0; if (!STR) - return (1); + return (0); while (STR[i + POS] && STR[i + POS] == ' ') { ft_putchar(STR[i + POS]); @@ -125,5 +125,5 @@ int ft_found_next_word(void) } POS += i; } - return (1); + return (0); } diff --git a/42sh/src/line-editing/move_up_and_down.c b/42sh/src/line-editing/move_up_and_down.c index 8cc50e23..43dbd192 100644 --- a/42sh/src/line-editing/move_up_and_down.c +++ b/42sh/src/line-editing/move_up_and_down.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/09 13:21:40 by gwojda #+# #+# */ -/* Updated: 2017/03/16 16:49:34 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 10:46:55 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -41,7 +41,7 @@ static void ft_up_2(size_t *pos, char *str) int ft_up(void) { if (!STR || !POS) - return (1); + return (0); if (STR[POS - 1] == '\n') { ft_puttermcaps("cd"); @@ -54,7 +54,7 @@ int ft_up(void) } else ft_up_2(&POS, STR); - return (1); + return (0); } static void ft_down_2(size_t *pos, char *str) @@ -81,7 +81,7 @@ int ft_down(void) i = 0; if (!STR) - return (1); + return (0); if (STR[POS] == '\n') ft_down_2(&POS, STR); else @@ -94,5 +94,5 @@ int ft_down(void) } POS += i; } - return (1); + return (0); } diff --git a/42sh/src/line-editing/print_and_del.c b/42sh/src/line-editing/print_and_del.c index 55ba40a0..250f4901 100644 --- a/42sh/src/line-editing/print_and_del.c +++ b/42sh/src/line-editing/print_and_del.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/05 16:02:43 by gwojda #+# #+# */ -/* Updated: 2017/03/16 17:15:41 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 10:47:11 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -38,7 +38,7 @@ int ft_print(int ret) ft_check_end_of_line(STR, POS + j); ft_putnc('\b', j - 1); ++POS; - return (1); + return (0); } static void ft_suppr_2(char **str, size_t *i, size_t tmp) @@ -61,7 +61,7 @@ int ft_suppr(void) boolean = 0; if (POS <= 0) - return (1); + return (0); if (STR[POS - 1] != '\n') boolean = 1; --POS; @@ -79,7 +79,7 @@ int ft_suppr(void) ft_get_beggin(STR, &POS); } ft_suppr_2(&STR, &POS, tmp); - return (1); + return (0); } int ft_del(void) @@ -90,7 +90,7 @@ int ft_del(void) if (!(STR = ft_remove_imput(STR, tmp))) return (-1); if (!(STR && POS < ft_strlen(STR) + 1)) - return (1); + return (0); if (POS) { --POS; @@ -103,5 +103,5 @@ int ft_del(void) ++POS; ft_putnc('\b', POS - tmp); POS = tmp; - return (1); + return (0); } diff --git a/42sh/src/line-editing/queue.c b/42sh/src/line-editing/queue.c index be5ea6ef..f0567514 100644 --- a/42sh/src/line-editing/queue.c +++ b/42sh/src/line-editing/queue.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/19 16:52:57 by gwojda #+# #+# */ -/* Updated: 2017/03/16 17:15:56 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 10:47:31 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -30,7 +30,7 @@ static int ft_read_it_3(char **str, char t[5], size_t *pos, int *j) } ++i; } - return (1); + return (0); } static void ft_read_it_2(int input, char t[5]) @@ -62,16 +62,16 @@ int ft_read_it(int input, size_t *pos, char **str) input == 126 || input == 993090331 || input == 925981467 || input == 21298 || input == 892427035 || input == 8270395 || input == 942758683 || input == 993090331 || input == 18489 || input == 17977) - return (1); + return (0); ft_read_it_2(input, t); if (ft_read_it_3(str, t, pos, &j) < 0) return (-1); if (!*str) - return (1); + return (0); *pos = pos_tmp; ft_current_str((*str), *pos); ft_get_next_str((*str), pos); ft_putnc('\b', *pos - (pos_tmp + j)); *pos = (pos_tmp + j); - return (1); + return (0); } diff --git a/42sh/src/line-editing/readline.c b/42sh/src/line-editing/readline.c index 922737b2..85c56566 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/16 17:08:28 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 10:51:27 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,7 +20,7 @@ int readline(int has_prompt, char **input) return ((ret = get_next_line(STDIN, input)) >= 0 ? !ret : ret); readline_init(has_prompt); ret = ft_read_stdin(input); - if (ret <= 0) + if (ret < 0) return (ret); if (STR) ft_current_str(STR, POS); diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 64f83380..8963ec80 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ -/* Updated: 2017/03/16 15:45:57 by jhalford ### ########.fr */ +/* Updated: 2017/03/17 10:51:23 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */