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

Commit55cbfa5

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 parent626092a commit55cbfa5

File tree

6 files changed

+53
-52
lines changed

6 files changed

+53
-52
lines changed

‎contrib/cube/cube.c

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

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

@@ -156,12 +156,12 @@ Datum
156156
cube_in(PG_FUNCTION_ARGS)
157157
{
158158
char*str=PG_GETARG_CSTRING(0);
159-
void*result;
159+
NDBOX*result;
160160

161161
cube_scanner_init(str);
162162

163163
if (cube_yyparse(&result)!=0)
164-
cube_yyerror("bogus input");
164+
cube_yyerror(&result,"bogus input");
165165

166166
cube_scanner_finish();
167167

‎contrib/cube/cubeparse.y

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

5-
/* contrib/cube/cubeparse.y*/
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: O_BRACKET paren_list COMMA paren_list C_BRACKET
7070
YYABORT;
7171
}
7272

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

7575
}
7676

@@ -97,7 +97,7 @@ box: O_BRACKET paren_list COMMA paren_list C_BRACKET
9797
YYABORT;
9898
}
9999

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

103103
|paren_list
@@ -114,7 +114,7 @@ box: O_BRACKET paren_list COMMA paren_list C_BRACKET
114114
YYABORT;
115115
}
116116

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

120120
|list
@@ -130,7 +130,7 @@ box: O_BRACKET paren_list COMMA paren_list C_BRACKET
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
@@ -61,7 +61,7 @@ float ({integer}|{real})([eE]{integer})?
6161
%%
6262

6363
void__attribute__((noreturn))
64-
yyerror(constchar *message)
64+
yyerror(NDBOX **result,constchar *message)
6565
{
6666
if (*yytext == YY_END_OF_BUFFER_CHAR)
6767
{

‎contrib/seg/seg.c

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

2424
PG_MODULE_MAGIC;
2525

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

@@ -126,7 +126,7 @@ seg_in(PG_FUNCTION_ARGS)
126126
seg_scanner_init(str);
127127

128128
if (seg_yyparse(result)!=0)
129-
seg_yyerror("bogus input");
129+
seg_yyerror(result,"bogus input");
130130

131131
seg_scanner_finish();
132132

‎contrib/seg/segparse.y

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
%{
2-
#defineYYPARSE_PARAM result/*need this to pass a pointer (void *) to yyparse*/
2+
/*contrib/seg/segparse.y*/
33

44
#include"postgres.h"
55

@@ -24,8 +24,8 @@ extern int seg_yylex(void);
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 @@ static char strbuf[25] = {
4040
%}
4141

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

@@ -65,59 +66,59 @@ static char strbuf[25] = {
6566

6667
range:boundaryPLUMINdeviation
6768
{
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
7980
{
80-
((SEG *)result)->lower =$1.val;
81-
((SEG *)result)->upper =$3.val;
82-
if (((SEG *)result)->lower >((SEG *)result)->upper ) {
81+
result->lower =$1.val;
82+
result->upper =$3.val;
83+
if ( result->lower > result->upper ) {
8384
ereport(ERROR,
8485
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
8586
errmsg("swapped boundaries: %g is greater than %g",
86-
((SEG *)result)->lower,((SEG *)result)->upper)));
87+
result->lower, result->upper)));
8788

8889
YYERROR;
8990
}
90-
((SEG *)result)->l_sigd =$1.sigd;
91-
((SEG *)result)->u_sigd =$3.sigd;
92-
((SEG *)result)->l_ext = ($1.ext ?$1.ext :'\0' );
93-
((SEG *)result)->u_ext = ($3.ext ?$3.ext :'\0' );
91+
result->l_sigd =$1.sigd;
92+
result->u_sigd =$3.sigd;
93+
result->l_ext = ($1.ext ?$1.ext :'\0' );
94+
result->u_ext = ($3.ext ?$3.ext :'\0' );
9495
}
9596

9697
|boundaryRANGE
9798
{
98-
((SEG *)result)->lower =$1.val;
99-
((SEG *)result)->upper = HUGE_VAL;
100-
((SEG *)result)->l_sigd =$1.sigd;
101-
((SEG *)result)->u_sigd =0;
102-
((SEG *)result)->l_ext = ($1.ext ?$1.ext :'\0' );
103-
((SEG *)result)->u_ext ='-';
99+
result->lower =$1.val;
100+
result->upper = HUGE_VAL;
101+
result->l_sigd =$1.sigd;
102+
result->u_sigd =0;
103+
result->l_ext = ($1.ext ?$1.ext :'\0' );
104+
result->u_ext ='-';
104105
}
105106

106107
|RANGEboundary
107108
{
108-
((SEG *)result)->lower = -HUGE_VAL;
109-
((SEG *)result)->upper =$2.val;
110-
((SEG *)result)->l_sigd =0;
111-
((SEG *)result)->u_sigd =$2.sigd;
112-
((SEG *)result)->l_ext ='-';
113-
((SEG *)result)->u_ext = ($2.ext ?$2.ext :'\0' );
109+
result->lower = -HUGE_VAL;
110+
result->upper =$2.val;
111+
result->l_sigd =0;
112+
result->u_sigd =$2.sigd;
113+
result->l_ext ='-';
114+
result->u_ext = ($2.ext ?$2.ext :'\0' );
114115
}
115116

116117
|boundary
117118
{
118-
((SEG *)result)->lower =((SEG *)result)->upper =$1.val;
119-
((SEG *)result)->l_sigd =((SEG *)result)->u_sigd =$1.sigd;
120-
((SEG *)result)->l_ext =((SEG *)result)->u_ext = ($1.ext ?$1.ext :'\0' );
119+
result->lower = result->upper =$1.val;
120+
result->l_sigd = result->u_sigd =$1.sigd;
121+
result->l_ext = result->u_ext = ($1.ext ?$1.ext :'\0' );
121122
}
122123
;
123124

‎contrib/seg/segscan.l

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

6262
void__attribute__((noreturn))
63-
yyerror(constchar *message)
63+
yyerror(SEG *result,constchar *message)
6464
{
6565
if (*yytext == YY_END_OF_BUFFER_CHAR)
6666
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp