Skip to content

Commit 568b801

Browse files
committed
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.
1 parent 7ce2ff2 commit 568b801

File tree

4 files changed

+66
-63
lines changed

4 files changed

+66
-63
lines changed

src/include/port.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@
66
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/port.h,v 1.97 2006/08/30 18:06:27 tgl Exp $
9+
* $PostgreSQL: pgsql/src/include/port.h,v 1.98 2006/09/11 20:10:30 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
1313

14-
#include <pwd.h>
15-
#include <netdb.h>
16-
1714
#include <ctype.h>
15+
#include <netdb.h>
16+
#include <pwd.h>
1817

1918
/* non-blocking */
2019
extern bool pg_set_noblock(int sock);
2120
extern bool pg_set_block(int sock);
2221

23-
/* Portable path handling for Unix/Win32 */
22+
/* Portable path handling for Unix/Win32 (in path.c) */
2423

2524
extern char *first_dir_separator(const char *filename);
2625
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);
4241
extern void get_locale_path(const char *my_exec_path, char *ret_path);
4342
extern void get_doc_path(const char *my_exec_path, char *ret_path);
4443
extern void get_man_path(const char *my_exec_path, char *ret_path);
45-
extern void set_pglocale_pgservice(const char *argv0, const char *app);
4644
extern bool get_home_path(char *ret_path);
4745
extern void get_parent_directory(char *path);
4846

4947
/*
5048
* is_absolute_path
5149
*
52-
* By making this a macro we prevent the need for libpq to include
53-
* path.c which uses exec.c.
50+
* By making this a macro we avoid needing to include path.c in libpq.
5451
*/
5552
#ifndef WIN32
5653
#define is_absolute_path(filename) \
@@ -67,8 +64,10 @@ extern void get_parent_directory(char *path);
6764
)
6865
#endif
6966

67+
/* Portable locale initialization (in exec.c) */
68+
extern void set_pglocale_pgservice(const char *argv0, const char *app);
7069

71-
/* Portable way to find binaries */
70+
/* Portable way to find binaries (in exec.c) */
7271
extern int find_my_exec(const char *argv0, char *retpath);
7372
extern int find_other_exec(const char *argv0, const char *target,
7473
const char *versionstr, char *retpath);

src/interfaces/ecpg/ecpglib/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.42 2006/09/10 22:07:02 tgl Exp $
7+
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.43 2006/09/11 20:10:30 tgl Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -26,7 +26,7 @@ override CFLAGS += $(PTHREAD_CFLAGS)
2626
LIBS := $(filter-out -lpgport, $(LIBS))
2727

2828
OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
29-
connect.o misc.o path.o exec.o \
29+
connect.o misc.o path.o \
3030
$(filter snprintf.o, $(LIBOBJS))
3131

3232
# thread.c is needed only for non-WIN32 implementation of path.c
@@ -51,7 +51,7 @@ include $(top_srcdir)/src/Makefile.shlib
5151
# necessarily use the same object files as the backend uses. Instead,
5252
# symlink the source files in here and build our own object file.
5353

54-
path.c exec.c snprintf.c thread.c: % : $(top_srcdir)/src/port/%
54+
path.c snprintf.c thread.c: % : $(top_srcdir)/src/port/%
5555
rm -f $@ && $(LN_S) $< .
5656

5757
path.o: path.c $(top_builddir)/src/port/pg_config_paths.h
@@ -67,7 +67,7 @@ installdirs:
6767
uninstall: uninstall-lib
6868

6969
clean distclean maintainer-clean: clean-lib
70-
rm -f $(OBJS) path.c exec.c snprintf.c thread.c
70+
rm -f $(OBJS) path.c snprintf.c thread.c
7171

7272
depend dep:
7373
$(CC) -MM $(CFLAGS) *.c >depend

src/port/exec.c

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/port/exec.c,v 1.42 2006/06/07 22:24:46 momjian Exp $
12+
* $PostgreSQL: pgsql/src/port/exec.c,v 1.43 2006/09/11 20:10:30 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -590,3 +590,55 @@ pclose_check(FILE *stream)
590590

591591
return -1;
592592
}
593+
594+
595+
/*
596+
* set_pglocale_pgservice
597+
*
598+
* Set application-specific locale and service directory
599+
*
600+
* This function takes the value of argv[0] rather than a full path.
601+
*
602+
* (You may be wondering why this is in exec.c. It requires this module's
603+
* services and doesn't introduce any new dependencies, so this seems as
604+
* good as anyplace.)
605+
*/
606+
void
607+
set_pglocale_pgservice(const char *argv0, const char *app)
608+
{
609+
char path[MAXPGPATH];
610+
char my_exec_path[MAXPGPATH];
611+
char env_path[MAXPGPATH + sizeof("PGSYSCONFDIR=")]; /* longer than
612+
* PGLOCALEDIR */
613+
614+
/* don't set LC_ALL in the backend */
615+
if (strcmp(app, "postgres") != 0)
616+
setlocale(LC_ALL, "");
617+
618+
if (find_my_exec(argv0, my_exec_path) < 0)
619+
return;
620+
621+
#ifdef ENABLE_NLS
622+
get_locale_path(my_exec_path, path);
623+
bindtextdomain(app, path);
624+
textdomain(app);
625+
626+
if (getenv("PGLOCALEDIR") == NULL)
627+
{
628+
/* set for libpq to use */
629+
snprintf(env_path, sizeof(env_path), "PGLOCALEDIR=%s", path);
630+
canonicalize_path(env_path + 12);
631+
putenv(strdup(env_path));
632+
}
633+
#endif
634+
635+
if (getenv("PGSYSCONFDIR") == NULL)
636+
{
637+
get_etc_path(my_exec_path, path);
638+
639+
/* set for libpq to use */
640+
snprintf(env_path, sizeof(env_path), "PGSYSCONFDIR=%s", path);
641+
canonicalize_path(env_path + 13);
642+
putenv(strdup(env_path));
643+
}
644+
}

src/port/path.c

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/port/path.c,v 1.66 2006/03/05 15:59:10 momjian Exp $
11+
* $PostgreSQL: pgsql/src/port/path.c,v 1.67 2006/09/11 20:10:30 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -652,54 +652,6 @@ get_parent_directory(char *path)
652652
}
653653

654654

655-
/*
656-
* set_pglocale_pgservice
657-
*
658-
* Set application-specific locale and service directory
659-
*
660-
* This function takes an argv[0] rather than a full path.
661-
*/
662-
void
663-
set_pglocale_pgservice(const char *argv0, const char *app)
664-
{
665-
char path[MAXPGPATH];
666-
char my_exec_path[MAXPGPATH];
667-
char env_path[MAXPGPATH + sizeof("PGSYSCONFDIR=")]; /* longer than
668-
* PGLOCALEDIR */
669-
670-
/* don't set LC_ALL in the backend */
671-
if (strcmp(app, "postgres") != 0)
672-
setlocale(LC_ALL, "");
673-
674-
if (find_my_exec(argv0, my_exec_path) < 0)
675-
return;
676-
677-
#ifdef ENABLE_NLS
678-
get_locale_path(my_exec_path, path);
679-
bindtextdomain(app, path);
680-
textdomain(app);
681-
682-
if (getenv("PGLOCALEDIR") == NULL)
683-
{
684-
/* set for libpq to use */
685-
snprintf(env_path, sizeof(env_path), "PGLOCALEDIR=%s", path);
686-
canonicalize_path(env_path + 12);
687-
putenv(strdup(env_path));
688-
}
689-
#endif
690-
691-
if (getenv("PGSYSCONFDIR") == NULL)
692-
{
693-
get_etc_path(my_exec_path, path);
694-
695-
/* set for libpq to use */
696-
snprintf(env_path, sizeof(env_path), "PGSYSCONFDIR=%s", path);
697-
canonicalize_path(env_path + 13);
698-
putenv(strdup(env_path));
699-
}
700-
}
701-
702-
703655
/*
704656
* trim_directory
705657
*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

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

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


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy