minishell
Minishell Project for École 42
|
Functions for handling the input array and tokenization. More...
#include "minishell.h"
Functions | |
int | skip_quotes (char *str) |
Skips over a quoted section ('\'' or '"') of a string. | |
void | no_delim_found (char *str, int *len) |
Checks if there is a quote('\'' or '"') at the current position the given string. | |
bool | is_token (char to_check) |
Check if a character is a token. | |
bool | is_token2 (char to_check) |
Check if a character is a token. | |
Functions for handling the input array and tokenization.
bool is_token | ( | char | to_check | ) |
Check if a character is a token.
Takes an input character and checks if it is a token character, which includes '<', '>', and '|'. If the input character matches any of these token characters, the function returns true. Otherwise, it returns false.
to_check | The character to check if it's a token. |
bool is_token2 | ( | char | to_check | ) |
Check if a character is a token.
Takes an input character and checks if it is a token character, which includes '<', '>'. If the input character matches any of these token characters, the function returns true. Otherwise, it returns false.
to_check | The character to check if it's a token. |
void no_delim_found | ( | char * | str, |
int * | len | ||
) |
Checks if there is a quote('\'' or '"') at the current position the given string.
The function is called when no delimiter(whitespace) is found. Checks if the current position in the string is a quote ('\'' or '"') and calls skip_quotes() to skip over the quoted section. Otherwise it incremets the lenght(and current position).
str | The input string. |
*len | A pointer to the lenght(and current index) of the string. |
int skip_quotes | ( | char * | str | ) |
Skips over a quoted section ('\'' or '"') of a string.
Used to skip over a quoted section ('\'' or '"') of a string. It starts from the quote pointed to by the str pointer, and iterates over the string until it finds the same quote. Handles escaped quotes (preceded by '\'). Returns the index of the character after the 2nd quote (closing quote).
str | The input string. |