cvs commit: ALFS/nALFS/src libXML-tree.c parser.c parser.h

kpfleming at linuxfromscratch.org kpfleming at linuxfromscratch.org
Thu Feb 12 20:26:41 PST 2004


kpfleming    04/02/12 21:26:41

  Modified:    nALFS/src libXML-tree.c parser.c parser.h
  Log:
  add profile pointer to element structure, so get_profile_by_element can quickly return profile containing element
  
  Revision  Changes    Path
  1.7       +6 -5      ALFS/nALFS/src/libXML-tree.c
  
  Index: libXML-tree.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/libXML-tree.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- libXML-tree.c	13 Feb 2004 02:46:53 -0000	1.6
  +++ libXML-tree.c	13 Feb 2004 04:26:41 -0000	1.7
  @@ -177,7 +177,7 @@
   	return el;
   }
   
  -static element_s *convert_nodes(xmlNodePtr node)
  +static element_s *convert_nodes(xmlNodePtr node, element_s *profile)
   {
   	element_s *el, *c, *prev = NULL;
   	xmlNodePtr child;
  @@ -190,8 +190,8 @@
   	el = create_element(node);
   
   	for (child = node->children; child; child = child->next) {
  -		if ((c = convert_nodes(child))) {
  -			link_element(c, prev, el);
  +		if ((c = convert_nodes(child, profile))) {
  +			link_element(c, prev, el, profile);
   
   			prev = c;
   		}
  @@ -219,10 +219,11 @@
   
   	profile->type = TYPE_PROFILE;
   	profile->id = element_id++;
  +	profile->profile = profile;
   
   	for (child = doc->children; child; child = child->next) {
  -		if ((el = convert_nodes(child))) {
  -			link_element(el, prev, profile);
  +		if ((el = convert_nodes(child, profile))) {
  +			link_element(el, prev, profile, profile);
   
   			prev = el;
   		}
  
  
  
  1.6       +5 -10     ALFS/nALFS/src/parser.c
  
  Index: parser.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/parser.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- parser.c	3 Nov 2003 21:45:04 -0000	1.5
  +++ parser.c	13 Feb 2004 04:26:41 -0000	1.6
  @@ -107,7 +107,8 @@
   }
   
   /* Link new element. */
  -void link_element(element_s *el, element_s *prev, element_s *parent)
  +void link_element(element_s *el, element_s *prev, element_s *parent,
  +		  element_s *profile)
   {
   	/* Parent<->Child */
   	if (parent) {
  @@ -124,6 +125,8 @@
   
   		prev->next = el;
   	}
  +
  +	el->profile = profile;
   }
   
   static void append_el_parents(char **el_path, element_s *el)
  @@ -257,15 +260,7 @@
   
   element_s *get_profile_by_element(element_s *el)
   {
  -	for (; el; el = el->parent) {
  -		if (el->type == TYPE_PROFILE && !el->parent->parent) {
  -			return el;
  -		}
  -	}
  -
  -	ASSERT(0); /* Shouldn't be reached. */
  -
  -	return NULL;
  +	return el->profile;
   }
   
   element_s *get_profile_by_name(element_s *root, const char *name)
  
  
  
  1.5       +3 -1      ALFS/nALFS/src/parser.h
  
  Index: parser.h
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/parser.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- parser.h	13 Feb 2004 02:46:53 -0000	1.4
  +++ parser.h	13 Feb 2004 04:26:41 -0000	1.5
  @@ -75,12 +75,14 @@
   	struct element_s *children;
   	struct element_s *prev;
   	struct element_s *next;
  +	struct element_s *profile;
   } element_s;
   
   
   element_s *init_new_element(void);
   void free_element(element_s *el);
  -void link_element(element_s *el, element_s *prev, element_s *parent);
  +void link_element(element_s *el, element_s *prev, element_s *parent,
  +		  element_s *profile);
   element_s *parse_profile(const char *filename);
   
   char *attr_value(const char *name, element_s *element);
  
  
  



More information about the alfs-log mailing list