Commit 28aaf32b by Jason Merrill

Update SunOS 4 code

From-SVN: r9041
parent 49be3a59
...@@ -1839,6 +1839,7 @@ scan_prog_file (prog_name, which_pass) ...@@ -1839,6 +1839,7 @@ scan_prog_file (prog_name, which_pass)
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/unistd.h> #include <sys/unistd.h>
#include <sys/dir.h>
/* pointers to the object file */ /* pointers to the object file */
unsigned object; /* address of memory mapped file */ unsigned object; /* address of memory mapped file */
...@@ -1872,6 +1873,43 @@ mapfile (name) ...@@ -1872,6 +1873,43 @@ mapfile (name)
close (fp); close (fp);
} }
/* Helpers for locatelib. */
static char *libname;
static int
libselect (d)
struct direct *d;
{
return (strncmp (libname, d->d_name, strlen (libname)) == 0);
}
static int
libcompare (d1, d2)
struct direct **d1, **d2;
{
int i1, i2 = strlen (libname);
char *e1 = (*d1)->d_name + i2;
char *e2 = (*d2)->d_name + i2;
while (*e1 && *e2)
{
++e1;
++e2;
i1 = strtol (e1, &e1, 10);
i2 = strtol (e2, &e2, 10);
if (i1 != i2)
return i1 - i2;
}
if (*e1)
return 1;
else if (*e2)
return -1;
else
return 0;
}
/* Given the name NAME of a dynamic dependency, find its pathname and add /* Given the name NAME of a dynamic dependency, find its pathname and add
it to the list of libraries. */ it to the list of libraries. */
...@@ -1941,11 +1979,14 @@ locatelib (name) ...@@ -1941,11 +1979,14 @@ locatelib (name)
*pp++ = "/usr/local/lib"; *pp++ = "/usr/local/lib";
*pp = 0; *pp = 0;
} }
libname = name;
for (pp = l; *pp != 0 ; pp++) for (pp = l; *pp != 0 ; pp++)
{ {
sprintf (buf, "%s/%s", *pp, name); struct direct **namelist;
if (access (buf, R_OK) == 0) int entries;
if ((entries = scandir (*pp, &namelist, libselect, libcompare)) > 0)
{ {
sprintf (buf, "%s/%s", *pp, namelist[entries - 1]->d_name);
add_to_list (&libraries, buf); add_to_list (&libraries, buf);
if (debug) if (debug)
fprintf (stderr, "%s\n", buf); fprintf (stderr, "%s\n", buf);
......
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