minishell
Minishell Project for École 42
Loading...
Searching...
No Matches
input_array_utils.c File Reference

Functions for handling the input array and tokenization. More...

#include "minishell.h"
Include dependency graph for input_array_utils.c:

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.
 

Detailed Description

Functions for handling the input array and tokenization.

Function Documentation

◆ is_token()

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.

Parameters
to_checkThe character to check if it's a token.
Returns
True if the input character is a token, false otherwise.

◆ is_token2()

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.

Parameters
to_checkThe character to check if it's a token.
Returns
True if the input character is a token, false otherwise.

◆ no_delim_found()

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).

Parameters
strThe input string.
*lenA pointer to the lenght(and current index) of the string.

◆ skip_quotes()

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).

Parameters
strThe input string.
Returns
The index of the character following the closing quote.