Fix wrong element insertion
authorLukas Jiriste <ljiriste@student.42prague.com>
Fri, 5 Jul 2024 07:41:49 +0000 (09:41 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Sun, 21 Jul 2024 18:21:21 +0000 (20:21 +0200)
Instead of a copy the original token was inserted. This caused the
elements sharing a token to be changed when only one shoud have been
changed.

ft_parse/ft_parsing_table_generate.c

index 2bdcf2850167f9ceda2669b919758b7f9b66c02e..c2f4c6c466638566b556272a8fb4d1badbf32319 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <ljiriste@student.42prague.com>   +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/06/27 11:16:53 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/07/04 16:33:02 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/07/05 08:27:38 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -262,7 +262,7 @@ t_ft_stat   add_first(t_vec *lookahead, const t_token *token, const t_vec *rules,
        if (is_terminal_token(token, tokens))
        {
                token_copy = ft_token_dup(token);
-               res = ft_vec_setinsert(lookahead, token, void_cmp_token_type);
+               res = ft_vec_setinsert(lookahead, &token_copy, void_cmp_token_type);
                if (res != success)
                        ft_free_token(&token_copy);
                return (res);