From 7c5af1b2768247984a08569b35e47ff927e70389 Mon Sep 17 00:00:00 2001 From: Anastasios Grammenos Date: Sun, 23 Oct 2022 19:20:39 +0300 Subject: Start work for step evaluation --- src/types.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/types.c') diff --git a/src/types.c b/src/types.c index 9314f8d..68c402c 100644 --- a/src/types.c +++ b/src/types.c @@ -72,7 +72,7 @@ new_step(recipe * r) r->s[r->sn] = (step *)malloc(sizeof(step)); if (!r->s[r->sn]) - die("Couldn't allocate memory for item"); + die("Couldn't allocate memory for step"); r->s[r->sn]->inst = NULL; r->s[r->sn]->duration = NULL; r->s[r->sn]->result = NULL; @@ -220,8 +220,8 @@ tojson(recipe * r) printf(",\"steps\":["); int i = 0; for (; i < r->sn - 1; i++) - printf("\"%s\",", r->s[i]->inst); - printf("\"%s\"]", r->s[i]->inst); + printf("{\"inst\":\"%s\",\"duration\":\"%s\",\"result\":\"%s\",\"type\":\"%s\"},", r->s[i]->inst, r->s[i]->duration, r->s[i]->result, r->s[i]->type == 0 ? "prep" : (r->s[i]->type == 1 ? "cook" : "serve") ); + printf("{\"inst\":\"%s\",\"duration\":\"%s\",\"result\":\"%s\",\"type\":\"%s\"}]", r->s[i]->inst, r->s[i]->duration, r->s[i]->result, r->s[i]->type == 0 ? "prep" : (r->s[i]->type == 1 ? "cook" : "serve") ); } printf("}"); } @@ -421,7 +421,8 @@ distinct_sum_items(recipe * dst, recipe * src) if (!strcmp(dst->i[n]->qty, "") && !strcmp(src->i[i]->qty, "")) { // noop - } else if (strlen(dst->i[n]->qty) + strlen(src->i[i]->qty) != 0) { + } else if (!strcmp(dst->i[n]->qty, "") + || !strcmp(src->i[i]->qty, "")) { char tmp[FOOD_MAX_ARRAY] = ""; strcat(tmp, dst->i[n]->qty); strcat(tmp, src->i[i]->qty); -- cgit v1.2.3