Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f16874c

Browse files
committed
Win32 can't have the same function coming from two library object files,
so we make is_absolute_path a macro so libpq doesn't use path.o.
1 parent 48eb73b commit f16874c

File tree

3 files changed

+31
-25
lines changed

3 files changed

+31
-25
lines changed

src/include/port.h

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2003, 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.32 2004/05/17 14:35:34 momjian Exp $
9+
* $PostgreSQL: pgsql/src/include/port.h,v 1.33 2004/05/19 04:21:49 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -21,7 +21,6 @@
2121
bool set_noblock(int sock);
2222

2323
/* Portable path handling for Unix/Win32 */
24-
extern bool is_absolute_path(const char *filename);
2524
extern char *first_path_separator(const char *filename);
2625
extern char *last_path_separator(const char *filename);
2726
extern void canonicalize_path(char *path);
@@ -32,6 +31,31 @@ extern void get_include_path(const char *my_exec_path, char *ret_path);
3231
extern void get_pkginclude_path(const char *my_exec_path, char *ret_path);
3332
extern void get_pkglib_path(const char *my_exec_path, char *ret_path);
3433

34+
/*
35+
* is_absolute_path
36+
*
37+
* This capability is needed by libpq and initdb.c
38+
* On Win32, you can't reference the same object file that is
39+
* in two different libraries (pgport and libpq), so a macro is best.
40+
*/
41+
#ifndef WIN32
42+
#define is_absolute_path(filename) \
43+
( \
44+
((filename)[0] == '/') \
45+
)
46+
#else
47+
#define is_absolute_path(filename) \
48+
( \
49+
((filename)[0] == '/') || \
50+
(filename)[0] == '\\' || \
51+
(isalpha((filename)[0]) && (filename)[1] == ':' && \
52+
((filename)[2] == '\\' || (filename)[2] == '/')) \
53+
)
54+
#endif
55+
56+
57+
58+
3559

3660
/* Portable way to find binaries */
3761
extern int find_my_exec(const char *argv0, char *full_path);

src/interfaces/libpq/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/libpq/Makefile,v 1.106 2004/05/17 14:35:34 momjian Exp $
7+
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.107 2004/05/19 04:21:49 momjian Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -30,7 +30,7 @@ override CFLAGS += $(PTHREAD_CFLAGS) \
3030
OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
3131
fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \
3232
dllist.o md5.o ip.o wchar.o encnames.o \
33-
$(filter crypt.o getaddrinfo.o inet_aton.o noblock.o pgstrcasecmp.o snprintf.o strerror.o open.o path.o thread.o, $(LIBOBJS))
33+
$(filter crypt.o getaddrinfo.o inet_aton.o noblock.o pgstrcasecmp.o snprintf.o strerror.o open.o thread.o, $(LIBOBJS))
3434
ifeq ($(PORTNAME), win32)
3535
OBJS+=win32.o
3636
endif
@@ -59,7 +59,7 @@ backend_src = $(top_srcdir)/src/backend
5959
# For port modules, this only happens if configure decides the module
6060
# is needed (see filter hack in OBJS, above).
6161

62-
crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c open.c path.c thread.c: % : $(top_srcdir)/src/port/%
62+
crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c open.c thread.c: % : $(top_srcdir)/src/port/%
6363
rm -f $@ && $(LN_S) $< .
6464

6565
md5.c ip.c: % : $(backend_src)/libpq/%
@@ -85,4 +85,4 @@ uninstall: uninstall-lib
8585
rm -f $(DESTDIR)$(includedir)/libpq-fe.h $(DESTDIR)$(includedir_internal)/libpq-int.h $(DESTDIR)$(includedir_internal)/pqexpbuffer.h
8686

8787
clean distclean maintainer-clean: clean-lib
88-
rm -f $(OBJS) crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c open.c path.c thread.c dllist.c md5.c ip.c encnames.c wchar.c
88+
rm -f $(OBJS) crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c open.c thread.c dllist.c md5.c ip.c encnames.c wchar.c

src/port/path.c

Lines changed: 1 addition & 19 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.9 2004/05/18 03:36:45 momjian Exp $
11+
* $PostgreSQL: pgsql/src/port/path.c,v 1.10 2004/05/19 04:21:49 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -34,24 +34,6 @@ static void trim_trailing_separator(char *path);
3434
}
3535

3636

37-
/*
38-
* is_absolute_path
39-
*/
40-
bool
41-
is_absolute_path(const char *filename)
42-
{
43-
return filename[0] == '/'
44-
#ifdef WIN32 /* WIN32 paths can either have forward or
45-
* backward slashes */
46-
|| filename[0] == '\\'
47-
|| (isalpha(filename[0]) && filename[1] == ':'
48-
&& (filename[2] == '\\' || filename[2] == '/'))
49-
#endif
50-
;
51-
}
52-
53-
54-
5537
/*
5638
* first_path_separator
5739
*/

0 commit comments

Comments
 (0)