aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTom Wood <wood@gnu.org>1992-12-08 13:34:05 +0000
committerTom Wood <wood@gnu.org>1992-12-08 13:34:05 +0000
commitfb2660307dc8c9417390e2c6810cf2ed3a13635c (patch)
tree75c8cee72e0144f1c58a18d2f678753f74721209 /gcc
parent164c8956a0bc23d8bfc8532baa32b9a8b1adc08e (diff)
downloadgcc-fb2660307dc8c9417390e2c6810cf2ed3a13635c.zip
gcc-fb2660307dc8c9417390e2c6810cf2ed3a13635c.tar.gz
gcc-fb2660307dc8c9417390e2c6810cf2ed3a13635c.tar.bz2
(temp_names): New variable.
(do_spec_1): Rewrite MKTEMP_EACH_FILE for %g/%u/%U. (choose_temp_base): Abort if mktemp yields a null string. From-SVN: r2847
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gcc.c56
1 files changed, 48 insertions, 8 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 1463f2b..80d3edd 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -836,6 +836,18 @@ static int argbuf_length;
static int argbuf_index;
+/* This is the list of suffixes and codes (%g/%u/%U) and the associated
+ temp file. Used only if MKTEMP_EACH_FILE. */
+
+static struct temp_name {
+ char *suffix; /* suffix associated with the code. */
+ int length; /* strlen (suffix). */
+ int unique; /* Indicates whether %g or %u/%U was used. */
+ char *filename; /* associated filename. */
+ int filename_length; /* strlen (filename). */
+ struct temp_name *next;
+} *temp_names;
+
/* Number of commands executed so far. */
static int execution_count;
@@ -1130,6 +1142,8 @@ choose_temp_base ()
mktemp (temp_filename);
temp_filename_length = strlen (temp_filename);
+ if (temp_filename_length == 0)
+ abort ();
}
@@ -2545,16 +2559,42 @@ do_spec_1 (spec, inswitch, soft_matched_part)
obstack_grow (&obstack, input_basename, basename_length);
else
{
-#ifdef MKTEMP_EACH_FILE /* ??? This has a problem: the total number of
- values mktemp can return is limited.
- That matters for the names of object files.
- In 2.4, do something about that. */
- /* Choose a new temp_filename, but get rid of the
- suffix that the spec wants to add to it. */
- choose_temp_base ();
+#ifdef MKTEMP_EACH_FILE
+ /* ??? This has a problem: the total number of
+ values mktemp can return is limited.
+ That matters for the names of object files.
+ In 2.4, do something about that. */
+ struct temp_name *t;
+ char *suffix = p;
while (*p == '.' || isalpha (*p))
p++;
- obstack_grow (&obstack, temp_filename, temp_filename_length);
+
+ /* See if we already have an association of %g/%u/%U and
+ suffix. */
+ for (t = temp_names; t; t = t->next)
+ if (t->length == p - suffix
+ && strncmp (t->suffix, suffix, p - suffix) == 0
+ && t->unique == (c != 'g'))
+ break;
+
+ /* Make a new association if needed. %u requires one. */
+ if (t == 0 || c == 'u')
+ {
+ if (t == 0)
+ {
+ t = (struct temp_name *) xmalloc (sizeof (struct temp_name));
+ t->next = temp_names;
+ temp_names = t;
+ }
+ t->length = p - suffix;
+ t->suffix = save_string (suffix, p - suffix);
+ t->unique = (c != 'g');
+ choose_temp_base ();
+ t->filename = temp_filename;
+ t->filename_length = temp_filename_length;
+ }
+
+ obstack_grow (&obstack, t->filename, t->filename_length);
delete_this_arg = 1;
#else
obstack_grow (&obstack, temp_filename, temp_filename_length);