--- compare.c	2002/08/01 17:02:19	1.1
+++ compare.c	2002/08/12 17:59:35
@@ -62,6 +62,7 @@
 
 extern int uflag;
 extern int lineno;
+extern int ftsoptions;
 
 static char *ftype __P((u_int));
 
@@ -125,7 +126,8 @@
 		(void)printf("%suser expected %lu found %lu",
 		    tab, (u_long)s->st_uid, (u_long)p->fts_statp->st_uid);
 		if (uflag)
-			if (chown(p->fts_accpath, s->st_uid, -1))
+			if (((ftsoptions & FTS_PHYSICAL)?lchown:chown)
+			    (p->fts_accpath, s->st_uid, -1))
 				(void)printf(" not modified: %s\n",
 				    strerror(errno));
 			else
@@ -139,7 +141,9 @@
 		(void)printf("%sgid expected %lu found %lu",
 		    tab, (u_long)s->st_gid, (u_long)p->fts_statp->st_gid);
 		if (uflag)
-			if (chown(p->fts_accpath, -1, s->st_gid))
+
+			if (((ftsoptions & FTS_PHYSICAL)?lchown:chown)
+			    (p->fts_accpath, -1, s->st_gid))
 				(void)printf(" not modified: %s\n",
 				    strerror(errno));
 			else
@@ -155,7 +159,8 @@
 		(void)printf("%spermissions expected %#o found %#o",
 		    tab, s->st_mode, p->fts_statp->st_mode & MBITS);
 		if (uflag)
-			if (chmod(p->fts_accpath, s->st_mode))
+			if (((ftsoptions & FTS_PHYSICAL)?lchmod:chmod)
+			    (p->fts_accpath, s->st_mode))
 				(void)printf(" not modified: %s\n",
 				    strerror(errno));
 			else
--- create.c	2002/07/31 22:32:39	1.1
+++ create.c	2002/08/12 17:59:35
@@ -69,7 +69,7 @@
 
 extern long int crc_total;
 extern int ftsoptions;
-extern int dflag, iflag, nflag, sflag;
+extern int dflag, iflag, nflag, sflag, Nflag;
 extern u_int keys;
 extern char fullpath[MAXPATHLEN];
 extern int lineno;
@@ -96,9 +96,10 @@
 
 	(void)time(&clock);
 	(void)gethostname(host, sizeof(host));
-	(void)printf(
-	    "#\t   user: %s\n#\tmachine: %s\n#\t   tree: %s\n#\t   date: %s",
-	    getlogin(), host, fullpath, ctime(&clock));
+	if (!Nflag)
+		(void)printf(
+		    "#\t   user: %s\n#\tmachine: %s\n#\t   tree: %s\n#\t   date: %s",
+		    getlogin(), host, fullpath, ctime(&clock));
 
 	argv[0] = ".";
 	argv[1] = NULL;
@@ -255,8 +256,17 @@
 	}
 #endif /* RMD160 */
 	if (keys & F_SLINK &&
-	    (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE))
-		output(indent, &offset, "link=%s", rlink(p->fts_accpath));
+	    (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) {
+		char *slink, *vslink;
+
+		slink = rlink(p->fts_accpath);
+		vslink = calloc(1, strlen(slink) * 4 + 1);
+		if (vslink == NULL)
+			errx(1, "statf(): calloc failed");
+		strvis(vslink, slink, VIS_WHITE | VIS_OCTAL);
+		output(indent, &offset, "link=%s", vslink);
+		free(vslink);
+	}
 	if (keys & F_FLAGS && p->fts_statp->st_flags != flags) {
 		fflags = flags_to_string(p->fts_statp->st_flags);
 		output(indent, &offset, "flags=%s", fflags);
--- mtree.c	2002/07/31 22:32:39	1.1
+++ mtree.c	2002/08/01 17:01:49
@@ -59,6 +59,7 @@
 
 int ftsoptions = FTS_PHYSICAL;
 int cflag, dflag, eflag, iflag, nflag, qflag, rflag, sflag, uflag, Uflag;
+int Nflag;
 u_int keys;
 char fullpath[MAXPATHLEN];
 
@@ -77,7 +78,7 @@
 	keys = KEYDEFAULT;
 	init_excludes();
 
-	while ((ch = getopt(argc, argv, "cdef:iK:k:LnPp:qrs:UuxX:")) != -1)
+	while ((ch = getopt(argc, argv, "cdef:iK:k:LNnPp:qrs:UuxX:")) != -1)
 		switch((char)ch) {
 		case 'c':
 			cflag = 1;
@@ -109,6 +110,10 @@
 		case 'L':
 			ftsoptions &= ~FTS_PHYSICAL;
 			ftsoptions |= FTS_LOGICAL;
+			break;
+		case 'N':
+			Nflag = 1;
+			nflag = 1;
 			break;
 		case 'n':
 			nflag = 1;
--- spec.c	2002/07/31 22:31:08	1.1
+++ spec.c	2002/08/12 17:59:34
@@ -54,6 +54,7 @@
 #include "extern.h"
 
 int lineno;				/* Current spec line number. */
+extern int Nflag;
 
 static void	 set __P((char *, NODE *));
 static void	 unset __P((char *, NODE *));
@@ -93,7 +94,7 @@
 		for (p = buf; *p && isspace(*p); ++p);
 
 		/* If nothing but whitespace or comment char, continue. */
-		if (!*p || *p == '#')
+		if (!*p || (!Nflag && *p == '#'))
 			continue;
 
 #ifdef DEBUG
@@ -148,7 +149,7 @@
 		if (strpbrk(p, MAGIC))
 			centry->flags |= F_MAGIC;
 		if (strunvis(centry->name, p) == -1) {
-			warnx("filename %s is ill-encoded and literally used",
+			warnx("filename `%s' is ill-encoded and literally used",
 			    p);
 			strcpy(centry->name, p);
 		}
@@ -250,8 +251,13 @@
 				lineno, val);
 			break;
 		case F_SLINK:
-			if ((ip->slink = strdup(val)) == NULL)
-				errx(1, "strdup");
+			if ((ip->slink = calloc(1, strlen(val) + 1)) == NULL)
+				errx(1, "calloc");
+			if (strunvis(ip->slink, val) == -1) {
+				warnx("line %d: symlink value `%s' is ill-encoded and literally used",
+				      lineno, val);
+				strcpy(ip->slink, val);
+			}
 			break;
 		case F_TIME:
 			ip->st_mtimespec.tv_sec = strtoul(val, &ep, 10);
