summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-10-06 11:58:10 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2019-10-06 11:59:16 -0700
commit6373b90fc8f9ab2bfa19a107d44cfad3404faf20 (patch)
treecfbfcd4214d17bf0f8ae9142e715761e071d7436 /data
parentbeceb2fa9382fd44816cae382dd12ffc6a210d5e (diff)
downloadbison-6373b90fc8f9ab2bfa19a107d44cfad3404faf20.tar.gz
Port better to C++ platforms
* data/skeletons/yacc.c (YYPTRDIFF_T, YYPTRDIFF_MAXIMUM): Default to long, not int. (yy_lac_stack_realloc, yy_lac, yytnamerr, yyparse): Avoid casts to YYPTRDIFF_T that were masking the problem.
Diffstat (limited to 'data')
-rw-r--r--data/skeletons/yacc.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c
index 5ef4289e..10708627 100644
--- a/data/skeletons/yacc.c
+++ b/data/skeletons/yacc.c
@@ -425,9 +425,9 @@ typedef short yytype_int16;
# include <stdint.h> /* INFRINGES ON USER NAME SPACE */
# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
# else
-# define YYPTRDIFF_T int
+# define YYPTRDIFF_T long
# include <limits.h> /* INFRINGES ON USER NAME SPACE */
-# define YYPTRDIFF_MAXIMUM INT_MAX
+# define YYPTRDIFF_MAXIMUM LONG_MAX
# endif
#endif
@@ -857,7 +857,7 @@ yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd,
yy_state_num **yytop, yy_state_num *yytop_empty)
{
YYPTRDIFF_T yysize_old =
- *yytop == yytop_empty ? 0 : (YYPTRDIFF_T) (*yytop - *yybottom + 1);
+ *yytop == yytop_empty ? 0 : *yytop - *yybottom + 1;
YYPTRDIFF_T yysize_new = yysize_old + yyadd;
if (*yycapacity < yysize_new)
{
@@ -1024,7 +1024,7 @@ yy_lac (yy_state_num *yyesa, yy_state_num **yyes,
YYDPRINTF ((stderr, " R%d", yyrule - 1));
if (yyesp != yyes_prev)
{
- YYPTRDIFF_T yysize = (YYPTRDIFF_T) (yyesp - *yyes + 1);
+ YYPTRDIFF_T yysize = yyesp - *yyes + 1;
if (yylen < yysize)
{
yyesp -= yylen;
@@ -1155,7 +1155,7 @@ yytnamerr (char *yyres, const char *yystr)
}
if (yyres)
- return (YYPTRDIFF_T) (yystpcpy (yyres, yystr) - yyres);
+ return yystpcpy (yyres, yystr) - yyres;
else
return yystrlen (yystr);
}
@@ -1535,7 +1535,7 @@ yysetstate:
#else
{
/* Get the current used size of the three stacks, in elements. */
- YYPTRDIFF_T yysize = (YYPTRDIFF_T) (yyssp - yyss + 1);
+ YYPTRDIFF_T yysize = yyssp - yyss + 1;
# if defined yyoverflow
{