From cfb142b9601cc648f15bf5738a3df09a23835e41 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 2 Aug 2015 22:18:19 -0700 Subject: 1923 Still iterating on the right way to handle incorrect number of ingredients. My first idea of creating null results doesn't really work once they're used in later instructions. Just add a warning at one place in the run loop, but otherwise only add products when there's something to save in them. Undoes some work around commit 1886. --- 024compare.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to '024compare.cc') diff --git a/024compare.cc b/024compare.cc index 7fb8c2e8..fb3481fd 100644 --- a/024compare.cc +++ b/024compare.cc @@ -6,7 +6,6 @@ EQUAL, Recipe_ordinal["equal"] = EQUAL; :(before "End Primitive Recipe Implementations") case EQUAL: { - products.resize(1); if (SIZE(ingredients) <= 1) { raise << current_recipe_name() << ": 'equal' needs at least two ingredients to compare in '" << current_instruction().to_string() << "'\n" << end(); break; @@ -19,6 +18,7 @@ case EQUAL: { break; } } + products.resize(1); products.at(0).push_back(result); break; } @@ -61,7 +61,6 @@ GREATER_THAN, Recipe_ordinal["greater-than"] = GREATER_THAN; :(before "End Primitive Recipe Implementations") case GREATER_THAN: { - products.resize(1); bool result = true; if (SIZE(ingredients) <= 1) { raise << current_recipe_name() << ": 'greater-than' needs at least two ingredients to compare in '" << current_instruction().to_string() << "'\n" << end(); @@ -79,6 +78,7 @@ case GREATER_THAN: { } } finish_greater_than: + products.resize(1); products.at(0).push_back(result); break; } @@ -117,7 +117,6 @@ LESSER_THAN, Recipe_ordinal["lesser-than"] = LESSER_THAN; :(before "End Primitive Recipe Implementations") case LESSER_THAN: { - products.resize(1); bool result = true; if (SIZE(ingredients) <= 1) { raise << current_recipe_name() << ": 'lesser-than' needs at least two ingredients to compare in '" << current_instruction().to_string() << "'\n" << end(); @@ -135,6 +134,7 @@ case LESSER_THAN: { } } finish_lesser_than: + products.resize(1); products.at(0).push_back(result); break; } @@ -173,7 +173,6 @@ GREATER_OR_EQUAL, Recipe_ordinal["greater-or-equal"] = GREATER_OR_EQUAL; :(before "End Primitive Recipe Implementations") case GREATER_OR_EQUAL: { - products.resize(1); bool result = true; if (SIZE(ingredients) <= 1) { raise << current_recipe_name() << ": 'greater-or-equal' needs at least two ingredients to compare in '" << current_instruction().to_string() << "'\n" << end(); @@ -191,6 +190,7 @@ case GREATER_OR_EQUAL: { } } finish_greater_or_equal: + products.resize(1); products.at(0).push_back(result); break; } @@ -237,7 +237,6 @@ LESSER_OR_EQUAL, Recipe_ordinal["lesser-or-equal"] = LESSER_OR_EQUAL; :(before "End Primitive Recipe Implementations") case LESSER_OR_EQUAL: { - products.resize(1); bool result = true; if (SIZE(ingredients) <= 1) { raise << current_recipe_name() << ": 'lesser-or-equal' needs at least two ingredients to compare in '" << current_instruction().to_string() << "'\n" << end(); @@ -255,6 +254,7 @@ case LESSER_OR_EQUAL: { } } finish_lesser_or_equal: + products.resize(1); products.at(0).push_back(result); break; } -- cgit 1.4.1-2-gfad0