examples: don't promote unchecked function calls

* etc/bench.pl.in, examples/c/bistromathic/parse.y,
* examples/c/calc/calc.y, examples/c/pushcalc/calc.y: Check scanf's
return value.
* doc/bison.texi: Likewise, but only for the second example, to avoid
cluttering the very simple case.
This commit is contained in:
Akim Demaille
2020-05-12 19:03:29 +02:00
parent ad921890c1
commit 4619b32dc0
6 changed files with 17 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
%code top {
#include <assert.h>
#include <ctype.h> /* isdigit. */
#include <stdio.h> /* For printf, etc. */
#include <string.h> /* strcmp. */
@@ -73,7 +74,8 @@ yylex (void)
if (c == '.' || isdigit (c))
{
ungetc (c, stdin);
scanf ("%lf", &yylval.NUM);
int n = scanf ("%lf", &yylval.NUM);
assert (n == 1);
return NUM;
}