summaryrefslogtreecommitdiffstats
path: root/parser.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2021-11-06 13:01:47 +0200
committergramanas <anastasis.gramm2@gmail.com>2021-11-06 13:01:47 +0200
commit66a86d1b20a1e97b2d008e73db7557887fc44edf (patch)
treed778fa893496fc7d4c3609dc8d3d8f667182217d /parser.c
parent9deed51aa2df7ca5979963f7452a6439ad2d3767 (diff)
downloadfoodtools-66a86d1b20a1e97b2d008e73db7557887fc44edf.tar.gz
foodtools-66a86d1b20a1e97b2d008e73db7557887fc44edf.tar.bz2
foodtools-66a86d1b20a1e97b2d008e73db7557887fc44edf.zip
Progress
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c22
1 files changed, 16 insertions, 6 deletions
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;
}