aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2004-05-25 01:00:30 +0000
committerBruce Momjian <bruce@momjian.us>2004-05-25 01:00:30 +0000
commit228897774c08012ee280e5110856d908a6047697 (patch)
tree9121ddcf98b32bc4cf4e03bbe28da78f0ef176a7 /src
parent244ee0c0f2b87656f7d1eefca7f46fc61c877fd2 (diff)
downloadpostgresql-228897774c08012ee280e5110856d908a6047697.tar.gz
postgresql-228897774c08012ee280e5110856d908a6047697.zip
Make the locale location relocatable.
Adjust get_*_path functions to be limited to MAXPGPATH.
Diffstat (limited to 'src')
-rw-r--r--src/backend/main/main.c9
-rw-r--r--src/bin/initdb/initdb.c14
-rw-r--r--src/bin/pg_controldata/Makefile9
-rw-r--r--src/bin/pg_controldata/pg_controldata.c8
-rw-r--r--src/bin/pg_dump/Makefile11
-rw-r--r--src/bin/pg_dump/pg_dump.c8
-rw-r--r--src/bin/pg_dump/pg_dumpall.c8
-rw-r--r--src/bin/pg_dump/pg_restore.c8
-rw-r--r--src/bin/pg_resetxlog/Makefile9
-rw-r--r--src/bin/pg_resetxlog/pg_resetxlog.c8
-rw-r--r--src/bin/psql/startup.c8
-rw-r--r--src/bin/scripts/Makefile25
-rw-r--r--src/bin/scripts/clusterdb.c4
-rw-r--r--src/bin/scripts/common.c10
-rw-r--r--src/bin/scripts/common.h2
-rw-r--r--src/bin/scripts/createdb.c4
-rw-r--r--src/bin/scripts/createlang.c4
-rw-r--r--src/bin/scripts/createuser.c4
-rw-r--r--src/bin/scripts/dropdb.c4
-rw-r--r--src/bin/scripts/droplang.c4
-rw-r--r--src/bin/scripts/dropuser.c4
-rw-r--r--src/bin/scripts/vacuumdb.c4
-rw-r--r--src/include/port.h4
-rw-r--r--src/interfaces/libpq/fe-misc.c3
-rw-r--r--src/port/Makefile3
-rw-r--r--src/port/path.c101
26 files changed, 158 insertions, 122 deletions
diff --git a/src/backend/main/main.c b/src/backend/main/main.c
index 9216c2c4be9..c93dc4ef4d8 100644
--- a/src/backend/main/main.c
+++ b/src/backend/main/main.c
@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/main/main.c,v 1.81 2004/05/24 02:47:44 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/main/main.c,v 1.82 2004/05/25 01:00:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -150,6 +150,8 @@ main(int argc, char *argv[])
* startup error messages to be localized.
*/
+ set_pglocale(argv[0], "postgres");
+
#ifdef WIN32
/*
* Windows uses codepages rather than the environment, so we work around
@@ -185,11 +187,6 @@ main(int argc, char *argv[])
setlocale(LC_NUMERIC, "C");
setlocale(LC_TIME, "C");
-#ifdef ENABLE_NLS
- bindtextdomain("postgres", LOCALEDIR);
- textdomain("postgres");
-#endif
-
/*
* Skip permission checks if we're just trying to do --help or
* --version; otherwise root will get unhelpful failure messages from
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 85d65ab459c..9b227807ae7 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -39,7 +39,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD.
*
- * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.32 2004/05/18 03:36:36 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.33 2004/05/25 01:00:22 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -167,7 +167,7 @@ static void check_ok(void);
static bool chklocale(const char *locale);
static void setlocales(void);
static void usage(const char *progname);
-static void init_nls(void);
+static void init_nls(const char *argv0);
/*
@@ -1754,13 +1754,9 @@ usage(const char *progname)
* Initialized NLS if enabled.
*/
static void
-init_nls(void)
+init_nls(const char *argv0)
{
-#ifdef ENABLE_NLS
- setlocale(LC_ALL, "");
- bindtextdomain("initdb", LOCALEDIR);
- textdomain("initdb");
-#endif
+ set_pglocale(argv0, "initdb");
}
@@ -1801,7 +1797,7 @@ main(int argc, char *argv[])
* environment */
char *subdirs[] =
{"global", "pg_xlog", "pg_clog", "base", "base/1"};
- init_nls();
+ init_nls(argv[0]);
progname = get_progname(argv[0]);
diff --git a/src/bin/pg_controldata/Makefile b/src/bin/pg_controldata/Makefile
index 0ec0705da37..17da2805700 100644
--- a/src/bin/pg_controldata/Makefile
+++ b/src/bin/pg_controldata/Makefile
@@ -4,7 +4,7 @@
#
# Copyright (c) 1998-2002, PostgreSQL Global Development Group
#
-# $PostgreSQL: pgsql/src/bin/pg_controldata/Makefile,v 1.7 2004/04/30 20:01:39 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/pg_controldata/Makefile,v 1.8 2004/05/25 01:00:23 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -14,7 +14,7 @@ include $(top_builddir)/src/Makefile.global
override CPPFLAGS += -DFRONTEND
-OBJS= pg_controldata.o pg_crc.o
+OBJS= pg_controldata.o pg_crc.o exec.o
all: submake-libpgport pg_controldata
@@ -24,6 +24,9 @@ pg_controldata: $(OBJS)
pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
rm -f $@ && $(LN_S) $< .
+exec.c: % : $(top_srcdir)/src/port/%
+ rm -f $@ && $(LN_S) $< .
+
install: all installdirs
$(INSTALL_PROGRAM) pg_controldata$(X) $(DESTDIR)$(bindir)/pg_controldata$(X)
@@ -34,4 +37,4 @@ uninstall:
rm -f $(DESTDIR)$(bindir)/pg_controldata$(X)
clean distclean maintainer-clean:
- rm -f pg_controldata$(X) pg_controldata.o pg_crc.o pg_crc.c
+ rm -f pg_controldata$(X) pg_controldata.o pg_crc.o pg_crc.c exec.c
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 86b4d557d9c..c7d28d11ee2 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -6,7 +6,7 @@
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
* licence: BSD
*
- * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.15 2004/05/12 13:38:43 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.16 2004/05/25 01:00:23 momjian Exp $
*/
#include "postgres.h"
@@ -77,11 +77,7 @@ main(int argc, char *argv[])
char *strftime_fmt = "%c";
const char *progname;
- setlocale(LC_ALL, "");
-#ifdef ENABLE_NLS
- bindtextdomain("pg_controldata", LOCALEDIR);
- textdomain("pg_controldata");
-#endif
+ set_pglocale(argv[0], "pg_controldata");
progname = get_progname(argv[0]);
diff --git a/src/bin/pg_dump/Makefile b/src/bin/pg_dump/Makefile
index 035e4a4275a..2a788b68de0 100644
--- a/src/bin/pg_dump/Makefile
+++ b/src/bin/pg_dump/Makefile
@@ -5,7 +5,7 @@
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
-# $PostgreSQL: pgsql/src/bin/pg_dump/Makefile,v 1.51 2004/05/24 01:01:37 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/pg_dump/Makefile,v 1.52 2004/05/25 01:00:24 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -17,8 +17,7 @@ override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) -DFRONTEND
OBJS= pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o \
pg_backup_files.o pg_backup_null.o pg_backup_tar.o \
- dumputils.o
-PG_DUMPALL_OBJS = exec.o
+ dumputils.o exec.o
EXTRA_OBJS = $(top_builddir)/src/backend/parser/keywords.o
@@ -31,8 +30,8 @@ pg_dump: pg_dump.o common.o pg_dump_sort.o $(OBJS) $(libpq_builddir)/libpq.a
pg_restore: pg_restore.o $(OBJS) $(libpq_builddir)/libpq.a
$(CC) $(CFLAGS) pg_restore.o $(OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
-pg_dumpall: pg_dumpall.o dumputils.o $(PG_DUMPALL_OBJS) $(libpq_builddir)/libpq.a
- $(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(PG_DUMPALL_OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
+pg_dumpall: pg_dumpall.o dumputils.o exec.o $(libpq_builddir)/libpq.a
+ $(CC) $(CFLAGS) pg_dumpall.o dumputils.o exec.o $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
# We need our own build of exec.c so it gets made with -DFRONTEND
exec.c: % : $(top_srcdir)/src/port/%
@@ -55,4 +54,4 @@ uninstall:
rm -f $(addprefix $(DESTDIR)$(bindir)/, pg_dump$(X) pg_restore$(X) pg_dumpall$(X))
clean distclean maintainer-clean:
- 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
+ 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
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index b6a7e053484..c178baa4726 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -12,7 +12,7 @@
* by PostgreSQL
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.370 2004/03/24 03:06:08 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.371 2004/05/25 01:00:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -242,11 +242,7 @@ main(int argc, char **argv)
};
int optindex;
-#ifdef ENABLE_NLS
- setlocale(LC_ALL, "");
- bindtextdomain("pg_dump", LOCALEDIR);
- textdomain("pg_dump");
-#endif
+ set_pglocale(argv[0], "pg_dump");
g_verbose = false;
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 55d52bd778c..872416b64f7 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
*
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.34 2004/05/19 21:21:26 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.35 2004/05/25 01:00:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -101,11 +101,7 @@ main(int argc, char *argv[])
int optindex;
-#ifdef ENABLE_NLS
- setlocale(LC_ALL, "");
- bindtextdomain("pg_dump", LOCALEDIR);
- textdomain("pg_dump");
-#endif
+ set_pglocale(argv[0], "pg_dump");
progname = get_progname(argv[0]);
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index d8dfcc4c486..de44b583d12 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -34,7 +34,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.56 2004/04/22 02:39:10 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.57 2004/05/25 01:00:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -121,11 +121,7 @@ main(int argc, char **argv)
{NULL, 0, NULL, 0}
};
-#ifdef ENABLE_NLS
- setlocale(LC_ALL, "");
- bindtextdomain("pg_dump", LOCALEDIR);
- textdomain("pg_dump");
-#endif
+ set_pglocale(argv[0], "pg_dump");
opts = NewRestoreOptions();
diff --git a/src/bin/pg_resetxlog/Makefile b/src/bin/pg_resetxlog/Makefile
index abbeea65c7f..8e8b3394f41 100644
--- a/src/bin/pg_resetxlog/Makefile
+++ b/src/bin/pg_resetxlog/Makefile
@@ -4,7 +4,7 @@
#
# Copyright (c) 1998-2002, PostgreSQL Global Development Group
#
-# $PostgreSQL: pgsql/src/bin/pg_resetxlog/Makefile,v 1.9 2004/05/24 01:01:37 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/pg_resetxlog/Makefile,v 1.10 2004/05/25 01:00:25 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -14,7 +14,7 @@ include $(top_builddir)/src/Makefile.global
override CPPFLAGS += -DFRONTEND
-OBJS= pg_resetxlog.o pg_crc.o dirmod.o
+OBJS= pg_resetxlog.o pg_crc.o dirmod.o exec.o
all: submake-libpgport pg_resetxlog
@@ -27,6 +27,9 @@ dirmod.c: % : $(top_srcdir)/src/port/%
pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
rm -f $@ && $(LN_S) $< .
+exec.c: % : $(top_srcdir)/src/port/%
+ rm -f $@ && $(LN_S) $< .
+
install: all installdirs
$(INSTALL_PROGRAM) pg_resetxlog$(X) $(DESTDIR)$(bindir)/pg_resetxlog$(X)
@@ -37,4 +40,4 @@ uninstall:
rm -f $(DESTDIR)$(bindir)/pg_resetxlog$(X)
clean distclean maintainer-clean:
- rm -f pg_resetxlog$(X) pg_crc.c dirmod.c $(OBJS)
+ rm -f pg_resetxlog$(X) pg_crc.c dirmod.c exec.c $(OBJS)
diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c
index 8c57f710115..6f2ed531611 100644
--- a/src/bin/pg_resetxlog/pg_resetxlog.c
+++ b/src/bin/pg_resetxlog/pg_resetxlog.c
@@ -23,7 +23,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.18 2004/05/12 13:38:44 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.19 2004/05/25 01:00:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -102,11 +102,7 @@ main(int argc, char *argv[])
int fd;
char path[MAXPGPATH];
- setlocale(LC_ALL, "");
-#ifdef ENABLE_NLS
- bindtextdomain("pg_resetxlog", LOCALEDIR);
- textdomain("pg_resetxlog");
-#endif
+ set_pglocale(argv[0], "pg_resetxlog");
progname = get_progname(argv[0]);
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index 908b8dec802..1d45105bd4b 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.93 2004/05/17 14:35:33 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.94 2004/05/25 01:00:26 momjian Exp $
*/
#include "postgres_fe.h"
@@ -102,11 +102,7 @@ main(int argc, char *argv[])
char *password = NULL;
bool need_pass;
- setlocale(LC_ALL, "");
-#ifdef ENABLE_NLS
- bindtextdomain("psql", LOCALEDIR);
- textdomain("psql");
-#endif
+ set_pglocale(argv[0], "psql");
pset.progname = get_progname(argv[0]);
diff --git a/src/bin/scripts/Makefile b/src/bin/scripts/Makefile
index 612b07071f8..15b692e2dbb 100644
--- a/src/bin/scripts/Makefile
+++ b/src/bin/scripts/Makefile
@@ -5,7 +5,7 @@
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
-# $PostgreSQL: pgsql/src/bin/scripts/Makefile,v 1.26 2004/04/26 17:40:48 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/scripts/Makefile,v 1.27 2004/05/25 01:00:27 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -15,21 +15,24 @@ include $(top_builddir)/src/Makefile.global
PROGRAMS = createdb createlang createuser dropdb droplang dropuser clusterdb vacuumdb
-override CPPFLAGS := -I$(top_srcdir)/src/bin/pg_dump -I$(top_srcdir)/src/bin/psql -I$(libpq_srcdir) $(CPPFLAGS)
+override CPPFLAGS := -DFRONTEND -I$(top_srcdir)/src/bin/pg_dump -I$(top_srcdir)/src/bin/psql -I$(libpq_srcdir) $(CPPFLAGS)
all: submake-libpq submake-backend $(PROGRAMS)
%: %.o
$(CC) $(CFLAGS) $^ $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
-createdb: createdb.o common.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
-createlang: createlang.o common.o print.o mbprint.o
-createuser: createuser.o common.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
-dropdb: dropdb.o common.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
-droplang: droplang.o common.o print.o mbprint.o
-dropuser: dropuser.o common.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
-clusterdb: clusterdb.o common.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
-vacuumdb: vacuumdb.o common.o
+createdb: createdb.o common.o exec.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
+createlang: createlang.o common.o exec.o print.o mbprint.o
+createuser: createuser.o common.o exec.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
+dropdb: dropdb.o common.o exec.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
+droplang: droplang.o common.o exec.o print.o mbprint.o
+dropuser: dropuser.o common.o exec.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
+clusterdb: clusterdb.o common.o exec.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
+vacuumdb: vacuumdb.o common.o exec.o
+
+exec.c: % : $(top_srcdir)/src/port/%
+ rm -f $@ && $(LN_S) $< .
dumputils.c: % : $(top_srcdir)/src/bin/pg_dump/%
rm -f $@ && $(LN_S) $< .
@@ -60,4 +63,4 @@ uninstall:
clean distclean maintainer-clean:
- rm -f $(addsuffix $(X), $(PROGRAMS)) $(addsuffix .o, $(PROGRAMS)) common.o dumputils.o print.o mbprint.o dumputils.c print.c mbprint.c
+ rm -f $(addsuffix $(X), $(PROGRAMS)) $(addsuffix .o, $(PROGRAMS)) common.o dumputils.o print.o mbprint.o dumputils.c exec.c print.c mbprint.c
diff --git a/src/bin/scripts/clusterdb.c b/src/bin/scripts/clusterdb.c
index 0fcab8ec6da..a912d0b1f97 100644
--- a/src/bin/scripts/clusterdb.c
+++ b/src/bin/scripts/clusterdb.c
@@ -4,7 +4,7 @@
*
* Portions Copyright (c) 2002-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.6 2004/05/12 13:38:46 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.7 2004/05/25 01:00:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -58,7 +58,7 @@ main(int argc, char *argv[])
char *table = NULL;
progname = get_progname(argv[0]);
- init_nls();
+ init_nls(argv[0]);
handle_help_version_opts(argc, argv, "clusterdb", help);
while ((c = getopt_long(argc, argv, "h:p:U:Weqd:at:", long_options, &optindex)) != -1)
diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c
index f14e0b206e1..715d7e3cdb1 100644
--- a/src/bin/scripts/common.c
+++ b/src/bin/scripts/common.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.7 2004/04/19 17:42:59 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.8 2004/05/25 01:00:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -51,13 +51,9 @@ get_user_name(const char *progname)
* Initialized NLS if enabled.
*/
void
-init_nls(void)
+init_nls(const char *argv0)
{
-#ifdef ENABLE_NLS
- setlocale(LC_ALL, "");
- bindtextdomain("pgscripts", LOCALEDIR);
- textdomain("pgscripts");
-#endif
+ set_pglocale(argv0, "pgscripts");
}
diff --git a/src/bin/scripts/common.h b/src/bin/scripts/common.h
index 3c9da3e0136..8898fc5fe6d 100644
--- a/src/bin/scripts/common.h
+++ b/src/bin/scripts/common.h
@@ -11,7 +11,7 @@ int optreset;
const char *get_user_name(const char *progname);
#define _(x) gettext((x))
-void init_nls(void);
+void init_nls(const char *argv0);
typedef void (*help_handler) (const char *);
diff --git a/src/bin/scripts/createdb.c b/src/bin/scripts/createdb.c
index 8ee5fdca651..cf75e83c20f 100644
--- a/src/bin/scripts/createdb.c
+++ b/src/bin/scripts/createdb.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/createdb.c,v 1.8 2004/05/12 13:38:47 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/createdb.c,v 1.9 2004/05/25 01:00:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -60,7 +60,7 @@ main(int argc, char *argv[])
PGresult *result;
progname = get_progname(argv[0]);
- init_nls();
+ init_nls(argv[0]);
handle_help_version_opts(argc, argv, "createdb", help);
while ((c = getopt_long(argc, argv, "h:p:U:WeqO:D:T:E:", long_options, &optindex)) != -1)
diff --git a/src/bin/scripts/createlang.c b/src/bin/scripts/createlang.c
index f75e9e07cdd..89eef3aa6be 100644
--- a/src/bin/scripts/createlang.c
+++ b/src/bin/scripts/createlang.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/createlang.c,v 1.9 2004/05/12 13:38:47 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/createlang.c,v 1.10 2004/05/25 01:00:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -61,7 +61,7 @@ main(int argc, char *argv[])
PGresult *result;
progname = get_progname(argv[0]);
- init_nls();
+ init_nls(argv[0]);
handle_help_version_opts(argc, argv, "createlang", help);
while ((c = getopt_long(argc, argv, "lh:p:U:Wd:L:e", long_options, &optindex)) != -1)
diff --git a/src/bin/scripts/createuser.c b/src/bin/scripts/createuser.c
index 2a262ecb39b..d3b395f6305 100644
--- a/src/bin/scripts/createuser.c
+++ b/src/bin/scripts/createuser.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.10 2004/05/12 13:38:48 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.11 2004/05/25 01:00:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -63,7 +63,7 @@ main(int argc, char *argv[])
PGresult *result;
progname = get_progname(argv[0]);
- init_nls();
+ init_nls(argv[0]);
handle_help_version_opts(argc, argv, "createuser", help);
while ((c = getopt_long(argc, argv, "h:p:U:WeqaAdDi:PEN", long_options, &optindex)) != -1)
diff --git a/src/bin/scripts/dropdb.c b/src/bin/scripts/dropdb.c
index 5b8540e4c38..08331a0f133 100644
--- a/src/bin/scripts/dropdb.c
+++ b/src/bin/scripts/dropdb.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/dropdb.c,v 1.9 2004/05/12 13:38:48 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/dropdb.c,v 1.10 2004/05/25 01:00:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -51,7 +51,7 @@ main(int argc, char *argv[])
PGresult *result;
progname = get_progname(argv[0]);
- init_nls();
+ init_nls(argv[0]);
handle_help_version_opts(argc, argv, "dropdb", help);
while ((c = getopt_long(argc, argv, "h:p:U:Weqi", long_options, &optindex)) != -1)
diff --git a/src/bin/scripts/droplang.c b/src/bin/scripts/droplang.c
index 63fe0f7c32c..fc7a94241c3 100644
--- a/src/bin/scripts/droplang.c
+++ b/src/bin/scripts/droplang.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/droplang.c,v 1.8 2004/05/12 13:38:48 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/droplang.c,v 1.9 2004/05/25 01:00:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -61,7 +61,7 @@ main(int argc, char *argv[])
PGresult *result;
progname = get_progname(argv[0]);
- init_nls();
+ init_nls(argv[0]);
handle_help_version_opts(argc, argv, "droplang", help);
while ((c = getopt_long(argc, argv, "lh:p:U:Wd:e", long_options, &optindex)) != -1)
diff --git a/src/bin/scripts/dropuser.c b/src/bin/scripts/dropuser.c
index 352f913a06c..a901b64bbb1 100644
--- a/src/bin/scripts/dropuser.c
+++ b/src/bin/scripts/dropuser.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/dropuser.c,v 1.8 2004/05/12 13:38:48 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/dropuser.c,v 1.9 2004/05/25 01:00:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -51,7 +51,7 @@ main(int argc, char *argv[])
PGresult *result;
progname = get_progname(argv[0]);
- init_nls();
+ init_nls(argv[0]);
handle_help_version_opts(argc, argv, "dropuser", help);
while ((c = getopt_long(argc, argv, "h:p:U:Weqi", long_options, &optindex)) != -1)
diff --git a/src/bin/scripts/vacuumdb.c b/src/bin/scripts/vacuumdb.c
index ae64f34ab92..eb4fb0d5e19 100644
--- a/src/bin/scripts/vacuumdb.c
+++ b/src/bin/scripts/vacuumdb.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/vacuumdb.c,v 1.6 2004/05/12 13:38:48 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/vacuumdb.c,v 1.7 2004/05/25 01:00:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -66,7 +66,7 @@ main(int argc, char *argv[])
bool verbose = false;
progname = get_progname(argv[0]);
- init_nls();
+ init_nls(argv[0]);
handle_help_version_opts(argc, argv, "vacuumdb", help);
while ((c = getopt_long(argc, argv, "h:p:U:Weqd:zat:fv", long_options, &optindex)) != -1)
diff --git a/src/include/port.h b/src/include/port.h
index 9526a0ba386..1357984afbb 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/port.h,v 1.37 2004/05/21 16:06:22 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/port.h,v 1.38 2004/05/25 01:00:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -31,6 +31,8 @@ extern void get_etc_path(const char *my_exec_path, char *ret_path);
extern void get_include_path(const char *my_exec_path, char *ret_path);
extern void get_pkginclude_path(const char *my_exec_path, char *ret_path);
extern void get_pkglib_path(const char *my_exec_path, char *ret_path);
+extern void get_locale_path(const char *my_exec_path, char *ret_path);
+extern void set_pglocale(const char *argv0, const char *app);
/*
* is_absolute_path
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c
index d484747b9c5..abf2111a508 100644
--- a/src/interfaces/libpq/fe-misc.c
+++ b/src/interfaces/libpq/fe-misc.c
@@ -23,7 +23,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.105 2004/03/15 10:41:26 ishii Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.106 2004/05/25 01:00:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1131,6 +1131,7 @@ libpq_gettext(const char *msgid)
if (!already_bound)
{
already_bound = 1;
+ /* No relocatable lookup here because the binary could be anywhere */
bindtextdomain("libpq", LOCALEDIR);
}
diff --git a/src/port/Makefile b/src/port/Makefile
index 76f967ae656..8540178de1e 100644
--- a/src/port/Makefile
+++ b/src/port/Makefile
@@ -7,7 +7,7 @@
# with broken/missing library files.
# IDENTIFICATION
-# $PostgreSQL: pgsql/src/port/Makefile,v 1.13 2004/05/22 02:15:08 tgl Exp $
+# $PostgreSQL: pgsql/src/port/Makefile,v 1.14 2004/05/25 01:00:30 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -37,6 +37,7 @@ pg_config_paths.h: $(top_builddir)/src/Makefile.global
echo "#define INCLUDEDIR \"$(includedir)\"" >>$@
echo "#define PKGINCLUDEDIR \"$(pkgincludedir)\"" >>$@
echo "#define PKGLIBDIR \"$(pkglibdir)\"" >>$@
+ echo "#define LOCALEDIR \"$(localedir)\"" >>$@
clean distclean maintainer-clean:
rm -f libpgport.a $(LIBOBJS) pg_config_paths.h
diff --git a/src/port/path.c b/src/port/path.c
index 616be999b10..af6cbf91bff 100644
--- a/src/port/path.c
+++ b/src/port/path.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/port/path.c,v 1.11 2004/05/21 20:56:50 tgl Exp $
+ * $PostgreSQL: pgsql/src/port/path.c,v 1.12 2004/05/25 01:00:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -113,12 +113,14 @@ get_progname(const char *argv0)
void
get_share_path(const char *my_exec_path, char *ret_path)
{
+ char path[MAXPGPATH];
+
if (relative_path(PGBINDIR, PGSHAREDIR))
{
- StrNCpy(ret_path, my_exec_path, MAXPGPATH);
- trim_directory(ret_path); /* trim off binary */
- trim_directory(ret_path); /* trim off /bin */
- strcat(ret_path, "/share"); /* add /share */
+ StrNCpy(path, my_exec_path, MAXPGPATH);
+ trim_directory(path); /* trim off binary */
+ trim_directory(path); /* trim off /bin */
+ snprintf(ret_path, MAXPGPATH, "%s/share", path);
}
else
StrNCpy(ret_path, PGSHAREDIR, MAXPGPATH);
@@ -132,12 +134,14 @@ get_share_path(const char *my_exec_path, char *ret_path)
void
get_etc_path(const char *my_exec_path, char *ret_path)
{
+ char path[MAXPGPATH];
+
if (relative_path(PGBINDIR, SYSCONFDIR))
{
- StrNCpy(ret_path, my_exec_path, MAXPGPATH);
- trim_directory(ret_path);
- trim_directory(ret_path);
- strcat(ret_path, "/etc");
+ StrNCpy(path, my_exec_path, MAXPGPATH);
+ trim_directory(path);
+ trim_directory(path);
+ snprintf(ret_path, MAXPGPATH, "%s/etc", path);
}
else
StrNCpy(ret_path, SYSCONFDIR, MAXPGPATH);
@@ -151,12 +155,14 @@ get_etc_path(const char *my_exec_path, char *ret_path)
void
get_include_path(const char *my_exec_path, char *ret_path)
{
+ char path[MAXPGPATH];
+
if (relative_path(PGBINDIR, INCLUDEDIR))
{
- StrNCpy(ret_path, my_exec_path, MAXPGPATH);
- trim_directory(ret_path);
- trim_directory(ret_path);
- strcat(ret_path, "/include");
+ StrNCpy(path, my_exec_path, MAXPGPATH);
+ trim_directory(path);
+ trim_directory(path);
+ snprintf(ret_path, MAXPGPATH, "%s/include", path);
}
else
StrNCpy(ret_path, INCLUDEDIR, MAXPGPATH);
@@ -170,12 +176,14 @@ get_include_path(const char *my_exec_path, char *ret_path)
void
get_pkginclude_path(const char *my_exec_path, char *ret_path)
{
+ char path[MAXPGPATH];
+
if (relative_path(PGBINDIR, PKGINCLUDEDIR))
{
- StrNCpy(ret_path, my_exec_path, MAXPGPATH);
- trim_directory(ret_path);
- trim_directory(ret_path);
- strcat(ret_path, "/include");
+ StrNCpy(path, my_exec_path, MAXPGPATH);
+ trim_directory(path);
+ trim_directory(path);
+ snprintf(ret_path, MAXPGPATH, "%s/include", path);
}
else
StrNCpy(ret_path, PKGINCLUDEDIR, MAXPGPATH);
@@ -191,12 +199,14 @@ get_pkginclude_path(const char *my_exec_path, char *ret_path)
void
get_pkglib_path(const char *my_exec_path, char *ret_path)
{
+ char path[MAXPGPATH];
+
if (relative_path(PGBINDIR, PKGLIBDIR))
{
- StrNCpy(ret_path, my_exec_path, MAXPGPATH);
- trim_directory(ret_path);
- trim_directory(ret_path);
- strcat(ret_path, "/lib");
+ StrNCpy(path, my_exec_path, MAXPGPATH);
+ trim_directory(path);
+ trim_directory(path);
+ snprintf(ret_path, MAXPGPATH, "%s/lib", path);
}
else
StrNCpy(ret_path, PKGLIBDIR, MAXPGPATH);
@@ -205,6 +215,55 @@ get_pkglib_path(const char *my_exec_path, char *ret_path)
/*
+ * get_locale_path
+ *
+ * Return locale path, either relative to /bin or hardcoded
+ */
+void
+get_locale_path(const char *my_exec_path, char *ret_path)
+{
+ char path[MAXPGPATH];
+
+ if (relative_path(PGBINDIR, LOCALEDIR))
+ {
+ StrNCpy(path, my_exec_path, MAXPGPATH);
+ trim_directory(path);
+ trim_directory(path);
+ snprintf(ret_path, MAXPGPATH, "%s/share/locale", path);
+ }
+ else
+ StrNCpy(ret_path, LOCALEDIR, MAXPGPATH);
+}
+
+
+
+/*
+ * set_pglocale
+ *
+ * Set application-specific locale
+ *
+ * This function takes an argv[0] rather than a full path.
+ */
+void
+set_pglocale(const char *argv0, const char *app)
+{
+#ifdef ENABLE_NLS
+ char path[MAXPGPATH];
+ char my_exec_path[MAXPGPATH];
+
+ setlocale(LC_ALL, "");
+ if (find_my_exec(argv0, my_exec_path) < 0)
+ return;
+
+ get_locale_path(argv0, path);
+ bindtextdomain(app, path);
+ textdomain(app);
+#endif
+}
+
+
+
+/*
* relative_path
*
* Do the supplied paths differ only in their last component?