Permalink
Browse files

Simplify error checking for HUGE_VAL. Removes need to link against er…

…rno.h
  • Loading branch information...
falconindy committed Apr 16, 2010
1 parent aa39fca commit f0560ec5bf6a44ca5f46d66fafe4624dc60b99f7
Showing with 2 additions and 9 deletions.
  1. +2 −9 posty.c
View
11 posty.c
@@ -1,5 +1,4 @@
#include <ctype.h>
-#include <errno.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
@@ -106,15 +105,9 @@ double top(stack_t *stack) {
int parse_operand(char *token, double *operand) {
char *endPtr;
- errno = 0;
*operand = strtod(token, &endPtr);
- if (errno != 0) {
- *operand = fabs(*operand);
- if (*operand == HUGE_VAL)
- fprintf(stderr, "!! Input overflow.\n");
- if (*operand == 0)
- fprintf(stderr, "!! Input underflow.\n");
-
+ if (*operand == HUGE_VAL) {
+ fprintf(stderr, "!! Input overflow.\n");
return 1;
}
if (token + strlen(token) != endPtr) {

0 comments on commit f0560ec

Please sign in to comment.