]> git.ipfire.org Git - thirdparty/make.git/commitdiff
cleaned up usage of filedef->update_status
authorTim Magill <magill@gate.net>
Sun, 13 Feb 2000 04:24:24 +0000 (04:24 +0000)
committerTim Magill <magill@gate.net>
Sun, 13 Feb 2000 04:24:24 +0000 (04:24 +0000)
ChangeLog
file.c
filedef.h
job.c
main.c
remake.c

index 5e789e787f840c15010165938eedba17d3cec900..6671f3fba70adaf76ffbc76f17558fce3f175312 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,28 @@
 2000-02-12  Tim Magill  <magill@gate.net>
 
+       * remake.c (update_file_1): 
+       (notice_finished_file): 
+       (remake_file): 
+
+       * main.c (main): 
+
+       * job.c (reap_children): 
+       (start_job_command): 
+
+       * file.c (enter_file)
+       (remove_intermediates): 
+       (print_file): 
+
+       * filedef.h: converted update_status field from a short int, to an
+       unsigned int :1.  previously, update status indicated whether the
+       file had actually executed any commands, won, lost, or lost under
+       -q conditions.  command_state indicates more clearly whether or
+       not any commands have been executed for this file.  lost or lost
+       under -q conditions can be determined by a combination of
+       question_flag and lost.  Thus, update_status needs only indicate
+       won or lost.
+
+
        * implicit.c (try_implicit_rule): 
        * remake.c (check_dep):
        * remake.c (update_file_1): 
diff --git a/file.c b/file.c
index 45ff8a5806ad0a7e0f33149e82f5e42b0f5311c8..e48ea71a26229e7ef571498fc1616d80f9210074 100644 (file)
--- a/file.c
+++ b/file.c
@@ -166,7 +166,7 @@ enter_file (name)
   new = (struct file *) xmalloc (sizeof (struct file));
   bzero ((char *) new, sizeof (struct file));
   new->name = new->hname = name;
-  new->update_status = -1;
+  new->update_status = 0;      /* assume the file won */
 
   if (f == 0)
     {
@@ -395,7 +395,7 @@ remove_intermediates (sig)
          && !f->secondary)
        {
          int status;
-         if (f->update_status == -1)
+         if (f->command_state == cs_not_started)
            /* If nothing would have created this file yet,
               don't print an "rm" command for it.  */
             continue;
@@ -668,26 +668,19 @@ print_file (f)
       puts (_("#  Dependencies commands running (THIS IS A BUG)."));
       break;
     case cs_not_started:
+      break;
     case cs_finished:
       switch (f->update_status)
        {
-       case -1:
-         break;
        case 0:
+         /* file won */
          puts (_("#  Successfully updated."));
          break;
        case 1:
-         assert (question_flag);
-         puts (_("#  Needs to be updated (-q is set)."));
-         break;
-       case 2:
-         puts (_("#  Failed to be updated."));
+         /* file lost */
+         puts (question_flag ? _("#  Needs to be updated (-q is set).")
+               :_("#  Failed to be updated."));
          break;
-       default:
-         puts (_("#  Invalid value in `update_status' member!"));
-         fflush (stdout);
-         fflush (stderr);
-         abort ();
        }
       break;
     default:
index cc83b0dceb48e2453235152d98de7153c8b62af0..c57add07821d60439d9796e425718b97dbf4f7b0 100644 (file)
--- a/filedef.h
+++ b/filedef.h
@@ -60,12 +60,6 @@ struct file
        the same file.  Otherwise this is null.  */
     struct file *double_colon;
 
-    short int update_status;   /* Status of the last attempt to update,
-                                  or -1 if none has been made.
-                                  0 = commands ran and won
-                                  1 = files need to be updated (-q)
-                                  2 = commands ran and lost */
-
     enum                       /* State of the commands.  */
       {                /* Note: It is important that cs_not_started be zero.  */
        cs_not_started,         /* Not yet started.  */
@@ -74,6 +68,10 @@ struct file
        cs_finished             /* Commands finished.  */
       } command_state ENUM_BITFIELD (2);
 
+
+    unsigned int update_status:1;  /* update status signifies only
+                                      whether the file won or lost */
+
     unsigned int precious:1;   /* Non-0 means don't delete file on quit */
     unsigned int tried_implicit:1; /* Nonzero if have searched
                                      for implicit rule for making
diff --git a/job.c b/job.c
index e82865ec6a06c6e4c240033b895f8394ce2308ec..cab17821d777b051c915ddfb338b00f5f98c1df6 100644 (file)
--- a/job.c
+++ b/job.c
@@ -665,7 +665,7 @@ reap_children (block, err)
              delete non-precious targets, and abort.  */
           static int delete_on_error = -1;
           child_error (c->file->name, exit_code, exit_sig, coredump, 0);
-          c->file->update_status = 2;
+          c->file->update_status = 1;
           if (delete_on_error == -1)
             {
               struct file *f = lookup_file (".DELETE_ON_ERROR");
@@ -693,7 +693,7 @@ reap_children (block, err)
                      Since there are more commands that wanted to be run,
                      the target was not completely remade.  So we treat
                      this as if a command had failed.  */
-                  c->file->update_status = 2;
+                  c->file->update_status = 1;
                 }
               else
                 {
@@ -1250,7 +1250,7 @@ start_job_command (child)
   return;
 
  error:
-  child->file->update_status = 2;
+  child->file->update_status = 1;
   notice_finished_file (child->file);
   return;
 }
diff --git a/main.c b/main.c
index 824b614f8354f0c8d122560bf43c5b712baff38a..6bdc5e07bb9420ca1ebb3f987736107f2c5ade4e 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1604,17 +1604,11 @@ int main (int argc, char ** argv)
 
       switch (update_goal_chain (read_makefiles, 1))
        {
-       case 1:
-       default:
-#define BOGUS_UPDATE_STATUS 0
-         assert (BOGUS_UPDATE_STATUS);
-         break;
-
        case -1:
          /* Did nothing.  */
          break;
 
-       case 2:
+       case 1:
          /* Failed to update.  Figure out if we care.  */
          {
            /* Nonzero if any makefile was successfully remade.  */
@@ -1834,18 +1828,19 @@ int main (int argc, char ** argv)
     {
       case -1:
         /* Nothing happened.  */
+       /* FALL THRU */
       case 0:
         /* Updated successfully.  */
         status = EXIT_SUCCESS;
         break;
-      case 2:
-        /* Updating failed.  POSIX.2 specifies exit status >1 for this;
-           but in VMS, there is only success and failure.  */
-        status = EXIT_FAILURE ? 2 : EXIT_FAILURE;
-        break;
       case 1:
+       if (question_flag)
         /* We are under -q and would run some commands.  */
-        status = EXIT_FAILURE;
+         status = EXIT_FAILURE;
+       else
+         /* Updating failed.  POSIX.2 specifies exit status >1 for this;
+            but in VMS, there is only success and failure.  */
+         status = EXIT_FAILURE ? 2 : EXIT_FAILURE;
         break;
       default:
         abort ();
index 1f0cf270d2457bc59f102174a274948e7f1dc887..2d25d901867245bfac6ebca26128470afc45b18e 100644 (file)
--- a/remake.c
+++ b/remake.c
@@ -354,7 +354,7 @@ update_file_1 (file, depth)
       return 0;
 
     case cs_finished:
-      if (file->update_status > 0)
+      if (file->update_status != 0)
        {
          DBF (DB_VERBOSE,
               _("Recently tried and failed to update file `%s'.\n"));
@@ -512,7 +512,7 @@ update_file_1 (file, depth)
 
   if (dep_status != 0)
     {
-      file->update_status = dep_status;
+      file->update_status = dep_status ? 1 : 0;
       notice_finished_file (file);
 
       depth--;
@@ -653,17 +653,15 @@ update_file_1 (file, depth)
 
   switch (file->update_status)
     {
-    case 2:
-      DBF (DB_BASIC, _("Failed to remake target file `%s'.\n"));
-      break;
     case 0:
       DBF (DB_BASIC, _("Successfully remade target file `%s'.\n"));
       break;
     case 1:
-      DBF (DB_BASIC, _("Target file `%s' needs remade under -q.\n"));
+      DBF (DB_BASIC, (question_flag ? _("Target file `%s' needs remade under -q.\n")
+                     : _("Failed to remake target file `%s'.\n")));
       break;
     default:
-      assert (file->update_status >= 0 && file->update_status <= 2);
+      assert (file->update_status >= 0 && file->update_status <= 1);
       break;
     }
 
@@ -710,7 +708,7 @@ notice_finished_file (file)
            file->update_status = 0;
          else
            /* Should set file's modification date and do nothing else.  */
-           file->update_status = touch_file (file);
+           file->update_status = touch_file (file) ? 1 : 0;
        }
     }
 
@@ -746,7 +744,7 @@ notice_finished_file (file)
        f->last_mtime = file->last_mtime;
     }
 
-  if (ran && file->update_status != -1)
+  if (ran)
     /* We actually tried to update FILE, which has
        updated its also_make's as well (if it worked).
        If it didn't work, it wouldn't work again for them.
@@ -763,10 +761,6 @@ notice_finished_file (file)
             never be done because the target is already updated.  */
          (void) f_mtime (d->file, 0);
       }
-  else if (file->update_status == -1)
-    /* Nothing was done for FILE, but it needed nothing done.
-       So mark it now as "succeeded".  */
-    file->update_status = 0;
 }
 \f
 /* Check whether another file (whose mtime is THIS_MTIME)
@@ -978,7 +972,7 @@ remake_file (file)
                 error (NILF, msg_parent, "*** ",
                        file->name, file->parent->name, ".");
             }
-          file->update_status = 2;
+          file->update_status = 1;
         }
     }
   else