summaryrefslogtreecommitdiffstats
path: root/src/m_prompt.c
diff options
context:
space:
mode:
authorsalad <fmoenne-@student.le-101.fr>2020-11-03 00:03:48 +0100
committersalad <fmoenne-@student.le-101.fr>2020-11-03 00:03:48 +0100
commitb18fbce9a7e33f7e54949ae8de32fd7fc42e6ad1 (patch)
tree859e4d58e05622ef7a402e50ddd2ec913a51ef5d /src/m_prompt.c
parentstrplen (diff)
download42-minishell-b18fbce9a7e33f7e54949ae8de32fd7fc42e6ad1.tar.gz
42-minishell-b18fbce9a7e33f7e54949ae8de32fd7fc42e6ad1.tar.bz2
42-minishell-b18fbce9a7e33f7e54949ae8de32fd7fc42e6ad1.tar.xz
42-minishell-b18fbce9a7e33f7e54949ae8de32fd7fc42e6ad1.tar.zst
42-minishell-b18fbce9a7e33f7e54949ae8de32fd7fc42e6ad1.zip
this is it \(2009\) \: a Micheal Jackson Biopic
Diffstat (limited to 'src/m_prompt.c')
-rw-r--r--src/m_prompt.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/m_prompt.c b/src/m_prompt.c
index e36a07e..0fbd9f2 100644
--- a/src/m_prompt.c
+++ b/src/m_prompt.c
@@ -25,7 +25,7 @@
#include "s_struct.h"
#include "u_vars.h"
-static void m_subst_prompt_rice(char var[], t_msh *msh)
+static void m_subst_prompt_rice(char var[], t_msh *msh)
{
size_t i;
@@ -43,7 +43,7 @@ static void m_subst_prompt_rice(char var[], t_msh *msh)
}
}
-static void m_update_psx(unsigned char x, t_msh *msh)
+static void m_update_psx(unsigned char x, t_msh *msh)
{
char var[ARG_MAX];
char psx[5];
@@ -59,7 +59,33 @@ static void m_update_psx(unsigned char x, t_msh *msh)
ft_strlcpy(msh->ps[x - 1], var, 255);
}
-void m_prompt_psx(unsigned char x, t_msh *msh)
+unsigned int m_plen(char *prompt)
+{
+ unsigned int i;
+ unsigned int size;
+
+ i = 0;
+ size = 0;
+ while (prompt[i] != '\0')
+ {
+ if (prompt[i] == 27)
+ {
+ while (prompt[i] != 'm' && prompt[i] != '\0')
+ i++;
+ }
+ if (ft_isalnum(prompt[i]) ||
+ ft_ischarset("<>", prompt[i]))
+ {
+ size++;
+ i++;
+ }
+ else
+ i++;
+ }
+ return (size);
+}
+
+void m_prompt_psx(unsigned char x, t_msh *msh)
{
m_update_psx(x, msh);
ft_dprintf(STDERR_FILENO, "%s", msh->ps[x - 1]);