aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2013-06-05 02:00:26 +0000
committerIngo Schwarze <schwarze@openbsd.org>2013-06-05 02:00:26 +0000
commit8400486b39e9f57a03d2efe49cf8eab233476669 (patch)
tree05031258c9f3babdf621263c0a55031f2a2a2c0a
parent91ed0105333c4ac483f7581f13a317c5560bdf58 (diff)
downloadmandoc-8400486b39e9f57a03d2efe49cf8eab233476669.tar.gz
mandoc-8400486b39e9f57a03d2efe49cf8eab233476669.tar.zst
mandoc-8400486b39e9f57a03d2efe49cf8eab233476669.zip
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.
-rw-r--r--cgi.c35
-rw-r--r--mandocdb.c34
-rw-r--r--manpage.c8
-rw-r--r--manpath.c8
-rw-r--r--mansearch.c15
-rw-r--r--mansearch.h4
6 files changed, 49 insertions, 55 deletions
diff --git a/cgi.c b/cgi.c
index 6b885976..6d40fcde 100644
--- a/cgi.c
+++ b/cgi.c
@@ -1,4 +1,4 @@
-/* $Id: cgi.c,v 1.44 2012/05/27 17:48:57 schwarze Exp $ */
+/* $Id: cgi.c,v 1.45 2013/06/05 02:00:26 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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 *file)
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 *path)
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 *path)
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 *path)
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 *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 *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 *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))) {
diff --git a/mandocdb.c b/mandocdb.c
index c3f1c4be..3f87a99f 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.57 2013/06/03 22:51:14 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.58 2013/06/05 02:00:26 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
@@ -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[MDOC_MAX] = {
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 char *file,
}
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 *mp, const char *base)
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 *mp, const char *base)
* 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 *mp, const char *base)
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);
}
diff --git a/manpage.c b/manpage.c
index b187e0f6..dadf98f1 100644
--- a/manpage.c
+++ b/manpage.c
@@ -1,4 +1,4 @@
-/* $Id: manpage.c,v 1.3 2012/06/09 17:49:13 kristaps Exp $ */
+/* $Id: manpage.c,v 1.4 2013/06/05 02:00:26 schwarze Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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);
diff --git a/manpath.c b/manpath.c
index 888c8db5..90089323 100644
--- a/manpath.c
+++ b/manpath.c
@@ -1,4 +1,4 @@
-/* $Id: manpath.c,v 1.10 2013/05/29 22:48:10 schwarze Exp $ */
+/* $Id: manpath.c,v 1.11 2013/06/05 02:00:26 schwarze Exp $ */
/*
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -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, const char *file,
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;
diff --git a/mansearch.c b/mansearch.c
index bec483fc..116b64dc 100644
--- a/mansearch.c
+++ b/mansearch.c
@@ -1,4 +1,4 @@
-/* $Id: mansearch.c,v 1.5 2012/06/09 14:11:16 kristaps Exp $ */
+/* $Id: mansearch.c,v 1.6 2013/06/05 02:00:26 schwarze Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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);
diff --git a/mansearch.h b/mansearch.h
index 8cfbc340..fc2dfe75 100644
--- a/mansearch.h
+++ b/mansearch.h
@@ -1,4 +1,4 @@
-/* $Id: mansearch.h,v 1.2 2012/06/09 14:11:16 kristaps Exp $ */
+/* $Id: mansearch.h,v 1.3 2013/06/05 02:00:26 schwarze Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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 */
};