mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
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.
This commit is contained in:
parent
1486c3b124
commit
76b2b8ec7f
2 changed files with 8 additions and 3 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/18 15:24:50 by khais #+# #+# */
|
||||
/* Updated: 2025/03/19 12:09:47 by khais ### ########.fr */
|
||||
/* Updated: 2025/03/19 14:00:35 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ void dedent(t_buffer *leader, bool is_last)
|
|||
idx = leader->length - length_to_remove;
|
||||
if (idx >= 0)
|
||||
{
|
||||
leader->buffer[idx] = '\0';
|
||||
ft_bzero(leader->buffer + idx, length_to_remove);
|
||||
leader->length = idx;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/18 12:24:25 by khais #+# #+# */
|
||||
/* Updated: 2025/03/19 12:10:05 by khais ### ########.fr */
|
||||
/* Updated: 2025/03/19 13:50:37 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -21,6 +21,11 @@
|
|||
# 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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue