source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Some places used PATH_MAX from <limits.h>, some MAXPATHLEN from
@ 2013-06-05  2:00 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2013-06-05  2:00 UTC (permalink / raw)
  To: source

Log Message:
-----------
Some places used PATH_MAX from <limits.h>, some MAXPATHLEN from <sys/param.h>.
Consistently use the PATH_MAX since it is specified by POSIX,
while MAXPATHLEN is not.
In preparation for using this at a few more places.

Modified Files:
--------------
    mdocml:
        cgi.c
        mandocdb.c
        manpage.c
        manpath.c
        mansearch.c
        mansearch.h

Revision Data
-------------
Index: mansearch.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mansearch.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lmansearch.h -Lmansearch.h -u -p -r1.2 -r1.3
--- mansearch.h
+++ mansearch.h
@@ -61,7 +61,7 @@
 __BEGIN_DECLS
 
 struct	manpage {
-	char		 file[MAXPATHLEN]; /* prefixed by manpath */
+	char		 file[PATH_MAX]; /* prefixed by manpath */
 	char		*desc; /* description of manpage */
 	int		 form; /* 0 == catpage */
 };
Index: manpage.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/manpage.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lmanpage.c -Lmanpage.c -u -p -r1.3 -r1.4
--- manpage.c
+++ manpage.c
@@ -17,10 +17,10 @@
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
-#include <sys/param.h>
 
 #include <assert.h>
 #include <getopt.h>
+#include <limits.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -40,7 +40,7 @@ main(int argc, char *argv[])
 	struct mansearch search;
 	struct manpage	*res;
 	char		*conf_file, *defpaths, *auxpaths, *cp;
-	char		 buf[MAXPATHLEN];
+	char		 buf[PATH_MAX];
 	const char	*cmd;
 	struct manpaths	 paths;
 	char		*progname;
@@ -132,7 +132,7 @@ main(int argc, char *argv[])
 	}
 show:
 	cmd = res[i - 1].form ? "mandoc" : "cat";
-	strlcpy(buf, res[i - 1].file, MAXPATHLEN);
+	strlcpy(buf, res[i - 1].file, PATH_MAX);
 	free(res);
 
 	show(cmd, buf);
Index: mansearch.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mansearch.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -Lmansearch.c -Lmansearch.c -u -p -r1.5 -r1.6
--- mansearch.c
+++ mansearch.c
@@ -18,11 +18,10 @@
 #include "config.h"
 #endif
 
-#include <sys/param.h>
-
 #include <assert.h>
 #include <fcntl.h>
 #include <getopt.h>
+#include <limits.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <stddef.h>
@@ -131,7 +130,7 @@ mansearch(const struct mansearch *search
 {
 	int		 fd, rc, c;
 	int64_t		 id;
-	char		 buf[MAXPATHLEN];
+	char		 buf[PATH_MAX];
 	char		*sql;
 	struct expr	*e, *ep;
 	sqlite3		*db;
@@ -168,7 +167,7 @@ mansearch(const struct mansearch *search
 	 * on our current directory from which to start the chdir().
 	 */
 
-	if (NULL == getcwd(buf, MAXPATHLEN)) {
+	if (NULL == getcwd(buf, PATH_MAX)) {
 		perror(NULL);
 		goto out;
 	} else if (-1 == (fd = open(buf, O_RDONLY, 0))) {
@@ -266,9 +265,9 @@ mansearch(const struct mansearch *search
 					(*res, maxres * sizeof(struct manpage));
 			}
 			strlcpy((*res)[cur].file, 
-				paths->paths[i], MAXPATHLEN);
-			strlcat((*res)[cur].file, "/", MAXPATHLEN);
-			strlcat((*res)[cur].file, mp->file, MAXPATHLEN);
+				paths->paths[i], PATH_MAX);
+			strlcat((*res)[cur].file, "/", PATH_MAX);
+			strlcat((*res)[cur].file, mp->file, PATH_MAX);
 			(*res)[cur].desc = mp->desc;
 			(*res)[cur].form = mp->form;
 			free(mp->file);
Index: mandocdb.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandocdb.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.57 -r1.58
--- mandocdb.c
+++ mandocdb.c
@@ -19,7 +19,6 @@
 #include "config.h"
 #endif
 
-#include <sys/param.h>
 #include <sys/stat.h>
 
 #include <assert.h>
@@ -28,6 +27,7 @@
 #include <fcntl.h>
 #include <fts.h>
 #include <getopt.h>
+#include <limits.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -98,7 +98,7 @@ struct	of {
 	struct of	*next; /* next in ofs */
 	enum form	 dform; /* path-cued form */
 	enum form	 sform; /* suffix-cued form */
-	char		 file[MAXPATHLEN]; /* filename rel. to manpath */
+	char		 file[PATH_MAX]; /* filename rel. to manpath */
 	const char	*desc; /* parsed description */
 	const char	*sec; /* suffix-cued section (or empty) */
 	const char	*dsec; /* path-cued section (or empty) */
@@ -313,7 +313,7 @@ static	const struct mdoc_handler mdocs[M
 int
 main(int argc, char *argv[])
 {
-	char		  cwd[MAXPATHLEN];
+	char		  cwd[PATH_MAX];
 	int		  ch, rc, fd, i;
 	unsigned int	  index;
 	size_t		  j, sz;
@@ -350,7 +350,7 @@ main(int argc, char *argv[])
 	 * handle relative paths, and by doing this, we can return to
 	 * the starting point.
 	 */
-	if (NULL == getcwd(cwd, MAXPATHLEN)) {
+	if (NULL == getcwd(cwd, PATH_MAX)) {
 		perror(NULL);
 		return(EXIT_FAILURE);
 	} else if (-1 == (fd = open(cwd, O_RDONLY, 0))) {
@@ -876,7 +876,7 @@ ofadd(const char *base, int dform, const
 	}
 
 	of = mandoc_calloc(1, sizeof(struct of));
-	strlcpy(of->file, file, MAXPATHLEN);
+	strlcpy(of->file, file, PATH_MAX);
 	of->name = name;
 	of->sec = sec;
 	of->dsec = dsec;
@@ -920,7 +920,7 @@ ofmerge(struct mchars *mc, struct mparse
 	size_t		 sz;
 	struct mdoc	*mdoc;
 	struct man	*man;
-	char		 buf[MAXPATHLEN];
+	char		 buf[PATH_MAX];
 	char		*bufp;
 	const char	*msec, *march, *mtitle, *cp;
 	struct of	*of;
@@ -935,8 +935,8 @@ ofmerge(struct mchars *mc, struct mparse
 		 * own.
 		 */
 		if ( ! use_all && FORM_CAT == of->dform) {
-			sz = strlcpy(buf, of->file, MAXPATHLEN);
-			if (sz >= MAXPATHLEN) {
+			sz = strlcpy(buf, of->file, PATH_MAX);
+			if (sz >= PATH_MAX) {
 				if (warnings)
 					say(base, of->file,
 					    "Filename too long");
@@ -947,7 +947,7 @@ ofmerge(struct mchars *mc, struct mparse
 			memcpy(bufp, "man", 3);
 			if (NULL != (bufp = strrchr(buf, '.')))
 				*++bufp = '\0';
-			strlcat(buf, of->dsec, MAXPATHLEN);
+			strlcat(buf, of->dsec, PATH_MAX);
 			if (filecheck(buf)) {
 				if (warnings)
 					say(base, of->file, "Man "
@@ -1875,7 +1875,7 @@ static void
 dbclose(const char *base, int real)
 {
 	size_t		 i;
-	char		 file[MAXPATHLEN];
+	char		 file[PATH_MAX];
 
 	if (nodb)
 		return;
@@ -1891,8 +1891,8 @@ dbclose(const char *base, int real)
 	if (real)
 		return;
 
-	strlcpy(file, MANDOC_DB, MAXPATHLEN);
-	strlcat(file, "~", MAXPATHLEN);
+	strlcpy(file, MANDOC_DB, PATH_MAX);
+	strlcat(file, "~", PATH_MAX);
 	if (-1 == rename(file, MANDOC_DB))
 		perror(MANDOC_DB);
 }
@@ -1908,7 +1908,7 @@ dbclose(const char *base, int real)
 static int
 dbopen(const char *base, int real)
 {
-	char		 file[MAXPATHLEN];
+	char		 file[PATH_MAX];
 	const char	*sql;
 	int		 rc, ofl;
 	size_t		 sz;
@@ -1916,11 +1916,11 @@ dbopen(const char *base, int real)
 	if (nodb) 
 		return(1);
 
-	sz = strlcpy(file, MANDOC_DB, MAXPATHLEN);
+	sz = strlcpy(file, MANDOC_DB, PATH_MAX);
 	if ( ! real)
-		sz = strlcat(file, "~", MAXPATHLEN);
+		sz = strlcat(file, "~", PATH_MAX);
 
-	if (sz >= MAXPATHLEN) {
+	if (sz >= PATH_MAX) {
 		fprintf(stderr, "%s: Path too long\n", file);
 		return(0);
 	}
Index: manpath.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/manpath.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -Lmanpath.c -Lmanpath.c -u -p -r1.10 -r1.11
--- manpath.c
+++ manpath.c
@@ -19,10 +19,6 @@
 #include "config.h"
 #endif
 
-#ifdef	USE_MANPATH
-#include <sys/param.h>
-#endif
-
 #include <assert.h>
 #include <ctype.h>
 #include <limits.h>
@@ -44,7 +40,7 @@ manpath_parse(struct manpaths *dirs, con
 		char *defp, char *auxp)
 {
 #ifdef	USE_MANPATH
-	char		 cmd[(MAXPATHLEN * 3) + 20];
+	char		 cmd[(PATH_MAX * 3) + 20];
 	FILE		*stream;
 	char		*buf;
 	size_t		 sz, bsz;
Index: cgi.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/cgi.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -Lcgi.c -Lcgi.c -u -p -r1.44 -r1.45
--- cgi.c
+++ cgi.c
@@ -18,7 +18,6 @@
 #include "config.h"
 #endif
 
-#include <sys/param.h>
 #include <sys/wait.h>
 
 #include <assert.h>
@@ -726,7 +725,7 @@ format(const struct req *req, const char
 	struct man	*man;
 	void		*vp;
 	enum mandoclevel rc;
-	char		 opts[MAXPATHLEN + 128];
+	char		 opts[PATH_MAX + 128];
 
 	if (-1 == (fd = open(file, O_RDONLY, 0))) {
 		resp_baddb();
@@ -777,7 +776,7 @@ pg_show(const struct req *req, char *pat
 	struct manpaths	 ps;
 	size_t		 sz;
 	char		*sub;
-	char		 file[MAXPATHLEN];
+	char		 file[PATH_MAX];
 	const char	*cp;
 	int		 rc, catm;
 	unsigned int	 vol, rec, mr;
@@ -831,10 +830,10 @@ pg_show(const struct req *req, char *pat
 		goto out;
 	}
 
-	sz = strlcpy(file, ps.paths[vol], MAXPATHLEN);
-	assert(sz < MAXPATHLEN);
-	strlcat(file, "/", MAXPATHLEN);
-	strlcat(file, MANDOC_IDX, MAXPATHLEN);
+	sz = strlcpy(file, ps.paths[vol], PATH_MAX);
+	assert(sz < PATH_MAX);
+	strlcat(file, "/", PATH_MAX);
+	strlcat(file, MANDOC_IDX, PATH_MAX);
 
 	/* Open the index recno(3) database. */
 
@@ -863,8 +862,8 @@ pg_show(const struct req *req, char *pat
 		resp_baddb();
 	else {
  		file[(int)sz] = '\0';
- 		strlcat(file, "/", MAXPATHLEN);
- 		strlcat(file, cp, MAXPATHLEN);
+ 		strlcat(file, "/", PATH_MAX);
+ 		strlcat(file, cp, PATH_MAX);
 		if (catm) 
 			catman(req, file);
 		else
@@ -973,7 +972,7 @@ int
 main(void)
 {
 	int		 i;
-	char		 buf[MAXPATHLEN];
+	char		 buf[PATH_MAX];
 	DIR		*cwd;
 	struct req	 req;
 	char		*p, *path, *subpath;
@@ -1010,7 +1009,7 @@ main(void)
 
 	memset(&req, 0, sizeof(struct req));
 
-	strlcpy(buf, ".", MAXPATHLEN);
+	strlcpy(buf, ".", PATH_MAX);
 	pathgen(cwd, buf, &req);
 	closedir(cwd);
 
@@ -1120,8 +1119,8 @@ pathgen(DIR *dir, char *path, struct req
 	int		 rc;
 	size_t		 sz, ssz;
 
-	sz = strlcat(path, "/", MAXPATHLEN);
-	if (sz >= MAXPATHLEN) {
+	sz = strlcat(path, "/", PATH_MAX);
+	if (sz >= PATH_MAX) {
 		fprintf(stderr, "%s: Path too long", path);
 		return;
 	} 
@@ -1138,9 +1137,9 @@ pathgen(DIR *dir, char *path, struct req
 			continue;
 
 		path[(int)sz] = '\0';
-		ssz = strlcat(path, d->d_name, MAXPATHLEN);
+		ssz = strlcat(path, d->d_name, PATH_MAX);
 
-		if (ssz >= MAXPATHLEN) {
+		if (ssz >= PATH_MAX) {
 			fprintf(stderr, "%s: Path too long", path);
 			return;
 		} else if (NULL == (cd = opendir(path))) {
@@ -1187,9 +1186,9 @@ pathgen(DIR *dir, char *path, struct req
 			continue;
 
 		path[(int)sz] = '\0';
-		ssz = strlcat(path, d->d_name, MAXPATHLEN);
+		ssz = strlcat(path, d->d_name, PATH_MAX);
 
-		if (ssz >= MAXPATHLEN) {
+		if (ssz >= PATH_MAX) {
 			fprintf(stderr, "%s: Path too long", path);
 			return;
 		} else if (NULL == (cd = opendir(path))) {
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-06-05  2:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-05  2:00 mdocml: Some places used PATH_MAX from <limits.h>, some MAXPATHLEN from schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).