Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e6afa89

Browse files
committed
Move wchar.c and encnames.c to src/common/.
Formerly, various frontend directories symlinked these two sources and then built them locally. That's an ancient, ugly hack, and we now have a much better way: put them into libpgcommon. So do that. (The immediate motivation for this is the prospect of having to introduce still more symlinking if we don't.) This commit moves these two files absolutely verbatim, for ease of reviewing the git history. There's some follow-on work to be done that will modify them a bit. Robert Haas, Tom Lane Discussion: https://postgr.es/m/CA+TgmoYO8oq-iy8E02rD8eX25T-9SmyxKWqqks5OMHxKvGXpXQ@mail.gmail.com
1 parent 2eb34ac commit e6afa89

File tree

12 files changed

+23
-51
lines changed

12 files changed

+23
-51
lines changed

src/backend/utils/mb/Makefile

-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ include $(top_builddir)/src/Makefile.global
1414

1515
OBJS = \
1616
conv.o \
17-
encnames.o \
1817
mbutils.o \
1918
stringinfo_mb.o \
20-
wchar.o \
2119
wstrcmp.o \
2220
wstrncmp.o
2321

src/backend/utils/mb/README

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@ src/backend/utils/mb/README
33
Encodings
44
=========
55

6-
encnames.c: public functions for both the backend and the frontend.
76
conv.c: static functions and a public table for code conversion
8-
wchar.c: mostly static functions and a public table for mb string and
9-
multibyte conversion
107
mbutils.c: public functions for the backend only.
11-
requires conv.c and wchar.c
128
stringinfo_mb.c: public backend-only multibyte-aware stringinfo functions
139
wstrcmp.c: strcmp for mb
1410
wstrncmp.c: strncmp for mb
1511
win866.c: a tool to generate KOI8 <--> CP866 conversion table
1612
iso.c: a tool to generate KOI8 <--> ISO8859-5 conversion table
1713
win1251.c: a tool to generate KOI8 <--> CP1251 conversion table
1814

15+
See also in src/common/:
16+
17+
encnames.c: public functions for encoding names
18+
wchar.c: mostly static functions and a public table for mb string and
19+
multibyte conversion
20+
1921
Introduction
2022
------------
2123
http://www.cprogramming.com/tutorial/unicode.html

src/bin/initdb/.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/encnames.c
21
/localtime.c
32

43
/initdb

src/bin/initdb/Makefile

+8-12
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ include $(top_builddir)/src/Makefile.global
1818

1919
override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) -I$(top_srcdir)/src/timezone $(CPPFLAGS)
2020

21-
# note: we need libpq only because fe_utils does
21+
# Note: it's important that we link to encnames.o from libpgcommon, not
22+
# from libpq, else we have risks of version skew if we run with a libpq
23+
# shared library from a different PG version. The libpq_pgport macro
24+
# should ensure that that happens.
25+
#
26+
# We need libpq only because fe_utils does.
2227
LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport)
2328

2429
# use system timezone data?
@@ -28,7 +33,6 @@ endif
2833

2934
OBJS = \
3035
$(WIN32RES) \
31-
encnames.o \
3236
findtimezone.o \
3337
initdb.o \
3438
localtime.o
@@ -38,15 +42,7 @@ all: initdb
3842
initdb: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
3943
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
4044

41-
# We used to pull in all of libpq to get encnames.c, but that
42-
# exposes us to risks of version skew if we link to a shared library.
43-
# Do it the hard way, instead, so that we're statically linked.
44-
45-
encnames.c: % : $(top_srcdir)/src/backend/utils/mb/%
46-
rm -f $@ && $(LN_S) $< .
47-
48-
# Likewise, pull in localtime.c from src/timezones
49-
45+
# We must pull in localtime.c from src/timezones
5046
localtime.c: % : $(top_srcdir)/src/timezone/%
5147
rm -f $@ && $(LN_S) $< .
5248

@@ -60,7 +56,7 @@ uninstall:
6056
rm -f '$(DESTDIR)$(bindir)/initdb$(X)'
6157

6258
clean distclean maintainer-clean:
63-
rm -f initdb$(X) $(OBJS) encnames.c localtime.c
59+
rm -f initdb$(X) $(OBJS) localtime.c
6460
rm -rf tmp_check
6561

6662
# ensure that changes in datadir propagate into object file

src/common/Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ OBJS_COMMON = \
5151
config_info.o \
5252
controldata_utils.o \
5353
d2s.o \
54+
encnames.o \
5455
exec.o \
5556
f2s.o \
5657
file_perm.o \
@@ -70,7 +71,8 @@ OBJS_COMMON = \
7071
stringinfo.o \
7172
unicode_norm.o \
7273
username.o \
73-
wait_error.o
74+
wait_error.o \
75+
wchar.o
7476

7577
ifeq ($(with_openssl),yes)
7678
OBJS_COMMON += sha2_openssl.o
File renamed without changes.

src/common/saslprep.c

-6
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@
2727

2828
#include "common/saslprep.h"
2929
#include "common/unicode_norm.h"
30-
31-
/*
32-
* Note: The functions in this file depend on functions from
33-
* src/backend/utils/mb/wchar.c, so in order to use this in frontend
34-
* code, you will need to link that in, too.
35-
*/
3630
#include "mb/pg_wchar.h"
3731

3832
/*
File renamed without changes.

src/include/mb/pg_wchar.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ typedef unsigned int pg_wchar;
222222
* PostgreSQL encoding identifiers
223223
*
224224
* WARNING: the order of this enum must be same as order of entries
225-
* in the pg_enc2name_tbl[] array (in mb/encnames.c), and
226-
* in the pg_wchar_table[] array (in mb/wchar.c)!
225+
* in the pg_enc2name_tbl[] array (in src/common/encnames.c), and
226+
* in the pg_wchar_table[] array (in src/common/wchar.c)!
227227
*
228228
* If you add some encoding don't forget to check
229229
* PG_ENCODING_BE_LAST macro.

src/interfaces/libpq/.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
11
/exports.list
2-
# .c files that are symlinked in from elsewhere
3-
/encnames.c
4-
/wchar.c

src/interfaces/libpq/Makefile

+1-18
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ OBJS = \
4545
pqexpbuffer.o \
4646
fe-auth.o
4747

48-
# src/backend/utils/mb
49-
OBJS += \
50-
encnames.o \
51-
wchar.o
52-
5348
ifeq ($(with_openssl),yes)
5449
OBJS += \
5550
fe-secure-common.o \
@@ -102,17 +97,7 @@ include $(top_srcdir)/src/Makefile.shlib
10297
backend_src = $(top_srcdir)/src/backend
10398

10499

105-
# We use a few backend modules verbatim, but since we need
106-
# to compile with appropriate options to build a shared lib, we can't
107-
# use the same object files built for the backend.
108-
# Instead, symlink the source files in here and build our own object files.
109-
# When you add a file here, remember to add it in the "clean" target below.
110-
111-
encnames.c wchar.c: % : $(backend_src)/utils/mb/%
112-
rm -f $@ && $(LN_S) $< .
113-
114-
115-
# Make dependencies on pg_config_paths.h visible, too.
100+
# Make dependencies on pg_config_paths.h visible in all builds.
116101
fe-connect.o: fe-connect.c $(top_builddir)/src/port/pg_config_paths.h
117102
fe-misc.o: fe-misc.c $(top_builddir)/src/port/pg_config_paths.h
118103

@@ -144,8 +129,6 @@ clean distclean: clean-lib
144129
rm -f $(OBJS) pthread.h
145130
# Might be left over from a Win32 client-only build
146131
rm -f pg_config_paths.h
147-
# Remove files we (may have) symlinked in from other places
148-
rm -f encnames.c wchar.c
149132

150133
maintainer-clean: distclean
151134
$(MAKE) -C test $@

src/tools/msvc/Mkvcbuild.pm

+3-2
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,12 @@ sub mkvcbuild
120120
}
121121

122122
our @pgcommonallfiles = qw(
123-
base64.c config_info.c controldata_utils.c d2s.c exec.c f2s.c file_perm.c ip.c
123+
base64.c config_info.c controldata_utils.c d2s.c encnames.c exec.c
124+
f2s.c file_perm.c ip.c
124125
keywords.c kwlookup.c link-canary.c md5.c
125126
pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
126127
saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
127-
wait_error.c);
128+
wait_error.c wchar.c);
128129

129130
if ($solution->{options}->{openssl})
130131
{

0 commit comments

Comments
 (0)