aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-26 22:51:42 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-26 22:51:42 +0100
commit19e6186d1a8cb9cbdd99c8b9fc07010ea8f6df46 (patch)
tree720c34dd71e2048fd70cab74e63805d707f40ee3
parent77bb2e29ec878a452cb06ca0583c4e7f8d9756b1 (diff)
Reformatted OpType()
-rw-r--r--FICS/formula.c54
1 files changed, 37 insertions, 17 deletions
diff --git a/FICS/formula.c b/FICS/formula.c
index 816445f..69bf824 100644
--- a/FICS/formula.c
+++ b/FICS/formula.c
@@ -261,24 +261,44 @@ int ScanForOp (char *string, int *i)
return (OP_BAD);
} /* end of function ScanForOp. */
-/* OpType returns the precedence of the operator op. */
-int OpType (int op)
+/*
+ * OpType() returns the precedence of the operator 'op'.
+ */
+int
+OpType(int op)
{
- switch (op)
- {
- case OP_BAD: return (OPTYPE_BAD);
- case OP_NONE: return (OPTYPE_NONE);
- case OP_RTPAREN: return (OPTYPE_RPAREN);
- case OP_OR: return (OPTYPE_OR);
- case OP_AND: return (OPTYPE_AND);
- case OP_EQ: case OP_NEQ: return (OPTYPE_COMPEQ);
- case OP_GT: case OP_GE: case OP_LT: case OP_LE: return (OPTYPE_COMPGL);
- case OP_PLUS: case OP_MINUS: return (OPTYPE_ADD);
- case OP_MULT: case OP_DIV: return (OPTYPE_MULT);
- case OP_NEGATE: case OP_NOT: return (OPTYPE_UNARY);
- default: return (OPTYPE_BAD);
- }
-} /* end of function OpType. */
+ switch (op) {
+ case OP_BAD:
+ return OPTYPE_BAD;
+ case OP_NONE:
+ return OPTYPE_NONE;
+ case OP_RTPAREN:
+ return OPTYPE_RPAREN;
+ case OP_OR:
+ return OPTYPE_OR;
+ case OP_AND:
+ return OPTYPE_AND;
+ case OP_EQ:
+ case OP_NEQ:
+ return OPTYPE_COMPEQ;
+ case OP_GT:
+ case OP_GE:
+ case OP_LT:
+ case OP_LE:
+ return OPTYPE_COMPGL;
+ case OP_PLUS:
+ case OP_MINUS:
+ return OPTYPE_ADD;
+ case OP_MULT:
+ case OP_DIV:
+ return OPTYPE_MULT;
+ case OP_NEGATE:
+ case OP_NOT:
+ return OPTYPE_UNARY;
+ default:
+ return OPTYPE_BAD;
+ }
+}
/*
* In EvalBinaryOp() 'left' is the left operand, and 'op' is the