summaryrefslogtreecommitdiffstats
path: root/parser.c
diff options
context:
space:
mode:
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;
}