Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
2a70ec1b
Commit
2a70ec1b
authored
20 years ago
by
Bruce Momjian
Browse files
Options
Downloads
Patches
Plain Diff
Allow relative paths as long as the hardcoded path matches the bin path
up to the last bin directory name.
parent
bfb77c15
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/port/path.c
+67
-81
67 additions, 81 deletions
src/port/path.c
with
67 additions
and
81 deletions
src/port/path.c
+
67
−
81
View file @
2a70ec1b
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/port/path.c,v 1.1
4
2004/05/25
18:18:29
momjian Exp $
* $PostgreSQL: pgsql/src/port/path.c,v 1.1
5
2004/05/25
20:47:41
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -26,7 +26,7 @@
#define ISSEP(ch) ((ch) == '/' || (ch) == '\\')
#endif
static
bool
relative_path
(
const
char
*
path
1
,
const
char
*
path
2
);
const
static
char
*
relative_path
(
const
char
*
bin_
path
,
const
char
*
other_
path
);
static
void
trim_directory
(
char
*
path
);
static
void
trim_trailing_separator
(
char
*
path
);
...
...
@@ -37,6 +37,14 @@ static void trim_trailing_separator(char *path);
(p)++; \
}
/* Macro creates a relative path */
#define MAKE_RELATIVE \
do { \
StrNCpy(path, my_exec_path, MAXPGPATH); \
trim_directory(path); \
trim_directory(path); \
snprintf(ret_path, MAXPGPATH, "%s/%s", path, p); \
} while (0)
/*
* first_path_separator
...
...
@@ -114,14 +122,10 @@ void
get_share_path
(
const
char
*
my_exec_path
,
char
*
ret_path
)
{
char
path
[
MAXPGPATH
];
const
char
*
p
;
if
(
relative_path
(
PGBINDIR
,
PGSHAREDIR
))
{
StrNCpy
(
path
,
my_exec_path
,
MAXPGPATH
);
trim_directory
(
path
);
/* trim off binary */
trim_directory
(
path
);
/* trim off /bin */
snprintf
(
ret_path
,
MAXPGPATH
,
"%s/share"
,
path
);
}
if
((
p
=
relative_path
(
PGBINDIR
,
PGSHAREDIR
)))
MAKE_RELATIVE
;
else
StrNCpy
(
ret_path
,
PGSHAREDIR
,
MAXPGPATH
);
}
...
...
@@ -135,14 +139,10 @@ void
get_etc_path
(
const
char
*
my_exec_path
,
char
*
ret_path
)
{
char
path
[
MAXPGPATH
];
const
char
*
p
;
if
(
relative_path
(
PGBINDIR
,
SYSCONFDIR
))
{
StrNCpy
(
path
,
my_exec_path
,
MAXPGPATH
);
trim_directory
(
path
);
trim_directory
(
path
);
snprintf
(
ret_path
,
MAXPGPATH
,
"%s/etc"
,
path
);
}
if
((
p
=
relative_path
(
PGBINDIR
,
SYSCONFDIR
)))
MAKE_RELATIVE
;
else
StrNCpy
(
ret_path
,
SYSCONFDIR
,
MAXPGPATH
);
}
...
...
@@ -156,14 +156,10 @@ void
get_include_path
(
const
char
*
my_exec_path
,
char
*
ret_path
)
{
char
path
[
MAXPGPATH
];
const
char
*
p
;
if
(
relative_path
(
PGBINDIR
,
INCLUDEDIR
))
{
StrNCpy
(
path
,
my_exec_path
,
MAXPGPATH
);
trim_directory
(
path
);
trim_directory
(
path
);
snprintf
(
ret_path
,
MAXPGPATH
,
"%s/include"
,
path
);
}
if
((
p
=
relative_path
(
PGBINDIR
,
INCLUDEDIR
)))
MAKE_RELATIVE
;
else
StrNCpy
(
ret_path
,
INCLUDEDIR
,
MAXPGPATH
);
}
...
...
@@ -177,14 +173,10 @@ void
get_pkginclude_path
(
const
char
*
my_exec_path
,
char
*
ret_path
)
{
char
path
[
MAXPGPATH
];
const
char
*
p
;
if
(
relative_path
(
PGBINDIR
,
PKGINCLUDEDIR
))
{
StrNCpy
(
path
,
my_exec_path
,
MAXPGPATH
);
trim_directory
(
path
);
trim_directory
(
path
);
snprintf
(
ret_path
,
MAXPGPATH
,
"%s/include"
,
path
);
}
if
((
p
=
relative_path
(
PGBINDIR
,
PKGINCLUDEDIR
)))
MAKE_RELATIVE
;
else
StrNCpy
(
ret_path
,
PKGINCLUDEDIR
,
MAXPGPATH
);
}
...
...
@@ -200,14 +192,10 @@ void
get_pkglib_path
(
const
char
*
my_exec_path
,
char
*
ret_path
)
{
char
path
[
MAXPGPATH
];
const
char
*
p
;
if
(
relative_path
(
PGBINDIR
,
PKGLIBDIR
))
{
StrNCpy
(
path
,
my_exec_path
,
MAXPGPATH
);
trim_directory
(
path
);
trim_directory
(
path
);
snprintf
(
ret_path
,
MAXPGPATH
,
"%s/lib"
,
path
);
}
if
((
p
=
relative_path
(
PGBINDIR
,
PKGLIBDIR
)))
MAKE_RELATIVE
;
else
StrNCpy
(
ret_path
,
PKGLIBDIR
,
MAXPGPATH
);
}
...
...
@@ -223,14 +211,10 @@ void
get_locale_path
(
const
char
*
my_exec_path
,
char
*
ret_path
)
{
char
path
[
MAXPGPATH
];
const
char
*
p
;
if
(
relative_path
(
PGBINDIR
,
LOCALEDIR
))
{
StrNCpy
(
path
,
my_exec_path
,
MAXPGPATH
);
trim_directory
(
path
);
trim_directory
(
path
);
snprintf
(
ret_path
,
MAXPGPATH
,
"%s/share/locale"
,
path
);
}
if
((
p
=
relative_path
(
PGBINDIR
,
LOCALEDIR
)))
MAKE_RELATIVE
;
else
StrNCpy
(
ret_path
,
LOCALEDIR
,
MAXPGPATH
);
}
...
...
@@ -271,68 +255,71 @@ set_pglocale(const char *argv0, const char *app)
*
* Do the supplied paths differ only in their last component?
*/
static
bool
relative_path
(
const
char
*
path
1
,
const
char
*
path
2
)
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
(
*
path
1
)
&&
path
1
[
1
]
==
':'
&&
(
!
isalpha
(
*
path
2
)
||
!
path
2
[
1
]
==
':'
))
return
false
;
if
((
!
isalpha
(
*
path
1
)
||
!
path
1
[
1
]
==
':'
)
&&
(
isalpha
(
*
path
2
)
&&
path
2
[
1
]
==
':'
))
return
false
;
if
(
isalpha
(
*
path
1
)
&&
path
1
[
1
]
==
':'
&&
isalpha
(
*
path
2
)
&&
path
2
[
1
]
==
':'
)
if
(
isalpha
(
*
bin_
path
)
&&
bin_
path
[
1
]
==
':'
&&
(
!
isalpha
(
*
other_
path
)
||
!
other_
path
[
1
]
==
':'
))
return
NULL
;
if
((
!
isalpha
(
*
bin_
path
)
||
!
bin_
path
[
1
]
==
':'
)
&&
(
isalpha
(
*
other_
path
)
&&
other_
path
[
1
]
==
':'
))
return
NULL
;
if
(
isalpha
(
*
bin_
path
)
&&
bin_
path
[
1
]
==
':'
&&
isalpha
(
*
other_
path
)
&&
other_
path
[
1
]
==
':'
)
{
if
(
toupper
(
*
path1
)
!=
toupper
(
*
path2
))
return
false
;
path1
+=
2
;
path2
+=
2
;
if
(
toupper
(
*
bin_path
)
!=
toupper
(
*
other_path
))
return
NULL
;
bin_path
+=
2
;
other_path
+=
2
;
other_sep
=
other_path
+
1
;
/* past separator */
}
#endif
while
(
1
)
{
/* Move past adjacent slashes like //, and trailing ones */
MOVE_TO_SEP_END
(
path
1
);
MOVE_TO_SEP_END
(
path
2
);
MOVE_TO_SEP_END
(
bin_
path
);
MOVE_TO_SEP_END
(
other_
path
);
/* One of the paths is done? */
if
(
!*
path
1
||
!*
path
2
)
if
(
!*
bin_
path
||
!*
other_
path
)
break
;
/* Win32 filesystem is case insensitive */
if
((
!
ISSEP
(
*
bin_path
)
||
!
ISSEP
(
*
other_path
))
&&
#ifndef WIN32
if
(
*
path
1
!=
*
path
2
)
*
bin_
path
!=
*
other_
path
)
#else
if
(
toupper
((
unsigned
char
)
*
path
1
)
!=
toupper
((
unsigned
char
)
*
path
2
))
toupper
((
unsigned
char
)
*
bin_
path
)
!=
toupper
((
unsigned
char
)
*
other_
path
))
#endif
break
;
break
;
path1
++
;
path2
++
;
if
(
ISSEP
(
*
other_path
))
other_sep
=
other_path
+
1
;
/* past separator */
bin_path
++
;
other_path
++
;
}
/*
both done,
identical? */
if
(
!*
path
1
&&
!*
path
2
)
return
false
;
/* identical? */
if
(
!*
bin_
path
&&
!*
other_
path
)
return
NULL
;
/* advance past directory name */
while
(
!
ISSEP
(
*
path1
)
&&
*
path1
)
path1
++
;
while
(
!
ISSEP
(
*
path2
)
&&
*
path2
)
path2
++
;
while
(
!
ISSEP
(
*
bin_path
)
&&
*
bin_path
)
bin_path
++
;
MOVE_TO_SEP_END
(
path1
);
MOVE_TO_SEP_END
(
path2
);
MOVE_TO_SEP_END
(
bin_path
);
/*
Are both strings
done? */
if
(
!*
path1
&&
!*
path
2
)
return
true
;
/*
Is bin
done? */
if
(
!*
bin_
path
)
return
other_path
;
else
return
false
;
return
NULL
;
}
...
...
@@ -372,4 +359,3 @@ trim_trailing_separator(char *path)
for
(
p
--
;
p
>=
path
&&
ISSEP
(
*
p
);
p
--
)
*
p
=
'\0'
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment