Commit 22889777 authored by Bruce Momjian's avatar Bruce Momjian

Make the locale location relocatable.

Adjust get_*_path functions to be limited to MAXPGPATH.
parent 244ee0c0
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* *
* *
* IDENTIFICATION * 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[]) ...@@ -150,6 +150,8 @@ main(int argc, char *argv[])
* startup error messages to be localized. * startup error messages to be localized.
*/ */
set_pglocale(argv[0], "postgres");
#ifdef WIN32 #ifdef WIN32
/* /*
* Windows uses codepages rather than the environment, so we work around * Windows uses codepages rather than the environment, so we work around
...@@ -185,11 +187,6 @@ main(int argc, char *argv[]) ...@@ -185,11 +187,6 @@ main(int argc, char *argv[])
setlocale(LC_NUMERIC, "C"); setlocale(LC_NUMERIC, "C");
setlocale(LC_TIME, "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 * Skip permission checks if we're just trying to do --help or
* --version; otherwise root will get unhelpful failure messages from * --version; otherwise root will get unhelpful failure messages from
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD. * 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); ...@@ -167,7 +167,7 @@ static void check_ok(void);
static bool chklocale(const char *locale); static bool chklocale(const char *locale);
static void setlocales(void); static void setlocales(void);
static void usage(const char *progname); 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) ...@@ -1754,13 +1754,9 @@ usage(const char *progname)
* Initialized NLS if enabled. * Initialized NLS if enabled.
*/ */
static void static void
init_nls(void) init_nls(const char *argv0)
{ {
#ifdef ENABLE_NLS set_pglocale(argv0, "initdb");
setlocale(LC_ALL, "");
bindtextdomain("initdb", LOCALEDIR);
textdomain("initdb");
#endif
} }
...@@ -1801,7 +1797,7 @@ main(int argc, char *argv[]) ...@@ -1801,7 +1797,7 @@ main(int argc, char *argv[])
* environment */ * environment */
char *subdirs[] = char *subdirs[] =
{"global", "pg_xlog", "pg_clog", "base", "base/1"}; {"global", "pg_xlog", "pg_clog", "base", "base/1"};
init_nls(); init_nls(argv[0]);
progname = get_progname(argv[0]); progname = get_progname(argv[0]);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
# Copyright (c) 1998-2002, PostgreSQL Global Development Group # 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 ...@@ -14,7 +14,7 @@ include $(top_builddir)/src/Makefile.global
override CPPFLAGS += -DFRONTEND override CPPFLAGS += -DFRONTEND
OBJS= pg_controldata.o pg_crc.o OBJS= pg_controldata.o pg_crc.o exec.o
all: submake-libpgport pg_controldata all: submake-libpgport pg_controldata
...@@ -24,6 +24,9 @@ pg_controldata: $(OBJS) ...@@ -24,6 +24,9 @@ pg_controldata: $(OBJS)
pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
rm -f $@ && $(LN_S) $< . rm -f $@ && $(LN_S) $< .
exec.c: % : $(top_srcdir)/src/port/%
rm -f $@ && $(LN_S) $< .
install: all installdirs install: all installdirs
$(INSTALL_PROGRAM) pg_controldata$(X) $(DESTDIR)$(bindir)/pg_controldata$(X) $(INSTALL_PROGRAM) pg_controldata$(X) $(DESTDIR)$(bindir)/pg_controldata$(X)
...@@ -34,4 +37,4 @@ uninstall: ...@@ -34,4 +37,4 @@ uninstall:
rm -f $(DESTDIR)$(bindir)/pg_controldata$(X) rm -f $(DESTDIR)$(bindir)/pg_controldata$(X)
clean distclean maintainer-clean: 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
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001; * copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
* licence: BSD * 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" #include "postgres.h"
...@@ -77,11 +77,7 @@ main(int argc, char *argv[]) ...@@ -77,11 +77,7 @@ main(int argc, char *argv[])
char *strftime_fmt = "%c"; char *strftime_fmt = "%c";
const char *progname; const char *progname;
setlocale(LC_ALL, ""); set_pglocale(argv[0], "pg_controldata");
#ifdef ENABLE_NLS
bindtextdomain("pg_controldata", LOCALEDIR);
textdomain("pg_controldata");
#endif
progname = get_progname(argv[0]); progname = get_progname(argv[0]);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group # Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California # 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 ...@@ -17,8 +17,7 @@ override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) -DFRONTEND
OBJS= pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o \ 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 \ pg_backup_files.o pg_backup_null.o pg_backup_tar.o \
dumputils.o dumputils.o exec.o
PG_DUMPALL_OBJS = exec.o
EXTRA_OBJS = $(top_builddir)/src/backend/parser/keywords.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 ...@@ -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 pg_restore: pg_restore.o $(OBJS) $(libpq_builddir)/libpq.a
$(CC) $(CFLAGS) pg_restore.o $(OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X) $(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 pg_dumpall: pg_dumpall.o dumputils.o exec.o $(libpq_builddir)/libpq.a
$(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(PG_DUMPALL_OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X) $(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 # We need our own build of exec.c so it gets made with -DFRONTEND
exec.c: % : $(top_srcdir)/src/port/% exec.c: % : $(top_srcdir)/src/port/%
...@@ -55,4 +54,4 @@ uninstall: ...@@ -55,4 +54,4 @@ uninstall:
rm -f $(addprefix $(DESTDIR)$(bindir)/, pg_dump$(X) pg_restore$(X) pg_dumpall$(X)) rm -f $(addprefix $(DESTDIR)$(bindir)/, pg_dump$(X) pg_restore$(X) pg_dumpall$(X))
clean distclean maintainer-clean: 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
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* by PostgreSQL * by PostgreSQL
* *
* IDENTIFICATION * 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) ...@@ -242,11 +242,7 @@ main(int argc, char **argv)
}; };
int optindex; int optindex;
#ifdef ENABLE_NLS set_pglocale(argv[0], "pg_dump");
setlocale(LC_ALL, "");
bindtextdomain("pg_dump", LOCALEDIR);
textdomain("pg_dump");
#endif
g_verbose = false; g_verbose = false;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * 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[]) ...@@ -101,11 +101,7 @@ main(int argc, char *argv[])
int optindex; int optindex;
#ifdef ENABLE_NLS set_pglocale(argv[0], "pg_dump");
setlocale(LC_ALL, "");
bindtextdomain("pg_dump", LOCALEDIR);
textdomain("pg_dump");
#endif
progname = get_progname(argv[0]); progname = get_progname(argv[0]);
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -121,11 +121,7 @@ main(int argc, char **argv)
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
#ifdef ENABLE_NLS set_pglocale(argv[0], "pg_dump");
setlocale(LC_ALL, "");
bindtextdomain("pg_dump", LOCALEDIR);
textdomain("pg_dump");
#endif
opts = NewRestoreOptions(); opts = NewRestoreOptions();
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
# Copyright (c) 1998-2002, PostgreSQL Global Development Group # 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 ...@@ -14,7 +14,7 @@ include $(top_builddir)/src/Makefile.global
override CPPFLAGS += -DFRONTEND 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 all: submake-libpgport pg_resetxlog
...@@ -27,6 +27,9 @@ dirmod.c: % : $(top_srcdir)/src/port/% ...@@ -27,6 +27,9 @@ dirmod.c: % : $(top_srcdir)/src/port/%
pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
rm -f $@ && $(LN_S) $< . rm -f $@ && $(LN_S) $< .
exec.c: % : $(top_srcdir)/src/port/%
rm -f $@ && $(LN_S) $< .
install: all installdirs install: all installdirs
$(INSTALL_PROGRAM) pg_resetxlog$(X) $(DESTDIR)$(bindir)/pg_resetxlog$(X) $(INSTALL_PROGRAM) pg_resetxlog$(X) $(DESTDIR)$(bindir)/pg_resetxlog$(X)
...@@ -37,4 +40,4 @@ uninstall: ...@@ -37,4 +40,4 @@ uninstall:
rm -f $(DESTDIR)$(bindir)/pg_resetxlog$(X) rm -f $(DESTDIR)$(bindir)/pg_resetxlog$(X)
clean distclean maintainer-clean: 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)
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * 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[]) ...@@ -102,11 +102,7 @@ main(int argc, char *argv[])
int fd; int fd;
char path[MAXPGPATH]; char path[MAXPGPATH];
setlocale(LC_ALL, ""); set_pglocale(argv[0], "pg_resetxlog");
#ifdef ENABLE_NLS
bindtextdomain("pg_resetxlog", LOCALEDIR);
textdomain("pg_resetxlog");
#endif
progname = get_progname(argv[0]); progname = get_progname(argv[0]);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2003, PostgreSQL Global Development Group * 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" #include "postgres_fe.h"
...@@ -102,11 +102,7 @@ main(int argc, char *argv[]) ...@@ -102,11 +102,7 @@ main(int argc, char *argv[])
char *password = NULL; char *password = NULL;
bool need_pass; bool need_pass;
setlocale(LC_ALL, ""); set_pglocale(argv[0], "psql");
#ifdef ENABLE_NLS
bindtextdomain("psql", LOCALEDIR);
textdomain("psql");
#endif
pset.progname = get_progname(argv[0]); pset.progname = get_progname(argv[0]);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group # Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California # 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 ...@@ -15,21 +15,24 @@ include $(top_builddir)/src/Makefile.global
PROGRAMS = createdb createlang createuser dropdb droplang dropuser clusterdb vacuumdb 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) all: submake-libpq submake-backend $(PROGRAMS)
%: %.o %: %.o
$(CC) $(CFLAGS) $^ $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X) $(CC) $(CFLAGS) $^ $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
createdb: createdb.o common.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o createdb: createdb.o common.o exec.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
createlang: createlang.o common.o print.o mbprint.o createlang: createlang.o common.o exec.o print.o mbprint.o
createuser: createuser.o common.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o createuser: createuser.o common.o exec.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
dropdb: dropdb.o common.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 print.o mbprint.o droplang: droplang.o common.o exec.o print.o mbprint.o
dropuser: dropuser.o common.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o dropuser: dropuser.o common.o exec.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
clusterdb: clusterdb.o common.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 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/% dumputils.c: % : $(top_srcdir)/src/bin/pg_dump/%
rm -f $@ && $(LN_S) $< . rm -f $@ && $(LN_S) $< .
...@@ -60,4 +63,4 @@ uninstall: ...@@ -60,4 +63,4 @@ uninstall:
clean distclean maintainer-clean: 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
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* *
* Portions Copyright (c) 2002-2003, PostgreSQL Global Development Group * 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[]) ...@@ -58,7 +58,7 @@ main(int argc, char *argv[])
char *table = NULL; char *table = NULL;
progname = get_progname(argv[0]); progname = get_progname(argv[0]);
init_nls(); init_nls(argv[0]);
handle_help_version_opts(argc, argv, "clusterdb", help); handle_help_version_opts(argc, argv, "clusterdb", help);
while ((c = getopt_long(argc, argv, "h:p:U:Weqd:at:", long_options, &optindex)) != -1) while ((c = getopt_long(argc, argv, "h:p:U:Weqd:at:", long_options, &optindex)) != -1)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * 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) ...@@ -51,13 +51,9 @@ get_user_name(const char *progname)
* Initialized NLS if enabled. * Initialized NLS if enabled.
*/ */
void void
init_nls(void) init_nls(const char *argv0)
{ {
#ifdef ENABLE_NLS set_pglocale(argv0, "pgscripts");
setlocale(LC_ALL, "");
bindtextdomain("pgscripts", LOCALEDIR);
textdomain("pgscripts");
#endif
} }
......
...@@ -11,7 +11,7 @@ int optreset; ...@@ -11,7 +11,7 @@ int optreset;
const char *get_user_name(const char *progname); const char *get_user_name(const char *progname);
#define _(x) gettext((x)) #define _(x) gettext((x))
void init_nls(void); void init_nls(const char *argv0);
typedef void (*help_handler) (const char *); typedef void (*help_handler) (const char *);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * 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[]) ...@@ -60,7 +60,7 @@ main(int argc, char *argv[])
PGresult *result; PGresult *result;
progname = get_progname(argv[0]); progname = get_progname(argv[0]);
init_nls(); init_nls(argv[0]);
handle_help_version_opts(argc, argv, "createdb", help); 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) while ((c = getopt_long(argc, argv, "h:p:U:WeqO:D:T:E:", long_options, &optindex)) != -1)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * 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[]) ...@@ -61,7 +61,7 @@ main(int argc, char *argv[])
PGresult *result; PGresult *result;
progname = get_progname(argv[0]); progname = get_progname(argv[0]);
init_nls(); init_nls(argv[0]);
handle_help_version_opts(argc, argv, "createlang", help); handle_help_version_opts(argc, argv, "createlang", help);
while ((c = getopt_long(argc, argv, "lh:p:U:Wd:L:e", long_options, &optindex)) != -1) while ((c = getopt_long(argc, argv, "lh:p:U:Wd:L:e", long_options, &optindex)) != -1)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * 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[]) ...@@ -63,7 +63,7 @@ main(int argc, char *argv[])
PGresult *result; PGresult *result;
progname = get_progname(argv[0]); progname = get_progname(argv[0]);
init_nls(); init_nls(argv[0]);
handle_help_version_opts(argc, argv, "createuser", help); handle_help_version_opts(argc, argv, "createuser", help);
while ((c = getopt_long(argc, argv, "h:p:U:WeqaAdDi:PEN", long_options, &optindex)) != -1) while ((c = getopt_long(argc, argv, "h:p:U:WeqaAdDi:PEN", long_options, &optindex)) != -1)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * 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[]) ...@@ -51,7 +51,7 @@ main(int argc, char *argv[])
PGresult *result; PGresult *result;
progname = get_progname(argv[0]); progname = get_progname(argv[0]);
init_nls(); init_nls(argv[0]);
handle_help_version_opts(argc, argv, "dropdb", help); handle_help_version_opts(argc, argv, "dropdb", help);
while ((c = getopt_long(argc, argv, "h:p:U:Weqi", long_options, &optindex)) != -1) while ((c = getopt_long(argc, argv, "h:p:U:Weqi", long_options, &optindex)) != -1)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * 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[]) ...@@ -61,7 +61,7 @@ main(int argc, char *argv[])
PGresult *result; PGresult *result;
progname = get_progname(argv[0]); progname = get_progname(argv[0]);
init_nls(); init_nls(argv[0]);
handle_help_version_opts(argc, argv, "droplang", help); handle_help_version_opts(argc, argv, "droplang", help);
while ((c = getopt_long(argc, argv, "lh:p:U:Wd:e", long_options, &optindex)) != -1) while ((c = getopt_long(argc, argv, "lh:p:U:Wd:e", long_options, &optindex)) != -1)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * 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[]) ...@@ -51,7 +51,7 @@ main(int argc, char *argv[])
PGresult *result; PGresult *result;
progname = get_progname(argv[0]); progname = get_progname(argv[0]);
init_nls(); init_nls(argv[0]);
handle_help_version_opts(argc, argv, "dropuser", help); handle_help_version_opts(argc, argv, "dropuser", help);
while ((c = getopt_long(argc, argv, "h:p:U:Weqi", long_options, &optindex)) != -1) while ((c = getopt_long(argc, argv, "h:p:U:Weqi", long_options, &optindex)) != -1)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * 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[]) ...@@ -66,7 +66,7 @@ main(int argc, char *argv[])
bool verbose = false; bool verbose = false;
progname = get_progname(argv[0]); progname = get_progname(argv[0]);
init_nls(); init_nls(argv[0]);
handle_help_version_opts(argc, argv, "vacuumdb", help); handle_help_version_opts(argc, argv, "vacuumdb", help);
while ((c = getopt_long(argc, argv, "h:p:U:Weqd:zat:fv", long_options, &optindex)) != -1) while ((c = getopt_long(argc, argv, "h:p:U:Weqd:zat:fv", long_options, &optindex)) != -1)
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * 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); ...@@ -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_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_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_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 * is_absolute_path
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * 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) ...@@ -1131,6 +1131,7 @@ libpq_gettext(const char *msgid)
if (!already_bound) if (!already_bound)
{ {
already_bound = 1; already_bound = 1;
/* No relocatable lookup here because the binary could be anywhere */
bindtextdomain("libpq", LOCALEDIR); bindtextdomain("libpq", LOCALEDIR);
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# with broken/missing library files. # with broken/missing library files.
# IDENTIFICATION # 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 ...@@ -37,6 +37,7 @@ pg_config_paths.h: $(top_builddir)/src/Makefile.global
echo "#define INCLUDEDIR \"$(includedir)\"" >>$@ echo "#define INCLUDEDIR \"$(includedir)\"" >>$@
echo "#define PKGINCLUDEDIR \"$(pkgincludedir)\"" >>$@ echo "#define PKGINCLUDEDIR \"$(pkgincludedir)\"" >>$@
echo "#define PKGLIBDIR \"$(pkglibdir)\"" >>$@ echo "#define PKGLIBDIR \"$(pkglibdir)\"" >>$@
echo "#define LOCALEDIR \"$(localedir)\"" >>$@
clean distclean maintainer-clean: clean distclean maintainer-clean:
rm -f libpgport.a $(LIBOBJS) pg_config_paths.h rm -f libpgport.a $(LIBOBJS) pg_config_paths.h
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -113,12 +113,14 @@ get_progname(const char *argv0)
void void
get_share_path(const char *my_exec_path, char *ret_path) get_share_path(const char *my_exec_path, char *ret_path)
{ {
char path[MAXPGPATH];
if (relative_path(PGBINDIR, PGSHAREDIR)) if (relative_path(PGBINDIR, PGSHAREDIR))
{ {
StrNCpy(ret_path, my_exec_path, MAXPGPATH); StrNCpy(path, my_exec_path, MAXPGPATH);
trim_directory(ret_path); /* trim off binary */ trim_directory(path); /* trim off binary */
trim_directory(ret_path); /* trim off /bin */ trim_directory(path); /* trim off /bin */
strcat(ret_path, "/share"); /* add /share */ snprintf(ret_path, MAXPGPATH, "%s/share", path);
} }
else else
StrNCpy(ret_path, PGSHAREDIR, MAXPGPATH); StrNCpy(ret_path, PGSHAREDIR, MAXPGPATH);
...@@ -132,12 +134,14 @@ get_share_path(const char *my_exec_path, char *ret_path) ...@@ -132,12 +134,14 @@ get_share_path(const char *my_exec_path, char *ret_path)
void void
get_etc_path(const char *my_exec_path, char *ret_path) get_etc_path(const char *my_exec_path, char *ret_path)
{ {
char path[MAXPGPATH];
if (relative_path(PGBINDIR, SYSCONFDIR)) if (relative_path(PGBINDIR, SYSCONFDIR))
{ {
StrNCpy(ret_path, my_exec_path, MAXPGPATH); StrNCpy(path, my_exec_path, MAXPGPATH);
trim_directory(ret_path); trim_directory(path);
trim_directory(ret_path); trim_directory(path);
strcat(ret_path, "/etc"); snprintf(ret_path, MAXPGPATH, "%s/etc", path);
} }
else else
StrNCpy(ret_path, SYSCONFDIR, MAXPGPATH); StrNCpy(ret_path, SYSCONFDIR, MAXPGPATH);
...@@ -151,12 +155,14 @@ get_etc_path(const char *my_exec_path, char *ret_path) ...@@ -151,12 +155,14 @@ get_etc_path(const char *my_exec_path, char *ret_path)
void void
get_include_path(const char *my_exec_path, char *ret_path) get_include_path(const char *my_exec_path, char *ret_path)
{ {
char path[MAXPGPATH];
if (relative_path(PGBINDIR, INCLUDEDIR)) if (relative_path(PGBINDIR, INCLUDEDIR))
{ {
StrNCpy(ret_path, my_exec_path, MAXPGPATH); StrNCpy(path, my_exec_path, MAXPGPATH);
trim_directory(ret_path); trim_directory(path);
trim_directory(ret_path); trim_directory(path);
strcat(ret_path, "/include"); snprintf(ret_path, MAXPGPATH, "%s/include", path);
} }
else else
StrNCpy(ret_path, INCLUDEDIR, MAXPGPATH); StrNCpy(ret_path, INCLUDEDIR, MAXPGPATH);
...@@ -170,12 +176,14 @@ get_include_path(const char *my_exec_path, char *ret_path) ...@@ -170,12 +176,14 @@ get_include_path(const char *my_exec_path, char *ret_path)
void void
get_pkginclude_path(const char *my_exec_path, char *ret_path) get_pkginclude_path(const char *my_exec_path, char *ret_path)
{ {
char path[MAXPGPATH];
if (relative_path(PGBINDIR, PKGINCLUDEDIR)) if (relative_path(PGBINDIR, PKGINCLUDEDIR))
{ {
StrNCpy(ret_path, my_exec_path, MAXPGPATH); StrNCpy(path, my_exec_path, MAXPGPATH);
trim_directory(ret_path); trim_directory(path);
trim_directory(ret_path); trim_directory(path);
strcat(ret_path, "/include"); snprintf(ret_path, MAXPGPATH, "%s/include", path);
} }
else else
StrNCpy(ret_path, PKGINCLUDEDIR, MAXPGPATH); StrNCpy(ret_path, PKGINCLUDEDIR, MAXPGPATH);
...@@ -191,12 +199,14 @@ get_pkginclude_path(const char *my_exec_path, char *ret_path) ...@@ -191,12 +199,14 @@ get_pkginclude_path(const char *my_exec_path, char *ret_path)
void void
get_pkglib_path(const char *my_exec_path, char *ret_path) get_pkglib_path(const char *my_exec_path, char *ret_path)
{ {
char path[MAXPGPATH];
if (relative_path(PGBINDIR, PKGLIBDIR)) if (relative_path(PGBINDIR, PKGLIBDIR))
{ {
StrNCpy(ret_path, my_exec_path, MAXPGPATH); StrNCpy(path, my_exec_path, MAXPGPATH);
trim_directory(ret_path); trim_directory(path);
trim_directory(ret_path); trim_directory(path);
strcat(ret_path, "/lib"); snprintf(ret_path, MAXPGPATH, "%s/lib", path);
} }
else else
StrNCpy(ret_path, PKGLIBDIR, MAXPGPATH); StrNCpy(ret_path, PKGLIBDIR, MAXPGPATH);
...@@ -204,6 +214,55 @@ get_pkglib_path(const char *my_exec_path, char *ret_path) ...@@ -204,6 +214,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 * relative_path
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment