here_doc: null marker returns error

This commit is contained in:
Khaïs COLIN 2025-03-11 11:10:58 +01:00
parent 99babbf6d2
commit 442aa85e84
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
3 changed files with 28 additions and 3 deletions

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/07 11:42:29 by khais #+# #+# */
/* Updated: 2025/03/11 11:22:54 by khais ### ########.fr */
/* Updated: 2025/03/11 11:24:30 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -55,3 +55,17 @@ char *here_doc_random_filename(void)
close(randomfd);
return (ft_buffer_to_charptr(filename));
}
/*
** Read from STDIN into some file until a line that is exactly equal to the
** marker is read.
**
** Then unlink the file, and return a filedescriptor to it, seeked to the start.
**
** If NULL is given as argument, or any other error occurs, return -1.
*/
int here_doc(t_worddesc *marker)
{
(void)marker;
return (-1);
}

View file

@ -6,13 +6,16 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/07 11:41:27 by khais #+# #+# */
/* Updated: 2025/03/11 10:58:19 by khais ### ########.fr */
/* Updated: 2025/03/11 11:18:47 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef HERE_DOC_H
# define HERE_DOC_H
# include "../../parser/worddesc/worddesc.h"
int here_doc(t_worddesc *marker);
char *here_doc_random_filename(void);
#endif // HERE_DOC_H

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/07 11:43:32 by khais #+# #+# */
/* Updated: 2025/03/10 18:23:36 by khais ### ########.fr */
/* Updated: 2025/03/11 11:19:16 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -34,7 +34,15 @@ static void test_here_doc_filename_generation(void)
do_leak_check();
}
static void test_here_doc_null_args(void)
{
ft_dprintf(STDERR_FILENO, "==> %s <==\n", __FUNCTION__);
assert(-1 == here_doc(NULL));
do_leak_check();
}
int main(void) {
test_here_doc_filename_generation();
test_here_doc_null_args();
return (0);
}