minishell/src/treedrawing.h
Khaïs COLIN 76b2b8ec7f
treedrawing: fix bug where rare circumstances could lead to incorrect indent
The problem took me a while to find, but the issue here was that push_buf does
not add a terminating null byte, and I was only asking push_buf to copy the
bytes that contained characters, not the terminating null byte as well.

This, combined with the fact that to remove bytes from the end of the buffer, I
just placed a null byte a the end, caused some combinations of indentation and
dedentations to overwrite the null byte, and not place a null byte after the new
indent, which would still contain data from a previous indentation.
2025-03-28 14:50:37 +01:00

32 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* treedrawing.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/18 12:24:25 by khais #+# #+# */
/* Updated: 2025/03/19 13:50:37 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TREEDRAWING_H
# define TREEDRAWING_H
# include <stdbool.h>
# include "buffer/buffer.h"
# define CROSS " ├─ "
# define CORNER " ╰─ "
# define VERTICAL " │ "
# define SPACE " "
/* # define CROSS " |- " */
/* # define CORNER " \\- " */
/* # define VERTICAL " | " */
/* # define SPACE " " */
void indent(t_buffer *indent, bool is_last);
void dedent(t_buffer *indent, bool is_last);
#endif // TREEDRAWING_H