Haliris / minishell

Minishell repo by bthomas and jteissie
2 stars 1 forks source link

Converted buffer in command tables created by parser to a simple vector. #109

Closed Haliris closed 1 month ago

Haliris commented 1 month ago

Created t_vector struct to hold the command buffer and size as well as word_count integers.

Parser now handles a vector when building a command table, and adds strings back to the buffer, each strings separated by a null byte.

The vector is then passed to the execution process that will split to make the command array execve() and some built_ins need. The split process is now simplified, the function will iterate through the vector buffer, stop when it encounters a word and copy it into the string we are currently making.

While copying, it will overwrite each characters in the vector with a null byte, so that we know we have already split it.

The function keeps going until its index is equal to the value of the word_count variable in t_vector. Size in t_vector serves for the parser to keep track of how many bytes are needed for allocations, and is used as a safety stopgap whilst iterating through the vector buffer and ignoring null bytes.