From 66a86d1b20a1e97b2d008e73db7557887fc44edf Mon Sep 17 00:00:00 2001 From: gramanas Date: Sat, 6 Nov 2021 13:01:47 +0200 Subject: Progress --- parser.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'parser.c') diff --git a/parser.c b/parser.c index c47096c..11e4876 100644 --- a/parser.c +++ b/parser.c @@ -47,7 +47,7 @@ parse_item(const char * s, recipe * r, pt * type, char * error) return 1; } - if (tmp[0] == '/') { + if (tmp[0] == '/' || tmp[0] == '~') { strcpy(path, tmp); } else { strcpy(path, r->path); @@ -60,8 +60,9 @@ parse_item(const char * s, recipe * r, pt * type, char * error) sprintf(error, "Couldn't include %s", path); return 1; } - copy_items(r, rr); - free_recipe(rr); + //copy_items(r, rr); + new_subrecipe(r, rr); + //free_recipe(rr); return 0; } @@ -115,9 +116,11 @@ parse_step(const char * s, recipe * r, char * error) { fdebug("^ step\n"); - if ((s[0] == '>' || s[0] == '-') && strlen(s+1)) { + if ((s[0] == '>' || + s[0] == '-' || + s[0] == '+') && strlen(s+1)) { new_step(r); - r->s[r->sn - 1]->type = s[0] == '>' ? COOK : PREP; + r->s[r->sn - 1]->type = s[0] == '>' ? COOK : s[0] == '-' ? PREP : SERVE; char *tmp = strdup(s+1); trim(tmp); r->s[r->sn - 1]->inst = tmp; @@ -201,7 +204,14 @@ parse(char * path, const char * prev) if (!strcmp(path, "-")) { f = stdin; } else { - f = fopen(path, "r"); + char tmp[LINE_SIZE] = ""; + if (path[0] == '~') { + strcpy(tmp, getenv("HOME")); + strcat(tmp, path + 1); + } else { + strcpy(tmp, path); + } + f = fopen(tmp, "r"); if (!f) return NULL; } -- cgit v1.2.3