diff options
Diffstat (limited to 'src/types.c')
-rw-r--r-- | src/types.c | 9 |
1 files changed, 5 insertions, 4 deletions
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); |