summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Magill <magill@gate.net>2000-02-13 04:24:24 +0000
committerTim Magill <magill@gate.net>2000-02-13 04:24:24 +0000
commit5ed230d3f8c277c0c359a0423e5a4cd690b117da (patch)
tree4283067bf557af7ce0ec103a1ea4d1e6cb253d7e
parentb0e3148933fd6e04b3ac447c79edace8b624a3e0 (diff)
downloadmake-git-5ed230d3f8c277c0c359a0423e5a4cd690b117da.tar.gz
cleaned up usage of filedef->update_status
-rw-r--r--ChangeLog23
-rw-r--r--file.c21
-rw-r--r--filedef.h10
-rw-r--r--job.c6
-rw-r--r--main.c21
-rw-r--r--remake.c22
6 files changed, 53 insertions, 50 deletions
diff --git a/ChangeLog b/ChangeLog
index 5e789e78..6671f3fb 100644
--- 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 45ff8a58..e48ea71a 100644
--- 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:
diff --git a/filedef.h b/filedef.h
index cc83b0dc..c57add07 100644
--- 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 e82865ec..cab17821 100644
--- 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 824b614f..6bdc5e07 100644
--- 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 ();
diff --git a/remake.c b/remake.c
index 1f0cf270..2d25d901 100644
--- 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;
}
/* 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