summaryrefslogtreecommitdiffstats
path: root/src/c_init.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-12-18 16:00:22 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-12-18 16:00:22 +0100
commit62a1c19e2095a8dd0fb66f4e29dce37eae0c5d69 (patch)
treef2e879822c0043495152b4c597d7234e29bfe063 /src/c_init.c
parentspammingnormcommits (diff)
download42-minishell-62a1c19e2095a8dd0fb66f4e29dce37eae0c5d69.tar.gz
42-minishell-62a1c19e2095a8dd0fb66f4e29dce37eae0c5d69.tar.bz2
42-minishell-62a1c19e2095a8dd0fb66f4e29dce37eae0c5d69.tar.xz
42-minishell-62a1c19e2095a8dd0fb66f4e29dce37eae0c5d69.tar.zst
42-minishell-62a1c19e2095a8dd0fb66f4e29dce37eae0c5d69.zip
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);
}