summaryrefslogtreecommitdiffstats
path: root/src/c_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/c_init.c')
-rw-r--r--src/c_init.c13
1 files changed, 8 insertions, 5 deletions
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);
}