mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +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:
		@@ -27,8 +27,8 @@ PG_MODULE_MAGIC;
 | 
				
			|||||||
#define ARRPTR(x)  ( (double *) ARR_DATA_PTR(x) )
 | 
					#define ARRPTR(x)  ( (double *) ARR_DATA_PTR(x) )
 | 
				
			||||||
#define ARRNELEMS(x)  ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
 | 
					#define ARRNELEMS(x)  ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern int	cube_yyparse();
 | 
					extern int	cube_yyparse(NDBOX **result);
 | 
				
			||||||
extern void cube_yyerror(const char *message);
 | 
					extern void cube_yyerror(NDBOX **result, const char *message);
 | 
				
			||||||
extern void cube_scanner_init(const char *str);
 | 
					extern void cube_scanner_init(const char *str);
 | 
				
			||||||
extern void cube_scanner_finish(void);
 | 
					extern void cube_scanner_finish(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -159,12 +159,12 @@ Datum
 | 
				
			|||||||
cube_in(PG_FUNCTION_ARGS)
 | 
					cube_in(PG_FUNCTION_ARGS)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char	   *str = PG_GETARG_CSTRING(0);
 | 
						char	   *str = PG_GETARG_CSTRING(0);
 | 
				
			||||||
	void	   *result;
 | 
						NDBOX	   *result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cube_scanner_init(str);
 | 
						cube_scanner_init(str);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (cube_yyparse(&result) != 0)
 | 
						if (cube_yyparse(&result) != 0)
 | 
				
			||||||
		cube_yyerror("bogus input");
 | 
							cube_yyerror(&result, "bogus input");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cube_scanner_finish();
 | 
						cube_scanner_finish();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,10 +1,9 @@
 | 
				
			|||||||
%{
 | 
					%{
 | 
				
			||||||
 | 
					/* contrib/cube/cubeparse.y */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* NdBox = [(lowerleft),(upperright)] */
 | 
					/* NdBox = [(lowerleft),(upperright)] */
 | 
				
			||||||
/* [(xLL(1)...xLL(N)),(xUR(1)...xUR(n))] */
 | 
					/* [(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 YYSTYPE char *
 | 
				
			||||||
#define YYDEBUG 1
 | 
					#define YYDEBUG 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -28,8 +27,8 @@ extern int cube_yylex(void);
 | 
				
			|||||||
static char *scanbuf;
 | 
					static char *scanbuf;
 | 
				
			||||||
static int	scanbuflen;
 | 
					static int	scanbuflen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void cube_yyerror(const char *message);
 | 
					extern int	cube_yyparse(NDBOX **result);
 | 
				
			||||||
int cube_yyparse(void *result);
 | 
					extern void cube_yyerror(NDBOX **result, const char *message);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int delim_count(char *s, char delim);
 | 
					static int delim_count(char *s, char delim);
 | 
				
			||||||
static NDBOX * write_box(unsigned int dim, char *str1, char *str2);
 | 
					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 */
 | 
					/* BISON Declarations */
 | 
				
			||||||
 | 
					%parse-param {NDBOX **result}
 | 
				
			||||||
%expect 0
 | 
					%expect 0
 | 
				
			||||||
%name-prefix="cube_yy"
 | 
					%name-prefix="cube_yy"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -70,7 +70,7 @@ box:
 | 
				
			|||||||
              YYABORT;
 | 
					              YYABORT;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	    *((void **)result) = write_box( dim, $2, $4 );
 | 
						    *result = write_box( dim, $2, $4 );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
      |
 | 
					      |
 | 
				
			||||||
@@ -96,7 +96,7 @@ box:
 | 
				
			|||||||
              YYABORT;
 | 
					              YYABORT;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	    *((void **)result) = write_box( dim, $1, $3 );
 | 
						    *result = write_box( dim, $1, $3 );
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
      |
 | 
					      |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -113,7 +113,7 @@ box:
 | 
				
			|||||||
              YYABORT;
 | 
					              YYABORT;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	    *((void **)result) = write_point_as_box($1, dim);
 | 
						    *result = write_point_as_box($1, dim);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      |
 | 
					      |
 | 
				
			||||||
@@ -130,7 +130,7 @@ box:
 | 
				
			|||||||
                                 CUBE_MAX_DIM)));
 | 
					                                 CUBE_MAX_DIM)));
 | 
				
			||||||
              YYABORT;
 | 
					              YYABORT;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
	    *((void **)result) = write_point_as_box($1, dim);
 | 
						    *result = write_point_as_box($1, dim);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
      ;
 | 
					      ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -54,7 +54,7 @@ float        ({integer}|{real})([eE]{integer})?
 | 
				
			|||||||
%%
 | 
					%%
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
yyerror(const char *message)
 | 
					yyerror(NDBOX **result, const char *message)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (*yytext == YY_END_OF_BUFFER_CHAR)
 | 
						if (*yytext == YY_END_OF_BUFFER_CHAR)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,8 +24,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
PG_MODULE_MAGIC;
 | 
					PG_MODULE_MAGIC;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern int	seg_yyparse();
 | 
					extern int	seg_yyparse(SEG *result);
 | 
				
			||||||
extern void seg_yyerror(const char *message);
 | 
					extern void seg_yyerror(SEG *result, const char *message);
 | 
				
			||||||
extern void seg_scanner_init(const char *str);
 | 
					extern void seg_scanner_init(const char *str);
 | 
				
			||||||
extern void seg_scanner_finish(void);
 | 
					extern void seg_scanner_finish(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -127,7 +127,7 @@ seg_in(PG_FUNCTION_ARGS)
 | 
				
			|||||||
	seg_scanner_init(str);
 | 
						seg_scanner_init(str);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (seg_yyparse(result) != 0)
 | 
						if (seg_yyparse(result) != 0)
 | 
				
			||||||
		seg_yyerror("bogus input");
 | 
							seg_yyerror(result, "bogus input");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	seg_scanner_finish();
 | 
						seg_scanner_finish();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
%{
 | 
					%{
 | 
				
			||||||
#define YYPARSE_PARAM result  /* need this to pass a pointer (void *) to yyparse */
 | 
					/* contrib/seg/segparse.y */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "postgres.h"
 | 
					#include "postgres.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -24,8 +24,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  extern int significant_digits(char *str);		/* defined in seg.c */
 | 
					  extern int significant_digits(char *str);		/* defined in seg.c */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void seg_yyerror(const char *message);
 | 
					  extern int	seg_yyparse(SEG *result);
 | 
				
			||||||
  int seg_yyparse(void *result);
 | 
					  extern void seg_yyerror(SEG *result, const char *message);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  static float seg_atof(char *value);
 | 
					  static float seg_atof(char *value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -40,6 +40,7 @@
 | 
				
			|||||||
%}
 | 
					%}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* BISON Declarations */
 | 
					/* BISON Declarations */
 | 
				
			||||||
 | 
					%parse-param {SEG *result}
 | 
				
			||||||
%expect 0
 | 
					%expect 0
 | 
				
			||||||
%name-prefix="seg_yy"
 | 
					%name-prefix="seg_yy"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -65,55 +66,55 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
range:
 | 
					range:
 | 
				
			||||||
          boundary PLUMIN deviation {
 | 
					          boundary PLUMIN deviation {
 | 
				
			||||||
	    ((SEG *)result)->lower = $1.val - $3.val;
 | 
						    result->lower = $1.val - $3.val;
 | 
				
			||||||
	    ((SEG *)result)->upper = $1.val + $3.val;
 | 
						    result->upper = $1.val + $3.val;
 | 
				
			||||||
	    sprintf(strbuf, "%g", ((SEG *)result)->lower);
 | 
						    sprintf(strbuf, "%g", result->lower);
 | 
				
			||||||
	    ((SEG *)result)->l_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd));
 | 
						    result->l_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd));
 | 
				
			||||||
	    sprintf(strbuf, "%g", ((SEG *)result)->upper);
 | 
						    sprintf(strbuf, "%g", result->upper);
 | 
				
			||||||
	    ((SEG *)result)->u_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd));
 | 
						    result->u_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd));
 | 
				
			||||||
	    ((SEG *)result)->l_ext = '\0';
 | 
						    result->l_ext = '\0';
 | 
				
			||||||
	    ((SEG *)result)->u_ext = '\0';
 | 
						    result->u_ext = '\0';
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
      |
 | 
					      |
 | 
				
			||||||
          boundary RANGE boundary {
 | 
					          boundary RANGE boundary {
 | 
				
			||||||
	    ((SEG *)result)->lower = $1.val;
 | 
						    result->lower = $1.val;
 | 
				
			||||||
	    ((SEG *)result)->upper = $3.val;
 | 
						    result->upper = $3.val;
 | 
				
			||||||
	    if ( ((SEG *)result)->lower > ((SEG *)result)->upper ) {
 | 
						    if ( result->lower > result->upper ) {
 | 
				
			||||||
	      ereport(ERROR,
 | 
						      ereport(ERROR,
 | 
				
			||||||
				  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
 | 
									  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
 | 
				
			||||||
				   errmsg("swapped boundaries: %g is greater than %g",
 | 
									   errmsg("swapped boundaries: %g is greater than %g",
 | 
				
			||||||
						  ((SEG *)result)->lower, ((SEG *)result)->upper)));
 | 
											  result->lower, result->upper)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	      YYERROR;
 | 
						      YYERROR;
 | 
				
			||||||
	    }
 | 
						    }
 | 
				
			||||||
	    ((SEG *)result)->l_sigd = $1.sigd;
 | 
						    result->l_sigd = $1.sigd;
 | 
				
			||||||
	    ((SEG *)result)->u_sigd = $3.sigd;
 | 
						    result->u_sigd = $3.sigd;
 | 
				
			||||||
	    ((SEG *)result)->l_ext = ( $1.ext ? $1.ext : '\0' );
 | 
						    result->l_ext = ( $1.ext ? $1.ext : '\0' );
 | 
				
			||||||
	    ((SEG *)result)->u_ext = ( $3.ext ? $3.ext : '\0' );
 | 
						    result->u_ext = ( $3.ext ? $3.ext : '\0' );
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
      |
 | 
					      |
 | 
				
			||||||
          boundary RANGE {
 | 
					          boundary RANGE {
 | 
				
			||||||
	    ((SEG *)result)->lower = $1.val;
 | 
						    result->lower = $1.val;
 | 
				
			||||||
	    ((SEG *)result)->upper = HUGE_VAL;
 | 
						    result->upper = HUGE_VAL;
 | 
				
			||||||
	    ((SEG *)result)->l_sigd = $1.sigd;
 | 
						    result->l_sigd = $1.sigd;
 | 
				
			||||||
	    ((SEG *)result)->u_sigd = 0;
 | 
						    result->u_sigd = 0;
 | 
				
			||||||
	    ((SEG *)result)->l_ext = ( $1.ext ? $1.ext : '\0' );
 | 
						    result->l_ext = ( $1.ext ? $1.ext : '\0' );
 | 
				
			||||||
	    ((SEG *)result)->u_ext = '-';
 | 
						    result->u_ext = '-';
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
      |
 | 
					      |
 | 
				
			||||||
          RANGE boundary {
 | 
					          RANGE boundary {
 | 
				
			||||||
	    ((SEG *)result)->lower = -HUGE_VAL;
 | 
						    result->lower = -HUGE_VAL;
 | 
				
			||||||
	    ((SEG *)result)->upper = $2.val;
 | 
						    result->upper = $2.val;
 | 
				
			||||||
	    ((SEG *)result)->l_sigd = 0;
 | 
						    result->l_sigd = 0;
 | 
				
			||||||
	    ((SEG *)result)->u_sigd = $2.sigd;
 | 
						    result->u_sigd = $2.sigd;
 | 
				
			||||||
	    ((SEG *)result)->l_ext = '-';
 | 
						    result->l_ext = '-';
 | 
				
			||||||
	    ((SEG *)result)->u_ext = ( $2.ext ? $2.ext : '\0' );
 | 
						    result->u_ext = ( $2.ext ? $2.ext : '\0' );
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
      |
 | 
					      |
 | 
				
			||||||
          boundary {
 | 
					          boundary {
 | 
				
			||||||
	    ((SEG *)result)->lower = ((SEG *)result)->upper = $1.val;
 | 
						    result->lower = result->upper = $1.val;
 | 
				
			||||||
	    ((SEG *)result)->l_sigd = ((SEG *)result)->u_sigd = $1.sigd;
 | 
						    result->l_sigd = result->u_sigd = $1.sigd;
 | 
				
			||||||
	    ((SEG *)result)->l_ext = ((SEG *)result)->u_ext = ( $1.ext ? $1.ext : '\0' );
 | 
						    result->l_ext = result->u_ext = ( $1.ext ? $1.ext : '\0' );
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
      ;
 | 
					      ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -53,7 +53,7 @@ float        ({integer}|{real})([eE]{integer})?
 | 
				
			|||||||
%%
 | 
					%%
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
yyerror(const char *message)
 | 
					yyerror(SEG *result, const char *message)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (*yytext == YY_END_OF_BUFFER_CHAR)
 | 
						if (*yytext == YY_END_OF_BUFFER_CHAR)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user