diff options
author | salad <fmoenne-@student.le-101.fr> | 2020-12-16 13:10:11 +0100 |
---|---|---|
committer | salad <fmoenne-@student.le-101.fr> | 2020-12-16 13:10:11 +0100 |
commit | 711bc9edbd9646900fc7e00e7b3457c2070ac31f (patch) | |
tree | 2b173316fcea1f8609fc9494dadce17588f248b4 /src/c_init.c | |
parent | norm tobecontinued2 (diff) | |
download | 42-minishell-711bc9edbd9646900fc7e00e7b3457c2070ac31f.tar.gz 42-minishell-711bc9edbd9646900fc7e00e7b3457c2070ac31f.tar.bz2 42-minishell-711bc9edbd9646900fc7e00e7b3457c2070ac31f.tar.xz 42-minishell-711bc9edbd9646900fc7e00e7b3457c2070ac31f.tar.zst 42-minishell-711bc9edbd9646900fc7e00e7b3457c2070ac31f.zip |
qwe
Diffstat (limited to 'src/c_init.c')
-rw-r--r-- | src/c_init.c | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/src/c_init.c b/src/c_init.c index a8ec6ee..472ee75 100644 --- a/src/c_init.c +++ b/src/c_init.c @@ -76,21 +76,8 @@ static short return (0); } -char *ft_strrbavchr(const char *s, int c, size_t start) -{ - size_t i; - - i = ft_strlen(s) - start; - while (s[i] != c) - { - if (i == 0) - return (NULL); - i--; - } - return ((char*)&s[i]); -} - -char *c_set_ptr(t_bool reset, char key, t_msh *msh) +char + *c_set_ptr(t_bool reset, char key, t_msh *msh) { static char *p = NULL; static char *context = NULL; @@ -109,7 +96,7 @@ char *c_set_ptr(t_bool reset, char key, t_msh *msh) context = msh->prev_hist; } if (key == 1 && context == msh->prev_hist - && p == ft_strrbavchr(msh->prev_hist, '\n', 2) + 1) + && p == ft_strrnchr(msh->prev_hist, '\n', 2) + 1) { p = msh->curr_hist_ptr; context = msh->curr_hist_ptr; @@ -136,9 +123,6 @@ static char { char *ptr; - if (*line == NULL) - if (!(*line = ft_calloc(1, sizeof(char)))) - return (NULL); if (ft_isprint(buf[0])) c_add_char(line, buf, tcaps); else if (((*((unsigned int *)buf)) == UP_K) || |