Magnus found out that LOCALEDIR wasn't being handled in a relocatable
manner.

This patch fixes that.  It also adjusts the get_*_path functions to
limit values to MAXPGPATH.

I have two questions.  First, setlocale() seemed to be inconsistently
set inside and outside of ENABLE_NLS.  I assume the proper location is
inside.   Second, libpq has a locale setting for error messages, but a
libpq program could be in any directory, so I see no way to make that
relocatable.  Instead, I just use the hardcoded path.  I could make it
relocatable, but that seems to error-prone, plus I would have to look up
the exec path and stuff, and it seemed too complicated.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  [EMAIL PROTECTED]               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/backend/main/main.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/main/main.c,v
retrieving revision 1.81
diff -c -c -r1.81 main.c
*** src/backend/main/main.c     24 May 2004 02:47:44 -0000      1.81
--- src/backend/main/main.c     25 May 2004 00:54:53 -0000
***************
*** 150,155 ****
--- 150,157 ----
         * startup error messages to be localized.
         */
  
+       set_pglocale(argv[0], "postgres");
+ 
  #ifdef WIN32
        /* 
         * Windows uses codepages rather than the environment, so we work around
***************
*** 184,194 ****
        setlocale(LC_MONETARY, "C");
        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
--- 186,191 ----
Index: src/bin/initdb/initdb.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/initdb/initdb.c,v
retrieving revision 1.32
diff -c -c -r1.32 initdb.c
*** src/bin/initdb/initdb.c     18 May 2004 03:36:36 -0000      1.32
--- src/bin/initdb/initdb.c     25 May 2004 00:54:56 -0000
***************
*** 167,173 ****
  static bool chklocale(const char *locale);
  static void setlocales(void);
  static void usage(const char *progname);
! static void init_nls(void);
  
  
  /*
--- 167,173 ----
  static bool chklocale(const char *locale);
  static void setlocales(void);
  static void usage(const char *progname);
! static void init_nls(const char *argv0);
  
  
  /*
***************
*** 1754,1766 ****
   * Initialized NLS if enabled.
   */
  static void
! init_nls(void)
  {
! #ifdef ENABLE_NLS
!         setlocale(LC_ALL, "");
!         bindtextdomain("initdb", LOCALEDIR);
!         textdomain("initdb");
! #endif
  }
  
  
--- 1754,1762 ----
   * Initialized NLS if enabled.
   */
  static void
! init_nls(const char *argv0)
  {
!       set_pglocale(argv0, "initdb");
  }
  
  
***************
*** 1801,1807 ****
                                                                 * environment */
        char       *subdirs[] =
        {"global", "pg_xlog", "pg_clog", "base", "base/1"};
!       init_nls();
  
        progname = get_progname(argv[0]);
  
--- 1797,1803 ----
                                                                 * environment */
        char       *subdirs[] =
        {"global", "pg_xlog", "pg_clog", "base", "base/1"};
!       init_nls(argv[0]);
  
        progname = get_progname(argv[0]);
  
Index: src/bin/pg_controldata/Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_controldata/Makefile,v
retrieving revision 1.7
diff -c -c -r1.7 Makefile
*** src/bin/pg_controldata/Makefile     30 Apr 2004 20:01:39 -0000      1.7
--- src/bin/pg_controldata/Makefile     25 May 2004 00:54:56 -0000
***************
*** 14,20 ****
  
  override CPPFLAGS += -DFRONTEND
  
! OBJS= pg_controldata.o pg_crc.o
  
  all: submake-libpgport pg_controldata
  
--- 14,20 ----
  
  override CPPFLAGS += -DFRONTEND
  
! OBJS= pg_controldata.o pg_crc.o exec.o
  
  all: submake-libpgport pg_controldata
  
***************
*** 24,29 ****
--- 24,32 ----
  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,37 ****
        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
--- 37,40 ----
        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 exec.c
Index: src/bin/pg_controldata/pg_controldata.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_controldata/pg_controldata.c,v
retrieving revision 1.15
diff -c -c -r1.15 pg_controldata.c
*** src/bin/pg_controldata/pg_controldata.c     12 May 2004 13:38:43 -0000      1.15
--- src/bin/pg_controldata/pg_controldata.c     25 May 2004 00:54:57 -0000
***************
*** 77,87 ****
        char       *strftime_fmt = "%c";
        const char *progname;
  
!       setlocale(LC_ALL, "");
! #ifdef ENABLE_NLS
!       bindtextdomain("pg_controldata", LOCALEDIR);
!       textdomain("pg_controldata");
! #endif
  
        progname = get_progname(argv[0]);
  
--- 77,83 ----
        char       *strftime_fmt = "%c";
        const char *progname;
  
!       set_pglocale(argv[0], "pg_controldata");
  
        progname = get_progname(argv[0]);
  
Index: src/bin/pg_dump/Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_dump/Makefile,v
retrieving revision 1.51
diff -c -c -r1.51 Makefile
*** src/bin/pg_dump/Makefile    24 May 2004 01:01:37 -0000      1.51
--- src/bin/pg_dump/Makefile    25 May 2004 00:54:57 -0000
***************
*** 17,24 ****
  
  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
  
  EXTRA_OBJS = $(top_builddir)/src/backend/parser/keywords.o
  
--- 17,23 ----
  
  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 exec.o
  
  EXTRA_OBJS = $(top_builddir)/src/backend/parser/keywords.o
  
***************
*** 31,38 ****
  pg_restore: pg_restore.o $(OBJS) $(libpq_builddir)/libpq.a
        $(CC) $(CFLAGS) pg_restore.o $(OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) 
-o [EMAIL PROTECTED](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 [EMAIL PROTECTED](X)
  
  # We need our own build of exec.c so it gets made with -DFRONTEND
  exec.c: % : $(top_srcdir)/src/port/%
--- 30,37 ----
  pg_restore: pg_restore.o $(OBJS) $(libpq_builddir)/libpq.a
        $(CC) $(CFLAGS) pg_restore.o $(OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) 
-o [EMAIL PROTECTED](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 [EMAIL PROTECTED](X)
  
  # We need our own build of exec.c so it gets made with -DFRONTEND
  exec.c: % : $(top_srcdir)/src/port/%
***************
*** 55,58 ****
        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
--- 54,57 ----
        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_dump.o common.o 
pg_dump_sort.o pg_restore.o pg_dumpall.o exec.c
Index: src/bin/pg_dump/pg_dump.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_dump/pg_dump.c,v
retrieving revision 1.370
diff -c -c -r1.370 pg_dump.c
*** src/bin/pg_dump/pg_dump.c   24 Mar 2004 03:06:08 -0000      1.370
--- src/bin/pg_dump/pg_dump.c   25 May 2004 00:55:02 -0000
***************
*** 242,252 ****
        };
        int                     optindex;
  
! #ifdef ENABLE_NLS
!       setlocale(LC_ALL, "");
!       bindtextdomain("pg_dump", LOCALEDIR);
!       textdomain("pg_dump");
! #endif
  
        g_verbose = false;
  
--- 242,248 ----
        };
        int                     optindex;
  
!       set_pglocale(argv[0], "pg_dump");
  
        g_verbose = false;
  
Index: src/bin/pg_dump/pg_dumpall.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_dump/pg_dumpall.c,v
retrieving revision 1.34
diff -c -c -r1.34 pg_dumpall.c
*** src/bin/pg_dump/pg_dumpall.c        19 May 2004 21:21:26 -0000      1.34
--- src/bin/pg_dump/pg_dumpall.c        25 May 2004 00:55:03 -0000
***************
*** 101,111 ****
  
        int                     optindex;
  
! #ifdef ENABLE_NLS
!       setlocale(LC_ALL, "");
!       bindtextdomain("pg_dump", LOCALEDIR);
!       textdomain("pg_dump");
! #endif
  
        progname = get_progname(argv[0]);
  
--- 101,107 ----
  
        int                     optindex;
  
!       set_pglocale(argv[0], "pg_dump");
  
        progname = get_progname(argv[0]);
  
Index: src/bin/pg_dump/pg_restore.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_dump/pg_restore.c,v
retrieving revision 1.56
diff -c -c -r1.56 pg_restore.c
*** src/bin/pg_dump/pg_restore.c        22 Apr 2004 02:39:10 -0000      1.56
--- src/bin/pg_dump/pg_restore.c        25 May 2004 00:55:03 -0000
***************
*** 121,131 ****
                {NULL, 0, NULL, 0}
        };
  
! #ifdef ENABLE_NLS
!       setlocale(LC_ALL, "");
!       bindtextdomain("pg_dump", LOCALEDIR);
!       textdomain("pg_dump");
! #endif
  
        opts = NewRestoreOptions();
  
--- 121,127 ----
                {NULL, 0, NULL, 0}
        };
  
!       set_pglocale(argv[0], "pg_dump");
  
        opts = NewRestoreOptions();
  
Index: src/bin/pg_resetxlog/Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_resetxlog/Makefile,v
retrieving revision 1.9
diff -c -c -r1.9 Makefile
*** src/bin/pg_resetxlog/Makefile       24 May 2004 01:01:37 -0000      1.9
--- src/bin/pg_resetxlog/Makefile       25 May 2004 00:55:03 -0000
***************
*** 14,20 ****
  
  override CPPFLAGS += -DFRONTEND
  
! OBJS= pg_resetxlog.o pg_crc.o dirmod.o
  
  all: submake-libpgport pg_resetxlog
  
--- 14,20 ----
  
  override CPPFLAGS += -DFRONTEND
  
! OBJS= pg_resetxlog.o pg_crc.o dirmod.o exec.o
  
  all: submake-libpgport pg_resetxlog
  
***************
*** 27,32 ****
--- 27,35 ----
  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,40 ****
        rm -f $(DESTDIR)$(bindir)/pg_resetxlog$(X)
  
  clean distclean maintainer-clean:
!       rm -f pg_resetxlog$(X) pg_crc.c dirmod.c $(OBJS)
--- 40,43 ----
        rm -f $(DESTDIR)$(bindir)/pg_resetxlog$(X)
  
  clean distclean maintainer-clean:
!       rm -f pg_resetxlog$(X) pg_crc.c dirmod.c exec.c $(OBJS)
Index: src/bin/pg_resetxlog/pg_resetxlog.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_resetxlog/pg_resetxlog.c,v
retrieving revision 1.18
diff -c -c -r1.18 pg_resetxlog.c
*** src/bin/pg_resetxlog/pg_resetxlog.c 12 May 2004 13:38:44 -0000      1.18
--- src/bin/pg_resetxlog/pg_resetxlog.c 25 May 2004 00:55:03 -0000
***************
*** 102,112 ****
        int                     fd;
        char            path[MAXPGPATH];
  
!       setlocale(LC_ALL, "");
! #ifdef ENABLE_NLS
!       bindtextdomain("pg_resetxlog", LOCALEDIR);
!       textdomain("pg_resetxlog");
! #endif
  
        progname = get_progname(argv[0]);
  
--- 102,108 ----
        int                     fd;
        char            path[MAXPGPATH];
  
!       set_pglocale(argv[0], "pg_resetxlog");
  
        progname = get_progname(argv[0]);
  
Index: src/bin/psql/startup.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/psql/startup.c,v
retrieving revision 1.93
diff -c -c -r1.93 startup.c
*** src/bin/psql/startup.c      17 May 2004 14:35:33 -0000      1.93
--- src/bin/psql/startup.c      25 May 2004 00:55:04 -0000
***************
*** 102,112 ****
        char       *password = NULL;
        bool            need_pass;
  
!       setlocale(LC_ALL, "");
! #ifdef ENABLE_NLS
!       bindtextdomain("psql", LOCALEDIR);
!       textdomain("psql");
! #endif
  
        pset.progname = get_progname(argv[0]);
  
--- 102,108 ----
        char       *password = NULL;
        bool            need_pass;
  
!       set_pglocale(argv[0], "psql");
  
        pset.progname = get_progname(argv[0]);
  
Index: src/bin/scripts/Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/scripts/Makefile,v
retrieving revision 1.26
diff -c -c -r1.26 Makefile
*** src/bin/scripts/Makefile    26 Apr 2004 17:40:48 -0000      1.26
--- src/bin/scripts/Makefile    25 May 2004 00:55:04 -0000
***************
*** 15,35 ****
  
  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)
  
  all: submake-libpq submake-backend $(PROGRAMS)
  
  %: %.o
        $(CC) $(CFLAGS) $^ $(libpq) $(LDFLAGS) $(LIBS) -o [EMAIL PROTECTED](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
  
  dumputils.c: % : $(top_srcdir)/src/bin/pg_dump/%
        rm -f $@ && $(LN_S) $< .
--- 15,38 ----
  
  PROGRAMS = createdb createlang createuser dropdb droplang dropuser clusterdb vacuumdb
  
! 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 [EMAIL PROTECTED](X)
  
! 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,63 ****
  
  
  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
--- 63,66 ----
  
  
  clean distclean maintainer-clean:
!       rm -f $(addsuffix $(X), $(PROGRAMS)) $(addsuffix .o, $(PROGRAMS)) common.o 
dumputils.o print.o mbprint.o dumputils.c exec.c print.c mbprint.c
Index: src/bin/scripts/clusterdb.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/scripts/clusterdb.c,v
retrieving revision 1.6
diff -c -c -r1.6 clusterdb.c
*** src/bin/scripts/clusterdb.c 12 May 2004 13:38:46 -0000      1.6
--- src/bin/scripts/clusterdb.c 25 May 2004 00:55:04 -0000
***************
*** 58,64 ****
        char       *table = NULL;
  
        progname = get_progname(argv[0]);
!       init_nls();
        handle_help_version_opts(argc, argv, "clusterdb", help);
  
        while ((c = getopt_long(argc, argv, "h:p:U:Weqd:at:", long_options, 
&optindex)) != -1)
--- 58,64 ----
        char       *table = NULL;
  
        progname = get_progname(argv[0]);
!       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)
Index: src/bin/scripts/common.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/scripts/common.c,v
retrieving revision 1.7
diff -c -c -r1.7 common.c
*** src/bin/scripts/common.c    19 Apr 2004 17:42:59 -0000      1.7
--- src/bin/scripts/common.c    25 May 2004 00:55:04 -0000
***************
*** 51,63 ****
   * Initialized NLS if enabled.
   */
  void
! init_nls(void)
  {
! #ifdef ENABLE_NLS
!       setlocale(LC_ALL, "");
!       bindtextdomain("pgscripts", LOCALEDIR);
!       textdomain("pgscripts");
! #endif
  }
  
  
--- 51,59 ----
   * Initialized NLS if enabled.
   */
  void
! init_nls(const char *argv0)
  {
!       set_pglocale(argv0, "pgscripts");
  }
  
  
Index: src/bin/scripts/common.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/scripts/common.h,v
retrieving revision 1.6
diff -c -c -r1.6 common.h
*** src/bin/scripts/common.h    8 Aug 2003 04:52:21 -0000       1.6
--- src/bin/scripts/common.h    25 May 2004 00:55:04 -0000
***************
*** 11,17 ****
  const char *get_user_name(const char *progname);
  
  #define _(x) gettext((x))
! void          init_nls(void);
  
  typedef void (*help_handler) (const char *);
  
--- 11,17 ----
  const char *get_user_name(const char *progname);
  
  #define _(x) gettext((x))
! void          init_nls(const char *argv0);
  
  typedef void (*help_handler) (const char *);
  
Index: src/bin/scripts/createdb.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/scripts/createdb.c,v
retrieving revision 1.8
diff -c -c -r1.8 createdb.c
*** src/bin/scripts/createdb.c  12 May 2004 13:38:47 -0000      1.8
--- src/bin/scripts/createdb.c  25 May 2004 00:55:04 -0000
***************
*** 60,66 ****
        PGresult   *result;
  
        progname = get_progname(argv[0]);
!       init_nls();
        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)
--- 60,66 ----
        PGresult   *result;
  
        progname = get_progname(argv[0]);
!       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)
Index: src/bin/scripts/createlang.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/scripts/createlang.c,v
retrieving revision 1.9
diff -c -c -r1.9 createlang.c
*** src/bin/scripts/createlang.c        12 May 2004 13:38:47 -0000      1.9
--- src/bin/scripts/createlang.c        25 May 2004 00:55:04 -0000
***************
*** 61,67 ****
        PGresult   *result;
  
        progname = get_progname(argv[0]);
!       init_nls();
        handle_help_version_opts(argc, argv, "createlang", help);
  
        while ((c = getopt_long(argc, argv, "lh:p:U:Wd:L:e", long_options, &optindex)) 
!= -1)
--- 61,67 ----
        PGresult   *result;
  
        progname = get_progname(argv[0]);
!       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)
Index: src/bin/scripts/createuser.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/scripts/createuser.c,v
retrieving revision 1.10
diff -c -c -r1.10 createuser.c
*** src/bin/scripts/createuser.c        12 May 2004 13:38:48 -0000      1.10
--- src/bin/scripts/createuser.c        25 May 2004 00:55:04 -0000
***************
*** 63,69 ****
        PGresult   *result;
  
        progname = get_progname(argv[0]);
!       init_nls();
        handle_help_version_opts(argc, argv, "createuser", help);
  
        while ((c = getopt_long(argc, argv, "h:p:U:WeqaAdDi:PEN", long_options, 
&optindex)) != -1)
--- 63,69 ----
        PGresult   *result;
  
        progname = get_progname(argv[0]);
!       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)
Index: src/bin/scripts/dropdb.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/scripts/dropdb.c,v
retrieving revision 1.9
diff -c -c -r1.9 dropdb.c
*** src/bin/scripts/dropdb.c    12 May 2004 13:38:48 -0000      1.9
--- src/bin/scripts/dropdb.c    25 May 2004 00:55:04 -0000
***************
*** 51,57 ****
        PGresult   *result;
  
        progname = get_progname(argv[0]);
!       init_nls();
        handle_help_version_opts(argc, argv, "dropdb", help);
  
        while ((c = getopt_long(argc, argv, "h:p:U:Weqi", long_options, &optindex)) != 
-1)
--- 51,57 ----
        PGresult   *result;
  
        progname = get_progname(argv[0]);
!       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)
Index: src/bin/scripts/droplang.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/scripts/droplang.c,v
retrieving revision 1.8
diff -c -c -r1.8 droplang.c
*** src/bin/scripts/droplang.c  12 May 2004 13:38:48 -0000      1.8
--- src/bin/scripts/droplang.c  25 May 2004 00:55:04 -0000
***************
*** 61,67 ****
        PGresult   *result;
  
        progname = get_progname(argv[0]);
!       init_nls();
        handle_help_version_opts(argc, argv, "droplang", help);
  
        while ((c = getopt_long(argc, argv, "lh:p:U:Wd:e", long_options, &optindex)) 
!= -1)
--- 61,67 ----
        PGresult   *result;
  
        progname = get_progname(argv[0]);
!       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)
Index: src/bin/scripts/dropuser.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/scripts/dropuser.c,v
retrieving revision 1.8
diff -c -c -r1.8 dropuser.c
*** src/bin/scripts/dropuser.c  12 May 2004 13:38:48 -0000      1.8
--- src/bin/scripts/dropuser.c  25 May 2004 00:55:04 -0000
***************
*** 51,57 ****
        PGresult   *result;
  
        progname = get_progname(argv[0]);
!       init_nls();
        handle_help_version_opts(argc, argv, "dropuser", help);
  
        while ((c = getopt_long(argc, argv, "h:p:U:Weqi", long_options, &optindex)) != 
-1)
--- 51,57 ----
        PGresult   *result;
  
        progname = get_progname(argv[0]);
!       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)
Index: src/bin/scripts/vacuumdb.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/scripts/vacuumdb.c,v
retrieving revision 1.6
diff -c -c -r1.6 vacuumdb.c
*** src/bin/scripts/vacuumdb.c  12 May 2004 13:38:48 -0000      1.6
--- src/bin/scripts/vacuumdb.c  25 May 2004 00:55:05 -0000
***************
*** 66,72 ****
        bool            verbose = false;
  
        progname = get_progname(argv[0]);
!       init_nls();
        handle_help_version_opts(argc, argv, "vacuumdb", help);
  
        while ((c = getopt_long(argc, argv, "h:p:U:Weqd:zat:fv", long_options, 
&optindex)) != -1)
--- 66,72 ----
        bool            verbose = false;
  
        progname = get_progname(argv[0]);
!       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)
Index: src/include/port.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port.h,v
retrieving revision 1.37
diff -c -c -r1.37 port.h
*** src/include/port.h  21 May 2004 16:06:22 -0000      1.37
--- src/include/port.h  25 May 2004 00:55:05 -0000
***************
*** 31,36 ****
--- 31,38 ----
  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
Index: src/interfaces/libpq/fe-misc.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/libpq/fe-misc.c,v
retrieving revision 1.105
diff -c -c -r1.105 fe-misc.c
*** src/interfaces/libpq/fe-misc.c      15 Mar 2004 10:41:26 -0000      1.105
--- src/interfaces/libpq/fe-misc.c      25 May 2004 00:55:06 -0000
***************
*** 1131,1136 ****
--- 1131,1137 ----
        if (!already_bound)
        {
                already_bound = 1;
+               /* No relocatable lookup here because the binary could be anywhere */
                bindtextdomain("libpq", LOCALEDIR);
        }
  
Index: src/port/Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/port/Makefile,v
retrieving revision 1.13
diff -c -c -r1.13 Makefile
*** src/port/Makefile   22 May 2004 02:15:08 -0000      1.13
--- src/port/Makefile   25 May 2004 00:55:06 -0000
***************
*** 37,42 ****
--- 37,43 ----
        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
Index: src/port/path.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/port/path.c,v
retrieving revision 1.11
diff -c -c -r1.11 path.c
*** src/port/path.c     21 May 2004 20:56:50 -0000      1.11
--- src/port/path.c     25 May 2004 00:55:06 -0000
***************
*** 113,124 ****
  void
  get_share_path(const char *my_exec_path, char *ret_path)
  {
        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 */
        }
        else
                StrNCpy(ret_path, PGSHAREDIR, MAXPGPATH);
--- 113,126 ----
  void
  get_share_path(const char *my_exec_path, char *ret_path)
  {
+       char path[MAXPGPATH];
+       
        if (relative_path(PGBINDIR, PGSHAREDIR))
        {
!               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,143 ****
  void
  get_etc_path(const char *my_exec_path, char *ret_path)
  {
        if (relative_path(PGBINDIR, SYSCONFDIR))
        {
!               StrNCpy(ret_path, my_exec_path, MAXPGPATH);
!               trim_directory(ret_path);
!               trim_directory(ret_path);
!               strcat(ret_path, "/etc");
        }
        else
                StrNCpy(ret_path, SYSCONFDIR, MAXPGPATH);
--- 134,147 ----
  void
  get_etc_path(const char *my_exec_path, char *ret_path)
  {
+       char path[MAXPGPATH];
+       
        if (relative_path(PGBINDIR, SYSCONFDIR))
        {
!               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,162 ****
  void
  get_include_path(const char *my_exec_path, char *ret_path)
  {
        if (relative_path(PGBINDIR, INCLUDEDIR))
        {
!               StrNCpy(ret_path, my_exec_path, MAXPGPATH);
!               trim_directory(ret_path);
!               trim_directory(ret_path);
!               strcat(ret_path, "/include");
        }
        else
                StrNCpy(ret_path, INCLUDEDIR, MAXPGPATH);
--- 155,168 ----
  void
  get_include_path(const char *my_exec_path, char *ret_path)
  {
+       char path[MAXPGPATH];
+       
        if (relative_path(PGBINDIR, INCLUDEDIR))
        {
!               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,181 ****
  void
  get_pkginclude_path(const char *my_exec_path, char *ret_path)
  {
        if (relative_path(PGBINDIR, PKGINCLUDEDIR))
        {
!               StrNCpy(ret_path, my_exec_path, MAXPGPATH);
!               trim_directory(ret_path);
!               trim_directory(ret_path);
!               strcat(ret_path, "/include");
        }
        else
                StrNCpy(ret_path, PKGINCLUDEDIR, MAXPGPATH);
--- 176,189 ----
  void
  get_pkginclude_path(const char *my_exec_path, char *ret_path)
  {
+       char path[MAXPGPATH];
+       
        if (relative_path(PGBINDIR, PKGINCLUDEDIR))
        {
!               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,205 ****
  void
  get_pkglib_path(const char *my_exec_path, char *ret_path)
  {
        if (relative_path(PGBINDIR, PKGLIBDIR))
        {
!               StrNCpy(ret_path, my_exec_path, MAXPGPATH);
!               trim_directory(ret_path);
!               trim_directory(ret_path);
!               strcat(ret_path, "/lib");
        }
        else
                StrNCpy(ret_path, PKGLIBDIR, MAXPGPATH);
  }
  
  
--- 199,264 ----
  void
  get_pkglib_path(const char *my_exec_path, char *ret_path)
  {
+       char path[MAXPGPATH];
+       
        if (relative_path(PGBINDIR, PKGLIBDIR))
        {
!               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);
+ }
+ 
+ 
+ 
+ /*
+  *    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
  }
  
  
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

Reply via email to