diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2022-10-14 22:11:50 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2022-10-14 22:11:50 +0300 |
commit | 7b7240d50dd5e418bc17beff48aa5681b398b980 (patch) | |
tree | b521f1da139ce85974b71f1698cc140b1e7fed6c /src/parser.c | |
parent | 433ce0f6795a4db89921b26274dd0b18fcccbb21 (diff) | |
download | foodtools-7b7240d50dd5e418bc17beff48aa5681b398b980.tar.gz foodtools-7b7240d50dd5e418bc17beff48aa5681b398b980.tar.bz2 foodtools-7b7240d50dd5e418bc17beff48aa5681b398b980.zip |
More changes
Diffstat (limited to 'src/parser.c')
-rw-r--r-- | src/parser.c | 28 |
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++) { |