summaryrefslogtreecommitdiffstats
path: root/src/c_utils.c
diff options
context:
space:
mode:
authorsalad <fmoenne-@student.le-101.fr>2020-09-14 15:59:30 +0200
committersalad <fmoenne-@student.le-101.fr>2020-09-14 15:59:30 +0200
commitb6806c73f4ae94dd76ad7a51ad25255b3493e9c9 (patch)
tree6d5d530cdd8b282caff2436651697d273e0f315e /src/c_utils.c
parentgrep TODO c_utils.c (diff)
download42-minishell-b6806c73f4ae94dd76ad7a51ad25255b3493e9c9.tar.gz
42-minishell-b6806c73f4ae94dd76ad7a51ad25255b3493e9c9.tar.bz2
42-minishell-b6806c73f4ae94dd76ad7a51ad25255b3493e9c9.tar.xz
42-minishell-b6806c73f4ae94dd76ad7a51ad25255b3493e9c9.tar.zst
42-minishell-b6806c73f4ae94dd76ad7a51ad25255b3493e9c9.zip
quelques additions
Diffstat (limited to '')
-rw-r--r--src/c_utils.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/c_utils.c b/src/c_utils.c
index d5a45e0..43d6452 100644
--- a/src/c_utils.c
+++ b/src/c_utils.c
@@ -25,9 +25,11 @@
/*
** TODO:
** quotes
-** leaks
+** leaks on line
** C-c
** tests varies
+** NORME
+** MULTILIGHNE
** term(0) on exit DONE
** cursor on char insert DONE
*/
@@ -93,6 +95,7 @@ int16_t
{
m_parse_and_run_line(*line, msh);
*line = NULL;
+ free(*line);
}
tcaps->cpos = 0;
tputs(tgetstr("cr", NULL), 1, ft_putchar);
@@ -119,7 +122,10 @@ char
while (i < len)
{
if (i == tcaps->cpos)
- dst[i++] = c;
+ {
+ dst[i] = c;
+ i++;
+ }
else
{
dst[i] = str[j];
@@ -127,8 +133,8 @@ char
j++;
}
}
+ free(str);
dst[i] = '\0';
- ft_memdel((void*)&str);
return (dst);
}
@@ -153,14 +159,14 @@ char
i++;
j++;
}
- free(str);
+ ft_memdel((void**)&str);
dst[j] = '\0';
return (dst);
}
int16_t
c_redraw_line(char *line,
- uint16_t cpos,
+ t_caps *tcaps,
t_msh *msh)
{
uint32_t i;
@@ -168,7 +174,6 @@ int16_t
int16_t ret;
i = 0;
- (void)cpos;
tputs(tgetstr("cr", NULL), 1, ft_putchar);
while (i < ft_strlen(msh->ps[0]))
{
@@ -177,8 +182,8 @@ int16_t
}
ret = ft_printf("%s", line) + ft_strlen(msh->ps[0]);
len = ft_strlen(line);
- if (cpos != len)
- while (--len > cpos)
+ if (tcaps->cpos != len)
+ while (--len > tcaps->cpos)
tputs(tgetstr("le", NULL), 1, ft_putchar);
return (ret);
}