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

Commitfb51ad3

Browse files
committed
Make all our flex and bison files use %option prefix or %name-prefix
(respectively) to rename yylex and related symbols. Some were doingit this way already, while others used not-too-reliable sed hacks inthe Makefiles. It's all nice and consistent now.
1 parent012abeb commitfb51ad3

File tree

16 files changed

+65
-69
lines changed

16 files changed

+65
-69
lines changed

‎contrib/cube/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $PostgreSQL: pgsql/contrib/cube/Makefile,v 1.16 2006/02/27 12:54:38 petere Exp $
1+
# $PostgreSQL: pgsql/contrib/cube/Makefile,v 1.17 2006/03/07 01:03:12 tgl Exp $
22

33
MODULE_big = cube
44
OBJS= cube.o cubeparse.o
@@ -28,11 +28,13 @@ endif
2828
# cubescan is compiled as part of cubeparse
2929
cubeparse.o: cubescan.c
3030

31+
# See notes in src/backend/parser/Makefile about the following two rules
32+
3133
cubeparse.c: cubeparse.h ;
3234

3335
cubeparse.h: cubeparse.y
3436
ifdefYACC
35-
$(YACC) -d $(YFLAGS)-p cube_yy$<
37+
$(YACC) -d $(YFLAGS) $<
3638
mv -f y.tab.c cubeparse.c
3739
mv -f y.tab.h cubeparse.h
3840
else

‎contrib/cube/cubeparse.y

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010

1111
#include"cubedata.h"
1212

13-
#undef yylex/* failure to redefine yylex will result in a call to the*/
14-
#defineyylex cube_yylex/* wrong scanner when running inside the postgres backend*/
15-
16-
externintyylex(void);/* defined as cube_yylex in cubescan.l*/
13+
externintcube_yylex(void);
1714

1815
staticchar *scanbuf;
1916
staticintscanbuflen;
@@ -28,6 +25,8 @@ static NDBOX * write_point_as_box(char *s, int dim);
2825
%}
2926

3027
/* BISON Declarations*/
28+
%name-prefix="cube_yy"
29+
3130
%tokenCUBEFLOATO_PARENC_PARENO_BRACKETC_BRACKETCOMMA
3231
%startbox
3332

‎contrib/seg/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $PostgreSQL: pgsql/contrib/seg/Makefile,v 1.15 2006/02/27 12:54:39 petere Exp $
1+
# $PostgreSQL: pgsql/contrib/seg/Makefile,v 1.16 2006/03/07 01:03:12 tgl Exp $
22

33
MODULE_big = seg
44
OBJS = seg.o segparse.o
@@ -21,14 +21,17 @@ include $(top_builddir)/src/Makefile.global
2121
include$(top_srcdir)/contrib/contrib-global.mk
2222
endif
2323

24+
2425
# segscan is compiled as part of segparse
2526
segparse.o: segscan.c
2627

28+
# See notes in src/backend/parser/Makefile about the following two rules
29+
2730
segparse.c: segparse.h ;
2831

2932
segparse.h: segparse.y
3033
ifdefYACC
31-
$(YACC) -d $(YFLAGS)-p seg_yy$<
34+
$(YACC) -d $(YFLAGS) $<
3235
mv -f y.tab.c segparse.c
3336
mv -f y.tab.h segparse.h
3437
else

‎contrib/seg/segparse.y

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99
#include"utils/builtins.h"
1010
#include"segdata.h"
1111

12-
#undef yylex/* failure to redefine yylex will result in calling the*/
13-
#defineyylex seg_yylex/* wrong scanner when running inside postgres backend*/
12+
externintseg_yylex(void);
1413

15-
externintyylex(void);/* defined as seg_yylex in segscan.l*/
1614
externintsignificant_digits(char *str );/* defined in seg.c*/
1715

1816
voidseg_yyerror(constchar *message);
19-
intseg_yyparse(void *result);
17+
intseg_yyparse(void *result);
2018

2119
floatseg_atof(char *value );
2220

@@ -32,6 +30,8 @@
3230
%}
3331

3432
/* BISON Declarations*/
33+
%name-prefix="seg_yy"
34+
3535
%union {
3636
structBND {
3737
float val;

‎src/backend/bootstrap/Makefile

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Makefile for the bootstrap module
44
#
5-
# $PostgreSQL: pgsql/src/backend/bootstrap/Makefile,v 1.33 2006/01/05 01:56:29 momjian Exp $
5+
# $PostgreSQL: pgsql/src/backend/bootstrap/Makefile,v 1.34 2006/03/07 01:03:12 tgl Exp $
66
#
77
#-------------------------------------------------------------------------
88

@@ -20,43 +20,37 @@ SUBSYS.o: $(OBJS)
2020
$(LD)$(LDREL)$(LDOUT)$@$^
2121

2222

23-
bootstrap.obootparse.o:$(srcdir)/bootstrap_tokens.h
24-
2523
# bootscanner is compiled as part of bootparse
2624
bootparse.o:$(srcdir)/bootscanner.c
2725

28-
# `sed' rules to remove conflicts between bootstrap scanner and parser
29-
# and the SQL scanner and parser. For correctness' sake the rules that
30-
# use this must depend on this Makefile.
31-
definesed-magic
32-
sed -e 's/^yy/Int_yy/g' \
33-
-e 's/\([^a-zA-Z0-9_]\)yy/\1Int_yy/g'
34-
endef
35-
26+
# See notes in src/backend/parser/Makefile about the following two rules
3627

3728
$(srcdir)/bootparse.c:$(srcdir)/bootstrap_tokens.h ;
3829

39-
$(srcdir)/bootstrap_tokens.h: bootparse.y Makefile
30+
$(srcdir)/bootstrap_tokens.h: bootparse.y
4031
ifdefYACC
4132
$(YACC) -d $(YFLAGS) $<
42-
$(sed-magic) < y.tab.c > $(srcdir)/bootparse.c
43-
$(sed-magic) < y.tab.h > $(srcdir)/bootstrap_tokens.h
44-
rm -f y.tab.c y.tab.h
33+
mv -f y.tab.c $(srcdir)/bootparse.c
34+
mv -f y.tab.h $(srcdir)/bootstrap_tokens.h
4535
else
4636
@$(missing) bison $< $@
4737
endif
4838

49-
$(srcdir)/bootscanner.c: bootscanner.l Makefile
39+
$(srcdir)/bootscanner.c: bootscanner.l
5040
ifdefFLEX
51-
$(FLEX) $(FLEXFLAGS) $<
52-
$(sed-magic) lex.yy.c > $@
53-
rm -f lex.yy.c
41+
$(FLEX) $(FLEXFLAGS) -o'$@' $<
5442
else
5543
@$(missing) flex $< $@
5644
endif
5745

46+
# Force these dependencies to be known even without dependency info built:
47+
bootstrap.obootparse.o:$(srcdir)/bootstrap_tokens.h
48+
49+
50+
# bootparse.c, bootstrap_tokens.h, and bootscanner.c are in the distribution
51+
# tarball, so they are not cleaned here.
5852
clean:
59-
rm -f SUBSYS.o$(OBJS) bootstrap.o
53+
rm -f SUBSYS.o$(OBJS)
6054
# And the garbage that might have been left behind by partial build:
6155
@rm -f y.tab.h y.tab.c y.output lex.yy.c
6256

‎src/backend/bootstrap/bootparse.y

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
/*-------------------------------------------------------------------------
33
*
44
* bootparse.y
5-
* yaccparsergrammar for the "backend" initialization program.
5+
* yacc grammar for the "bootstrap" mode (BKI file format)
66
*
77
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.79 2006/03/05 15:58:22 momjian Exp $
12+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.80 2006/03/07 01:03:12 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -79,6 +79,8 @@ int num_columns_read = 0;
7979

8080
%}
8181

82+
%name-prefix="boot_yy"
83+
8284
%union
8385
{
8486
List*list;

‎src/backend/bootstrap/bootscanner.l

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootscanner.l,v 1.41 2006/03/05 15:58:22 momjian Exp $
12+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootscanner.l,v 1.42 2006/03/07 01:03:12 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -54,6 +54,7 @@ static intyyline = 1;/* line number for error reporting */
5454
%optionnodefault
5555
%optionnounput
5656
%optionnoyywrap
57+
%optionprefix="boot_yy"
5758

5859

5960
D[0-9]

‎src/backend/bootstrap/bootstrap.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.212 2006/03/05 15:58:22 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.213 2006/03/07 01:03:12 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -53,8 +53,6 @@ extern char *optarg;
5353

5454
#defineALLOC(t,c)((t *) calloc((unsigned)(c), sizeof(t)))
5555

56-
externintInt_yyparse(void);
57-
5856
staticvoidusage(void);
5957
staticvoidbootstrap_signals(void);
6058
statichashnode*AddStr(char*str,intstrlength,intmderef);
@@ -468,11 +466,8 @@ BootstrapMain(int argc, char *argv[])
468466

469467
/*
470468
* Process bootstrap input.
471-
*
472-
* the sed script boot.sed renamed yyparse to Int_yyparse for the
473-
* bootstrap parser to avoid conflicts with the normal SQL parser
474469
*/
475-
Int_yyparse();
470+
boot_yyparse();
476471

477472
/* Perform a checkpoint to ensure everything's down to disk */
478473
SetProcessingMode(NormalProcessing);

‎src/backend/utils/misc/Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile for utils/misc
55
#
66
# IDENTIFICATION
7-
# $PostgreSQL: pgsql/src/backend/utils/misc/Makefile,v 1.24 2005/10/03 22:52:23 tgl Exp $
7+
# $PostgreSQL: pgsql/src/backend/utils/misc/Makefile,v 1.25 2006/03/07 01:03:12 tgl Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -33,9 +33,7 @@ guc.o: $(srcdir)/guc-file.c
3333

3434
$(srcdir)/guc-file.c: guc-file.l
3535
ifdefFLEX
36-
$(FLEX) $(FLEXFLAGS) $<
37-
sed -e 's/^yy/GUC_yy/g' -e 's/\([^a-zA-Z0-9_]\)yy/\1GUC_yy/g' lex.yy.c > $@
38-
rm -f lex.yy.c
36+
$(FLEX) $(FLEXFLAGS) -o'$@' $<
3937
else
4038
@$(missing) flex $< $@
4139
endif

‎src/backend/utils/misc/guc-file.l

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.36 2006/03/05 15:58:49 momjian Exp $
7+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.37 2006/03/07 01:03:12 tgl Exp $
88
*/
99

1010
%{
@@ -61,6 +61,7 @@ static char *GUC_scanstr(const char *s);
6161
%option nodefault
6262
%option nounput
6363
%option noyywrap
64+
%option prefix="GUC_yy"
6465

6566

6667
SIGN ("-"|"+")

‎src/include/bootstrap/bootstrap.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/bootstrap/bootstrap.h,v 1.40 2006/03/05 15:58:54 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/bootstrap/bootstrap.h,v 1.41 2006/03/07 01:03:12 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -52,8 +52,10 @@ extern char *CleanUpStr(char *s);
5252
externintEnterString(char*str);
5353
externvoidbuild_indices(void);
5454

55-
externintInt_yylex(void);
56-
externvoidInt_yyerror(constchar*str);
55+
externintboot_yyparse(void);
56+
57+
externintboot_yylex(void);
58+
externvoidboot_yyerror(constchar*str);
5759

5860
#defineBS_XLOG_NOP0
5961
#defineBS_XLOG_BOOTSTRAP1

‎src/pl/plpgsql/src/Makefile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Makefile for the plpgsql shared object
44
#
5-
# $PostgreSQL: pgsql/src/pl/plpgsql/src/Makefile,v 1.28 2006/01/05 01:56:30 momjian Exp $
5+
# $PostgreSQL: pgsql/src/pl/plpgsql/src/Makefile,v 1.29 2006/03/07 01:03:12 tgl Exp $
66
#
77
#-------------------------------------------------------------------------
88

@@ -48,29 +48,28 @@ installdirs:
4848
uninstall:
4949
rm -f'$(DESTDIR)$(pkglibdir)/plpgsql$(DLSUFFIX)'
5050

51+
# Force these dependencies to be known even without dependency info built:
5152
pl_gram.opl_handler.opl_comp.opl_exec.opl_funcs.o: plpgsql.h$(srcdir)/pl.tab.h
5253

5354
# pl_scan is compiled as part of pl_gram
5455
pl_gram.o:$(srcdir)/pl_scan.c
5556

56-
# Note: Since the yacc and lex files are shipped in the distribution,
57-
# they must be generated in the srcdir (as opposed to builddir).
57+
# See notes in src/backend/parser/Makefile about the following two rules
5858

5959
$(srcdir)/pl_gram.c:$(srcdir)/pl.tab.h ;
6060

6161
$(srcdir)/pl.tab.h: gram.y
6262
ifdefYACC
6363
$(YACC) -d $(YFLAGS) $<
64-
sed -e 's/yy/plpgsql_yy/g' -e 's/YY/PLPGSQL_YY/g' < y.tab.c > $(srcdir)/pl_gram.c
65-
sed -e 's/yy/plpgsql_yy/g' -e 's/YY/PLPGSQL_YY/g' < y.tab.h > $(srcdir)/pl.tab.h
66-
rm -f y.tab.c y.tab.h
64+
mv -f y.tab.c $(srcdir)/pl_gram.c
65+
mv -f y.tab.h $(srcdir)/pl.tab.h
6766
else
6867
@$(missing) bison $< $@
6968
endif
7069

7170
$(srcdir)/pl_scan.c: scan.l
7271
ifdefFLEX
73-
$(FLEX) $(FLEXFLAGS) -Pplpgsql_base_yy -o'$@' $<
72+
$(FLEX) $(FLEXFLAGS) -o'$@' $<
7473
else
7574
@$(missing) flex $< $@
7675
endif
@@ -82,7 +81,7 @@ distprep: $(srcdir)/pl_scan.c $(srcdir)/pl.tab.h $(srcdir)/pl_gram.c
8281
cleandistclean: clean-lib
8382
rm -f$(OBJS)
8483
# And the garbage that might have been left behind by partial build:
85-
@rm -f y.tab.c y.tab.h lex.yy.c
84+
@rm -f y.tab.h y.tab.c y.output lex.yy.c
8685

8786
maintainer-clean: clean
8887
rm -f$(srcdir)/pl_gram.c$(srcdir)/pl.tab.h$(srcdir)/pl_scan.c

‎src/pl/plpgsql/src/gram.y

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* procedural language
55
*
66
* IDENTIFICATION
7-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.85 2006/02/12 06:37:05 tgl Exp $
7+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.86 2006/03/07 01:03:12 tgl Exp $
88
*
99
* This software is copyrighted by Jan Wieck - Hamburg.
1010
*
@@ -64,6 +64,8 @@ staticvoid check_labels(const char *start_label,
6464

6565
%}
6666

67+
%name-prefix="plpgsql_yy"
68+
6769
%union {
6870
int32ival;
6971
boolboolean;
@@ -2363,4 +2365,7 @@ check_labels(const char *start_label, const char *end_label)
23632365
}
23642366
}
23652367

2368+
/* Needed to avoid conflict between different prefix settings:*/
2369+
#undef yylex
2370+
23662371
#include"pl_scan.c"

‎src/pl/plpgsql/src/pl_comp.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* procedural language
44
*
55
* IDENTIFICATION
6-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.98 2005/12/28 18:11:25 tgl Exp $
6+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.99 2006/03/07 01:03:12 tgl Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -60,12 +60,6 @@
6060
#include"utils/syscache.h"
6161

6262

63-
/* ----------
64-
* Variables in the parser that shouldn't go into plpgsql.h
65-
* ----------
66-
*/
67-
externPLPGSQL_YYSTYPEplpgsql_yylval;
68-
6963
/* ----------
7064
* Our own local and global variables
7165
* ----------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp