From 97b7240286475031377c6c170c0525d185f4717a Mon Sep 17 00:00:00 2001 From: "Gu://em_" Date: Sat, 10 Jan 2026 19:57:36 +0100 Subject: [PATCH] fix: Fixed ALL the code --- .gitignore | 43 +++++++++++++++++++++++++++ configure.ac | 1 - src/execution/execution.c | 5 ++-- src/io_backend/io_backend.c | 7 +++-- src/lexer/lexer.c | 7 ++++- src/main.c | 2 ++ src/parser/parser.c | 1 + src/utils/Makefile.am | 4 ++- src/utils/string_utils/string_utils.c | 7 +++-- src/utils/string_utils/string_utils.h | 2 ++ 10 files changed, 68 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index ccbc1e7..64c4a76 100644 --- a/.gitignore +++ b/.gitignore @@ -132,3 +132,46 @@ $RECYCLE.BIN/ *.msm *.msp *.lnk + +# Autotools (since it disappeared for some reason) + +Makefile.in +/ar-lib +/mdate-sh +/py-compile +/test-driver +/ylwrap +.deps/ +.dirstamp + +autom4te.cache +/autoscan.log +/autoscan-*.log +/aclocal.m4 +/compile +/config.cache +/config.guess +/config.h.in +/config.log +/config.status +/config.sub +/configure +/configure.scan +/depcomp +/install-sh +/missing +/stamp-h1 + +/libtool +/ltmain.sh +.libs/ + +/texinfo.tex + +m4/libtool.m4 +m4/ltoptions.m4 +m4/ltsugar.m4 +m4/ltversion.m4 +m4/lt~obsolete.m4 + +Makefile diff --git a/configure.ac b/configure.ac index f9684ed..f8638ca 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,6 @@ AC_PROG_CC # List Makefiles in subdirectories AC_CONFIG_FILES([ src/Makefile - src/ast/Makefile src/parser/Makefile src/lexer/Makefile src/io_backend/Makefile diff --git a/src/execution/execution.c b/src/execution/execution.c index 3f6b1a3..855fd37 100644 --- a/src/execution/execution.c +++ b/src/execution/execution.c @@ -112,12 +112,11 @@ int execution(struct ast *ast) return 0; } case AST_CMD: { - struct ast_cmd *cmd = ast->data->ast_cmd; // Cast implicit + struct ast_cmd *cmd = ast_get_cmd(ast); return exec_command(cmd); // It's recursive } case AST_IF: { - struct ast_if *if_node = - ast->data->ast_if; // We cast the union to ast_if + struct ast_if *if_node = ast_get_if(ast); int cond = execution(if_node->condition); if (cond == 0) // True { diff --git a/src/io_backend/io_backend.c b/src/io_backend/io_backend.c index ee6b09b..176585f 100644 --- a/src/io_backend/io_backend.c +++ b/src/io_backend/io_backend.c @@ -11,18 +11,19 @@ int iob_init(struct iob_context *ctx) switch (context.mode) { - IOB_MODE_STDIN: + case IOB_MODE_STDIN: input = stdin; return 0; - IOB_MODE_SCRIPT: + case IOB_MODE_SCRIPT: if (context.args == NULL) return -2; input = fopen(context.args, "r"); if (input == NULL) return -4; + return 0; - IOB_MODE_CMD: + case IOB_MODE_CMD: if (context.args != NULL) return -2; else diff --git a/src/lexer/lexer.c b/src/lexer/lexer.c index 5b03c18..def814c 100644 --- a/src/lexer/lexer.c +++ b/src/lexer/lexer.c @@ -1,13 +1,16 @@ #include "lexer.h" #include +#include +#include +#include #include "io_backend/io_backend.h" static char *end_last_token; static ssize_t remaining_chars; -char *new_token(char *begin, size_t size) +char *new_token(char *begin, ssize_t size) { char *res = calloc(size + 1, sizeof(char)); if (res == NULL) @@ -56,6 +59,7 @@ char *get_token(void) // skip blank char // exit from loop char *token = new_token(stream, i); + return token; } default: break; @@ -64,4 +68,5 @@ char *get_token(void) } remaining_chars -= i; + return NULL; } diff --git a/src/main.c b/src/main.c index e05c6f6..f20378e 100644 --- a/src/main.c +++ b/src/main.c @@ -2,5 +2,7 @@ int main(int argc, char **argv) { + (void)argc; + (void)argv; return 0; } diff --git a/src/parser/parser.c b/src/parser/parser.c index 6651e53..30cecdd 100644 --- a/src/parser/parser.c +++ b/src/parser/parser.c @@ -9,5 +9,6 @@ struct ast *get_ast() struct ast *get_ast_str(char *command) { + (void)command; return NULL; } diff --git a/src/utils/Makefile.am b/src/utils/Makefile.am index 5b72df3..b876698 100644 --- a/src/utils/Makefile.am +++ b/src/utils/Makefile.am @@ -1,7 +1,9 @@ lib_LIBRARIES = libutils.a libutils_a_SOURCES = \ - string_utils.c + string_utils/string_utils.c \ + ast/ast.c \ + lists/lists.c libutils_a_CPPFLAGS = -I$(top_srcdir)/src diff --git a/src/utils/string_utils/string_utils.c b/src/utils/string_utils/string_utils.c index 6e07f7e..6762b07 100644 --- a/src/utils/string_utils/string_utils.c +++ b/src/utils/string_utils/string_utils.c @@ -1,4 +1,7 @@ -#include "utils/string_utils/string_utils.h" +#include "string_utils.h" + +#include +#include ssize_t skip_blanks(char **str) { @@ -7,7 +10,7 @@ ssize_t skip_blanks(char **str) return 0; } ssize_t skipped = 0; - while (str[skipped] != '\0' && !isblank(str[skipped])) + while (*str[skipped] != '\0' && !isblank(str[skipped])) { skipped++; } diff --git a/src/utils/string_utils/string_utils.h b/src/utils/string_utils/string_utils.h index 3fee923..5e6df94 100644 --- a/src/utils/string_utils/string_utils.h +++ b/src/utils/string_utils/string_utils.h @@ -1,6 +1,8 @@ #ifndef STRING_UTILS_H #define STRING_UTILS_H +#include + /* * @brief: skips blank characters at the beginning of [str]. * @return: number of characters skipped.