Module Name:    src
Committed By:   kre
Date:           Thu May 23 04:34:25 UTC 2019

Modified Files:
        src/sbin/mount_portal: conf.c mount_portal.8

Log Message:
Better handling of comments in portal.conf ... # now only introduces
a comment at beginning of line, or after whitespace.   This allows #
to be used as data otherwhere in the line (there is no escape mechanism).


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sbin/mount_portal/conf.c
cvs rdiff -u -r1.22 -r1.23 src/sbin/mount_portal/mount_portal.8

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

Modified files:

Index: src/sbin/mount_portal/conf.c
diff -u src/sbin/mount_portal/conf.c:1.13 src/sbin/mount_portal/conf.c:1.14
--- src/sbin/mount_portal/conf.c:1.13	Thu May 23 02:39:06 2019
+++ src/sbin/mount_portal/conf.c	Thu May 23 04:34:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: conf.c,v 1.13 2019/05/23 02:39:06 kre Exp $	*/
+/*	$NetBSD: conf.c,v 1.14 2019/05/23 04:34:25 kre Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: conf.c,v 1.13 2019/05/23 02:39:06 kre Exp $");
+__RCSID("$NetBSD: conf.c,v 1.14 2019/05/23 04:34:25 kre Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -153,21 +153,19 @@ palloc(char *cline, int lno, const char 
 	char **ap;
 
 	/*
-	 * Implement comment chars
-	 */
-	s = strchr(cline, '#');
-	if (s)
-		*s = 0;
-
-	/*
 	 * Do a pass through the string to count the number
-	 * of arguments
+	 * of arguments.   Stop if we encounter a comment.
 	 */
 	c = 0;
 	key = strdup(cline);
 	for (s = key; s != NULL; ) {
 		char *val;
 
+		if (*s == '#') {	/* '#" at beginning of word */
+			cline[s-key] = '\0';	/* delete comment -> EOL */
+			break;
+		}
+
 		while ((val = strsep(&s, " \t\n")) != NULL && *val == '\0')
 			;
 		if (val)

Index: src/sbin/mount_portal/mount_portal.8
diff -u src/sbin/mount_portal/mount_portal.8:1.22 src/sbin/mount_portal/mount_portal.8:1.23
--- src/sbin/mount_portal/mount_portal.8:1.22	Mon Jul  3 21:33:41 2017
+++ src/sbin/mount_portal/mount_portal.8	Thu May 23 04:34:25 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mount_portal.8,v 1.22 2017/07/03 21:33:41 wiz Exp $
+.\"	$NetBSD: mount_portal.8,v 1.23 2019/05/23 04:34:25 kre Exp $
 .\"
 .\" Copyright (c) 1993, 1994
 .\"	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\"	@(#)mount_portal.8	8.3 (Berkeley) 3/27/94
 .\"
-.Dd December 5, 2009
+.Dd May 23, 2019
 .Dt MOUNT_PORTAL 8
 .Os
 .Sh NAME
@@ -122,7 +122,8 @@ Each rule takes one line and consists of
 whitespace separated fields.
 A hash
 .Pq Dq #
-character causes the remainder of a line to be ignored.
+character at beginning of the line, or after whitespace,
+causes the remainder of a line to be ignored.
 Blank lines are ignored.
 .Pp
 The first field is a pathname prefix to match

Reply via email to