summaryrefslogtreecommitdiff
path: root/examples/c/calc
diff options
context:
space:
mode:
Diffstat (limited to 'examples/c/calc')
-rw-r--r--examples/c/calc/calc.y6
-rw-r--r--examples/c/calc/local.mk1
2 files changed, 5 insertions, 2 deletions
diff --git a/examples/c/calc/calc.y b/examples/c/calc/calc.y
index 7757648d..97e352a0 100644
--- a/examples/c/calc/calc.y
+++ b/examples/c/calc/calc.y
@@ -1,6 +1,7 @@
%code top {
#include <ctype.h> /* isdigit. */
- #include <stdio.h> /* For printf, etc. */
+ #include <stdio.h> /* printf. */
+ #include <stdlib.h> /* abort. */
#include <string.h> /* strcmp. */
int yylex (void);
@@ -73,7 +74,8 @@ yylex (void)
if (c == '.' || isdigit (c))
{
ungetc (c, stdin);
- scanf ("%lf", &yylval.NUM);
+ if (scanf ("%lf", &yylval.NUM) != 1)
+ abort ();
return NUM;
}
diff --git a/examples/c/calc/local.mk b/examples/c/calc/local.mk
index 14b78f3b..503b034a 100644
--- a/examples/c/calc/local.mk
+++ b/examples/c/calc/local.mk
@@ -27,6 +27,7 @@ nodist_%C%_calc_SOURCES = %D%/calc.y
# Don't use gnulib's system headers.
%C%_calc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
+%C%_calc_CFLAGS = $(TEST_CFLAGS)
dist_calc_DATA = %D%/calc.y %D%/Makefile %D%/README.md
CLEANFILES += %D%/calc.[ch] %D%/calc.output %D%/scan.c