mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-14 14:53:03 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user