Move set_pglocale_pgservice() from path.c to exec.c, so that pulling in

path.c does not in itself force linking of both exec.c and libintl.
Should fix current ecpglib build failure on pickier platforms.
REL8_2_STABLE
Tom Lane 20 years ago
parent 7ce2ff2d22
commit 568b80168f
  1. 17
      src/include/port.h
  2. 8
      src/interfaces/ecpg/ecpglib/Makefile
  3. 54
      src/port/exec.c
  4. 50
      src/port/path.c

@ -6,21 +6,20 @@
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/port.h,v 1.97 2006/08/30 18:06:27 tgl Exp $
* $PostgreSQL: pgsql/src/include/port.h,v 1.98 2006/09/11 20:10:30 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include <pwd.h>
#include <netdb.h>
#include <ctype.h>
#include <netdb.h>
#include <pwd.h>
/* non-blocking */
extern bool pg_set_noblock(int sock);
extern bool pg_set_block(int sock);
/* Portable path handling for Unix/Win32 */
/* Portable path handling for Unix/Win32 (in path.c) */
extern char *first_dir_separator(const char *filename);
extern char *last_dir_separator(const char *filename);
@ -42,15 +41,13 @@ 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 get_doc_path(const char *my_exec_path, char *ret_path);
extern void get_man_path(const char *my_exec_path, char *ret_path);
extern void set_pglocale_pgservice(const char *argv0, const char *app);
extern bool get_home_path(char *ret_path);
extern void get_parent_directory(char *path);
/*
* is_absolute_path
*
* By making this a macro we prevent the need for libpq to include
* path.c which uses exec.c.
* By making this a macro we avoid needing to include path.c in libpq.
*/
#ifndef WIN32
#define is_absolute_path(filename) \
@ -67,8 +64,10 @@ extern void get_parent_directory(char *path);
)
#endif
/* Portable locale initialization (in exec.c) */
extern void set_pglocale_pgservice(const char *argv0, const char *app);
/* Portable way to find binaries */
/* Portable way to find binaries (in exec.c) */
extern int find_my_exec(const char *argv0, char *retpath);
extern int find_other_exec(const char *argv0, const char *target,
const char *versionstr, char *retpath);

@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.42 2006/09/10 22:07:02 tgl Exp $
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.43 2006/09/11 20:10:30 tgl Exp $
#
#-------------------------------------------------------------------------
@ -26,7 +26,7 @@ override CFLAGS += $(PTHREAD_CFLAGS)
LIBS := $(filter-out -lpgport, $(LIBS))
OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
connect.o misc.o path.o exec.o \
connect.o misc.o path.o \
$(filter snprintf.o, $(LIBOBJS))
# thread.c is needed only for non-WIN32 implementation of path.c
@ -51,7 +51,7 @@ include $(top_srcdir)/src/Makefile.shlib
# necessarily use the same object files as the backend uses. Instead,
# symlink the source files in here and build our own object file.
path.c exec.c snprintf.c thread.c: % : $(top_srcdir)/src/port/%
path.c snprintf.c thread.c: % : $(top_srcdir)/src/port/%
rm -f $@ && $(LN_S) $< .
path.o: path.c $(top_builddir)/src/port/pg_config_paths.h
@ -67,7 +67,7 @@ installdirs:
uninstall: uninstall-lib
clean distclean maintainer-clean: clean-lib
rm -f $(OBJS) path.c exec.c snprintf.c thread.c
rm -f $(OBJS) path.c snprintf.c thread.c
depend dep:
$(CC) -MM $(CFLAGS) *.c >depend

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/port/exec.c,v 1.42 2006/06/07 22:24:46 momjian Exp $
* $PostgreSQL: pgsql/src/port/exec.c,v 1.43 2006/09/11 20:10:30 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -590,3 +590,55 @@ pclose_check(FILE *stream)
return -1;
}
/*
* set_pglocale_pgservice
*
* Set application-specific locale and service directory
*
* This function takes the value of argv[0] rather than a full path.
*
* (You may be wondering why this is in exec.c. It requires this module's
* services and doesn't introduce any new dependencies, so this seems as
* good as anyplace.)
*/
void
set_pglocale_pgservice(const char *argv0, const char *app)
{
char path[MAXPGPATH];
char my_exec_path[MAXPGPATH];
char env_path[MAXPGPATH + sizeof("PGSYSCONFDIR=")]; /* longer than
* PGLOCALEDIR */
/* don't set LC_ALL in the backend */
if (strcmp(app, "postgres") != 0)
setlocale(LC_ALL, "");
if (find_my_exec(argv0, my_exec_path) < 0)
return;
#ifdef ENABLE_NLS
get_locale_path(my_exec_path, path);
bindtextdomain(app, path);
textdomain(app);
if (getenv("PGLOCALEDIR") == NULL)
{
/* set for libpq to use */
snprintf(env_path, sizeof(env_path), "PGLOCALEDIR=%s", path);
canonicalize_path(env_path + 12);
putenv(strdup(env_path));
}
#endif
if (getenv("PGSYSCONFDIR") == NULL)
{
get_etc_path(my_exec_path, path);
/* set for libpq to use */
snprintf(env_path, sizeof(env_path), "PGSYSCONFDIR=%s", path);
canonicalize_path(env_path + 13);
putenv(strdup(env_path));
}
}

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/port/path.c,v 1.66 2006/03/05 15:59:10 momjian Exp $
* $PostgreSQL: pgsql/src/port/path.c,v 1.67 2006/09/11 20:10:30 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -652,54 +652,6 @@ get_parent_directory(char *path)
}
/*
* set_pglocale_pgservice
*
* Set application-specific locale and service directory
*
* This function takes an argv[0] rather than a full path.
*/
void
set_pglocale_pgservice(const char *argv0, const char *app)
{
char path[MAXPGPATH];
char my_exec_path[MAXPGPATH];
char env_path[MAXPGPATH + sizeof("PGSYSCONFDIR=")]; /* longer than
* PGLOCALEDIR */
/* don't set LC_ALL in the backend */
if (strcmp(app, "postgres") != 0)
setlocale(LC_ALL, "");
if (find_my_exec(argv0, my_exec_path) < 0)
return;
#ifdef ENABLE_NLS
get_locale_path(my_exec_path, path);
bindtextdomain(app, path);
textdomain(app);
if (getenv("PGLOCALEDIR") == NULL)
{
/* set for libpq to use */
snprintf(env_path, sizeof(env_path), "PGLOCALEDIR=%s", path);
canonicalize_path(env_path + 12);
putenv(strdup(env_path));
}
#endif
if (getenv("PGSYSCONFDIR") == NULL)
{
get_etc_path(my_exec_path, path);
/* set for libpq to use */
snprintf(env_path, sizeof(env_path), "PGSYSCONFDIR=%s", path);
canonicalize_path(env_path + 13);
putenv(strdup(env_path));
}
}
/*
* trim_directory
*

Loading…
Cancel
Save