* Ignore attempt to change a file into itself.
authorPaul Smith <psmith@gnu.org>
Sun, 26 Mar 2000 06:56:54 +0000 (06:56 +0000)
committerPaul Smith <psmith@gnu.org>
Sun, 26 Mar 2000 06:56:54 +0000 (06:56 +0000)
* Define COFLAGS to avoid unknown variable warning.
* Fix some usec problems on UnixWare.
* Don't remove .INTERMEDIATE targets specified on the command line.

ChangeLog
default.c
file.c
filedef.h
make.h
tests/ChangeLog
tests/scripts/targets/INTERMEDIATE

index cc7cd75..1a9afd9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2000-03-26  Paul D. Smith  <psmith@gnu.org>
+
+       * file.c (remove_intermediates): Never remove targets explicitly
+       requested on the command-line by checking the cmd_target flag.
+       Fixed PR/1669.
+
+2000-03-23  Paul Eggert  <eggert@twinsun.com>
+
+       * filedef.h (FILE_TIMESTAMP_STAT_MODTIME): Don't use
+       st_mtim.tv_sec; this doesn't work on Unixware.
+
+2000-03-18  Paul D. Smith  <psmith@gnu.org>
+
+       * file.c (file_hash_enter): If we're trying to change a file into
+       itself, just return.  We used to assert this wasn't true, but
+       someone came up with a weird case involving archives.  After
+       playing with it for a while I decided it was OK to ignore it.
+
+       * default.c: Define COFLAGS to empty to avoid spurious warnings.
+
+       * filedef.h: Change #if ST_MTIM_NSEC to #ifdef; this is a macro
+       containing the name of the nsec field, not true/false.
+       * make.h: Ditto.
+       Reported by Marco Franzen <Marco.Franzen@Thyron.com>.
+
 2000-02-09  Paul D. Smith  <psmith@gnu.org>
 
        * Version 3.78.91 released.
index 517d325..5d981b9 100644 (file)
--- a/default.c
+++ b/default.c
@@ -396,10 +396,10 @@ static char *default_variables[] =
 
     /* This expands to $(CO) $(COFLAGS) $< $@ if $@ does not exist,
        and to the empty string if $@ does exist.  */
-    "CHECKOUT,v",
-    "+$(if $(wildcard $@),,$(CO) $(COFLAGS) $< $@)",
-
+    "CHECKOUT,v", "+$(if $(wildcard $@),,$(CO) $(COFLAGS) $< $@)",
     "CO", "co",
+    "COFLAGS", "",
+
     "CPP", "$(CC) -E",
 #ifdef CRAY
     "CF77PPFLAGS", "-P",
diff --git a/file.c b/file.c
index a1003a9..c64db0b 100644 (file)
--- a/file.c
+++ b/file.c
@@ -128,8 +128,7 @@ enter_file (name)
   char *lname, *ln;
 #endif
 
-  if (*name == '\0')
-    abort ();
+  assert (*name != '\0');
 
 #if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
   lname = (char *)malloc (strlen (name) + 1);
@@ -252,8 +251,9 @@ file_hash_enter (file, name, oldhash, oldname)
     if (strieq (oldfile->hname, name))
       break;
 
-  /* If the old file is the same as the new file, something's wrong.  */
-  assert (oldfile != file);
+  /* If the old file is the same as the new file, never mind.  */
+  if (oldfile == file)
+    return;
 
   if (oldhash != 0 && (newbucket != oldbucket || oldfile != 0))
     {
@@ -394,7 +394,7 @@ remove_intermediates (sig)
   for (i = 0; i < FILE_BUCKETS; ++i)
     for (f = files[i]; f != 0; f = f->next)
       if (f->intermediate && (f->dontcare || !f->precious)
-         && !f->secondary)
+         && !f->secondary && !f->cmd_target)
        {
          int status;
          if (f->update_status == -1)
index 8712e98..9391818 100644 (file)
--- a/filedef.h
+++ b/filedef.h
@@ -117,9 +117,9 @@ extern void set_command_state PARAMS ((struct file *file, int state));
 extern void notice_finished_file PARAMS ((struct file *file));
 
 
-#if ST_MTIM_NSEC
+#ifdef ST_MTIM_NSEC
 # define FILE_TIMESTAMP_STAT_MODTIME(st) \
-    FILE_TIMESTAMP_FROM_S_AND_NS ((st).st_mtim.tv_sec, \
+    FILE_TIMESTAMP_FROM_S_AND_NS ((st).st_mtime, \
                                   (st).st_mtim.ST_MTIM_NSEC)
 # define FILE_TIMESTAMPS_PER_S \
     MIN ((FILE_TIMESTAMP) 1000000000, \
diff --git a/make.h b/make.h
index 3b79d5d..62aa8ed 100644 (file)
--- a/make.h
+++ b/make.h
@@ -275,7 +275,7 @@ extern char *alloca ();
 # endif /* HAVE_ALLOCA_H.  */
 #endif /* GCC.  */
 
-#if ST_MTIM_NSEC
+#ifdef ST_MTIM_NSEC
 # if HAVE_INTTYPES_H
 #  include <inttypes.h>
 # endif
index 6fba7ea..4d859ad 100644 (file)
@@ -1,3 +1,8 @@
+2000-03-26  Paul D. Smith  <psmith@gnu.org>
+
+       * scripts/targets/INTERMEDIATE: Test that make doesn't remove
+       .INTERMEDIATE files when given on the command line (PR/1669).
+
 2000-02-07  Paul D. Smith  <psmith@gnu.org>
 
        * scripts/features/escape: Add a test for backslash-escaped spaces
index 7041e83..fe3f4e9 100644 (file)
@@ -77,9 +77,15 @@ sleep($wtime);
 $answer = "cp foo.f foo.e\ncp bar.f bar.e\ncat foo.e bar.e > foo.c\nrm foo.e bar.e\n";
 &compare_output($answer, &get_logfile(1));
 
+# TEST #6 -- added for PR/1669: don't remove files mentioned on the cmd line.
+
+&run_make_with_options($makefile,'foo.e',&get_logfile);
+$answer = "cp foo.f foo.e\n";
+&compare_output($answer, &get_logfile(1));
+
 unlink('foo.f', 'foo.e', 'foo.d', 'foo.c', 'bar.f', 'bar.e', 'bar.d', 'bar.c');
 
-# TEST #6 -- added for PR/1423
+# TEST #7 -- added for PR/1423
 
 $makefile2 = &get_tmpfile;
 
@@ -94,7 +100,7 @@ EOF
 
 close(MAKEFILE);
 
-&run_make_with_options($makefile2, "-R", &get_logfile);
+&run_make_with_options($makefile2, '-R', &get_logfile);
 $answer = "touch foo.a\ntouch foo\nrm foo.a\n";
 &compare_output($answer, &get_logfile(1));