Change the way tokens are compared for zeroth rule
authorLukas Jiriste <ljiriste@student.42prague.com>
Fri, 5 Jul 2024 10:16:03 +0000 (12:16 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Sun, 21 Jul 2024 18:21:21 +0000 (20:21 +0200)
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

index 1ebfe5f988ae6bb708272dbca9212aa03392e898..eac57873b9350ee2f607c9dac68d0ffe23ebbab5 100644 (file)
@@ -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));
 }