Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f0f4e82

Browse files
committed
The win32 port backend will require the functionality provided by
canonicalize_path. Patch moves it from initdb.c to port/path.c. Claudio Natoli
1 parent 96ef668 commit f0f4e82

File tree

3 files changed

+30
-29
lines changed

3 files changed

+30
-29
lines changed

src/bin/initdb/initdb.c

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
* Portions Copyright (c) 1994, Regents of the University of California
4444
* Portions taken from FreeBSD.
4545
*
46-
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.22 2004/02/02 00:11:31 momjian Exp $
46+
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.23 2004/03/09 04:49:02 momjian Exp $
4747
*
4848
*-------------------------------------------------------------------------
4949
*/
@@ -151,7 +151,6 @@ char *pgpath;
151151
/* forward declare all our functions */
152152
static bool rmtree(char *, bool);
153153
static void exit_nicely(void);
154-
static void canonicalize_path(char *);
155154
#ifdef WIN32
156155
static char *expanded_path(char *);
157156
#else
@@ -288,31 +287,6 @@ rmtree(char *path, bool rmtopdir)
288287
}
289288

290289

291-
/*
292-
* make all paths look like unix, with forward slashes
293-
* also strip any trailing slash.
294-
*
295-
* The Windows command processor will accept suitably quoted paths
296-
* with forward slashes, but barfs badly with mixed forward and back
297-
* slashes. Removing the trailing slash on a path means we never get
298-
* ugly double slashes. Don't remove a leading slash, though.
299-
*/
300-
static void
301-
canonicalize_path(char *path)
302-
{
303-
char *p;
304-
305-
for (p = path; *p; p++)
306-
{
307-
#ifdef WIN32
308-
if (*p == '\\')
309-
*p = '/';
310-
#endif
311-
}
312-
if (p > path+1 && *--p == '/')
313-
*p = '\0';
314-
}
315-
316290
/*
317291
* make a copy of the array of lines, with token replaced by replacement
318292
* the first time it occurs on each line.

src/include/port.h

Lines changed: 2 additions & 1 deletion
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.20 2004/02/25 19:41:23 momjian Exp $
9+
* $PostgreSQL: pgsql/src/include/port.h,v 1.21 2004/03/09 04:49:02 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -21,6 +21,7 @@
2121
extern bool is_absolute_path(const char *filename);
2222
extern char *first_path_separator(const char *filename);
2323
extern char *last_path_separator(const char *filename);
24+
extern void canonicalize_path(char *path);
2425
extern char *get_progname(char *argv0);
2526

2627
/* Portable delay handling */

src/port/path.c

Lines changed: 27 additions & 1 deletion
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.4 2003/11/29 19:52:13 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/port/path.c,v 1.5 2004/03/09 04:49:02 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -84,6 +84,32 @@ last_path_separator(const char *filename)
8484
}
8585

8686

87+
/*
88+
* make all paths look like unix, with forward slashes
89+
* also strip any trailing slash.
90+
*
91+
* The Windows command processor will accept suitably quoted paths
92+
* with forward slashes, but barfs badly with mixed forward and back
93+
* slashes. Removing the trailing slash on a path means we never get
94+
* ugly double slashes. Don't remove a leading slash, though.
95+
*/
96+
void
97+
canonicalize_path(char *path)
98+
{
99+
char *p;
100+
101+
for (p = path; *p; p++)
102+
{
103+
#ifdef WIN32
104+
if (*p == '\\')
105+
*p = '/';
106+
#endif
107+
}
108+
if (p > path+1 && *--p == '/')
109+
*p = '\0';
110+
}
111+
112+
87113
/*
88114
* Extracts the actual name of the program as called.
89115
*/

0 commit comments

Comments
 (0)