diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2013-07-29 10:42:44 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2013-07-29 10:42:44 -0400 |
commit | 9822dc38e193f5f9e6f088e6566cfcb1dba49db2 (patch) | |
tree | b9f293f8c76544ec7e460c08288594861acc8314 /contrib/seg/segparse.y | |
parent | 8714465f0f5ca54b6ad8b1fc8320fad6b8e9e2aa (diff) |
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.
Diffstat (limited to 'contrib/seg/segparse.y')
-rw-r--r-- | contrib/seg/segparse.y | 69 |
1 files changed, 35 insertions, 34 deletions
diff --git a/contrib/seg/segparse.y b/contrib/seg/segparse.y index e6a0bad5912..3fad9910bd5 100644 --- a/contrib/seg/segparse.y +++ b/contrib/seg/segparse.y @@ -1,5 +1,5 @@ %{ -#define YYPARSE_PARAM result /* need this to pass a pointer (void *) to yyparse */ +/* contrib/seg/segparse.y */ #include "postgres.h" @@ -24,8 +24,8 @@ extern int seg_yylex(void); extern int significant_digits(char *str); /* defined in seg.c */ -void seg_yyerror(const char *message); -int seg_yyparse(void *result); +extern int seg_yyparse(SEG *result); +extern void seg_yyerror(SEG *result, const char *message); static float seg_atof(char *value); @@ -40,6 +40,7 @@ static char strbuf[25] = { %} /* BISON Declarations */ +%parse-param {SEG *result} %expect 0 %name-prefix="seg_yy" @@ -65,59 +66,59 @@ static char strbuf[25] = { range: boundary PLUMIN deviation { - ((SEG *)result)->lower = $1.val - $3.val; - ((SEG *)result)->upper = $1.val + $3.val; - sprintf(strbuf, "%g", ((SEG *)result)->lower); - ((SEG *)result)->l_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd)); - sprintf(strbuf, "%g", ((SEG *)result)->upper); - ((SEG *)result)->u_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd)); - ((SEG *)result)->l_ext = '\0'; - ((SEG *)result)->u_ext = '\0'; + result->lower = $1.val - $3.val; + result->upper = $1.val + $3.val; + sprintf(strbuf, "%g", result->lower); + result->l_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd)); + sprintf(strbuf, "%g", result->upper); + result->u_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd)); + result->l_ext = '\0'; + result->u_ext = '\0'; } | boundary RANGE boundary { - ((SEG *)result)->lower = $1.val; - ((SEG *)result)->upper = $3.val; - if ( ((SEG *)result)->lower > ((SEG *)result)->upper ) { + result->lower = $1.val; + result->upper = $3.val; + if ( result->lower > result->upper ) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("swapped boundaries: %g is greater than %g", - ((SEG *)result)->lower, ((SEG *)result)->upper))); + result->lower, result->upper))); YYERROR; } - ((SEG *)result)->l_sigd = $1.sigd; - ((SEG *)result)->u_sigd = $3.sigd; - ((SEG *)result)->l_ext = ( $1.ext ? $1.ext : '\0' ); - ((SEG *)result)->u_ext = ( $3.ext ? $3.ext : '\0' ); + result->l_sigd = $1.sigd; + result->u_sigd = $3.sigd; + result->l_ext = ( $1.ext ? $1.ext : '\0' ); + result->u_ext = ( $3.ext ? $3.ext : '\0' ); } | boundary RANGE { - ((SEG *)result)->lower = $1.val; - ((SEG *)result)->upper = HUGE_VAL; - ((SEG *)result)->l_sigd = $1.sigd; - ((SEG *)result)->u_sigd = 0; - ((SEG *)result)->l_ext = ( $1.ext ? $1.ext : '\0' ); - ((SEG *)result)->u_ext = '-'; + result->lower = $1.val; + result->upper = HUGE_VAL; + result->l_sigd = $1.sigd; + result->u_sigd = 0; + result->l_ext = ( $1.ext ? $1.ext : '\0' ); + result->u_ext = '-'; } | RANGE boundary { - ((SEG *)result)->lower = -HUGE_VAL; - ((SEG *)result)->upper = $2.val; - ((SEG *)result)->l_sigd = 0; - ((SEG *)result)->u_sigd = $2.sigd; - ((SEG *)result)->l_ext = '-'; - ((SEG *)result)->u_ext = ( $2.ext ? $2.ext : '\0' ); + result->lower = -HUGE_VAL; + result->upper = $2.val; + result->l_sigd = 0; + result->u_sigd = $2.sigd; + result->l_ext = '-'; + result->u_ext = ( $2.ext ? $2.ext : '\0' ); } | boundary { - ((SEG *)result)->lower = ((SEG *)result)->upper = $1.val; - ((SEG *)result)->l_sigd = ((SEG *)result)->u_sigd = $1.sigd; - ((SEG *)result)->l_ext = ((SEG *)result)->u_ext = ( $1.ext ? $1.ext : '\0' ); + result->lower = result->upper = $1.val; + result->l_sigd = result->u_sigd = $1.sigd; + result->l_ext = result->u_ext = ( $1.ext ? $1.ext : '\0' ); } ; |