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

Commitdac048f

Browse files
committed
Build all Flex files standalone
The proposed Meson build system will need a way to ignore certaingenerated files in order to coexist with the autoconf build system,and C files generated by Flex which are #include'd into .y files makethis more difficult. In similar vein to72b1e3a, arrange for all FlexC files to compile to their own .o targets.Reviewed by Andres FreundDiscussion:https://www.postgresql.org/message-id/20220810171935.7k5zgnjwqzalzmtm%40awork3.anarazel.deDiscussion:https://www.postgresql.org/message-id/CAFBsxsF8Gc2StS3haXofshHCzqNMRXiSxvQEYGwnFsTmsdwNeg@mail.gmail.com
1 parent80e8450 commitdac048f

38 files changed

+307
-190
lines changed

‎contrib/cube/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/cubeparse.h
12
/cubeparse.c
23
/cubescan.c
34
# Generated subdirectories

‎contrib/cube/Makefile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ MODULE_big = cube
44
OBJS =\
55
$(WIN32RES)\
66
cube.o\
7-
cubeparse.o
7+
cubeparse.o\
8+
cubescan.o
89

910
EXTENSION = cube
1011
DATA = cube--1.2.sql cube--1.2--1.3.sql cube--1.3--1.4.sql cube--1.4--1.5.sql\
@@ -15,8 +16,6 @@ HEADERS = cubedata.h
1516

1617
REGRESS = cube cube_sci
1718

18-
EXTRA_CLEAN = y.tab.c y.tab.h
19-
2019
SHLIB_LINK +=$(filter -lm,$(LIBS))
2120

2221
ifdefUSE_PGXS
@@ -30,11 +29,16 @@ include $(top_builddir)/src/Makefile.global
3029
include$(top_srcdir)/contrib/contrib-global.mk
3130
endif
3231

32+
# See notes in src/backend/parser/Makefile about the following two rules
33+
cubeparse.h: cubeparse.c
34+
touch$@
35+
36+
cubeparse.c: BISONFLAGS += -d
3337

34-
#cubescan is compiled as part of cubeparse
35-
cubeparse.o: cubescan.c
38+
#Force these dependencies to be known even without dependency info built:
39+
cubeparse.ocubescan.o: cubeparse.h
3640

3741
distprep: cubeparse.c cubescan.c
3842

3943
maintainer-clean:
40-
rm -f cubeparse.c cubescan.c
44+
rm -f cubeparse.h cubeparse.c cubescan.c

‎contrib/cube/cube.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ cube_in(PG_FUNCTION_ARGS)
119119
{
120120
char*str=PG_GETARG_CSTRING(0);
121121
NDBOX*result;
122+
Sizescanbuflen;
122123

123-
cube_scanner_init(str);
124+
cube_scanner_init(str,&scanbuflen);
124125

125-
if (cube_yyparse(&result)!=0)
126-
cube_yyerror(&result,"cube parser failed");
126+
cube_yyparse(&result,scanbuflen);
127127

128128
cube_scanner_finish();
129129

‎contrib/cube/cubedata.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ typedef struct NDBOX
6161

6262
/* in cubescan.l */
6363
externintcube_yylex(void);
64-
externvoidcube_yyerror(NDBOX**result,constchar*message)pg_attribute_noreturn();
65-
externvoidcube_scanner_init(constchar*str);
64+
externvoidcube_yyerror(NDBOX**result,Sizescanbuflen,constchar*message)pg_attribute_noreturn();
65+
externvoidcube_scanner_init(constchar*str,Size*scanbuflen);
6666
externvoidcube_scanner_finish(void);
6767

6868
/* in cubeparse.y */
69-
externintcube_yyparse(NDBOX**result);
69+
externintcube_yyparse(NDBOX**result,Sizescanbuflen);

‎contrib/cube/cubeparse.y

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
#defineYYMALLOC palloc
2424
#defineYYFREE pfree
2525

26-
staticchar *scanbuf;
27-
staticintscanbuflen;
28-
2926
staticintitem_count(constchar *s,char delim);
3027
static NDBOX *write_box(int dim,char *str1,char *str2);
3128
static NDBOX *write_point_as_box(int dim,char *str);
@@ -34,6 +31,7 @@ static NDBOX *write_point_as_box(int dim, char *str);
3431

3532
/* BISON Declarations*/
3633
%parse-param {NDBOX **result}
34+
%parse-param {Size scanbuflen}
3735
%expect0
3836
%name-prefix="cube_yy"
3937

@@ -265,5 +263,3 @@ write_point_as_box(int dim, char *str)
265263

266264
return bp;
267265
}
268-
269-
#include"cubescan.c"

‎contrib/cube/cubescan.l

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
1-
%{
1+
%top{
22
/*
33
* A scanner for EMP-style numeric ranges
44
* contrib/cube/cubescan.l
55
*/
66

7+
#include "postgres.h"
8+
9+
/*
10+
* NB: include cubeparse.h only AFTER defining YYSTYPE (to match cubeparse.y)
11+
* and cubedata.h for NDBOX.
12+
*/
13+
#include "cubedata.h"
14+
#define YYSTYPE char *
15+
#include "cubeparse.h"
16+
}
17+
18+
%{
719
/* LCOV_EXCL_START*/
820

921
/* No reason to constrain amount of data slurped*/
@@ -21,9 +33,7 @@ fprintf_to_ereport(const char *fmt, const char *msg)
2133

2234
/* Handles to the buffer that the lexer uses internally*/
2335
static YY_BUFFER_STATE scanbufhandle;
24-
/* this is now declared in cubeparse.y:*/
25-
/* static char *scanbuf;*/
26-
/* static intscanbuflen;*/
36+
staticchar *scanbuf;
2737
%}
2838

2939
%option8bit
@@ -45,24 +55,24 @@ NaN [nN][aA][nN]
4555

4656
%%
4757

48-
{float}yylval = yytext;return CUBEFLOAT;
49-
{infinity}yylval = yytext;return CUBEFLOAT;
50-
{NaN}yylval = yytext;return CUBEFLOAT;
51-
\[yylval ="(";return O_BRACKET;
52-
\]yylval =")";return C_BRACKET;
53-
\(yylval ="(";return O_PAREN;
54-
\)yylval =")";return C_PAREN;
55-
\,yylval =",";return COMMA;
58+
{float}cube_yylval = yytext;return CUBEFLOAT;
59+
{infinity}cube_yylval = yytext;return CUBEFLOAT;
60+
{NaN}cube_yylval = yytext;return CUBEFLOAT;
61+
\[cube_yylval ="(";return O_BRACKET;
62+
\]cube_yylval =")";return C_BRACKET;
63+
\(cube_yylval ="(";return O_PAREN;
64+
\)cube_yylval =")";return C_PAREN;
65+
\,cube_yylval =",";return COMMA;
5666
[\t\n\r\f]+/* discard spaces */
5767
.return yytext[0];/* alert parser of the garbage*/
5868

5969
%%
6070

6171
/* LCOV_EXCL_STOP */
6272

63-
/* resultis not used, but Bison expects this signature */
73+
/* resultand scanbuflen are not used, but Bison expects this signature */
6474
void
65-
yyerror(NDBOX **result,constchar *message)
75+
cube_yyerror(NDBOX **result,Size scanbuflen,constchar *message)
6676
{
6777
if (*yytext == YY_END_OF_BUFFER_CHAR)
6878
{
@@ -87,9 +97,9 @@ yyerror(NDBOX **result, const char *message)
8797
* Called before any actual parsing is done
8898
*/
8999
void
90-
cube_scanner_init(constchar *str)
100+
cube_scanner_init(constchar *str,Size *scanbuflen)
91101
{
92-
Sizeslen =strlen(str);
102+
Sizeslen =strlen(str);
93103

94104
/*
95105
* Might be left over after ereport()
@@ -100,7 +110,7 @@ cube_scanner_init(const char *str)
100110
/*
101111
* Make a scan buffer with special termination needed by flex.
102112
*/
103-
scanbuflen = slen;
113+
*scanbuflen = slen;
104114
scanbuf =palloc(slen +2);
105115
memcpy(scanbuf, str, slen);
106116
scanbuf[slen] = scanbuf[slen +1] = YY_END_OF_BUFFER_CHAR;

‎contrib/seg/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/segparse.h
12
/segparse.c
23
/segscan.c
34
# Generated subdirectories

‎contrib/seg/Makefile

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ MODULE_big = seg
44
OBJS =\
55
$(WIN32RES)\
66
seg.o\
7-
segparse.o
7+
segparse.o\
8+
segscan.o
89

910
EXTENSION = seg
1011
DATA = seg--1.1.sql seg--1.1--1.2.sql seg--1.2--1.3.sql seg--1.3--1.4.sql\
@@ -29,10 +30,16 @@ include $(top_srcdir)/contrib/contrib-global.mk
2930
endif
3031

3132

32-
# segscan is compiled as part of segparse
33-
segparse.o: segscan.c
33+
# See notes in src/backend/parser/Makefile about the following two rules
34+
segparse.h: segparse.c
35+
touch$@
36+
37+
segparse.c: BISONFLAGS += -d
38+
39+
# Force these dependencies to be known even without dependency info built:
40+
segparse.osegscan.o: segparse.h
3441

3542
distprep: segparse.c segscan.c
3643

3744
maintainer-clean:
38-
rm -f segparse.c segscan.c
45+
rm -f segparse.h segparse.c segscan.c

‎contrib/seg/segparse.y

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,3 @@ seg_atof(const char *value)
160160
datum =DirectFunctionCall1(float4in,CStringGetDatum(value));
161161
returnDatumGetFloat4(datum);
162162
}
163-
164-
165-
#include"segscan.c"

‎contrib/seg/segscan.l

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
%{
1+
%top{
22
/*
33
* A scanner for EMP-style numeric ranges
44
*/
5+
#include "postgres.h"
6+
7+
/*
8+
* NB: include segparse.h only AFTER including segdata.h, because segdata.h
9+
* contains the definition for SEG.
10+
*/
11+
#include "segdata.h"
12+
#include "segparse.h"
13+
}
514

15+
%{
616
/* LCOV_EXCL_START*/
717

818
/* No reason to constrain amount of data slurped*/
@@ -21,7 +31,6 @@ fprintf_to_ereport(const char *fmt, const char *msg)
2131
/* Handles to the buffer that the lexer uses internally*/
2232
static YY_BUFFER_STATE scanbufhandle;
2333
staticchar *scanbuf;
24-
staticintscanbuflen;
2534
%}
2635

2736
%option8bit
@@ -42,12 +51,12 @@ float ({integer}|{real})([eE]{integer})?
4251

4352
%%
4453

45-
{range}yylval.text = yytext;return RANGE;
46-
{plumin}yylval.text = yytext;return PLUMIN;
47-
{float}yylval.text = yytext;return SEGFLOAT;
48-
\<yylval.text ="<";return EXTENSION;
49-
\>yylval.text =">";return EXTENSION;
50-
\~yylval.text ="~";return EXTENSION;
54+
{range}seg_yylval.text = yytext;return RANGE;
55+
{plumin}seg_yylval.text = yytext;return PLUMIN;
56+
{float}seg_yylval.text = yytext;return SEGFLOAT;
57+
\<seg_yylval.text ="<";return EXTENSION;
58+
\>seg_yylval.text =">";return EXTENSION;
59+
\~seg_yylval.text ="~";return EXTENSION;
5160
[\t\n\r\f]+/* discard spaces */
5261
.return yytext[0];/* alert parser of the garbage*/
5362

@@ -56,7 +65,7 @@ float ({integer}|{real})([eE]{integer})?
5665
/* LCOV_EXCL_STOP */
5766

5867
void
59-
yyerror(SEG *result,constchar *message)
68+
seg_yyerror(SEG *result,constchar *message)
6069
{
6170
if (*yytext == YY_END_OF_BUFFER_CHAR)
6271
{
@@ -94,7 +103,6 @@ seg_scanner_init(const char *str)
94103
/*
95104
* Make a scan buffer with special termination needed by flex.
96105
*/
97-
scanbuflen = slen;
98106
scanbuf =palloc(slen +2);
99107
memcpy(scanbuf, str, slen);
100108
scanbuf[slen] = scanbuf[slen +1] = YY_END_OF_BUFFER_CHAR;

‎src/backend/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ utils/probes.o: utils/probes.d $(SUBDIROBJS)
174174
# Be sure that these files get removed by the maintainer-clean target
175175
distprep:
176176
$(MAKE) -C parsergram.c gram.h scan.c
177-
$(MAKE) -C bootstrapbootparse.c bootscanner.c
177+
$(MAKE) -C bootstrapbootparse.cbootparse.hbootscanner.c
178178
$(MAKE) -C catalogdistprep
179179
$(MAKE) -C nodesdistprep
180-
$(MAKE) -C replicationrepl_gram.c repl_scanner.c syncrep_gram.c syncrep_scanner.c
180+
$(MAKE) -C replicationrepl_gram.crepl_gram.hrepl_scanner.c syncrep_gram.c syncrep_gram.h syncrep_scanner.c
181181
$(MAKE) -C storage/lmgrlwlocknames.h lwlocknames.c
182182
$(MAKE) -C utilsdistprep
183183
$(MAKE) -C utils/adtjsonpath_gram.c jsonpath_scan.c
@@ -292,13 +292,16 @@ maintainer-clean: distclean
292292
$(MAKE) -C nodes$@
293293
$(MAKE) -C utils$@
294294
rm -f bootstrap/bootparse.c\
295+
bootstrap/bootparse.h\
295296
bootstrap/bootscanner.c\
296297
parser/gram.c\
297298
parser/gram.h\
298299
parser/scan.c\
299300
replication/repl_gram.c\
301+
replication/repl_gram.h\
300302
replication/repl_scanner.c\
301303
replication/syncrep_gram.c\
304+
replication/syncrep_gram.h\
302305
replication/syncrep_scanner.c\
303306
storage/lmgr/lwlocknames.c\
304307
storage/lmgr/lwlocknames.h\

‎src/backend/bootstrap/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
/bootparse.h
12
/bootparse.c
23
/bootscanner.c

‎src/backend/bootstrap/Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,19 @@ override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS)
1414

1515
OBJS =\
1616
bootparse.o\
17+
bootscanner.o\
1718
bootstrap.o
1819

1920
include$(top_srcdir)/src/backend/common.mk
2021

21-
# bootscanner is compiled as part of bootparse
22-
bootparse.o: bootscanner.c
22+
# See notes in src/backend/parser/Makefile about the following two rules
23+
bootparse.h: bootparse.c
24+
touch$@
25+
26+
bootparse.c: BISONFLAGS += -d
27+
28+
# Force these dependencies to be known even without dependency info built:
29+
bootparse.obootscanner.o: bootparse.h
2330

2431
# bootparse.c and bootscanner.c are in the distribution tarball, so
2532
# they are not cleaned here.

‎src/backend/bootstrap/bootparse.y

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,5 +488,3 @@ boot_ident:
488488
|XNULL{$$ = pstrdup($1); }
489489
;
490490
%%
491-
492-
#include"bootscanner.c"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp