Fix tokenization type comparison
authorLukas Jiriste <ljiriste@student.42prague.com>
Sun, 1 Sep 2024 07:22:34 +0000 (09:22 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Sun, 1 Sep 2024 07:51:05 +0000 (09:51 +0200)
commit7086badbd4b4c44e2662617e3ef34105322188e1
treeb1840a5729dd97d08c837cab5b2624d29d4cfffd
parentd300bff66c664a8c2a51fda65282aa2c780e0ae5
Fix tokenization type comparison

The tokenization was built around the types not being allocated to lower
the number of failure points. This was achieved by creating a static
constant global array that holds all the possible values. The type
character pointer in every token then points to a value in this array.

This was exploited to make string comparison faster - instead of
comparing every character, only the address (the raw pointer) was
compared.

This was broken by moving the definition of the static global variable
into a header file. With that every file that includes it gets its own
version of the variable - its own memory - and te comparison fails.

The solution is the make an access function that holds the definition
of the static variable and all the other functions access the variable
through this function instead of directly. Now the variable is only ever
defined inside the function and address comparison works again.
inc/minishell.h
inc/minishell_structs.h
inc/tokens.h [deleted file]
src/token_finish.c
src/tokenization.c