summaryrefslogtreecommitdiffstats
path: root/src/parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.c')
-rw-r--r--src/parser.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/parser.c b/src/parser.c
index e90b200..a5b1a11 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -1,5 +1,3 @@
-#include <libgen.h>
-
#include "parser.h"
#include "util.h"
@@ -23,14 +21,8 @@ parse_title(const char * s, recipe * r, pt * type)
}
int
-parse_item(const char * s, recipe * r, pt * type, char * error)
+try_include(const char * s, recipe * r, char * error)
{
- fdebug("^ item\n");
- if (!strcmp(s, "---")) {
- if (type) *type = STEPS;
- return 0;
- }
-
/* 1 - 9 in ascii */
if ((s[0] > 48 && s[0] < 58) || s[0] == '!') {
fdebug("INCLUDING: %s\n", s);
@@ -80,6 +72,22 @@ parse_item(const char * s, recipe * r, pt * type, char * error)
return 0;
}
+ return -1;
+}
+
+int
+parse_item(const char * s, recipe * r, pt * type, char * error)
+{
+ fdebug("^ item\n");
+ if (!strcmp(s, "---")) {
+ if (type) *type = STEPS;
+ return 0;
+ }
+
+ int rc = try_include(s, r, error);
+ if (rc != -1)
+ return rc;
+
int l = strlen(s);
int val = 1; /* key vs value flag */
int itemc = 0;
@@ -123,7 +131,7 @@ parse_item(const char * s, recipe * r, pt * type, char * error)
if (!strlen(buf)) {
// sprintf(error, "empty ingredient quantity: %s", s);
// return 1;
- strcpy(buf, "*");
+ strcpy(buf, "");
}
for (int i = 0; i < itemc; i++) {