fix: small bugs to make it compile

This commit is contained in:
Matteo Flebus 2026-01-27 18:00:59 +01:00
parent c48d86c8de
commit 13018e0a03
10 changed files with 33 additions and 4 deletions

View file

@ -14,6 +14,9 @@ libutils_a_SOURCES = \
ast/ast_redir.c \
ast/ast_void.c \
ast/ast_end.c \
ast/ast_word.c \
ast/ast_neg.c \
ast/ast_pipe.c \
args/args.c \
vars/vars.c

View file

@ -11,6 +11,7 @@
#include "ast_void.h"
#include "ast_word.h"
#include "ast_pipe.h"
#include "ast_neg.h"
/**
* Prints the Graphviz DOT representation of the given AST to stdout.

View file

@ -29,6 +29,7 @@ struct ast
* - struct ast_command* (AST_CMD)
* - struct ast_and_or* (AST_AND_OR)
* - struct ast_redir* (AST_REDIR)
* - and a lot more now...
*/
void *data;
};

View file

@ -18,7 +18,7 @@ struct ast *ast_create_command(struct list *command)
struct ast_command *ast_get_command(struct ast *node)
{
if (node == NULL || node->type == AST_CMD)
if (node == NULL || node->type != AST_CMD)
return NULL;
return (struct ast_command *)node->data;
}

View file

@ -4,7 +4,7 @@
bool ast_is_neg(struct ast *node)
{
return node != NULL && node->type == AST_REDIR;
return node != NULL && node->type == AST_NEG;
}
struct ast_neg *ast_get_neg(struct ast *node)
@ -20,6 +20,8 @@ struct ast *ast_create_neg(bool negation, struct ast *child)
if (!node)
return NULL;
node->negation = negation;
node->child = child;
return ast_create(AST_NEG, node);
}

View file

@ -1,5 +1,7 @@
#define _POSIX_C_SOURCE 200809L
#include "ast_word.h"
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>