Output ``[]'' when a list.
[deliverable/binutils-gdb.git] / ld / ldfile.c
index cab604e47d0c99e4b46c1251dd1492265c609631..0e4d0ec3a2e4d027531a95736316b77710a9a8fe 100644 (file)
@@ -1,5 +1,5 @@
 /* Linker file opening and searching.
-   Copyright (C) 1991, 92, 93, 94, 95, 98, 99, 2000
+   Copyright 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001
    Free Software Foundation, Inc.
 
 This file is part of GLD, the Gnu Linker.
@@ -33,6 +33,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "ldgram.h"
 #include "ldlex.h"
 #include "ldemul.h"
+#include "libiberty.h"
 
 #include <ctype.h>
 
@@ -62,8 +63,7 @@ char *slash = ":";
 
 static search_dirs_type **search_tail_ptr = &search_head;
 
-typedef struct search_arch
-{
+typedef struct search_arch {
   char *name;
   struct search_arch *next;
 } search_arch_type;
@@ -165,7 +165,7 @@ ldfile_open_file_search (arch, entry, lib, suffix)
     }
 
   for (search = search_head;
-       search != (search_dirs_type *)NULL;
+       search != (search_dirs_type *) NULL;
        search = search->next)
     {
       char *string;
@@ -232,23 +232,32 @@ ldfile_open_file (entry)
   else
     {
       search_arch_type *arch;
+      boolean found = false;
 
       /* Try to open <filename><suffix> or lib<filename><suffix>.a */
       for (arch = search_arch_head;
           arch != (search_arch_type *) NULL;
           arch = arch->next)
        {
-         if (ldfile_open_file_search (arch->name, entry, "lib", ".a"))
-           return;
+         found = ldfile_open_file_search (arch->name, entry, "lib", ".a");
+         if (found)
+           break;
 #ifdef VMS
-         if (ldfile_open_file_search (arch->name, entry, ":lib", ".a"))
-           return;
+         found = ldfile_open_file_search (arch->name, entry, ":lib", ".a");
+         if (found)
+           break;
 #endif
-         if (ldemul_find_potential_libraries (arch->name, entry))
-           return;
+         found = ldemul_find_potential_libraries (arch->name, entry);
+         if (found)
+           break;
        }
 
-      einfo (_("%F%P: cannot find %s\n"), entry->local_sym_name);
+      /* If we have found the file, we don't need to search directories
+        again.  */
+      if (found)
+       entry->search_dirs_flag = false;
+      else
+       einfo (_("%F%P: cannot find %s\n"), entry->local_sym_name);
     }
 }
 
@@ -304,16 +313,16 @@ ldfile_find_command_file (name, extend)
   FILE *result;
   char buffer[1000];
 
-  /* First try raw name */
+  /* First try raw name */
   result = try_open (name, "");
-  if (result == (FILE *)NULL)
+  if (result == (FILE *) NULL)
     {
-      /* Try now prefixes */
+      /* Try now prefixes */
       for (search = search_head;
-          search != (search_dirs_type *)NULL;
+          search != (search_dirs_type *) NULL;
           search = search->next)
        {
-         sprintf (buffer,"%s%s%s", search->name, slash, name);
+         sprintf (buffer, "%s%s%s", search->name, slash, name);
 
          result = try_open (buffer, extend);
          if (result)
@@ -331,7 +340,7 @@ ldfile_open_command_file (name)
   FILE *ldlex_input_stack;
   ldlex_input_stack = ldfile_find_command_file (name, "");
 
-  if (ldlex_input_stack == (FILE *)NULL)
+  if (ldlex_input_stack == (FILE *) NULL)
     {
       bfd_set_error (bfd_error_system_call);
       einfo (_("%P%F: cannot open linker script file %s: %E\n"), name);
@@ -371,7 +380,7 @@ gnu960_map_archname (name)
     }
 
   if (tp->cmd_switch == NULL)
-    einfo (_("%P%F: unknown architecture: %s\n"),name);
+    einfo (_("%P%F: unknown architecture: %s\n"), name);
 
   return tp->arch;
 }
@@ -381,7 +390,7 @@ ldfile_add_arch (name)
      char *name;
 {
   search_arch_type *new =
-    (search_arch_type *)xmalloc ((bfd_size_type)(sizeof (search_arch_type)));
+    (search_arch_type *) xmalloc ((bfd_size_type) (sizeof (search_arch_type)));
 
   if (*name != '\0')
     {
@@ -394,26 +403,26 @@ ldfile_add_arch (name)
       ldfile_output_machine_name = name;
     }
 
-  new->next = (search_arch_type*)NULL;
+  new->next = (search_arch_type *) NULL;
   new->name = gnu960_map_archname (name);
   *search_arch_tail_ptr = new;
   search_arch_tail_ptr = &new->next;
 }
 
-#else  /* not GNU960 */
+#else /* not GNU960 */
 
 void
 ldfile_add_arch (in_name)
-     CONST char * in_name;
+     CONST char *in_name;
 {
-  char *name = buystring (in_name);
+  char *name = xstrdup (in_name);
   search_arch_type *new =
     (search_arch_type *) xmalloc (sizeof (search_arch_type));
 
   ldfile_output_machine_name = in_name;
 
   new->name = name;
-  new->next = (search_arch_type*)NULL;
+  new->next = (search_arch_type *) NULL;
   while (*name)
     {
       if (isupper ((unsigned char) *name))
@@ -426,7 +435,8 @@ ldfile_add_arch (in_name)
 }
 #endif
 
-/* Set the output architecture */
+/* Set the output architecture.  */
+
 void
 ldfile_set_output_arch (string)
      CONST char *string;
This page took 0.02646 seconds and 4 git commands to generate.