Skip to content

Commit

Permalink
Merge pull request #112 from hartwork/issue-111-require-finite-values
Browse files Browse the repository at this point in the history
Require finite values from stdin (fixes #111)
  • Loading branch information
hartwork authored Nov 30, 2023
2 parents 1ac58c4 + bb5915e commit ef2c97a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ttyplot.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <assert.h>
#include <ctype.h> // isspace
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -385,6 +386,8 @@ size_t handle_input_data(char *buffer, size_t length)
double value = strtod(token, &number_end);
if (*number_end != '\0') // garbage found
value = 0;
if (! isfinite(value))
value = 0;
if (handle_value(value))
records++;
str = NULL; // tell strtok() to stay on the same string
Expand Down

0 comments on commit ef2c97a

Please sign in to comment.