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.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/c_init.c b/src/c_init.c
index 84098ec..b2fd3d3 100644
--- a/src/c_init.c
+++ b/src/c_init.c
@@ -76,6 +76,22 @@ static short
return (0);
}
+static void
+ c_set_ptr_norme(char key, t_bool *sw, char **p, char **context)
+{
+ if ((key == -1 && *p - *context != 0) || key == 1)
+ {
+ *p += (key == -1) ? (2 * key) : (0);
+ while (*sw == FALSE && ((key == -1 && *p - *context != 0) || key == 1)
+ && **p != C_LF && **p != C_NUL)
+ *p += key;
+ if (*sw == TRUE)
+ *sw = FALSE;
+ if (*p - *context != 0 && **p != C_NUL)
+ *p += 1;
+ }
+}
+
char
*c_set_ptr(t_bool reset, char key, t_msh *msh)
{
@@ -102,17 +118,7 @@ char
context = msh->curr_hist_ptr;
sw = TRUE;
}
- if ((key == -1 && p - context != 0) || key == 1)
- {
- p += (key == -1) ? (2 * key) : (0);
- while (sw == FALSE && ((key == -1 && p - context != 0) || key == 1)
- && *p != C_LF && *p != C_NUL)
- p += key;
- if (sw == TRUE)
- sw = FALSE;
- if (p - context != 0 && *p != C_NUL)
- p += 1;
- }
+ c_set_ptr_norme(key, &sw, &p, &context);
return (p);
}