Module Name:    src
Committed By:   cegger
Date:           Tue Oct  6 06:43:15 UTC 2009

Modified Files:
        src/usr.bin/man: man.c

Log Message:
- use EXIT_FAILURE/EXIT_SUCCESS
- whitespace nits
- ansify cleanup()/usage()
- remove pointless parenthesis on return


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/man/man.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.bin/man/man.c
diff -u src/usr.bin/man/man.c:1.37 src/usr.bin/man/man.c:1.38
--- src/usr.bin/man/man.c:1.37	Mon Jul 21 14:19:24 2008
+++ src/usr.bin/man/man.c	Tue Oct  6 06:43:15 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: man.c,v 1.37 2008/07/21 14:19:24 lukem Exp $	*/
+/*	$NetBSD: man.c,v 1.38 2009/10/06 06:43:15 cegger Exp $	*/
 
 /*
  * Copyright (c) 1987, 1993, 1994, 1995
@@ -40,7 +40,7 @@
 #if 0
 static char sccsid[] = "@(#)man.c	8.17 (Berkeley) 1/31/95";
 #else
-__RCSID("$NetBSD: man.c,v 1.37 2008/07/21 14:19:24 lukem Exp $");
+__RCSID("$NetBSD: man.c,v 1.38 2009/10/06 06:43:15 cegger Exp $");
 #endif
 #endif /* not lint */
 
@@ -104,7 +104,6 @@
 /*
  * prototypes
  */
-int		 main(int, char **);
 static void	 build_page(char *, char **, struct manstate *);
 static void	 cat(char *);
 static const char	*check_pager(const char *);
@@ -197,7 +196,7 @@
 
 		if (uname(&utsname) == -1) {
 			perror("uname");
-			exit(1);
+			exit(EXIT_FAILURE);
 		}
 		machine = utsname.machine;
 	}
@@ -220,7 +219,7 @@
 
 		m.section = gettag(m.sectionname, 0); /* -s must be a section */
 		if (m.section == NULL)
-			errx(1, "unknown section: %s", m.sectionname);
+			errx(EXIT_FAILURE, "unknown section: %s", m.sectionname);
 
 	} else if (argc > 1) {
 
@@ -252,7 +251,7 @@
 	m.intmp = gettag("_intmp", 1);
 	if (!m.defaultpath || !m.subdirs || !m.suffixlist || !m.buildlist ||
 	    !m.mymanpath || !m.missinglist || !m.intmp)
-		errx(1, "malloc failed");
+		errx(EXIT_FAILURE, "malloc failed");
 
 	/*
 	 * are we using a section whose elements are all absolute paths?
@@ -321,7 +320,7 @@
 					 p, (p[len-1] == '/') ? "" : "/",
 					 esubd->s, machine);
 				if (addentry(m.mymanpath, buf, 0) < 0)
-					errx(1, "malloc failed");
+					errx(EXIT_FAILURE, "malloc failed");
 			}
 		}
 
@@ -335,7 +334,7 @@
 				(void)snprintf(buf, sizeof(buf),
 				    "%s{/%s,}", epath->s, machine);
 				if (addentry(m.mymanpath, buf, 0) < 0)
-					errx(1, "malloc failed");
+					errx(EXIT_FAILURE, "malloc failed");
 				continue;
 			}
 
@@ -346,7 +345,7 @@
 									 : "/",
 					 esubd->s, machine);
 				if (addentry(m.mymanpath, buf, 0) < 0)
-					errx(1, "malloc failed");
+					errx(EXIT_FAILURE, "malloc failed");
 			}
 		}
 
@@ -370,7 +369,7 @@
 					 esubd->s, machine);
 				/* add at front */
 				if (addentry(m.mymanpath, buf, 1) < 0)
-					errx(1, "malloc failed");
+					errx(EXIT_FAILURE, "malloc failed");
 			}
 		}
 
@@ -404,7 +403,7 @@
 	/* if nothing found, we're done. */
 	if (!found) {
 		(void)cleanup();
-		exit (1);
+		exit(EXIT_FAILURE);
 	}
 
 	/*
@@ -416,7 +415,7 @@
 				continue;
 			cat(*ap);
 		}
-		exit (cleanup());
+		exit(cleanup());
 	}
 	if (m.how) {
 		for (ap = pg.gl_pathv; *ap != NULL; ++ap) {
@@ -448,7 +447,7 @@
 	if ((cmd = malloc(len)) == NULL) {
 		warn("malloc");
 		(void)cleanup();
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 
 	/* now build the command string... */
@@ -495,7 +494,7 @@
 	if ((escpage = malloc((2 * strlen(page)) + 1)) == NULL) {
 		warn("malloc");
 		(void)cleanup();
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 
 	p = page;
@@ -526,7 +525,7 @@
 			else {
 				warn("globbing");
 				(void)cleanup();
-				exit(1);
+				exit(EXIT_FAILURE);
 			}
 		}
 		if (pg->gl_matchc == 0)
@@ -623,12 +622,12 @@
 		if (addentry(mp->missinglist, page, 0) < 0) {
 			warn("malloc");
 			(void)cleanup();
-			exit(1);
+			exit(EXIT_FAILURE);
 		}
 	}
 
 	free(escpage);
-	return (anyfound);
+	return anyfound;
 }
 
 /* 
@@ -701,7 +700,7 @@
 	if ((fd = mkstemp(tpath)) == -1) {
 		warn("%s", tpath);
 		(void)cleanup();
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 	(void)snprintf(buf, sizeof(buf), "%s > %s", fmt, tpath);
 	(void)snprintf(cmd, sizeof(cmd), buf, p);
@@ -710,14 +709,14 @@
 	if ((*pathp = strdup(tpath)) == NULL) {
 		warn("malloc");
 		(void)cleanup();
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 
 	/* Link the built file into the remove-when-done list. */
 	if (addentry(mp->intmp, *pathp, 0) < 0) {
 		warn("malloc");
 		(void)cleanup();
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 
 	/* restore old directory so relative manpaths still work */
@@ -742,7 +741,7 @@
 	if (!(fp = fopen(fname, "r"))) {
 		warn("%s", fname);
 		(void)cleanup();
-		exit (1);
+		exit(EXIT_FAILURE);
 	}
 #define	S1	"SYNOPSIS"
 #define	S2	"S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS"
@@ -787,18 +786,18 @@
 	if ((fd = open(fname, O_RDONLY, 0)) < 0) {
 		warn("%s", fname);
 		(void)cleanup();
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 	while ((n = read(fd, buf, sizeof(buf))) > 0)
 		if (write(STDOUT_FILENO, buf, n) != n) {
 			warn("write");
 			(void)cleanup();
-			exit (1);
+			exit(EXIT_FAILURE);
 		}
 	if (n == -1) {
 		warn("read");
 		(void)cleanup();
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 	(void)close(fd);
 }
@@ -829,7 +828,7 @@
 		name = newname;
 	}
 
-	return (name);
+	return name;
 }
 
 /*
@@ -849,7 +848,7 @@
 		arg[0] = arg[1];
 	execvp(name, argv);
 	(void)fprintf(stderr, "%s: Command not found.\n", name);
-	exit(1);
+	exit(EXIT_FAILURE);
 }
 
 /* 
@@ -865,7 +864,7 @@
 	(void)raise_default_signal(signo);
 
 	/* NOTREACHED */
-	exit (1);
+	exit(EXIT_FAILURE);
 }
 
 /*
@@ -873,13 +872,13 @@
  *	Clean up temporary files, show any error messages.
  */
 static int
-cleanup()
+cleanup(void)
 {
 	TAG *intmpp, *missp;
 	ENTRY *ep;
 	int rval;
 
-	rval = 0;
+	rval = EXIT_SUCCESS;
 	/* 
 	 * note that _missing and _intmp were created by main(), so
 	 * gettag() cannot return NULL here.
@@ -889,13 +888,13 @@
 
 	TAILQ_FOREACH(ep, &missp->entrylist, q) {
 		warnx("no entry for %s in the manual.", ep->s);
-		rval = 1;
+		rval = EXIT_FAILURE;
 	}
 
 	TAILQ_FOREACH(ep, &intmpp->entrylist, q)
 		(void)unlink(ep->s);
 
-	return (rval);
+	return rval;
 }
 
 /*
@@ -903,12 +902,12 @@
  *	print usage message and die
  */
 static void
-usage()
+usage(void)
 {
 	(void)fprintf(stderr, "usage: %s [-acw|-h] [-C cfg] [-M path] "
 	    "[-m path] [-S srch] [[-s] sect] name ...\n", getprogname());
 	(void)fprintf(stderr, 
 	    "usage: %s -k [-C cfg] [-M path] [-m path] keyword ...\n", 
 	    getprogname());
-	exit(1);
+	exit(EXIT_FAILURE);
 }

Reply via email to