1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-15 19:21:59 +03:00

Fix contrib/cube and contrib/seg to build with bison 3.0.

These modules used the YYPARSE_PARAM macro, which has been deprecated
by the bison folk since 1.875, and which they finally removed in 3.0.
Adjust the code to use the replacement facility, %parse-param, which
is a much better solution anyway since it allows specification of the
type of the extra parser parameter.  We can thus get rid of a lot of
unsightly casting.

Back-patch to all active branches, since somebody might try to build
a back branch with up-to-date tools.
This commit is contained in:
Tom Lane
2013-07-29 10:42:44 -04:00
parent 8714465f0f
commit 9822dc38e1
6 changed files with 53 additions and 52 deletions

View File

@ -26,8 +26,8 @@ PG_MODULE_MAGIC;
#define ARRPTR(x) ( (double *) ARR_DATA_PTR(x) )
#define ARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
extern int cube_yyparse();
extern void cube_yyerror(const char *message);
extern int cube_yyparse(NDBOX **result);
extern void cube_yyerror(NDBOX **result, const char *message);
extern void cube_scanner_init(const char *str);
extern void cube_scanner_finish(void);
@ -158,12 +158,12 @@ Datum
cube_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
void *result;
NDBOX *result;
cube_scanner_init(str);
if (cube_yyparse(&result) != 0)
cube_yyerror("bogus input");
cube_yyerror(&result, "bogus input");
cube_scanner_finish();

View File

@ -1,10 +1,9 @@
%{
/* contrib/cube/cubeparse.y */
/* NdBox = [(lowerleft),(upperright)] */
/* [(xLL(1)...xLL(N)),(xUR(1)...xUR(n))] */
/* contrib/cube/cubeparse.y */
#define YYPARSE_PARAM result /* need this to pass a pointer (void *) to yyparse */
#define YYSTYPE char *
#define YYDEBUG 1
@ -28,8 +27,8 @@ extern int cube_yylex(void);
static char *scanbuf;
static int scanbuflen;
void cube_yyerror(const char *message);
int cube_yyparse(void *result);
extern int cube_yyparse(NDBOX **result);
extern void cube_yyerror(NDBOX **result, const char *message);
static int delim_count(char *s, char delim);
static NDBOX * write_box(unsigned int dim, char *str1, char *str2);
@ -38,6 +37,7 @@ static NDBOX * write_point_as_box(char *s, int dim);
%}
/* BISON Declarations */
%parse-param {NDBOX **result}
%expect 0
%name-prefix="cube_yy"
@ -70,7 +70,7 @@ box: O_BRACKET paren_list COMMA paren_list C_BRACKET
YYABORT;
}
*((void **)result) = write_box( dim, $2, $4 );
*result = write_box( dim, $2, $4 );
}
@ -97,7 +97,7 @@ box: O_BRACKET paren_list COMMA paren_list C_BRACKET
YYABORT;
}
*((void **)result) = write_box( dim, $1, $3 );
*result = write_box( dim, $1, $3 );
}
| paren_list
@ -114,7 +114,7 @@ box: O_BRACKET paren_list COMMA paren_list C_BRACKET
YYABORT;
}
*((void **)result) = write_point_as_box($1, dim);
*result = write_point_as_box($1, dim);
}
| list
@ -130,7 +130,7 @@ box: O_BRACKET paren_list COMMA paren_list C_BRACKET
CUBE_MAX_DIM)));
YYABORT;
}
*((void **)result) = write_point_as_box($1, dim);
*result = write_point_as_box($1, dim);
}
;

View File

@ -55,7 +55,7 @@ float ({integer}|{real})([eE]{integer})?
%%
void
yyerror(const char *message)
yyerror(NDBOX **result, const char *message)
{
if (*yytext == YY_END_OF_BUFFER_CHAR)
{