cvs commit: ALFS/nALFS/src backend.c nalfs.c parser.h

kpfleming at linuxfromscratch.org kpfleming at linuxfromscratch.org
Sat Mar 27 11:51:56 PST 2004


kpfleming    04/03/27 12:51:56

  Modified:    nALFS/src backend.c nalfs.c parser.h
  Log:
  eliminate unneeded Can_run macro
  rebuild element "run status" computation
  
  Revision  Changes    Path
  1.18      +1 -5      ALFS/nALFS/src/backend.c
  
  Index: backend.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/backend.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- backend.c	21 Mar 2004 04:38:52 -0000	1.17
  +++ backend.c	27 Mar 2004 19:51:56 -0000	1.18
  @@ -356,7 +356,7 @@
   {
   	int i = 0;
   
  -	if (! (Can_run(el) && el->should_run)) {
  +	if (!el->should_run) {
   		return 0;
   	}
   
  @@ -399,10 +399,6 @@
   int do_execute_test_element(element_s *element, int *result)
   {
   	int i = 0;
  -
  -	if (! (Can_run(element) && element->should_run)) {
  -		return 0;
  -	}
   
   	comm_send_ctrl_msg(BACKEND_CTRL_SOCK, CTRL_ELEMENT_STARTED, "%d", element->id);
   
  
  
  
  1.54      +36 -58    ALFS/nALFS/src/nalfs.c
  
  Index: nalfs.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/nalfs.c,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- nalfs.c	27 Mar 2004 06:59:06 -0000	1.53
  +++ nalfs.c	27 Mar 2004 19:51:56 -0000	1.54
  @@ -253,9 +253,7 @@
   	element_s *parent;
   
   
  -	if (Can_run(el)) {
  -		do_mark_element(el, el->marked ? 0 : 1);
  -	}
  +	do_mark_element(el, el->marked ? 0 : 1);
   
   	/* Mark/unmark all our parents, if needed. */
   	for (parent = el->parent; parent; parent = parent->parent) {
  @@ -354,9 +352,8 @@
   
   static void set_run_status(element_s *el, run_status_e status)
   {
  -	if (!Can_run(el) || !*opt_run_interactive) {
  +	if (!*opt_run_interactive)
   		return;
  -	}
   
   	/* Change status. */
   	el->run_status = status;
  @@ -365,46 +362,43 @@
   	change_run_status_mark(el, status);
   }
   
  -static int has_child_with_run_status(element_s *el, run_status_e status)
  +run_status_e get_element_status(element_s *el)
   {
   	element_s *child;
  -
  +	int child_normal = 0;
  +	int child_status_none = 0;
  +	int child_status_some_done = 0;
  +	int child_status_done = 0;
  +	run_status_e status = RUN_STATUS_NONE;
   
   	for (child = el->children; child; child = child->next) {
  -		if (Can_run(child) && child->run_status == status) {
  -			return 1;
  +		if ((child->handler->type & HTYPE_NORMAL) == 0)
  +			continue;
  +		child_normal++;
  +		switch (child->run_status) {
  +		case RUN_STATUS_RUNNING:
  +			return child->run_status;
  +		case RUN_STATUS_FAILED:
  +			return child->run_status;
  +		case RUN_STATUS_NONE:
  +			child_status_none++;
  +			break;
  +		case RUN_STATUS_DONE:
  +			child_status_done++;
  +			break;
  +		case RUN_STATUS_SOME_DONE:
  +			child_status_some_done++;
  +			break;
   		}
   	}
   
  -	return 0;
  -}
  -
  -run_status_e get_element_status(element_s *el)
  -{
  -	run_status_e status;
  -
  -
  -	if (! el->children) {
  +	if (child_normal == 0)
   		status = RUN_STATUS_DONE;
  -
  -	} else if (has_child_with_run_status(el, RUN_STATUS_RUNNING)) {
  -		status = RUN_STATUS_RUNNING;
  -
  -	} else if (has_child_with_run_status(el, RUN_STATUS_FAILED)) {
  -		status = RUN_STATUS_FAILED;
  -
  -	} else if (! has_child_with_run_status(el, RUN_STATUS_NONE)
  -	&& ! has_child_with_run_status(el, RUN_STATUS_SOME_DONE)) {
  +	else if (child_status_done == child_normal)
   		status = RUN_STATUS_DONE;
  -
  -	} else if (has_child_with_run_status(el, RUN_STATUS_DONE)
  -	|| has_child_with_run_status(el, RUN_STATUS_SOME_DONE)) {
  +	else if ((child_status_done + child_status_some_done) != 0)
   		status = RUN_STATUS_SOME_DONE;
   
  -	} else {
  -		status = RUN_STATUS_NONE;
  -	}
  -
   	return status;
   }
   
  @@ -412,10 +406,7 @@
   {
   	element_s *child;
   
  -
  -	if (Can_run(el)) {
  -		el->run_status = status;
  -	}
  +	el->run_status = status;
   
   	for (child = el->children; child; child = child->next) {
   		do_change_run_status_marks(child, status);
  @@ -431,9 +422,7 @@
   
   	/* Update the marks of element's parents. */
   	for (parent = el->parent; parent; parent = parent->parent) {
  -		if (Can_run(parent)) {
  -			parent->run_status = get_element_status(parent);
  -		}
  +		parent->run_status = get_element_status(parent);
   	}
   }
   
  @@ -2859,9 +2848,11 @@
   	element_s *child;
   
   
  -	if (el->run_status == RUN_STATUS_DONE || ! Can_run(el)) {
  +	if (el->run_status == RUN_STATUS_DONE)
  +		return;
  +
  +	if ((el->handler->type & HTYPE_NORMAL) == 0)
   		return;
  -	}
   
   	el->should_run = 1;
   
  @@ -2901,18 +2892,16 @@
   {
   	element_s *parent;
   
  -
   	if (el->run_status == RUN_STATUS_DONE) {
   		Nprint_warn("Nothing to run. "
   		"Use 's' -> 'f' to force running of already run elements.");
   		return;
   	}
  -	if (! Can_run(el)) {
  +	if ((el->handler->type & HTYPE_NORMAL) == 0) {
   		Nprint_warn("This is not an element that can run.");
   		return;
   	}
   
  -
   	/* Mark all element parents. */
   	for (parent = el->parent; parent; parent = parent->parent) {
   		parent->should_run = 1;
  @@ -2939,7 +2928,7 @@
   		"Use 's' -> 'f' to force running of already run elements.");
   		return;
   	}
  -	if (! Can_run(el)) {
  +	if ((el->handler->type & HTYPE_NORMAL) == 0) {
   		Nprint_warn("This is not an element that can run.");
   		return;
   	}
  @@ -3604,12 +3593,6 @@
   				start_executing_next(Current_element);
   
   			} else if (input == 'f') {
  -				if (! Can_run(Current_element)) {
  -					Nprint_warn(
  -					"This is not an element that can run.");
  -					break;
  -				}
  -
   				clear_done_run_status(Current_element);
   				rewrite_main();
   
  @@ -3755,11 +3738,6 @@
   			break;
   #endif
   		case 'm': /* Change run-status marks. */
  -			if (! Can_run(Current_element)) {
  -				Nprint("Wrong element type.");
  -				break;
  -			}
  -
   			if (Current_element->should_run) {
   				Nprint_warn("Can't change status mark "
   				"of this element now - it's marked for "
  
  
  
  1.14      +0 -5      ALFS/nALFS/src/parser.h
  
  Index: parser.h
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/parser.h,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- parser.h	21 Mar 2004 18:40:32 -0000	1.13
  +++ parser.h	27 Mar 2004 19:51:56 -0000	1.14
  @@ -25,11 +25,6 @@
   #define H_PARSER_
   
   
  -#define Can_run(el) ( \
  -	(el)->type == TYPE_ELEMENT || \
  -	(el)->type == TYPE_PROFILE || \
  -	(el)->type == TYPE_ROOT )
  -
   #define Is_element_name(el,str) \
   	(el->type == TYPE_ELEMENT && strcmp(el->handler->name, str) == 0)
   
  
  
  



More information about the alfs-log mailing list