cvs commit: ALFS/nALFS/src/handlers textdump.c

kpfleming at linuxfromscratch.org kpfleming at linuxfromscratch.org
Sat Apr 3 12:54:44 PST 2004


kpfleming    04/04/03 13:54:44

  Modified:    nALFS/src libXML-tree.c
               nALFS/src/handlers textdump.c
  Log:
  add display details to <textdump> handler
  make content parameter for <textdump> be whitespace-trimmed
  clean up XML text content retrieval
  
  Revision  Changes    Path
  1.29      +5 -8      ALFS/nALFS/src/libXML-tree.c
  
  Index: libXML-tree.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/libXML-tree.c,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- libXML-tree.c	3 Apr 2004 16:23:04 -0000	1.28
  +++ libXML-tree.c	3 Apr 2004 20:54:44 -0000	1.29
  @@ -159,10 +159,8 @@
   			const char *content = NULL;
   			xmlNodePtr free_child;
   
  -			if (child->children &&
  -			    child->children->type == XML_TEXT_NODE &&
  -			    child->children->next == NULL)
  -				xml_content = xmlNodeGetContent(child);
  +			if (child->children && xmlNodeIsText(child->children))
  +				xml_content = xmlNodeGetContent(child->children);
   
   			if (xml_content) {
   				if (param->untrimmed) {
  @@ -231,10 +229,9 @@
   
   			if (node->type == XML_COMMENT_NODE) {
   				content = xmlNodeGetContent(node);
  -			} else if (node->children
  -				   && node->children->type == XML_TEXT_NODE
  -				   && node->children->next == NULL) {
  -				content = xmlNodeGetContent(node);
  +			} else if (node->children &&
  +				   xmlNodeIsText(node->children)) {
  +				content = xmlNodeGetContent(node->children);
   			}
   			if (content) {
   				result = handler->content(element,
  
  
  
  1.29      +19 -6     ALFS/nALFS/src/handlers/textdump.c
  
  Index: textdump.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/textdump.c,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- textdump.c	21 Mar 2004 03:40:52 -0000	1.28
  +++ textdump.c	3 Apr 2004 20:54:44 -0000	1.29
  @@ -54,7 +54,7 @@
   static const struct handler_parameter textdump_parameters_v2[] = {
   	{ .name = "base", .private = TEXTDUMP_BASE },
   	{ .name = "file", .private = TEXTDUMP_FILE },
  -	{ .name = "content", .private = TEXTDUMP_CONTENT, .untrimmed = 1 },
  +	{ .name = "content", .private = TEXTDUMP_CONTENT },
   	{ .name = NULL }
   };
   
  @@ -69,7 +69,7 @@
   
   static const struct handler_parameter textdump_parameters_v3[] = {
   	{ .name = "file", .private = TEXTDUMP_FILE },
  -	{ .name = "content", .private = TEXTDUMP_CONTENT, .untrimmed = 1 },
  +	{ .name = "content", .private = TEXTDUMP_CONTENT },
   	{ .name = NULL }
   };
   
  @@ -224,6 +224,19 @@
   	struct textdump_data *data = (struct textdump_data *) element->handler_data;
   
   	switch (data_requested) {
  +	case HDATA_DISPLAY_DETAILS:
  +	{
  +		char *display = NULL;
  +
  +		if (data->base)
  +			append_str_format(&display, "Base directory: %s\n", data->base);
  +		append_str_format(&display, "File: %s (%s)\n", data->file,
  +				  (data->append_mode) ? "append" : "overwrite");
  +
  +		append_str_format(&display, "Content:\n%s\n", data->content);
  +
  +		return display;
  +	}
   	case HDATA_DISPLAY_NAME:
   	{
   		char *display = NULL;
  @@ -250,7 +263,7 @@
   		.description = "Dump text",
   		.syntax_version = "2.0",
   		.type = HTYPE_NORMAL,
  -		.data = HDATA_DISPLAY_NAME,
  +		.data = HDATA_DISPLAY_NAME | HDATA_DISPLAY_DETAILS,
   		.alloc_data = textdump_data,
   		.is_action = 1,
   		.main = textdump_main,
  @@ -269,7 +282,7 @@
   		.description = "Dump text",
   		.syntax_version = "3.0",
   		.type = HTYPE_NORMAL,
  -		.data = HDATA_DISPLAY_NAME,
  +		.data = HDATA_DISPLAY_NAME | HDATA_DISPLAY_DETAILS,
   		.alloc_data = textdump_data,
   		.is_action = 1,
   		.main = textdump_main,
  @@ -288,7 +301,7 @@
   		.description = "Dump text",
   		.syntax_version = "3.1",
   		.type = HTYPE_NORMAL,
  -		.data = HDATA_DISPLAY_NAME,
  +		.data = HDATA_DISPLAY_NAME | HDATA_DISPLAY_DETAILS,
   		.alloc_data = textdump_data,
   		.is_action = 1,
   		.main = textdump_main,
  @@ -307,7 +320,7 @@
   		.description = "Dump text",
   		.syntax_version = "3.2",
   		.type = HTYPE_NORMAL,
  -		.data = HDATA_DISPLAY_NAME,
  +		.data = HDATA_DISPLAY_NAME | HDATA_DISPLAY_DETAILS,
   		.alloc_data = textdump_data,
   		.is_action = 1,
   		.alternate_shell = 1,
  
  
  



More information about the alfs-log mailing list