[Midnightbsd-cvs] src [11582] trunk/usr.bin/catman/catman.c: sync with freebsd.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun Jul 8 11:39:22 EDT 2018


Revision: 11582
          http://svnweb.midnightbsd.org/src/?rev=11582
Author:   laffer1
Date:     2018-07-08 11:39:22 -0400 (Sun, 08 Jul 2018)
Log Message:
-----------
sync with freebsd.

Modified Paths:
--------------
    trunk/usr.bin/catman/Makefile
    trunk/usr.bin/catman/catman.1
    trunk/usr.bin/catman/catman.c

Property Changed:
----------------
    trunk/usr.bin/catman/catman.1

Modified: trunk/usr.bin/catman/Makefile
===================================================================
--- trunk/usr.bin/catman/Makefile	2018-07-08 15:38:52 UTC (rev 11581)
+++ trunk/usr.bin/catman/Makefile	2018-07-08 15:39:22 UTC (rev 11582)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/catman/Makefile 201386 2010-01-02 10:27:05Z ed $
 
 PROG=	catman
 

Modified: trunk/usr.bin/catman/catman.1
===================================================================
--- trunk/usr.bin/catman/catman.1	2018-07-08 15:38:52 UTC (rev 11581)
+++ trunk/usr.bin/catman/catman.1	2018-07-08 15:39:22 UTC (rev 11582)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 2002 John Rochester
 .\" All rights reserved.
 .\"
@@ -22,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.bin/catman/catman.1 153115 2005-12-05 14:22:12Z ru $
 .\"
 .Dd December 3, 2005
 .Dt CATMAN 1


Property changes on: trunk/usr.bin/catman/catman.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/catman/catman.c
===================================================================
--- trunk/usr.bin/catman/catman.c	2018-07-08 15:38:52 UTC (rev 11581)
+++ trunk/usr.bin/catman/catman.c	2018-07-08 15:39:22 UTC (rev 11582)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2002 John Rochester
  * All rights reserved.
@@ -27,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/catman/catman.c 300269 2016-05-20 06:24:16Z truckman $");
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -34,9 +35,11 @@
 #include <sys/param.h>
 #include <sys/utsname.h>
 
+#include <assert.h>
 #include <ctype.h>
 #include <dirent.h>
 #include <err.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <locale.h>
 #include <langinfo.h>
@@ -94,7 +97,7 @@
 static uid_t uid;
 static int starting_dir;
 static char tmp_file[MAXPATHLEN];
-struct stat test_st;
+static struct stat test_st;
 
 /*
  * A hashtable is an array of chains composed of this entry structure.
@@ -267,7 +270,8 @@
 	char *cat_section;
 
 	cat_section = strdup(section);
-	strncpy(cat_section, "cat", 3);
+	assert(strlen(section) > 3 && strncmp(section, "man", 3) == 0);
+	memcpy(cat_section, "cat", 3);
 	return cat_section;
 }
 
@@ -419,8 +423,11 @@
 			fprintf(stderr, "%slink %s -> %s\n",
 			    verbose ? "\t" : "", cat, link_name);
 		}
-		if (!pretend)
-			link(link_name, cat);
+		if (!pretend) {
+			(void) unlink(cat);
+			if (link(link_name, cat) < 0)
+				warn("%s %s: link", link_name, cat);
+		}
 		return;
 	}
 	insert_hashtable(links, src_ino, src_dev, strdup(cat));
@@ -608,7 +615,8 @@
 static void
 process_mandir(char *dir_name, char *section)
 {
-	fchdir(starting_dir);
+	if (fchdir(starting_dir) < 0)
+		err(1, "fchdir");
 	if (already_visited(NULL, dir_name, section == NULL))
 		return;
 	check_writable(dir_name);



More information about the Midnightbsd-cvs mailing list