From ebb6dc4ca9bf9d8fb39adbc515555a37ceb26daa Mon Sep 17 00:00:00 2001 From: barant Date: Thu, 9 Jan 2025 07:01:58 -0800 Subject: [PATCH] think i fixed if tag. --- __if.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/__if.cpp b/__if.cpp index 3307f28..84451d4 100644 --- a/__if.cpp +++ b/__if.cpp @@ -16,16 +16,24 @@ namespace jet { throw coreutils::Exception("type expected if value1 and value2 specified."); } else throw coreutils::Exception("value2 required if value1 specified."); + coreutils::MString type = resolveKeyword("type"); + if((type != "eq") && + (type != "ne") && + (type != "lt") && + (type != "le") && + (type != "gt") && + (type != "ge")) + throw coreutils::Exception("type value must be 'eq','ne','lt','le','gt','ge'."); int rc = keywords[resolveKeyword("value1")].compare(keywords[resolveKeyword("value2")]); - if(((keywords[resolveKeyword("type")] == "eq") && (rc == 0)) || - ((keywords[resolveKeyword("type")] == "ne") && (rc != 0)) || - ((keywords[resolveKeyword("type")] == "lt") && (rc == -1)) || - ((keywords[resolveKeyword("type")] == "le") && (rc != 1)) || - ((keywords[resolveKeyword("type")] == "gt") && (rc == 1)) || - ((keywords[resolveKeyword("type")] == "ge") && (rc != -1))) + if(((type == "eq") && (rc == 0)) || + ((type == "ne") && (rc != 0)) || + ((type == "lt") && (rc == -1)) || + ((type == "le") && (rc != 1)) || + ((type == "gt") && (rc == 1)) || + ((type == "ge") && (rc != -1))) booleanResult = true; else - throw coreutils::Exception("type value must be 'eq','ne','lt','le','gt','ge'."); + booleanResult = false; } else if(keywordDefined("expr")) { if(keywordDefined("value2")) throw coreutils::Exception("value2 should not be specified with expr.");