From f0e3c2f41b195d51e9fbcf5a12824e78d205bbde Mon Sep 17 00:00:00 2001 From: Matteo Flebus Date: Thu, 15 Jan 2026 17:41:15 +0100 Subject: [PATCH] fix(ast): rename *_cmd() functions to *_command() --- src/utils/ast/ast_base.h | 2 ++ src/utils/ast/ast_command.c | 24 ++++++++++++------------ src/utils/ast/ast_command.h | 14 +++++++------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/utils/ast/ast_base.h b/src/utils/ast/ast_base.h index aa20b76..955ccdc 100644 --- a/src/utils/ast/ast_base.h +++ b/src/utils/ast/ast_base.h @@ -1,6 +1,8 @@ #ifndef AST_BASE_H #define AST_BASE_H +#include + enum ast_type { AST_END, diff --git a/src/utils/ast/ast_command.c b/src/utils/ast/ast_command.c index 9eb2dd7..6ad8fcc 100644 --- a/src/utils/ast/ast_command.c +++ b/src/utils/ast/ast_command.c @@ -6,33 +6,33 @@ #include "utils/lists/lists.h" -struct ast *ast_create_cmd(struct list *cmd) +struct ast *ast_create_command(struct list *command) { - struct ast_cmd *cmd_data = malloc(sizeof(struct ast_cmd)); - if (!cmd_data) + struct ast_command *command_data = malloc(sizeof(struct ast_command)); + if (!command_data) return NULL; - cmd_data->cmd = cmd; + command_data->command = command; - return ast_create(AST_CMD, cmd_data); + return ast_create(AST_CMD, command_data); } -struct ast_cmd *ast_get_cmd(struct ast *node) +struct ast_command *ast_get_command(struct ast *node) { assert(node != NULL); assert(node->type == AST_CMD); - return (struct ast_cmd *)node->data; + return (struct ast_command *)node->data; } -bool ast_is_cmd(struct ast *node) +bool ast_is_command(struct ast *node) { assert(node != NULL); return node->type == AST_CMD; } -void ast_free_cmd(struct ast_cmd **cmd_data) +void ast_free_command(struct ast_command **command_data) { - list_deep_destroy((*cmd_data)->cmd); - free(*cmd_data); - *cmd_data = NULL; + list_deep_destroy((*command_data)->command); + free(*command_data); + *command_data = NULL; } diff --git a/src/utils/ast/ast_command.h b/src/utils/ast/ast_command.h index f7d22a1..0e442a5 100644 --- a/src/utils/ast/ast_command.h +++ b/src/utils/ast/ast_command.h @@ -6,30 +6,30 @@ #include "utils/lists/lists.h" #include "utils/ast/ast_base.h" -struct ast_cmd +struct ast_command { - struct list *cmd; // A list of words (char*) + struct list *command; // A list of words (char*) }; /** * Checks if the given AST node is a command. */ -bool ast_is_cmd(struct ast *node); +bool ast_is_command(struct ast *node); /** * Retrieves the command data from the given AST node. * Assumes that the node is of type AST_CMD. */ -struct ast_cmd *ast_get_cmd(struct ast *node); +struct ast_command *ast_get_command(struct ast *node); /** * Creates a new AST node representing a command. */ -struct ast *ast_create_cmd(struct list *cmd); +struct ast *ast_create_command(struct list *command); /* - * @brief: frees the given ast_cmd and sets the pointer to NULL. + * @brief: frees the given ast_command and sets the pointer to NULL. */ -void ast_free_cmd(struct ast_cmd **cmd_data); +void ast_free_command(struct ast_command **command_data); #endif /* ! AST_COMMAND_H */