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

kpfleming at linuxfromscratch.org kpfleming at linuxfromscratch.org
Sat Mar 13 22:11:07 PST 2004


kpfleming    04/03/13 23:11:07

  Modified:    nALFS/src handlers.h libXML-tree.c
               nALFS/src/handlers search_replace.c setenv.c textdump.c
  Log:
  provide handler-selectable trimming of attribute and parameter values
  
  Revision  Changes    Path
  1.27      +2 -0      ALFS/nALFS/src/handlers.h
  
  Index: handlers.h
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers.h,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- handlers.h	14 Mar 2004 05:40:27 -0000	1.26
  +++ handlers.h	14 Mar 2004 06:11:07 -0000	1.27
  @@ -58,12 +58,14 @@
   	const char * const name;
   	const int private;		/* Internal to handler. */
   	const int content_optional;
  +	const int untrimmed;		/* handler wants raw content */
   };
   
   struct handler_parameter {
   	const char * const name;
   	const int private;		/* Internal to handler. */
   	const int content_optional;
  +	const int untrimmed;		/* handler wants raw content */
   };
   
   typedef char *(*handler_data_f)(const element_s * const element,
  
  
  
  1.19      +18 -4     ALFS/nALFS/src/libXML-tree.c
  
  Index: libXML-tree.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/libXML-tree.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- libXML-tree.c	14 Mar 2004 05:40:27 -0000	1.18
  +++ libXML-tree.c	14 Mar 2004 06:11:07 -0000	1.19
  @@ -174,13 +174,20 @@
   		if (prop->children && prop->children->content)
   			content = (const char *) prop->children->content;
   
  +		if (content && !attr->untrimmed)
  +			content = alloc_trimmed_str(content);
  +
   		if (!attr->content_optional && (!content ||
   						(strlen(content) == 0))) {
   			Nprint_err("<%s>: \"%s\" attribute cannot be empty.", handler->name, attr->name);
  -			return 1;
  +			result = 1;
  +		} else {
  +			result = handler->attribute(element, attr, content);
   		}
   
  -		result = handler->attribute(element, attr, content);
  +		if (content && !attr->untrimmed)
  +			xfree(content);
  +
   		if (result)
   			return result;
   	}
  @@ -216,13 +223,20 @@
   			if (child->children && child->children->content)
   				content = (const char *) child->children->content;
   
  +			if (content && !param->untrimmed)
  +				content = alloc_trimmed_str(content);
  +
   			if (!param->content_optional && (!content ||
   							 (strlen(content) == 0))) {
   				Nprint_err("<%s>: \"%s\" parameter cannot be empty.", handler->name, param->name);
  -				return 1;
  +				result = 1;
  +			} else {
  +				result = handler->parameter(element, param, content);
   			}
   
  -			result = handler->parameter(element, param, content);
  +			if (content && !param->untrimmed)
  +				xfree(content);
  +
   			if (result)
   				return result;
   			/* remove the child node from the DOM tree and free it,
  
  
  
  1.22      +4 -4      ALFS/nALFS/src/handlers/search_replace.c
  
  Index: search_replace.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/search_replace.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- search_replace.c	2 Mar 2004 06:17:50 -0000	1.21
  +++ search_replace.c	14 Mar 2004 06:11:07 -0000	1.22
  @@ -63,8 +63,8 @@
   
   static const struct handler_parameter search_replace_parameters_v2[] = {
   	{ .name = "base", .private = SEARCH_REPLACE_BASE },
  -	{ .name = "find", .private = SEARCH_REPLACE_FIND },
  -	{ .name = "replace", .private = SEARCH_REPLACE_REPLACE },
  +	{ .name = "find", .private = SEARCH_REPLACE_FIND, .untrimmed = 1 },
  +	{ .name = "replace", .private = SEARCH_REPLACE_REPLACE, .untrimmed = 1 },
   	{ .name = "file", .private = SEARCH_REPLACE_FILE },
   	{ .name = NULL }
   };
  @@ -74,8 +74,8 @@
   #if HANDLER_SYNTAX_3_0 || HANDLER_SYNTAX_3_1 || HANDLER_SYNTAX_3_2
   
   static const struct handler_parameter search_replace_parameters_v3[] = {
  -	{ .name = "find", .private = SEARCH_REPLACE_FIND },
  -	{ .name = "replace", .private = SEARCH_REPLACE_REPLACE },
  +	{ .name = "find", .private = SEARCH_REPLACE_FIND, .untrimmed = 1 },
  +	{ .name = "replace", .private = SEARCH_REPLACE_REPLACE, .untrimmed = 1 },
   	{ .name = "file", .private = SEARCH_REPLACE_FILE },
   	{ .name = NULL }
   };
  
  
  
  1.20      +1 -1      ALFS/nALFS/src/handlers/setenv.c
  
  Index: setenv.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/setenv.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- setenv.c	8 Mar 2004 17:21:43 -0000	1.19
  +++ setenv.c	14 Mar 2004 06:11:07 -0000	1.20
  @@ -53,7 +53,7 @@
   
   static const struct handler_parameter setenv_parameters[] = {
   	{ .name = "variable", .private = SETENV_VARIABLE },
  -	{ .name = "value", .private = SETENV_VALUE },
  +	{ .name = "value", .private = SETENV_VALUE, .untrimmed = 1 },
   	{ .name = NULL }
   };
   
  
  
  
  1.25      +2 -2      ALFS/nALFS/src/handlers/textdump.c
  
  Index: textdump.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/textdump.c,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- textdump.c	8 Mar 2004 17:21:43 -0000	1.24
  +++ textdump.c	14 Mar 2004 06:11:07 -0000	1.25
  @@ -59,7 +59,7 @@
   static const struct handler_parameter textdump_parameters_v2[] = {
   	{ .name = "base", .private = TEXTDUMP_BASE },
   	{ .name = "file", .private = TEXTDUMP_FILE },
  -	{ .name = "content", .private = TEXTDUMP_CONTENT },
  +	{ .name = "content", .private = TEXTDUMP_CONTENT, .untrimmed = 1 },
   	{ .name = NULL }
   };
   
  @@ -74,7 +74,7 @@
   
   static const struct handler_parameter textdump_parameters_v3[] = {
   	{ .name = "file", .private = TEXTDUMP_FILE },
  -	{ .name = "content", .private = TEXTDUMP_CONTENT },
  +	{ .name = "content", .private = TEXTDUMP_CONTENT, .untrimmed = 1 },
   	{ .name = NULL }
   };
   
  
  
  



More information about the alfs-log mailing list