From 919ea7b1ba8c90cbec6b2ddc2caafa99d6847ba5 Mon Sep 17 00:00:00 2001 From: Guillem George Date: Wed, 7 Jan 2026 20:18:11 +0100 Subject: [PATCH] fix: added header guards, and some testing purpose autotools rules --- src/Makefile.am | 49 ++++++++++++++++++++++++++----------- src/ast/ast.h | 22 +++++++++++++++++ src/execution/execution.h | 4 +++ src/expansion/expansion.h | 4 +++ src/io_backend/io_backend.h | 4 +++ src/lexer/lexer.h | 4 +++ src/{42sh.c => main.c} | 0 src/parser/parser.h | 4 +++ src/utils/Makefile.am | 11 +++++++++ 9 files changed, 88 insertions(+), 14 deletions(-) rename src/{42sh.c => main.c} (100%) create mode 100644 src/utils/Makefile.am diff --git a/src/Makefile.am b/src/Makefile.am index 564dfaa..8ecd21f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,25 +1,46 @@ # define the subdirectories SUBDIRS = \ - ast \ - parser \ - lexer \ - io_backend \ - execution \ - expansion -# + utils if needed + ast \ + parser \ + lexer \ + io_backend \ + execution \ + expansin \ + utils bin_PROGRAMS = 42sh -42sh_SOURCES = 42sh.c +42sh_SOURCES = main.c 42sh_CPPFLAGS = -I%D% 42sh_CFLAGS = -std=c99 -pedantic -Werror -Wall -Wextra -Wvla 42sh_LDADD = \ - ast/libast.a \ - parser/libparser.a \ - lexer/liblexer.a \ - io_backend/libio_backend.a \ - expansion/libexpansion.a \ - execution/libexecution.a + ast/libast.a \ + parser/libparser.a \ + lexer/liblexer.a \ + io_backend/libio_backend.a \ + expansion/libexpansion.a \ + execution/libexecution.a \ + utils/libutils.a + + +################################################# Test + +bin_PROGRAMS = 42sh_asan + +42sh_asan_SOURCES = main.c + +42sh_asan_CPPFLAGS = -I%D% + +42sh_asan_CFLAGS = -std=c99 -pedantic -Werror -Wall -Wextra -Wvla -g -fsanitize=address + +42sh_asan_LDADD = \ + ast/libast.a \ + parser/libparser.a \ + lexer/liblexer.a \ + io_backend/libio_backend.a \ + expansion/libexpansion.a \ + execution/libexecution.a \ + utils/libutils.a diff --git a/src/ast/ast.h b/src/ast/ast.h index e69de29..4c14043 100644 --- a/src/ast/ast.h +++ b/src/ast/ast.h @@ -0,0 +1,22 @@ +#ifndef AST_H +#define AST_H + + +enum ast_type +{ + AST_NULL = 0, + ATS_IF, + AST_CMD +}; + +union ast_union +{ +}; + +struct ast +{ + enum ast_type type; + union ast_union data; +}; + +#endif /* ! AST_H */ diff --git a/src/execution/execution.h b/src/execution/execution.h index e69de29..e773de0 100644 --- a/src/execution/execution.h +++ b/src/execution/execution.h @@ -0,0 +1,4 @@ +#ifndef EXECUTION_H +#define EXECUTION_H + +#endif /* ! EXECUTION_H */ diff --git a/src/expansion/expansion.h b/src/expansion/expansion.h index e69de29..b10b198 100644 --- a/src/expansion/expansion.h +++ b/src/expansion/expansion.h @@ -0,0 +1,4 @@ +#ifndef EXPANSION_H +#define EXPANSION_H + +#endif /* ! EXPANSION_H */ diff --git a/src/io_backend/io_backend.h b/src/io_backend/io_backend.h index e69de29..d202b1a 100644 --- a/src/io_backend/io_backend.h +++ b/src/io_backend/io_backend.h @@ -0,0 +1,4 @@ +#ifndef IO_BACKEND_H +#define IO_BACKEND_H + +#endif /* ! IO_BACKEND_H */ diff --git a/src/lexer/lexer.h b/src/lexer/lexer.h index e69de29..9e7cd67 100644 --- a/src/lexer/lexer.h +++ b/src/lexer/lexer.h @@ -0,0 +1,4 @@ +#ifndef LEXER_H +#define LEXER_H + +#endif /* ! LEXER_H */ diff --git a/src/42sh.c b/src/main.c similarity index 100% rename from src/42sh.c rename to src/main.c diff --git a/src/parser/parser.h b/src/parser/parser.h index e69de29..ef5a449 100644 --- a/src/parser/parser.h +++ b/src/parser/parser.h @@ -0,0 +1,4 @@ +#ifndef PARSER_H +#define PARSER_H + +#endif /* ! PARSER_H */ diff --git a/src/utils/Makefile.am b/src/utils/Makefile.am new file mode 100644 index 0000000..dba2e51 --- /dev/null +++ b/src/utils/Makefile.am @@ -0,0 +1,11 @@ +lib_LIBRARIES = libutils.a + +# libutils_a_SOURCES = \ +# utils.c \ +# utils.h + +# libutils_a_CPPFLAGS = -I$(top_srcdir)/src + +# libutils_a_CFLAGS = -std=c99 -pedantic -Werror -Wall -Wextra -Wvla + +# noinst_LIBRARIES = libutils.a