summaryrefslogtreecommitdiff
path: root/elf/ldconfig.c
diff options
context:
space:
mode:
authorAndreas Jaeger <aj@suse.de>2000-09-24 18:35:20 +0000
committerAndreas Jaeger <aj@suse.de>2000-09-24 18:35:20 +0000
commita8fd59b06931e3b606ffbbad741688ba7f5bbda2 (patch)
tree16e5e0fa18dbbd8918234ecd9a7e1a3eee7a03d2 /elf/ldconfig.c
parentfaa78e96be79af0594b44f935e34a67416b7f6bb (diff)
Update.
* elf/ldconfig.c (add_dir): Move logic to add entry to list to new function add_single_dir. (add_single_dir): New function. (search_dir): Use add_single_dir instead of recursing.
Diffstat (limited to 'elf/ldconfig.c')
-rw-r--r--elf/ldconfig.c70
1 files changed, 41 insertions, 29 deletions
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index 50b6a261f9..2730ad579e 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -258,12 +258,42 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
"Andreas Jaeger");
}
+/* Add a single directory entry. */
+static void
+add_single_dir (struct dir_entry *entry, int verbose)
+{
+ struct dir_entry *ptr, *prev;
+
+ ptr = dir_entries;
+ prev = ptr;
+ while (ptr != NULL)
+ {
+ /* Check for duplicates. */
+ if (strcmp (ptr->path, entry->path) == 0)
+ {
+ if (opt_verbose && verbose)
+ error (0, 0, _("Path `%s' given more than once"), entry->path);
+ /* Use the newer information. */
+ ptr->flag = entry->flag;
+ free (entry);
+ break;
+ }
+ prev = ptr;
+ ptr = ptr->next;
+ }
+ /* Is this the first entry? */
+ if (ptr == NULL && dir_entries == NULL)
+ dir_entries = entry;
+ else if (ptr == NULL)
+ prev->next = entry;
+}
+
/* Add one directory to the list of directories to process. */
static void
add_dir (const char *line)
{
char *equal_sign;
- struct dir_entry *entry, *ptr, *prev;
+ struct dir_entry *entry;
unsigned int i;
entry = xmalloc (sizeof (struct dir_entry));
@@ -299,28 +329,7 @@ add_dir (const char *line)
--i;
}
- ptr = dir_entries;
- prev = ptr;
- while (ptr != NULL)
- {
- /* Check for duplicates. */
- if (strcmp (ptr->path, entry->path) == 0)
- {
- if (opt_verbose)
- error (0, 0, _("Path `%s' given more than once"), entry->path);
- /* Use the newer information. */
- ptr->flag = entry->flag;
- free (entry);
- break;
- }
- prev = ptr;
- ptr = ptr->next;
- }
- /* Is this the first entry? */
- if (ptr == NULL && dir_entries == NULL)
- dir_entries = entry;
- else if (ptr == NULL)
- prev->next = entry;
+ add_single_dir (entry, 1);
}
@@ -571,12 +580,15 @@ search_dir (const struct dir_entry *entry)
if (S_ISDIR (stat_buf.st_mode) && is_hwcap (direntry->d_name))
{
- /* Handle subdirectory also, make a recursive call. */
- struct dir_entry new_entry;
- new_entry.path = buf;
- new_entry.flag = entry->flag;
- new_entry.next = NULL;
- search_dir (&new_entry);
+ /* Handle subdirectory later. */
+ struct dir_entry *new_entry;
+
+ new_entry = xmalloc (sizeof (struct dir_entry));
+
+ new_entry->path = buf;
+ new_entry->flag = entry->flag;
+ new_entry->next = NULL;
+ add_single_dir (new_entry, 0);
continue;
}
else if (!S_ISREG (stat_buf.st_mode) && !S_ISLNK (stat_buf.st_mode))