diff options
-rw-r--r-- | libft/include/libft.h | 6 | ||||
-rw-r--r-- | src/c_init.c | 13 |
2 files changed, 12 insertions, 7 deletions
diff --git a/libft/include/libft.h b/libft/include/libft.h index 265d87c..427f873 100644 --- a/libft/include/libft.h +++ b/libft/include/libft.h @@ -23,11 +23,13 @@ # define BUFFER_SIZE 72 # endif -typedef enum e_bool +typedef unsigned char t_bool; + +enum e_bool { FALSE, TRUE -} t_bool; +}; typedef struct s_list { diff --git a/src/c_init.c b/src/c_init.c index a10daa7..f707c69 100644 --- a/src/c_init.c +++ b/src/c_init.c @@ -122,8 +122,9 @@ char *ft_strrbavchr(const char *s, int c, size_t start) char *c_set_ptr(t_bool reset, char key, t_msh *msh) { - static char *p = NULL; - static char *context = NULL; + static char *p = NULL; + static char *context = NULL; + static t_bool sw = FALSE; if (reset == TRUE) { @@ -142,18 +143,20 @@ char *c_set_ptr(t_bool reset, char key, t_msh *msh) { p = msh->curr_hist_ptr; context = msh->curr_hist_ptr; + sw = TRUE; } if ((key == -1 && p - context != 0) || key == 1) { p += (key == -1) ? (2 * key) : (0); - while (((key == -1 && p - context != 0) || key == 1) + while (sw == FALSE && ((key == -1 && p - context != 0) || key == 1) && *p != C_LF && *p != C_NUL) p += key; - if (key == 1 && p - context == 1) - p -= 1; + if (sw == TRUE) + sw = FALSE; if (p - context != 0 && *p != C_NUL) p += 1; } + /* ft_printf("\n\r[%s]\n\r[%s]\n\r", context, p); */ return (p); } |