Commit f0f4e82f authored by Bruce Momjian's avatar Bruce Momjian

The win32 port backend will require the functionality provided by

canonicalize_path. Patch moves it from initdb.c to port/path.c.

Claudio Natoli
parent 96ef6682
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD. * Portions taken from FreeBSD.
* *
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.22 2004/02/02 00:11:31 momjian Exp $ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.23 2004/03/09 04:49:02 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -151,7 +151,6 @@ char *pgpath; ...@@ -151,7 +151,6 @@ char *pgpath;
/* forward declare all our functions */ /* forward declare all our functions */
static bool rmtree(char *, bool); static bool rmtree(char *, bool);
static void exit_nicely(void); static void exit_nicely(void);
static void canonicalize_path(char *);
#ifdef WIN32 #ifdef WIN32
static char *expanded_path(char *); static char *expanded_path(char *);
#else #else
...@@ -288,31 +287,6 @@ rmtree(char *path, bool rmtopdir) ...@@ -288,31 +287,6 @@ rmtree(char *path, bool rmtopdir)
} }
/*
* make all paths look like unix, with forward slashes
* also strip any trailing slash.
*
* The Windows command processor will accept suitably quoted paths
* with forward slashes, but barfs badly with mixed forward and back
* slashes. Removing the trailing slash on a path means we never get
* ugly double slashes. Don't remove a leading slash, though.
*/
static void
canonicalize_path(char *path)
{
char *p;
for (p = path; *p; p++)
{
#ifdef WIN32
if (*p == '\\')
*p = '/';
#endif
}
if (p > path+1 && *--p == '/')
*p = '\0';
}
/* /*
* make a copy of the array of lines, with token replaced by replacement * make a copy of the array of lines, with token replaced by replacement
* the first time it occurs on each line. * the first time it occurs on each line.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/port.h,v 1.20 2004/02/25 19:41:23 momjian Exp $ * $PostgreSQL: pgsql/src/include/port.h,v 1.21 2004/03/09 04:49:02 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
extern bool is_absolute_path(const char *filename); extern bool is_absolute_path(const char *filename);
extern char *first_path_separator(const char *filename); extern char *first_path_separator(const char *filename);
extern char *last_path_separator(const char *filename); extern char *last_path_separator(const char *filename);
extern void canonicalize_path(char *path);
extern char *get_progname(char *argv0); extern char *get_progname(char *argv0);
/* Portable delay handling */ /* Portable delay handling */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/port/path.c,v 1.4 2003/11/29 19:52:13 pgsql Exp $ * $PostgreSQL: pgsql/src/port/path.c,v 1.5 2004/03/09 04:49:02 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -84,6 +84,32 @@ last_path_separator(const char *filename) ...@@ -84,6 +84,32 @@ last_path_separator(const char *filename)
} }
/*
* make all paths look like unix, with forward slashes
* also strip any trailing slash.
*
* The Windows command processor will accept suitably quoted paths
* with forward slashes, but barfs badly with mixed forward and back
* slashes. Removing the trailing slash on a path means we never get
* ugly double slashes. Don't remove a leading slash, though.
*/
void
canonicalize_path(char *path)
{
char *p;
for (p = path; *p; p++)
{
#ifdef WIN32
if (*p == '\\')
*p = '/';
#endif
}
if (p > path+1 && *--p == '/')
*p = '\0';
}
/* /*
* Extracts the actual name of the program as called. * Extracts the actual name of the program as called.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment