aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--input.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/input.c b/input.c
index ac706ae..82c1cd1 100644
--- a/input.c
+++ b/input.c
@@ -10,11 +10,13 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
+#include <fenv.h>
char pending_op = 0;
int making_number = 0;
int base = 10;
int quiet = 0;
+int showing_err = 0;
#define MAXIN 40
@@ -79,6 +81,12 @@ show_value()
char commas[40], *cp, *dp;
double v = value;
+ if(fetestexcept(FE_ALL_EXCEPT)) {
+ set_string("Err");
+ showing_err = 1;
+ return;
+ }
+
if (base == 2)
{
int q = (long long)v & 0xffffffffL;
@@ -226,10 +234,16 @@ key(char c)
int v = c;
/* printf("key_number 0x%x\n", v); */
+ feclearexcept(FE_ALL_EXCEPT);
+
+ if(showing_err && c != 27 && c != 'C')
+ return;
+
switch (c)
{
case 27:
case 'C':
+ showing_err = 0;
making_number = 0;
iptr = 0;
pending_op = 0;