Improved contracts
This commit is contained in:
17
src/ee.c
17
src/ee.c
@@ -3,8 +3,13 @@ int error = 0;
|
|||||||
void printStack(STACK);
|
void printStack(STACK);
|
||||||
|
|
||||||
int
|
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;
|
STACK expr = NULL;
|
||||||
|
|
||||||
@@ -58,9 +63,7 @@ int
|
|||||||
isNum(const char* query)
|
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;
|
char *extra_char;
|
||||||
strtod(query, &extra_char);
|
strtod(query, &extra_char);
|
||||||
@@ -90,6 +93,10 @@ arrity(const char query)
|
|||||||
bool
|
bool
|
||||||
isDivByZero(double *_operands)
|
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;
|
return _operands[0] == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user