From 7b7240d50dd5e418bc17beff48aa5681b398b980 Mon Sep 17 00:00:00 2001 From: gramanas Date: Fri, 14 Oct 2022 22:11:50 +0300 Subject: More changes --- src/parser.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'src/parser.c') 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 - #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++) { -- cgit v1.2.3