From b371ea6150879d8374981f445d24958909d673e0 Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Fri, 5 Jul 2024 12:16:03 +0200 Subject: [PATCH] Change the way tokens are compared for zeroth rule The zeroth rule contains a token which has NULL at type. Because the function cmp_token_type is used when comparing rules (items) it has to be able to handle this NULL. --- ft_parse/ft_parsing_table_generate.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ft_parse/ft_parsing_table_generate.c b/ft_parse/ft_parsing_table_generate.c index 1ebfe5f..eac5787 100644 --- a/ft_parse/ft_parsing_table_generate.c +++ b/ft_parse/ft_parsing_table_generate.c @@ -50,10 +50,14 @@ void void_free_generator_state(void *v_state) int cmp_token_type(const t_token *token1, const t_token *token2) { - if (!token1 && !token2) + if ((!token1 && !token2)) return(0); else if (!token1 || !token2) return(1); + if ((!token1->type && !token2->type)) + return(0); + else if (!token1->type || !token2->type) + return(1); return (ft_strcmp(token1->type, token2->type)); } -- 2.30.2