Skip to content

Commit 2288977

Browse files
committed
Make the locale location relocatable.
Adjust get_*_path functions to be limited to MAXPGPATH.
1 parent 244ee0c commit 2288977

File tree

26 files changed

+158
-122
lines changed

26 files changed

+158
-122
lines changed

src/backend/main/main.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.81 2004/05/24 02:47:44 momjian Exp $
16+
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.82 2004/05/25 01:00:20 momjian Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -150,6 +150,8 @@ main(int argc, char *argv[])
150150
* startup error messages to be localized.
151151
*/
152152

153+
set_pglocale(argv[0], "postgres");
154+
153155
#ifdef WIN32
154156
/*
155157
* Windows uses codepages rather than the environment, so we work around
@@ -185,11 +187,6 @@ main(int argc, char *argv[])
185187
setlocale(LC_NUMERIC, "C");
186188
setlocale(LC_TIME, "C");
187189

188-
#ifdef ENABLE_NLS
189-
bindtextdomain("postgres", LOCALEDIR);
190-
textdomain("postgres");
191-
#endif
192-
193190
/*
194191
* Skip permission checks if we're just trying to do --help or
195192
* --version; otherwise root will get unhelpful failure messages from

src/bin/initdb/initdb.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* Portions Copyright (c) 1994, Regents of the University of California
4040
* Portions taken from FreeBSD.
4141
*
42-
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.32 2004/05/18 03:36:36 momjian Exp $
42+
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.33 2004/05/25 01:00:22 momjian Exp $
4343
*
4444
*-------------------------------------------------------------------------
4545
*/
@@ -167,7 +167,7 @@ static void check_ok(void);
167167
static bool chklocale(const char *locale);
168168
static void setlocales(void);
169169
static void usage(const char *progname);
170-
static void init_nls(void);
170+
static void init_nls(const char *argv0);
171171

172172

173173
/*
@@ -1754,13 +1754,9 @@ usage(const char *progname)
17541754
* Initialized NLS if enabled.
17551755
*/
17561756
static void
1757-
init_nls(void)
1757+
init_nls(const char *argv0)
17581758
{
1759-
#ifdef ENABLE_NLS
1760-
setlocale(LC_ALL, "");
1761-
bindtextdomain("initdb", LOCALEDIR);
1762-
textdomain("initdb");
1763-
#endif
1759+
set_pglocale(argv0, "initdb");
17641760
}
17651761

17661762

@@ -1801,7 +1797,7 @@ main(int argc, char *argv[])
18011797
* environment */
18021798
char *subdirs[] =
18031799
{"global", "pg_xlog", "pg_clog", "base", "base/1"};
1804-
init_nls();
1800+
init_nls(argv[0]);
18051801

18061802
progname = get_progname(argv[0]);
18071803

src/bin/pg_controldata/Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1998-2002, PostgreSQL Global Development Group
66
#
7-
# $PostgreSQL: pgsql/src/bin/pg_controldata/Makefile,v 1.7 2004/04/30 20:01:39 momjian Exp $
7+
# $PostgreSQL: pgsql/src/bin/pg_controldata/Makefile,v 1.8 2004/05/25 01:00:23 momjian Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -14,7 +14,7 @@ include $(top_builddir)/src/Makefile.global
1414

1515
override CPPFLAGS += -DFRONTEND
1616

17-
OBJS= pg_controldata.o pg_crc.o
17+
OBJS= pg_controldata.o pg_crc.o exec.o
1818

1919
all: submake-libpgport pg_controldata
2020

@@ -24,6 +24,9 @@ pg_controldata: $(OBJS)
2424
pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
2525
rm -f $@ && $(LN_S) $< .
2626

27+
exec.c: % : $(top_srcdir)/src/port/%
28+
rm -f $@ && $(LN_S) $< .
29+
2730
install: all installdirs
2831
$(INSTALL_PROGRAM) pg_controldata$(X) $(DESTDIR)$(bindir)/pg_controldata$(X)
2932

@@ -34,4 +37,4 @@ uninstall:
3437
rm -f $(DESTDIR)$(bindir)/pg_controldata$(X)
3538

3639
clean distclean maintainer-clean:
37-
rm -f pg_controldata$(X) pg_controldata.o pg_crc.o pg_crc.c
40+
rm -f pg_controldata$(X) pg_controldata.o pg_crc.o pg_crc.c exec.c

src/bin/pg_controldata/pg_controldata.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
77
* licence: BSD
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.15 2004/05/12 13:38:43 momjian Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.16 2004/05/25 01:00:23 momjian Exp $
1010
*/
1111
#include "postgres.h"
1212

@@ -77,11 +77,7 @@ main(int argc, char *argv[])
7777
char *strftime_fmt = "%c";
7878
const char *progname;
7979

80-
setlocale(LC_ALL, "");
81-
#ifdef ENABLE_NLS
82-
bindtextdomain("pg_controldata", LOCALEDIR);
83-
textdomain("pg_controldata");
84-
#endif
80+
set_pglocale(argv[0], "pg_controldata");
8581

8682
progname = get_progname(argv[0]);
8783

src/bin/pg_dump/Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
66
# Portions Copyright (c) 1994, Regents of the University of California
77
#
8-
# $PostgreSQL: pgsql/src/bin/pg_dump/Makefile,v 1.51 2004/05/24 01:01:37 momjian Exp $
8+
# $PostgreSQL: pgsql/src/bin/pg_dump/Makefile,v 1.52 2004/05/25 01:00:24 momjian Exp $
99
#
1010
#-------------------------------------------------------------------------
1111

@@ -17,8 +17,7 @@ override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) -DFRONTEND
1717

1818
OBJS= pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o \
1919
pg_backup_files.o pg_backup_null.o pg_backup_tar.o \
20-
dumputils.o
21-
PG_DUMPALL_OBJS = exec.o
20+
dumputils.o exec.o
2221

2322
EXTRA_OBJS = $(top_builddir)/src/backend/parser/keywords.o
2423

@@ -31,8 +30,8 @@ pg_dump: pg_dump.o common.o pg_dump_sort.o $(OBJS) $(libpq_builddir)/libpq.a
3130
pg_restore: pg_restore.o $(OBJS) $(libpq_builddir)/libpq.a
3231
$(CC) $(CFLAGS) pg_restore.o $(OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
3332

34-
pg_dumpall: pg_dumpall.o dumputils.o $(PG_DUMPALL_OBJS) $(libpq_builddir)/libpq.a
35-
$(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(PG_DUMPALL_OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
33+
pg_dumpall: pg_dumpall.o dumputils.o exec.o $(libpq_builddir)/libpq.a
34+
$(CC) $(CFLAGS) pg_dumpall.o dumputils.o exec.o $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
3635

3736
# We need our own build of exec.c so it gets made with -DFRONTEND
3837
exec.c: % : $(top_srcdir)/src/port/%
@@ -55,4 +54,4 @@ uninstall:
5554
rm -f $(addprefix $(DESTDIR)$(bindir)/, pg_dump$(X) pg_restore$(X) pg_dumpall$(X))
5655

5756
clean distclean maintainer-clean:
58-
rm -f pg_dump$(X) pg_restore$(X) pg_dumpall$(X) $(OBJS) $(PG_DUMPALL_OBJS) pg_dump.o common.o pg_dump_sort.o pg_restore.o pg_dumpall.o exec.c
57+
rm -f pg_dump$(X) pg_restore$(X) pg_dumpall$(X) $(OBJS) pg_dump.o common.o pg_dump_sort.o pg_restore.o pg_dumpall.o exec.c

src/bin/pg_dump/pg_dump.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.370 2004/03/24 03:06:08 momjian Exp $
15+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.371 2004/05/25 01:00:24 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -242,11 +242,7 @@ main(int argc, char **argv)
242242
};
243243
int optindex;
244244

245-
#ifdef ENABLE_NLS
246-
setlocale(LC_ALL, "");
247-
bindtextdomain("pg_dump", LOCALEDIR);
248-
textdomain("pg_dump");
249-
#endif
245+
set_pglocale(argv[0], "pg_dump");
250246

251247
g_verbose = false;
252248

src/bin/pg_dump/pg_dumpall.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.34 2004/05/19 21:21:26 momjian Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.35 2004/05/25 01:00:24 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -101,11 +101,7 @@ main(int argc, char *argv[])
101101

102102
int optindex;
103103

104-
#ifdef ENABLE_NLS
105-
setlocale(LC_ALL, "");
106-
bindtextdomain("pg_dump", LOCALEDIR);
107-
textdomain("pg_dump");
108-
#endif
104+
set_pglocale(argv[0], "pg_dump");
109105

110106
progname = get_progname(argv[0]);
111107

src/bin/pg_dump/pg_restore.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
*
3636
* IDENTIFICATION
37-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.56 2004/04/22 02:39:10 momjian Exp $
37+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.57 2004/05/25 01:00:24 momjian Exp $
3838
*
3939
*-------------------------------------------------------------------------
4040
*/
@@ -121,11 +121,7 @@ main(int argc, char **argv)
121121
{NULL, 0, NULL, 0}
122122
};
123123

124-
#ifdef ENABLE_NLS
125-
setlocale(LC_ALL, "");
126-
bindtextdomain("pg_dump", LOCALEDIR);
127-
textdomain("pg_dump");
128-
#endif
124+
set_pglocale(argv[0], "pg_dump");
129125

130126
opts = NewRestoreOptions();
131127

src/bin/pg_resetxlog/Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1998-2002, PostgreSQL Global Development Group
66
#
7-
# $PostgreSQL: pgsql/src/bin/pg_resetxlog/Makefile,v 1.9 2004/05/24 01:01:37 momjian Exp $
7+
# $PostgreSQL: pgsql/src/bin/pg_resetxlog/Makefile,v 1.10 2004/05/25 01:00:25 momjian Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -14,7 +14,7 @@ include $(top_builddir)/src/Makefile.global
1414

1515
override CPPFLAGS += -DFRONTEND
1616

17-
OBJS= pg_resetxlog.o pg_crc.o dirmod.o
17+
OBJS= pg_resetxlog.o pg_crc.o dirmod.o exec.o
1818

1919
all: submake-libpgport pg_resetxlog
2020

@@ -27,6 +27,9 @@ dirmod.c: % : $(top_srcdir)/src/port/%
2727
pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
2828
rm -f $@ && $(LN_S) $< .
2929

30+
exec.c: % : $(top_srcdir)/src/port/%
31+
rm -f $@ && $(LN_S) $< .
32+
3033
install: all installdirs
3134
$(INSTALL_PROGRAM) pg_resetxlog$(X) $(DESTDIR)$(bindir)/pg_resetxlog$(X)
3235

@@ -37,4 +40,4 @@ uninstall:
3740
rm -f $(DESTDIR)$(bindir)/pg_resetxlog$(X)
3841

3942
clean distclean maintainer-clean:
40-
rm -f pg_resetxlog$(X) pg_crc.c dirmod.c $(OBJS)
43+
rm -f pg_resetxlog$(X) pg_crc.c dirmod.c exec.c $(OBJS)

src/bin/pg_resetxlog/pg_resetxlog.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
2424
* Portions Copyright (c) 1994, Regents of the University of California
2525
*
26-
* $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.18 2004/05/12 13:38:44 momjian Exp $
26+
* $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.19 2004/05/25 01:00:25 momjian Exp $
2727
*
2828
*-------------------------------------------------------------------------
2929
*/
@@ -102,11 +102,7 @@ main(int argc, char *argv[])
102102
int fd;
103103
char path[MAXPGPATH];
104104

105-
setlocale(LC_ALL, "");
106-
#ifdef ENABLE_NLS
107-
bindtextdomain("pg_resetxlog", LOCALEDIR);
108-
textdomain("pg_resetxlog");
109-
#endif
105+
set_pglocale(argv[0], "pg_resetxlog");
110106

111107
progname = get_progname(argv[0]);
112108

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy