From 90d63cbcbf6e550f2e8af5afb7fe37d723105853 Mon Sep 17 00:00:00 2001 From: Vera Lewis Date: Sun, 4 Jan 2026 01:09:19 -0600 Subject: [PATCH] Improved contracts --- src/ee.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/ee.c b/src/ee.c index ddcd50d..24f55a0 100644 --- a/src/ee.c +++ b/src/ee.c @@ -3,8 +3,13 @@ int error = 0; void printStack(STACK); int -main (const int argc, const char* argv[]) -{ +main (const int argc, const char* argv[]) { + /* if argv is an array of strings corresponding to a well-formed RPN + * expression, then main prints the value of the expression and returns 0 + * otherwise, main will return one of ERR_NO_EXPR, ERR_INVALID_INPUT, + * ERR_NS_OPERANDS, or ERR_NS_OPERATORS, as defined in ee.h, depending + * on the type of malformed expression. + */ STACK expr = NULL; @@ -58,9 +63,7 @@ int isNum(const char* query) { - /* - * If query is a string, isNum(query) iff query represents a number. - */ + // If query is a string, isNum(query) iff query represents a number. char *extra_char; strtod(query, &extra_char); @@ -90,6 +93,10 @@ arrity(const char query) bool isDivByZero(double *_operands) { + /* if _operands represents an array of operands, isDivByZero(_operands) + * iff the first operand (corresponding to the divisor) is zero + */ + return _operands[0] == 0; }