MiniDevil As beautiful as a shell
parser_redir_utils.c File Reference

Redirection utilities. More...

#include "libft.h"
#include "parser.h"
+ Include dependency graph for parser_redir_utils.c:

Detailed Description

Redirection utilities.

Definition in file parser_redir_utils.c.

Functions

static int is_redir (t_ast *node)
 Check if an AST node is of redirection type. More...
 
t_astreverse_redir_chain (t_ast *node)
 Reverse a redirection chain for left to right execution order. More...
 
char * join_connected_delim (t_token **tokens, int *quoted)
 Join connected tokens in a single string. More...
 

Function Documentation

◆ is_redir()

static int is_redir ( t_ast node)
static

Check if an AST node is of redirection type.

Parameters
nodeNode to check
Returns
1 if redirection and 0 if not

Definition at line 22 of file parser_redir_utils.c.

References NODE_REDIR_HEREDOC, NODE_REDIR_IN, and t_ast::type.

Referenced by reverse_redir_chain().

+ Here is the caller graph for this function:

◆ reverse_redir_chain()

t_ast* reverse_redir_chain ( t_ast node)

Reverse a redirection chain for left to right execution order.

The parser builds redirections with the outermost being last, so this reverses the chain so that the first parsed redirection is outermost, matching BASH's left to right behavior

Parameters
nodeOutermost redirection
Returns
New outermost node of the reverse chain

Definition at line 39 of file parser_redir_utils.c.

References t_redir_node::cmd, t_ast::data, is_redir(), and t_ast_data::redir.

Referenced by parse_command().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ join_connected_delim()

char* join_connected_delim ( t_token **  tokens,
int *  quoted 
)

Join connected tokens in a single string.

  • Walks the connected tokens, accumulating their values
  • Sets quoted to 1 if any token in the chain was quoted
Parameters
tokensPointer to current token pointer
quotedSet to 1 if any was quoted
Returns
Joined string or NULL on allocation failure

Definition at line 69 of file parser_redir_utils.c.

References t_token::next, and QUOTE_NONE.

Referenced by parse_one_redirection().

+ Here is the caller graph for this function:

Go to the source code of this file.