fix here_doc leak
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/11/11 18:46:43 by lperrey #+# #+# */
|
||||
/* Updated: 2021/11/14 10:58:37 by lperrey ### ########.fr */
|
||||
/* Updated: 2021/11/14 11:12:44 by lperrey ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -25,22 +25,24 @@ int here_doc(char *delimiter)
|
||||
and the here-document lines shall not be expanded.
|
||||
Otherwise, the delimiter shall be the word itself. */
|
||||
// TODO : A voir si on fait les expansions de variables dans le here_doc.
|
||||
// implementer une gestion des signaux pour here_doc (actuellement ça leaks).
|
||||
// implementer une gestion des signaux pour here_doc (verifier comportement bash et doc POSIX).
|
||||
// Peut-être remplacer gnl() par readline() pour avoir une gestion correct
|
||||
// du terminal (actuellement l'affichage lors du changement de ligne est foireux).
|
||||
int here_doc;
|
||||
|
||||
delimiter = ft_strdup_quotes(delimiter);
|
||||
if (!delimiter)
|
||||
return (ft_reti_perror(-1, "ft_strdup_quotes()"));
|
||||
here_doc = open(TMP_HERE_DOC, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
|
||||
if (here_doc == -1)
|
||||
return (ft_reti_perror_io(-1, "open() ", TMP_HERE_DOC));
|
||||
delimiter = ft_strdup_quotes(delimiter);
|
||||
if (!delimiter)
|
||||
return (ft_reti_perror(-1, "ft_strdup_quotes()"));
|
||||
if (!here_doc_write(delimiter, here_doc))
|
||||
{
|
||||
free(delimiter);
|
||||
gnl(STDIN_FILENO, NULL, 1);
|
||||
return (0);
|
||||
}
|
||||
free(delimiter);
|
||||
if (close(here_doc) == -1)
|
||||
ft_perror_io("close() ", TMP_HERE_DOC);
|
||||
here_doc = open(TMP_HERE_DOC, O_RDONLY);
|
||||
|
||||
Reference in New Issue
Block a user