From eb75ad1bb21826e482b3bc3251e83ac5a9121678 Mon Sep 17 00:00:00 2001 From: Anastasios Grammenos Date: Wed, 9 Nov 2022 16:31:55 +0200 Subject: Remove prev from parse() --- src/cookbook.c | 2 +- src/food.c | 2 +- src/parser.c | 10 +++++----- src/parser.h | 5 ++++- 4 files changed, 11 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/cookbook.c b/src/cookbook.c index b1a4f76..c67a728 100644 --- a/src/cookbook.c +++ b/src/cookbook.c @@ -140,7 +140,7 @@ main(int argc, char * argv[]) cookbook = (recipe **)malloc(sizeof(recipe *) * n); for (int i = 0; i < n; i++) { - cookbook[i] = parse(lib[i], NULL); + cookbook[i] = parse(lib[i]); if (opt.eval) { recipe * _r = eval(cookbook[i]); free_recipe(cookbook[i]); diff --git a/src/food.c b/src/food.c index 5c9730b..a2b8920 100644 --- a/src/food.c +++ b/src/food.c @@ -191,7 +191,7 @@ main(int argc, char * argv[]) opt.includes, opt.includes_n); for (int i = 0; i < n; i++) { - recipe * r = parse(lib[i], NULL); + recipe * r = parse(lib[i]); if (!r) { fprintf(stderr, "Couldn't parse recipe: %s\n", lib[i]); continue; diff --git a/src/parser.c b/src/parser.c index a5b1a11..75bd582 100644 --- a/src/parser.c +++ b/src/parser.c @@ -56,7 +56,7 @@ try_include(const char * s, recipe * r, char * error) } recipe * rr = NULL; - rr = parse(path, r->filename); + rr = parse(path); /* TODO: Check for path from included libs */ @@ -141,7 +141,7 @@ parse_item(const char * s, recipe * r, pt * type, char * error) return 0; } -static const int +int parse_step(const char * s, recipe * r, char * error) { fdebug("^ step\n"); @@ -162,7 +162,7 @@ parse_step(const char * s, recipe * r, char * error) } static const int -handle_line(const char * s, recipe * r, char * error, pt * type, const char * prev) +handle_line(const char * s, recipe * r, char * error, pt * type) { fdebug("Handling line: %s\n", s); @@ -247,7 +247,7 @@ file_from_path(const char * path) } recipe * -parse(char * path, const char * prev) +parse(char * path) { fdebug("Parsing: %s\n", path); @@ -273,7 +273,7 @@ parse(char * path, const char * prev) enum parser_type type = TITLE; while (!next_escaped_line(f, line, &lino, error)) { - if (handle_line(line, r, error, &type, prev)) + if (handle_line(line, r, error, &type)) break; } diff --git a/src/parser.h b/src/parser.h index 70b3120..3a25a94 100644 --- a/src/parser.h +++ b/src/parser.h @@ -18,9 +18,12 @@ typedef enum parser_type { * input from stdin */ recipe * -parse(char * path, const char * prev); +parse(char * path); int parse_item(const char * s, recipe * r, pt * type, char * error); +int +parse_step(const char * s, recipe * r, char * error); + #endif /* __PARSER_H */ -- cgit v1.2.3