(our_file_name): New variable.
authorRichard Kenner <kenner@gcc.gnu.org>
Fri, 22 Jan 1993 12:56:23 +0000 (07:56 -0500)
committerRichard Kenner <kenner@gcc.gnu.org>
Fri, 22 Jan 1993 12:56:23 +0000 (07:56 -0500)
(find_a_file): Ignore filename equal to that in our_file_name.
(main): Initialize our_file_name.

From-SVN: r3299

gcc/collect2.c

index 67304010cd9d3f721102886aa2d39e586f47659d..2cd9b1762d882d009fda429669a847ef95c19e85 100644 (file)
@@ -483,6 +483,11 @@ static struct path_prefix cpath, path;
 
 static char *target_machine = TARGET_MACHINE;
 #endif
+
+/* Name under which we were executed.  Never return that file in our
+   searches.  */
+
+static char *our_file_name;
 \f
 /* Search for NAME using prefix list PPREFIX.  We only look for executable
    files. 
@@ -519,14 +524,14 @@ find_a_file (pprefix, name)
       {
        strcpy (temp, pl->prefix);
        strcat (temp, name);
-       if (access (temp, X_OK) == 0)
+       if (strcmp (temp, our_file_name) != 0 && access (temp, X_OK) == 0)
          return temp;
 
 #ifdef EXECUTABLE_SUFFIX
        /* Some systems have a suffix for executable files.
           So try appending that.  */
        strcat (temp, EXECUTABLE_SUFFIX);
-       if (access (temp, X_OK) == 0)
+       if (strcmp (temp, our_file_name) != 0 && access (temp, X_OK) == 0)
          return temp;
 #endif
       }
@@ -657,6 +662,8 @@ main (argc, argv)
   vflag = 1;
 #endif
 
+  our_file_name = argv[0];
+
   p = (char *) getenv ("COLLECT_GCC_OPTIONS");
   if (p)
     while (*p)