Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3587f78

Browse files
committed
Fix contrib/cube and contrib/seg to build with bison 3.0.
These modules used the YYPARSE_PARAM macro, which has been deprecatedby the bison folk since 1.875, and which they finally removed in 3.0.Adjust the code to use the replacement facility, %parse-param, whichis a much better solution anyway since it allows specification of thetype of the extra parser parameter. We can thus get rid of a lot ofunsightly casting.Back-patch to all active branches, since somebody might try to builda back branch with up-to-date tools.
1 parent8e992b0 commit3587f78

File tree

6 files changed

+54
-53
lines changed

6 files changed

+54
-53
lines changed

‎contrib/cube/cube.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ PG_MODULE_MAGIC;
2727
#defineARRPTR(x) ( (double *) ARR_DATA_PTR(x) )
2828
#defineARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
2929

30-
externintcube_yyparse();
31-
externvoidcube_yyerror(constchar*message);
30+
externintcube_yyparse(NDBOX**result);
31+
externvoidcube_yyerror(NDBOX**result,constchar*message);
3232
externvoidcube_scanner_init(constchar*str);
3333
externvoidcube_scanner_finish(void);
3434

@@ -159,12 +159,12 @@ Datum
159159
cube_in(PG_FUNCTION_ARGS)
160160
{
161161
char*str=PG_GETARG_CSTRING(0);
162-
void*result;
162+
NDBOX*result;
163163

164164
cube_scanner_init(str);
165165

166166
if (cube_yyparse(&result)!=0)
167-
cube_yyerror("bogus input");
167+
cube_yyerror(&result,"bogus input");
168168

169169
cube_scanner_finish();
170170

‎contrib/cube/cubeparse.y

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
%{
2+
/* $PostgreSQL: pgsql/contrib/cube/cubeparse.y,v 1.19 2008/11/26 08:45:11 petere Exp $*/
3+
24
/* NdBox = [(lowerleft),(upperright)]*/
35
/* [(xLL(1)...xLL(N)),(xUR(1)...xUR(n))]*/
46

5-
/* $PostgreSQL: pgsql/contrib/cube/cubeparse.y,v 1.19 2008/11/26 08:45:11 petere Exp $*/
6-
7-
#defineYYPARSE_PARAM result/* need this to pass a pointer (void *) to yyparse*/
87
#defineYYSTYPEchar *
98
#defineYYDEBUG1
109

@@ -28,8 +27,8 @@ extern int cube_yylex(void);
2827
staticchar *scanbuf;
2928
staticintscanbuflen;
3029

31-
voidcube_yyerror(constchar *message);
32-
intcube_yyparse(void*result);
30+
externintcube_yyparse(NDBOX **result);
31+
externvoidcube_yyerror(NDBOX **result,constchar *message);
3332

3433
staticintdelim_count(char *s,char delim);
3534
static NDBOX *write_box(unsignedint dim,char *str1,char *str2);
@@ -38,6 +37,7 @@ static NDBOX * write_point_as_box(char *s, int dim);
3837
%}
3938

4039
/* BISON Declarations*/
40+
%parse-param {NDBOX **result}
4141
%expect0
4242
%name-prefix="cube_yy"
4343

@@ -70,7 +70,7 @@ box:
7070
YYABORT;
7171
}
7272

73-
*((void **)result) = write_box( dim,$2,$4 );
73+
*result = write_box( dim,$2,$4 );
7474

7575
}
7676
|
@@ -96,7 +96,7 @@ box:
9696
YYABORT;
9797
}
9898

99-
*((void **)result) = write_box( dim,$1,$3 );
99+
*result = write_box( dim,$1,$3 );
100100
}
101101
|
102102

@@ -113,7 +113,7 @@ box:
113113
YYABORT;
114114
}
115115

116-
*((void **)result) = write_point_as_box($1, dim);
116+
*result = write_point_as_box($1, dim);
117117
}
118118

119119
|
@@ -130,7 +130,7 @@ box:
130130
CUBE_MAX_DIM)));
131131
YYABORT;
132132
}
133-
*((void **)result) = write_point_as_box($1, dim);
133+
*result = write_point_as_box($1, dim);
134134
}
135135
;
136136

‎contrib/cube/cubescan.l

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ float ({integer}|{real})([eE]{integer})?
5454
%%
5555

5656
void
57-
yyerror(constchar *message)
57+
yyerror(NDBOX **result,constchar *message)
5858
{
5959
if (*yytext == YY_END_OF_BUFFER_CHAR)
6060
{

‎contrib/seg/seg.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
PG_MODULE_MAGIC;
2626

27-
externintseg_yyparse();
28-
externvoidseg_yyerror(constchar*message);
27+
externintseg_yyparse(SEG*result);
28+
externvoidseg_yyerror(SEG*result,constchar*message);
2929
externvoidseg_scanner_init(constchar*str);
3030
externvoidseg_scanner_finish(void);
3131

@@ -117,7 +117,7 @@ seg_in(PG_FUNCTION_ARGS)
117117
seg_scanner_init(str);
118118

119119
if (seg_yyparse(result)!=0)
120-
seg_yyerror("bogus input");
120+
seg_yyerror(result,"bogus input");
121121

122122
seg_scanner_finish();
123123

‎contrib/seg/segparse.y

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%{
2-
#defineYYPARSE_PARAM result/*need this to pass a pointer (void *) to yyparse*/
3-
2+
/*contrib/seg/segparse.y*/
3+
44
#include"postgres.h"
55

66
#include<math.h>
@@ -24,8 +24,8 @@
2424

2525
externintsignificant_digits(char *str);/* defined in seg.c*/
2626

27-
voidseg_yyerror(constchar *message);
28-
intseg_yyparse(void *result);
27+
externintseg_yyparse(SEG *result);
28+
externvoidseg_yyerror(SEG*result,constchar *message);
2929

3030
staticfloatseg_atof(char *value);
3131

@@ -40,6 +40,7 @@
4040
%}
4141

4242
/* BISON Declarations*/
43+
%parse-param {SEG *result}
4344
%expect0
4445
%name-prefix="seg_yy"
4546

@@ -65,55 +66,55 @@
6566

6667
range:
6768
boundaryPLUMINdeviation {
68-
((SEG *)result)->lower =$1.val -$3.val;
69-
((SEG *)result)->upper =$1.val +$3.val;
70-
sprintf(strbuf,"%g",((SEG *)result)->lower);
71-
((SEG *)result)->l_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd,$3.sigd));
72-
sprintf(strbuf,"%g",((SEG *)result)->upper);
73-
((SEG *)result)->u_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd,$3.sigd));
74-
((SEG *)result)->l_ext ='\0';
75-
((SEG *)result)->u_ext ='\0';
69+
result->lower =$1.val -$3.val;
70+
result->upper =$1.val +$3.val;
71+
sprintf(strbuf,"%g", result->lower);
72+
result->l_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd,$3.sigd));
73+
sprintf(strbuf,"%g", result->upper);
74+
result->u_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd,$3.sigd));
75+
result->l_ext ='\0';
76+
result->u_ext ='\0';
7677
}
7778
|
7879
boundaryRANGEboundary {
79-
((SEG *)result)->lower =$1.val;
80-
((SEG *)result)->upper =$3.val;
81-
if (((SEG *)result)->lower >((SEG *)result)->upper ) {
80+
result->lower =$1.val;
81+
result->upper =$3.val;
82+
if ( result->lower > result->upper ) {
8283
ereport(ERROR,
8384
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
8485
errmsg("swapped boundaries: %g is greater than %g",
85-
((SEG *)result)->lower,((SEG *)result)->upper)));
86+
result->lower, result->upper)));
8687

8788
YYERROR;
8889
}
89-
((SEG *)result)->l_sigd =$1.sigd;
90-
((SEG *)result)->u_sigd =$3.sigd;
91-
((SEG *)result)->l_ext = ($1.ext ?$1.ext :'\0' );
92-
((SEG *)result)->u_ext = ($3.ext ?$3.ext :'\0' );
90+
result->l_sigd =$1.sigd;
91+
result->u_sigd =$3.sigd;
92+
result->l_ext = ($1.ext ?$1.ext :'\0' );
93+
result->u_ext = ($3.ext ?$3.ext :'\0' );
9394
}
9495
|
9596
boundaryRANGE {
96-
((SEG *)result)->lower =$1.val;
97-
((SEG *)result)->upper = HUGE_VAL;
98-
((SEG *)result)->l_sigd =$1.sigd;
99-
((SEG *)result)->u_sigd =0;
100-
((SEG *)result)->l_ext = ($1.ext ?$1.ext :'\0' );
101-
((SEG *)result)->u_ext ='-';
97+
result->lower =$1.val;
98+
result->upper = HUGE_VAL;
99+
result->l_sigd =$1.sigd;
100+
result->u_sigd =0;
101+
result->l_ext = ($1.ext ?$1.ext :'\0' );
102+
result->u_ext ='-';
102103
}
103104
|
104105
RANGEboundary {
105-
((SEG *)result)->lower = -HUGE_VAL;
106-
((SEG *)result)->upper =$2.val;
107-
((SEG *)result)->l_sigd =0;
108-
((SEG *)result)->u_sigd =$2.sigd;
109-
((SEG *)result)->l_ext ='-';
110-
((SEG *)result)->u_ext = ($2.ext ?$2.ext :'\0' );
106+
result->lower = -HUGE_VAL;
107+
result->upper =$2.val;
108+
result->l_sigd =0;
109+
result->u_sigd =$2.sigd;
110+
result->l_ext ='-';
111+
result->u_ext = ($2.ext ?$2.ext :'\0' );
111112
}
112113
|
113114
boundary {
114-
((SEG *)result)->lower =((SEG *)result)->upper =$1.val;
115-
((SEG *)result)->l_sigd =((SEG *)result)->u_sigd =$1.sigd;
116-
((SEG *)result)->l_ext =((SEG *)result)->u_ext = ($1.ext ?$1.ext :'\0' );
115+
result->lower = result->upper =$1.val;
116+
result->l_sigd = result->u_sigd =$1.sigd;
117+
result->l_ext = result->u_ext = ($1.ext ?$1.ext :'\0' );
117118
}
118119
;
119120

‎contrib/seg/segscan.l

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ float ({integer}|{real})([eE]{integer})?
5353
%%
5454

5555
void
56-
yyerror(constchar *message)
56+
yyerror(SEG *result,constchar *message)
5757
{
5858
if (*yytext == YY_END_OF_BUFFER_CHAR)
5959
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp