Commit 460dcab4 by Richard Kenner

(find_a_file): Try EXECUTABLE_SUFFIX first, then file without the

suffix.

From-SVN: r7459
parent d008e26c
...@@ -1626,20 +1626,26 @@ find_a_file (pprefix, name, mode) ...@@ -1626,20 +1626,26 @@ find_a_file (pprefix, name, mode)
{ {
if (machine_suffix) if (machine_suffix)
{ {
/* Some systems have a suffix for executable files.
So try appending that first. */
if (file_suffix[0] != 0)
{
strcpy (temp, pl->prefix); strcpy (temp, pl->prefix);
strcat (temp, machine_suffix); strcat (temp, machine_suffix);
strcat (temp, name); strcat (temp, name);
strcat (temp, file_suffix);
if (access (temp, mode) == 0) if (access (temp, mode) == 0)
{ {
if (pl->used_flag_ptr != 0) if (pl->used_flag_ptr != 0)
*pl->used_flag_ptr = 1; *pl->used_flag_ptr = 1;
return temp; return temp;
} }
/* Some systems have a suffix for executable files. }
So try appending that. */
if (file_suffix[0] != 0) /* Now try just the name. */
{ strcpy (temp, pl->prefix);
strcat (temp, file_suffix); strcat (temp, machine_suffix);
strcat (temp, name);
if (access (temp, mode) == 0) if (access (temp, mode) == 0)
{ {
if (pl->used_flag_ptr != 0) if (pl->used_flag_ptr != 0)
...@@ -1647,25 +1653,30 @@ find_a_file (pprefix, name, mode) ...@@ -1647,25 +1653,30 @@ find_a_file (pprefix, name, mode)
return temp; return temp;
} }
} }
}
/* Certain prefixes are tried with just the machine type, /* Certain prefixes are tried with just the machine type,
not the version. This is used for finding as, ld, etc. */ not the version. This is used for finding as, ld, etc. */
if (just_machine_suffix && pl->require_machine_suffix == 2) if (just_machine_suffix && pl->require_machine_suffix == 2)
{ {
/* Some systems have a suffix for executable files.
So try appending that first. */
if (file_suffix[0] != 0)
{
strcpy (temp, pl->prefix); strcpy (temp, pl->prefix);
strcat (temp, just_machine_suffix); strcat (temp, just_machine_suffix);
strcat (temp, name); strcat (temp, name);
strcat (temp, file_suffix);
if (access (temp, mode) == 0) if (access (temp, mode) == 0)
{ {
if (pl->used_flag_ptr != 0) if (pl->used_flag_ptr != 0)
*pl->used_flag_ptr = 1; *pl->used_flag_ptr = 1;
return temp; return temp;
} }
/* Some systems have a suffix for executable files. }
So try appending that. */
if (file_suffix[0] != 0) strcpy (temp, pl->prefix);
{ strcat (temp, just_machine_suffix);
strcat (temp, file_suffix); strcat (temp, name);
if (access (temp, mode) == 0) if (access (temp, mode) == 0)
{ {
if (pl->used_flag_ptr != 0) if (pl->used_flag_ptr != 0)
...@@ -1673,24 +1684,28 @@ find_a_file (pprefix, name, mode) ...@@ -1673,24 +1684,28 @@ find_a_file (pprefix, name, mode)
return temp; return temp;
} }
} }
}
/* Certain prefixes can't be used without the machine suffix /* Certain prefixes can't be used without the machine suffix
when the machine or version is explicitly specified. */ when the machine or version is explicitly specified. */
if (!pl->require_machine_suffix) if (!pl->require_machine_suffix)
{ {
/* Some systems have a suffix for executable files.
So try appending that first. */
if (file_suffix[0] != 0)
{
strcpy (temp, pl->prefix); strcpy (temp, pl->prefix);
strcat (temp, name); strcat (temp, name);
strcat (temp, file_suffix);
if (access (temp, mode) == 0) if (access (temp, mode) == 0)
{ {
if (pl->used_flag_ptr != 0) if (pl->used_flag_ptr != 0)
*pl->used_flag_ptr = 1; *pl->used_flag_ptr = 1;
return temp; return temp;
} }
/* Some systems have a suffix for executable files. }
So try appending that. */
if (file_suffix[0] != 0) strcpy (temp, pl->prefix);
{ strcat (temp, name);
strcat (temp, file_suffix);
if (access (temp, mode) == 0) if (access (temp, mode) == 0)
{ {
if (pl->used_flag_ptr != 0) if (pl->used_flag_ptr != 0)
...@@ -1699,7 +1714,6 @@ find_a_file (pprefix, name, mode) ...@@ -1699,7 +1714,6 @@ find_a_file (pprefix, name, mode)
} }
} }
} }
}
free (temp); free (temp);
return 0; return 0;
......
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