Commit d4348177 by Alan Modra Committed by Alan Modra

prefix.c (update_path): Don't strip single `.' path components unless stripping…

prefix.c (update_path): Don't strip single `.' path components unless stripping a later `..' component.

	* prefix.c (update_path): Don't strip single `.' path components
	unless stripping a later `..' component.  Exit loop as soon as
	a valid path is found.

From-SVN: r55814
parent 3e75a2f9
2002-07-28 Alan Modra <amodra@bigpond.net.au>
* prefix.c (update_path): Don't strip single `.' path components
unless stripping a later `..' component. Exit loop as soon as
a valid path is found.
2002-07-27 Roger Sayle <roger@eyesopen.com> 2002-07-27 Roger Sayle <roger@eyesopen.com>
* builtins.def [DEF_GCC_BUILTIN]: Require an explicit ATTRS * builtins.def [DEF_GCC_BUILTIN]: Require an explicit ATTRS
......
...@@ -284,26 +284,8 @@ update_path (path, key) ...@@ -284,26 +284,8 @@ update_path (path, key)
p = strchr (p, '.'); p = strchr (p, '.');
if (p == NULL) if (p == NULL)
break; break;
/* Get rid of a leading `./' and replace `/./' with `/', when
such components are followed with another `.'. */
if (IS_DIR_SEPARATOR (p[1])
&& (p == result || IS_DIR_SEPARATOR (p[-1])))
{
src = p + 2;
/* Be careful about .//foo */
while (IS_DIR_SEPARATOR (*src))
++src;
if (*src == '.')
{
dest = p;
while ((*dest++ = *src++) != 0)
;
}
else
++p;
}
/* Look for `/../' */ /* Look for `/../' */
else if (p[1] == '.' if (p[1] == '.'
&& IS_DIR_SEPARATOR (p[2]) && IS_DIR_SEPARATOR (p[2])
&& (p != result && IS_DIR_SEPARATOR (p[-1]))) && (p != result && IS_DIR_SEPARATOR (p[-1])))
{ {
...@@ -311,22 +293,30 @@ update_path (path, key) ...@@ -311,22 +293,30 @@ update_path (path, key)
if (!ALWAYS_STRIP_DOTDOT && access (result, X_OK) == 0) if (!ALWAYS_STRIP_DOTDOT && access (result, X_OK) == 0)
{ {
*p = '.'; *p = '.';
p += 3; break;
} }
else else
{ {
/* We can't access the dir, so we won't be able to /* We can't access the dir, so we won't be able to
access dir/.. either. Strip out dir/.. We know dir access dir/.. either. Strip out `dir/../'. If `dir'
isn't `.' because we've rid ourselves of `.' path turns out to be `.', strip one more path component. */
components above. */ dest = p;
dest = p - 1; do
{
--dest;
while (dest != result && IS_DIR_SEPARATOR (*dest)) while (dest != result && IS_DIR_SEPARATOR (*dest))
--dest; --dest;
while (dest != result && !IS_DIR_SEPARATOR (dest[-1])) while (dest != result && !IS_DIR_SEPARATOR (dest[-1]))
--dest; --dest;
/* Don't strip leading `/'. */ }
while (IS_DIR_SEPARATOR (*dest)) while (dest != result && *dest == '.');
++dest; /* If we have something like `./..' or `/..', don't
strip anything more. */
if (*dest == '.' || IS_DIR_SEPARATOR (*dest))
{
*p = '.';
break;
}
src = p + 3; src = p + 3;
while (IS_DIR_SEPARATOR (*src)) while (IS_DIR_SEPARATOR (*src))
++src; ++src;
......
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