fix: small bugs to make it compile
This commit is contained in:
parent
c48d86c8de
commit
13018e0a03
10 changed files with 33 additions and 4 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue