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

kpfleming at linuxfromscratch.org kpfleming at linuxfromscratch.org
Mon Feb 23 13:35:41 PST 2004


kpfleming    04/02/23 14:35:41

  Modified:    nALFS/src libXML-tree.c
  Log:
  clean up checking for empty attributes and parameters
  
  Revision  Changes    Path
  1.14      +21 -15    ALFS/nALFS/src/libXML-tree.c
  
  Index: libXML-tree.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/libXML-tree.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- libXML-tree.c	23 Feb 2004 21:19:35 -0000	1.13
  +++ libXML-tree.c	23 Feb 2004 21:35:41 -0000	1.14
  @@ -152,9 +152,8 @@
   static int parse_node_attributes(xmlNodePtr node, element_s *element)
   {
   	handler_info_s *handler = element->handler;
  -	xmlAttrPtr attr;
  -	const struct handler_attribute *handler_attr;
  -	const char *content;
  +	xmlAttrPtr prop;
  +	const struct handler_attribute *attr;
   	int result;
   
   	/* Pass any attributes present in the node to the
  @@ -162,22 +161,26 @@
   	   any data associated with them.
   	*/
   
  -	for (attr = node->properties; attr; attr = attr->next) {
  -		handler_attr = find_handler_attribute(handler,
  -						      (const char *) attr->name);
  -		if (!handler_attr) {
  -			Nprint_warn("<%s>: \"%s\" attribute is not supported.", handler->name, (const char *) attr->name);
  +	for (prop = node->properties; prop; prop = prop->next) {
  +		const char *content = NULL;
  +
  +		attr = find_handler_attribute(handler,
  +					      (const char *) prop->name);
  +		if (!attr) {
  +			Nprint_warn("<%s>: \"%s\" attribute is not supported.", handler->name, (const char *) prop->name);
   			continue;
   		}
   		
  -		content = (const char *) attr->children->content;
  +		if (prop->children && prop->children->content)
  +			content = (const char *) prop->children->content;
   
  -		if ((!handler_attr->content_optional) && (strlen(content) == 0)) {
  -			Nprint_err("<%s>: \"%s\" attribute cannot be empty.", handler->name, handler_attr->name);
  +		if (!attr->content_optional && (!content ||
  +						(strlen(content) == 0))) {
  +			Nprint_err("<%s>: \"%s\" attribute cannot be empty.", handler->name, attr->name);
   			return 1;
   		}
   
  -		result = handler->attribute(element, handler_attr, content);
  +		result = handler->attribute(element, attr, content);
   		if (result)
   			return result;
   	}
  @@ -190,7 +193,6 @@
   	handler_info_s *handler = element->handler;
   	xmlNodePtr child;
   	const struct handler_parameter *param;
  -	const char *content;
   	int result;
   
   	/* Check all elements inside the node to see if they are
  @@ -206,9 +208,13 @@
   					       (const char *) child->name);
   
   		if (param) {
  -			content = (const char *) child->children->content;
  +			const char *content = NULL;
  +
  +			if (child->children && child->children->content)
  +				content = (const char *) child->children->content;
   
  -			if ((!param->content_optional) && (strlen(content) == 0)) {
  +			if (!param->content_optional && (!content ||
  +							 (strlen(content) == 0))) {
   				Nprint_err("<%s>: \"%s\" parameter cannot be empty.", handler->name, param->name);
   				return 1;
   			}
  
  
  



More information about the alfs-log mailing list