summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-09-10 20:21:39 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-09-10 20:21:39 +0200
commit4b84aadfcb1dcc46d686fd984e0566d84e116278 (patch)
tree97193b041f7441f3de5a579ed511e190e6e07c60
parentNew libft func, cool stuff (diff)
download42-minishell-4b84aadfcb1dcc46d686fd984e0566d84e116278.tar.gz
42-minishell-4b84aadfcb1dcc46d686fd984e0566d84e116278.tar.bz2
42-minishell-4b84aadfcb1dcc46d686fd984e0566d84e116278.tar.xz
42-minishell-4b84aadfcb1dcc46d686fd984e0566d84e116278.tar.zst
42-minishell-4b84aadfcb1dcc46d686fd984e0566d84e116278.zip
LOT to fix
-rw-r--r--src/d_define.h1
-rw-r--r--src/m_prompt.c11
2 files changed, 9 insertions, 3 deletions
diff --git a/src/d_define.h b/src/d_define.h
index 50b0f3c..6d3cc45 100644
--- a/src/d_define.h
+++ b/src/d_define.h
@@ -67,6 +67,7 @@
*/
#define C_NUL 0x00
+#define C_LF 0x0a
#define C_SUB 0x1a
#define C_ESC 0x1b
#define C_DQUOTE 0x22
diff --git a/src/m_prompt.c b/src/m_prompt.c
index 2d88088..ff491c8 100644
--- a/src/m_prompt.c
+++ b/src/m_prompt.c
@@ -34,9 +34,14 @@ static char
{
if (var[i + 1] == '0' && var[i + 2] == '3' && var[i + 3] == '3')
{
- ft_memmove(var + i, var + i + 3, ft_strlen(var + i + 3) + 1);
+ (void)ft_memmove(var + i, var + i + 3, ft_strlen(var + i + 3) + 1);
var[i] = C_ESC;
}
+ else if (var[i + 1] == 'n')
+ {
+ (void)ft_memmove(var + i, var + i + 1, ft_strlen(var + i + 1) + 1);
+ var[i] = C_LF;
+ }
else if (var[i + 1] == 'w')
{
u_get_var_value(tmp, "$PWD", PATH_MAX, msh);
@@ -65,9 +70,9 @@ static char
ft_strsubst_s(var, "\\w", "?");
}
else if (var[i + 1] == 'v')
- var = ft_strsubst(var, "\\v", FT_MSH_VERSION);
+ ft_strsubst_s(var, "\\v", FT_MSH_VERSION);
else if (var[i + 1] == 's')
- var = ft_strsubst(var, "\\s", FT_PROGNAME);
+ ft_strsubst_s(var, "\\s", FT_PROGNAME);
}
i++;
}