Module Name:    src
Committed By:   apb
Date:           Sat Apr  4 21:49:49 UTC 2009

Modified Files:
        src/usr.sbin/mtree: mtree.h spec.c

Log Message:
Tags are internally stored with leading and trailing commas, for ease
of using strcmp(3) to check them against inclusion or exclusion lists.
Don't output the leading or trailing commas.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/mtree/mtree.h
cvs rdiff -u -r1.69 -r1.70 src/usr.sbin/mtree/spec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.h
diff -u src/usr.sbin/mtree/mtree.h:1.26 src/usr.sbin/mtree/mtree.h:1.27
--- src/usr.sbin/mtree/mtree.h:1.26	Sun Feb  4 08:03:18 2007
+++ src/usr.sbin/mtree/mtree.h	Sat Apr  4 21:49:49 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtree.h,v 1.26 2007/02/04 08:03:18 elad Exp $	*/
+/*	$NetBSD: mtree.h,v 1.27 2009/04/04 21:49:49 apb Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -59,7 +59,9 @@
 	char	*sha256digest;			/* SHA256 digest */
 	char	*sha384digest;			/* SHA384 digest */
 	char	*sha512digest;			/* SHA512 digest */
-	char	*tags;				/* tags, comma delimited */
+	char	*tags;				/* tags, comma delimited,
+						 * also with leading and
+						 * trailing commas */
 	size_t	lineno;				/* line # entry came from */
 
 #define	F_CKSUM		0x00000001		/* cksum(1) check sum */

Index: src/usr.sbin/mtree/spec.c
diff -u src/usr.sbin/mtree/spec.c:1.69 src/usr.sbin/mtree/spec.c:1.70
--- src/usr.sbin/mtree/spec.c:1.69	Fri Apr  3 21:18:59 2009
+++ src/usr.sbin/mtree/spec.c	Sat Apr  4 21:49:49 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec.c,v 1.69 2009/04/03 21:18:59 apb Exp $	*/
+/*	$NetBSD: spec.c,v 1.70 2009/04/04 21:49:49 apb Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -67,7 +67,7 @@
 #if 0
 static char sccsid[] = "@(#)spec.c	8.2 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: spec.c,v 1.69 2009/04/03 21:18:59 apb Exp $");
+__RCSID("$NetBSD: spec.c,v 1.70 2009/04/04 21:49:49 apb Exp $");
 #endif
 #endif /* not lint */
 
@@ -290,6 +290,7 @@
 	char	path[MAXPATHLEN];
 	const char *name;
 	char	*str;
+	char	*p, *q;
 
 	for (cur = root; cur != NULL; cur = cur->next) {
 		if (cur->type != F_DIR && !matchtags(cur))
@@ -358,8 +359,16 @@
 			printf("ignore ");
 		if (MATCHFLAG(F_OPT))
 			printf("optional ");
-		if (MATCHFLAG(F_TAGS))
-			printf("tags=%s ", cur->tags);
+		if (MATCHFLAG(F_TAGS)) {
+			/* don't output leading or trailing commas */
+			p = cur->tags;
+			while (*p == ',')
+				p++;
+			q = p + strlen(p);
+			while(q > p && q[-1] == ',')
+				q--;
+			printf("tags=%.*s ", q - p, p);
+		}
 		puts(pathlast ? vispath(path) : "");
 
 		if (cur->child)

Reply via email to