OSDN Git Service

* collect2.c: #include "gansidecl.h".
authordje <dje@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 15 Apr 1996 17:49:08 +0000 (17:49 +0000)
committerdje <dje@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 15 Apr 1996 17:49:08 +0000 (17:49 +0000)
(const,PROTO): Delete.
(P_tmpdir): Delete.
(choose_temp_base): Declare as extern, delete internal copy.
(main): Update call to choose_temp_base.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@11789 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/collect2.c

index e351dbc..59ea363 100644 (file)
@@ -40,6 +40,7 @@ Boston, MA 02111-1307, USA.  */
 
 #include "demangle.h"
 #include "obstack.h"
+#include "gansidecl.h"
 
 #ifndef errno
 extern int errno;
@@ -60,23 +61,10 @@ char *strerror();
 #define obstack_chunk_alloc xmalloc
 #define obstack_chunk_free free
 
-#if !defined (__STDC__) && !defined (const)
-#define const
-#endif
-
 #ifdef USG
 #define vfork fork
 #endif
 
-/* Add prototype support.  */
-#ifndef PROTO
-#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
-#define PROTO(ARGS) ARGS
-#else
-#define PROTO(ARGS) ()
-#endif
-#endif
-
 #ifndef R_OK
 #define R_OK 4
 #define W_OK 2
@@ -96,13 +84,7 @@ char *strerror();
 #define WEXITSTATUS(S) (((S) & 0xff00) >> 8)
 #endif
 
-/* On MSDOS, write temp files in current dir
-   because there's no place else we can expect to use.  */
-#ifdef __MSDOS__
-#ifndef P_tmpdir
-#define P_tmpdir "./"
-#endif
-#endif
+extern char *choose_temp_base ();
 \f
 /* On certain systems, we have code that works by scanning the object file
    directly.  But this code uses system-specific header files and library
@@ -296,7 +278,6 @@ void collect_execute                PROTO((char *, char **, char *));
 void dump_file                 PROTO((char *));
 static void handler            PROTO((int));
 static int is_ctor_dtor                PROTO((char *));
-static void choose_temp_base   PROTO((void));
 static int is_in_prefix_list   PROTO((struct path_prefix *, char *, int));
 static char *find_a_file       PROTO((struct path_prefix *, char *));
 static void add_prefix         PROTO((struct path_prefix *, char *));
@@ -625,42 +606,6 @@ is_ctor_dtor (s)
     }
   return 0;
 }
-
-\f
-/* Compute a string to use as the base of all temporary file names.
-   It is substituted for %g.  */
-
-static void
-choose_temp_base ()
-{
-  char *base = getenv ("TMPDIR");
-  int len;
-
-  if (base == (char *)0)
-    {
-#ifdef P_tmpdir
-      if (access (P_tmpdir, R_OK | W_OK) == 0)
-       base = P_tmpdir;
-#endif
-      if (base == (char *)0)
-       {
-         if (access ("/usr/tmp", R_OK | W_OK) == 0)
-           base = "/usr/tmp/";
-         else
-           base = "/tmp/";
-       }
-    }
-
-  len = strlen (base);
-  temp_filename = xmalloc (len + sizeof("/ccXXXXXX") + 1);
-  strcpy (temp_filename, base);
-  if (len > 0 && temp_filename[len-1] != '/')
-    temp_filename[len++] = '/';
-  strcpy (temp_filename + len, "ccXXXXXX");
-
-  mktemp (temp_filename);
-  temp_filename_length = strlen (temp_filename);
-}
 \f
 /* Routine to add variables to the environment.  */
 
@@ -1200,7 +1145,8 @@ main (argc, argv)
   *ld1++ = *ld2++ = ld_file_name;
 
   /* Make temp file names. */
-  choose_temp_base ();
+  temp_filename = choose_temp_base ();
+  temp_filename_length = strlen (temp_filename);
   c_file = xcalloc (temp_filename_length + sizeof (".c"), 1);
   o_file = xcalloc (temp_filename_length + sizeof (".o"), 1);
   export_file = xmalloc (temp_filename_length + sizeof (".x"));