Skip to content

Commit c115641

Browse files
committed
Move psql's psqlscan.l into src/fe_utils.
This completes (at least for now) the project of getting rid of ad-hoc linkages among the src/bin/ subdirectories. Everything they share is now in src/fe_utils/ and is included from a static library at link time. A side benefit is that we can restore the FLEX_NO_BACKUP check for psqlscanslash.l. We might need to think of another way to do that check if we ever need to build two lexers with that property in the same source directory, but there's no foreseeable reason to need that.
1 parent d65bea2 commit c115641

File tree

20 files changed

+120
-90
lines changed

20 files changed

+120
-90
lines changed

src/backend/parser/scan.l

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* NOTE NOTE NOTE:
88
*
9-
* The rules in this file must be kept in sync with psql's psqlscan.l!
9+
* The rules in this file must be kept in sync with src/fe_utils/psqlscan.l!
1010
*
1111
* The rules are designed so that the scanner never has to backtrack,
1212
* in the sense that there is always a rule that can match the input

src/bin/pgbench/Makefile

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ subdir = src/bin/pgbench
77
top_builddir = ../../..
88
include $(top_builddir)/src/Makefile.global
99

10-
OBJS = pgbench.o exprparse.o psqlscan.o $(WIN32RES)
10+
OBJS = pgbench.o exprparse.o $(WIN32RES)
1111

12-
override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) \
13-
-I$(top_srcdir)/src/bin/psql $(CPPFLAGS)
12+
override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) $(CPPFLAGS)
13+
LDFLAGS += -L$(top_builddir)/src/fe_utils -lpgfeutils
1414

1515
ifneq ($(PORTNAME), win32)
1616
override CFLAGS += $(PTHREAD_CFLAGS)
@@ -19,21 +19,12 @@ endif
1919

2020
all: pgbench
2121

22-
pgbench: $(OBJS) | submake-libpq submake-libpgport
22+
pgbench: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
2323
$(CC) $(CFLAGS) $^ $(libpq_pgport) $(PTHREAD_LIBS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
2424

2525
# exprscan is compiled as part of exprparse
2626
exprparse.o: exprscan.c
2727

28-
# we import psqlscan.o as-is from psql
29-
submake-psqlscan:
30-
$(MAKE) -C $(top_builddir)/src/bin/psql psqlscan.o
31-
32-
psqlscan.o: | submake-psqlscan
33-
rm -f $@ && $(LN_S) $(top_builddir)/src/bin/psql/psqlscan.o .
34-
35-
.PHONY: submake-psqlscan
36-
3728
distprep: exprparse.c exprscan.c
3829

3930
install: all installdirs

src/bin/pgbench/exprscan.l

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*-------------------------------------------------------------------------
2424
*/
2525

26-
#include "psqlscan_int.h"
26+
#include "fe_utils/psqlscan_int.h"
2727

2828
/* context information for reporting errors in expressions */
2929
static const char *expr_source = NULL;

src/bin/pgbench/pgbench.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#ifndef PGBENCH_H
1212
#define PGBENCH_H
1313

14-
#include "psqlscan.h"
14+
#include "fe_utils/psqlscan.h"
1515

1616
/*
1717
* This file is included outside exprscan.l, in places where we can't see

src/bin/psql/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/psqlscan.c
21
/psqlscanslash.c
32
/sql_help.h
43
/sql_help.c

src/bin/psql/Makefile

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ LDFLAGS += -L$(top_builddir)/src/fe_utils -lpgfeutils
2424
OBJS= command.o common.o help.o input.o stringutils.o mainloop.o copy.o \
2525
startup.o prompt.o variables.o large_obj.o describe.o \
2626
tab-complete.o \
27-
sql_help.o psqlscan.o psqlscanslash.o \
27+
sql_help.o psqlscanslash.o \
2828
$(WIN32RES)
2929

3030

@@ -39,20 +39,15 @@ sql_help.c: sql_help.h ;
3939
sql_help.h: create_help.pl $(wildcard $(REFDOCDIR)/*.sgml)
4040
$(PERL) $< $(REFDOCDIR) $*
4141

42-
psqlscan.c: FLEXFLAGS = -Cfe -p -p
43-
psqlscan.c: FLEX_NO_BACKUP=yes
44-
4542
psqlscanslash.c: FLEXFLAGS = -Cfe -p -p
46-
# Ideally we'd check this, but parallel make causes problems:
47-
# psqlscanslash.c: FLEX_NO_BACKUP=yes
43+
psqlscanslash.c: FLEX_NO_BACKUP=yes
4844

49-
# Latest flex causes warnings in these files.
45+
# Latest flex causes warnings in this file.
5046
ifeq ($(GCC),yes)
51-
psqlscan.o: CFLAGS += -Wno-error
5247
psqlscanslash.o: CFLAGS += -Wno-error
5348
endif
5449

55-
distprep: sql_help.h psqlscan.c psqlscanslash.c
50+
distprep: sql_help.h psqlscanslash.c
5651

5752
install: all installdirs
5853
$(INSTALL_PROGRAM) psql$(X) '$(DESTDIR)$(bindir)/psql$(X)'
@@ -70,4 +65,4 @@ clean distclean:
7065
# files removed here are supposed to be in the distribution tarball,
7166
# so do not clean them in the clean/distclean rules
7267
maintainer-clean: distclean
73-
rm -f sql_help.h sql_help.c psqlscan.c psqlscanslash.c
68+
rm -f sql_help.h sql_help.c psqlscanslash.c

src/bin/psql/command.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#define COMMAND_H
1010

1111
#include "fe_utils/print.h"
12-
#include "psqlscan.h"
12+
#include "fe_utils/psqlscan.h"
1313

1414

1515
typedef enum _backslashResult

src/bin/psql/mainloop.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "command.h"
1212
#include "common.h"
1313
#include "input.h"
14+
#include "prompt.h"
1415
#include "settings.h"
1516

1617
#include "mb/pg_wchar.h"

src/bin/psql/mainloop.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#ifndef MAINLOOP_H
99
#define MAINLOOP_H
1010

11-
#include "psqlscan.h"
11+
#include "fe_utils/psqlscan.h"
1212

1313
extern const PsqlScanCallbacks psqlscan_callbacks;
1414

src/bin/psql/nls.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
CATALOG_NAME = psql
33
AVAIL_LANGUAGES = cs de es fr it ja pl pt_BR ru zh_CN zh_TW
44
GETTEXT_FILES = command.c common.c copy.c help.c input.c large_obj.c \
5-
mainloop.c psqlscan.c psqlscanslash.c startup.c \
5+
mainloop.c psqlscanslash.c startup.c \
66
describe.c sql_help.h sql_help.c \
77
tab-complete.c variables.c \
8-
../../fe_utils/print.c \
8+
../../fe_utils/print.c ../../fe_utils/psqlscan.c \
99
../../common/exec.c ../../common/fe_memutils.c ../../common/username.c \
1010
../../common/wait_error.c
1111
GETTEXT_TRIGGERS = N_ psql_error simple_prompt

0 commit comments

Comments
 (0)