summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2020-05-12 19:03:29 +0200
committerAkim Demaille <akim.demaille@gmail.com>2020-05-16 14:39:57 +0200
commit4619b32dc079b7833a784d788114cb1129647723 (patch)
tree7f29c087d194f446ac6eee6c3c3c8b3e5c170e35 /doc
parentad921890c1af6926ccbe80f2c8ba532ac7f5a302 (diff)
downloadbison-4619b32dc079b7833a784d788114cb1129647723.tar.gz
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.
Diffstat (limited to 'doc')
-rw-r--r--doc/bison.texi4
1 files changed, 3 insertions, 1 deletions
diff --git a/doc/bison.texi b/doc/bison.texi
index 726cbf22..15c9b1c0 100644
--- a/doc/bison.texi
+++ b/doc/bison.texi
@@ -2656,6 +2656,7 @@ found, a pointer to that symbol is returned; otherwise zero is returned.
always succeed, and that integer calculations
never overflow. Production-quality code should
not make these assumptions. */
+#include <assert.h>
#include <stdlib.h> /* malloc, realloc. */
#include <string.h> /* strlen. */
@end group
@@ -2728,7 +2729,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;
@}
@end group