Skip to content

Commit fb51ad3

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 doing it this way already, while others used not-too-reliable sed hacks in the Makefiles. It's all nice and consistent now.
1 parent 012abeb commit fb51ad3

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
ifdef YACC
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-
#define yylex cube_yylex /* wrong scanner when running inside the postgres backend */
15-
16-
extern int yylex(void); /* defined as cube_yylex in cubescan.l */
13+
extern int cube_yylex(void);
1714

1815
static char *scanbuf;
1916
static int scanbuflen;
@@ -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
%token CUBEFLOAT O_PAREN C_PAREN O_BRACKET C_BRACKET COMMA
3231
%start box
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
ifdef YACC
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-
#define yylex seg_yylex /* wrong scanner when running inside postgres backend */
12+
extern int seg_yylex(void);
1413

15-
extern int yylex(void); /* defined as seg_yylex in segscan.l */
1614
extern int significant_digits( char *str ); /* defined in seg.c */
1715

1816
void seg_yyerror(const char *message);
19-
int seg_yyparse( void *result );
17+
int seg_yyparse(void *result);
2018

2119
float seg_atof( char *value );
2220

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

3432
/* BISON Declarations */
33+
%name-prefix="seg_yy"
34+
3535
%union {
3636
struct BND {
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.o bootparse.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-
define sed-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
ifdef YACC
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
ifdef FLEX
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.o bootparse.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-
* yacc parser grammar 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 int yyline = 1; /* line number for error reporting */
5454
%option nodefault
5555
%option nounput
5656
%option noyywrap
57+
%option prefix="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
#define ALLOC(t, c) ((t *) calloc((unsigned)(c), sizeof(t)))
5555

56-
extern int Int_yyparse(void);
57-
5856
static void usage(void);
5957
static void bootstrap_signals(void);
6058
static hashnode *AddStr(char *str, int strlength, int mderef);
@@ -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
ifdef FLEX
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 ("-"|"+")

0 commit comments

Comments
 (0)