aboutsummaryrefslogtreecommitdiff
path: root/src/port/path.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2004-08-29 05:07:03 +0000
committerBruce Momjian <bruce@momjian.us>2004-08-29 05:07:03 +0000
commitb6b71b85bc45b49005b5aec87cba2c33fc8baf49 (patch)
treec23dbd1dbc43972a8e48327c8a771baf36952f3d /src/port/path.c
parent90cb9c305140684b2b00c739b724f67915e11404 (diff)
downloadpostgresql-b6b71b85bc45b49005b5aec87cba2c33fc8baf49.tar.gz
postgresql-b6b71b85bc45b49005b5aec87cba2c33fc8baf49.zip
Pgindent run for 8.0.
Diffstat (limited to 'src/port/path.c')
-rw-r--r--src/port/path.c116
1 files changed, 60 insertions, 56 deletions
diff --git a/src/port/path.c b/src/port/path.c
index 6a4efa14b88..dae4eeab099 100644
--- a/src/port/path.c
+++ b/src/port/path.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/port/path.c,v 1.32 2004/08/29 04:13:12 momjian Exp $
+ * $PostgreSQL: pgsql/src/port/path.c,v 1.33 2004/08/29 05:07:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,15 +21,15 @@
#ifndef WIN32
-#define IS_DIR_SEP(ch) ((ch) == '/')
+#define IS_DIR_SEP(ch) ((ch) == '/')
#else
-#define IS_DIR_SEP(ch) ((ch) == '/' || (ch) == '\\')
+#define IS_DIR_SEP(ch) ((ch) == '/' || (ch) == '\\')
#endif
#ifndef WIN32
-#define IS_PATH_SEP(ch) ((ch) == ':')
+#define IS_PATH_SEP(ch) ((ch) == ':')
#else
-#define IS_PATH_SEP(ch) ((ch) == ';')
+#define IS_PATH_SEP(ch) ((ch) == ';')
#endif
const static char *relative_path(const char *bin_path, const char *other_path);
@@ -52,7 +52,7 @@ first_dir_separator(const char *filename)
{
char *p;
- for (p = (char *)filename; *p; p++)
+ for (p = (char *) filename; *p; p++)
if (IS_DIR_SEP(*p))
return p;
return NULL;
@@ -66,7 +66,7 @@ first_path_separator(const char *filename)
{
char *p;
- for (p = (char *)filename; *p; p++)
+ for (p = (char *) filename; *p; p++)
if (IS_PATH_SEP(*p))
return p;
return NULL;
@@ -78,9 +78,10 @@ first_path_separator(const char *filename)
char *
last_dir_separator(const char *filename)
{
- char *p, *ret = NULL;
+ char *p,
+ *ret = NULL;
- for (p = (char *)filename; *p; p++)
+ for (p = (char *) filename; *p; p++)
if (IS_DIR_SEP(*p))
ret = p;
return ret;
@@ -104,8 +105,8 @@ void
make_native_path(char *filename)
{
#ifdef WIN32
- char *p;
-
+ char *p;
+
for (p = filename; *p; p++)
if (*p == '/')
*p = '\\';
@@ -120,6 +121,7 @@ void
canonicalize_path(char *path)
{
#ifdef WIN32
+
/*
* The Windows command processor will accept suitably quoted paths
* with forward slashes, but barfs badly with mixed forward and back
@@ -133,18 +135,18 @@ canonicalize_path(char *path)
*p = '/';
}
- /* In Win32, if you do:
- * prog.exe "a b" "\c\d\"
- * the system will pass \c\d" as argv[2].
+ /*
+ * In Win32, if you do: prog.exe "a b" "\c\d\" the system will pass
+ * \c\d" as argv[2].
*/
- if (p > path && *(p-1) == '"')
- *(p-1) = '/';
+ if (p > path && *(p - 1) == '"')
+ *(p - 1) = '/';
#endif
/*
- * Removing the trailing slash on a path means we never get ugly double
- * slashes. Also, Win32 can't stat() a directory with a trailing slash.
- * Don't remove a leading slash, though.
+ * Removing the trailing slash on a path means we never get ugly
+ * double slashes. Also, Win32 can't stat() a directory with a
+ * trailing slash. Don't remove a leading slash, though.
*/
trim_trailing_separator(path);
@@ -153,7 +155,7 @@ canonicalize_path(char *path)
*/
for (;;)
{
- int len = strlen(path);
+ int len = strlen(path);
if (len >= 2 && strcmp(path + len - 2, "/.") == 0)
{
@@ -192,7 +194,7 @@ void
get_share_path(const char *my_exec_path, char *ret_path)
{
const char *p;
-
+
if ((p = relative_path(PGBINDIR, PGSHAREDIR)))
make_relative(my_exec_path, p, ret_path);
else
@@ -209,7 +211,7 @@ void
get_etc_path(const char *my_exec_path, char *ret_path)
{
const char *p;
-
+
if ((p = relative_path(PGBINDIR, SYSCONFDIR)))
make_relative(my_exec_path, p, ret_path);
else
@@ -226,7 +228,7 @@ void
get_include_path(const char *my_exec_path, char *ret_path)
{
const char *p;
-
+
if ((p = relative_path(PGBINDIR, INCLUDEDIR)))
make_relative(my_exec_path, p, ret_path);
else
@@ -243,7 +245,7 @@ void
get_pkginclude_path(const char *my_exec_path, char *ret_path)
{
const char *p;
-
+
if ((p = relative_path(PGBINDIR, PKGINCLUDEDIR)))
make_relative(my_exec_path, p, ret_path);
else
@@ -260,7 +262,7 @@ void
get_includeserver_path(const char *my_exec_path, char *ret_path)
{
const char *p;
-
+
if ((p = relative_path(PGBINDIR, INCLUDEDIRSERVER)))
make_relative(my_exec_path, p, ret_path);
else
@@ -277,7 +279,7 @@ void
get_lib_path(const char *my_exec_path, char *ret_path)
{
const char *p;
-
+
if ((p = relative_path(PGBINDIR, LIBDIR)))
make_relative(my_exec_path, p, ret_path);
else
@@ -294,7 +296,7 @@ void
get_pkglib_path(const char *my_exec_path, char *ret_path)
{
const char *p;
-
+
if ((p = relative_path(PGBINDIR, PKGLIBDIR)))
make_relative(my_exec_path, p, ret_path);
else
@@ -313,7 +315,7 @@ void
get_locale_path(const char *my_exec_path, char *ret_path)
{
const char *p;
-
+
if ((p = relative_path(PGBINDIR, LOCALEDIR)))
make_relative(my_exec_path, p, ret_path);
else
@@ -333,9 +335,10 @@ get_locale_path(const char *my_exec_path, char *ret_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 */
+ 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)
@@ -343,7 +346,7 @@ set_pglocale_pgservice(const char *argv0, const char *app)
if (find_my_exec(argv0, my_exec_path) < 0)
return;
-
+
#ifdef ENABLE_NLS
get_locale_path(my_exec_path, path);
bindtextdomain(app, path);
@@ -361,7 +364,7 @@ set_pglocale_pgservice(const char *argv0, const char *app)
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);
@@ -397,7 +400,7 @@ get_home_path(char *ret_path)
static void
make_relative(const char *my_exec_path, const char *p, char *ret_path)
{
- char path[MAXPGPATH];
+ char path[MAXPGPATH];
StrNCpy(path, my_exec_path, MAXPGPATH);
trim_directory(path);
@@ -415,7 +418,7 @@ static const char *
relative_path(const char *bin_path, const char *other_path)
{
const char *other_sep = other_path;
-
+
#ifdef WIN32
/* Driver letters match? */
if (isalpha(*bin_path) && bin_path[1] == ':' &&
@@ -450,14 +453,14 @@ relative_path(const char *bin_path, const char *other_path)
#ifndef WIN32
*bin_path != *other_path
#else
- toupper((unsigned char) *bin_path) != toupper((unsigned char)*other_path)
+ toupper((unsigned char) *bin_path) != toupper((unsigned char) *other_path)
#endif
)
break;
if (IS_DIR_SEP(*other_path))
- other_sep = other_path + 1; /* past separator */
-
+ other_sep = other_path + 1; /* past separator */
+
bin_path++;
other_path++;
}
@@ -466,7 +469,7 @@ relative_path(const char *bin_path, const char *other_path)
if (!*bin_path && !*other_path)
return NULL;
- /* advance past directory name */
+ /* advance past directory name */
while (!IS_DIR_SEP(*bin_path) && *bin_path)
bin_path++;
@@ -488,8 +491,8 @@ relative_path(const char *bin_path, const char *other_path)
static void
trim_directory(char *path)
{
- char *p;
-
+ char *p;
+
if (path[0] == '\0')
return;
@@ -508,28 +511,29 @@ trim_directory(char *path)
static void
trim_trailing_separator(char *path)
{
- char *p = path + strlen(path);
+ char *p = path + strlen(path);
#ifdef WIN32
+
/*
- * Skip over network and drive specifiers for win32.
- * Set 'path' to point to the last character we must keep.
+ * Skip over network and drive specifiers for win32. Set 'path' to
+ * point to the last character we must keep.
*/
- if (strlen(path) >= 2)
- {
- if (IS_DIR_SEP(path[0]) && IS_DIR_SEP(path[1]))
- {
- path += 2;
+ if (strlen(path) >= 2)
+ {
+ if (IS_DIR_SEP(path[0]) && IS_DIR_SEP(path[1]))
+ {
+ path += 2;
while (*path && !IS_DIR_SEP(*path))
path++;
}
- else if (isalpha(path[0]) && path[1] == ':')
- {
- path++;
- if (IS_DIR_SEP(path[1]))
- path++;
- }
- }
+ else if (isalpha(path[0]) && path[1] == ':')
+ {
+ path++;
+ if (IS_DIR_SEP(path[1]))
+ path++;
+ }
+ }
#endif
/* trim off trailing slashes */