summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-11-03 17:28:09 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-11-03 17:28:09 +0100
commit517cf2dd5b1cb7314a215f32b9b5470eefae540f (patch)
tree2b5f151fd751232f4f0902ecfdf7a14c4ff70dd2
parentuhhhhhhhhh (diff)
download42-minishell-517cf2dd5b1cb7314a215f32b9b5470eefae540f.tar.gz
42-minishell-517cf2dd5b1cb7314a215f32b9b5470eefae540f.tar.bz2
42-minishell-517cf2dd5b1cb7314a215f32b9b5470eefae540f.tar.xz
42-minishell-517cf2dd5b1cb7314a215f32b9b5470eefae540f.tar.zst
42-minishell-517cf2dd5b1cb7314a215f32b9b5470eefae540f.zip
plen fixed
-rw-r--r--Makefile2
-rw-r--r--src/c_init.c2
-rw-r--r--src/m_prompt.c12
-rw-r--r--src/m_prompt.h2
4 files changed, 8 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 3e94e0c..6445b7a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-default: msan
+default: asan
#==============================================================================#
#--------------------------------- SHELL --------------------------------------#
#==============================================================================#
diff --git a/src/c_init.c b/src/c_init.c
index 1023ced..1cc31b0 100644
--- a/src/c_init.c
+++ b/src/c_init.c
@@ -127,7 +127,7 @@ short
tputs(tgetstr("cr", NULL), 1, ft_putchar);
m_prompt_psx(psx, msh);
ft_bzero(nread, 5);
- tcaps.plen = m_plen(msh->ps[psx - 1]);
+ tcaps.plen = (unsigned int)m_plen(msh->ps[psx - 1]);
tcaps.plen += (psx != 1);
if (!(c_get_win_size(&tcaps.ws)))
return (-1);
diff --git a/src/m_prompt.c b/src/m_prompt.c
index 0fbd9f2..68126ff 100644
--- a/src/m_prompt.c
+++ b/src/m_prompt.c
@@ -59,10 +59,10 @@ static void m_update_psx(unsigned char x, t_msh *msh)
ft_strlcpy(msh->ps[x - 1], var, 255);
}
-unsigned int m_plen(char *prompt)
+size_t m_plen(char *prompt)
{
- unsigned int i;
- unsigned int size;
+ size_t i;
+ size_t size;
i = 0;
size = 0;
@@ -72,15 +72,13 @@ unsigned int m_plen(char *prompt)
{
while (prompt[i] != 'm' && prompt[i] != '\0')
i++;
+ i++;
}
- if (ft_isalnum(prompt[i]) ||
- ft_ischarset("<>", prompt[i]))
+ else
{
size++;
i++;
}
- else
- i++;
}
return (size);
}
diff --git a/src/m_prompt.h b/src/m_prompt.h
index 59f627f..843bab7 100644
--- a/src/m_prompt.h
+++ b/src/m_prompt.h
@@ -15,7 +15,7 @@
# include "s_struct.h"
-unsigned int m_plen(char *prompt);
+size_t m_plen(char *prompt);
void m_prompt_psx(unsigned char x, t_msh *msh);
#endif