version 1.57, 2013/06/03 22:51:14 |
version 1.58, 2013/06/05 02:00:26 |
|
|
#include "config.h" |
#include "config.h" |
#endif |
#endif |
|
|
#include <sys/param.h> |
|
#include <sys/stat.h> |
#include <sys/stat.h> |
|
|
#include <assert.h> |
#include <assert.h> |
|
|
#include <fcntl.h> |
#include <fcntl.h> |
#include <fts.h> |
#include <fts.h> |
#include <getopt.h> |
#include <getopt.h> |
|
#include <limits.h> |
#include <stddef.h> |
#include <stddef.h> |
#include <stdint.h> |
#include <stdint.h> |
#include <stdlib.h> |
#include <stdlib.h> |
|
|
struct of *next; /* next in ofs */ |
struct of *next; /* next in ofs */ |
enum form dform; /* path-cued form */ |
enum form dform; /* path-cued form */ |
enum form sform; /* suffix-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 *desc; /* parsed description */ |
const char *sec; /* suffix-cued section (or empty) */ |
const char *sec; /* suffix-cued section (or empty) */ |
const char *dsec; /* path-cued section (or empty) */ |
const char *dsec; /* path-cued section (or empty) */ |
Line 313 static const struct mdoc_handler mdocs[MDOC_MAX] = { |
|
Line 313 static const struct mdoc_handler mdocs[MDOC_MAX] = { |
|
int |
int |
main(int argc, char *argv[]) |
main(int argc, char *argv[]) |
{ |
{ |
char cwd[MAXPATHLEN]; |
char cwd[PATH_MAX]; |
int ch, rc, fd, i; |
int ch, rc, fd, i; |
unsigned int index; |
unsigned int index; |
size_t j, sz; |
size_t j, sz; |
Line 350 main(int argc, char *argv[]) |
|
Line 350 main(int argc, char *argv[]) |
|
* handle relative paths, and by doing this, we can return to |
* handle relative paths, and by doing this, we can return to |
* the starting point. |
* the starting point. |
*/ |
*/ |
if (NULL == getcwd(cwd, MAXPATHLEN)) { |
if (NULL == getcwd(cwd, PATH_MAX)) { |
perror(NULL); |
perror(NULL); |
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} else if (-1 == (fd = open(cwd, O_RDONLY, 0))) { |
} else if (-1 == (fd = open(cwd, O_RDONLY, 0))) { |
Line 876 ofadd(const char *base, int dform, const char *file, |
|
Line 876 ofadd(const char *base, int dform, const char *file, |
|
} |
} |
|
|
of = mandoc_calloc(1, sizeof(struct of)); |
of = mandoc_calloc(1, sizeof(struct of)); |
strlcpy(of->file, file, MAXPATHLEN); |
strlcpy(of->file, file, PATH_MAX); |
of->name = name; |
of->name = name; |
of->sec = sec; |
of->sec = sec; |
of->dsec = dsec; |
of->dsec = dsec; |
Line 920 ofmerge(struct mchars *mc, struct mparse *mp, const ch |
|
Line 920 ofmerge(struct mchars *mc, struct mparse *mp, const ch |
|
size_t sz; |
size_t sz; |
struct mdoc *mdoc; |
struct mdoc *mdoc; |
struct man *man; |
struct man *man; |
char buf[MAXPATHLEN]; |
char buf[PATH_MAX]; |
char *bufp; |
char *bufp; |
const char *msec, *march, *mtitle, *cp; |
const char *msec, *march, *mtitle, *cp; |
struct of *of; |
struct of *of; |
Line 935 ofmerge(struct mchars *mc, struct mparse *mp, const ch |
|
Line 935 ofmerge(struct mchars *mc, struct mparse *mp, const ch |
|
* own. |
* own. |
*/ |
*/ |
if ( ! use_all && FORM_CAT == of->dform) { |
if ( ! use_all && FORM_CAT == of->dform) { |
sz = strlcpy(buf, of->file, MAXPATHLEN); |
sz = strlcpy(buf, of->file, PATH_MAX); |
if (sz >= MAXPATHLEN) { |
if (sz >= PATH_MAX) { |
if (warnings) |
if (warnings) |
say(base, of->file, |
say(base, of->file, |
"Filename too long"); |
"Filename too long"); |
Line 947 ofmerge(struct mchars *mc, struct mparse *mp, const ch |
|
Line 947 ofmerge(struct mchars *mc, struct mparse *mp, const ch |
|
memcpy(bufp, "man", 3); |
memcpy(bufp, "man", 3); |
if (NULL != (bufp = strrchr(buf, '.'))) |
if (NULL != (bufp = strrchr(buf, '.'))) |
*++bufp = '\0'; |
*++bufp = '\0'; |
strlcat(buf, of->dsec, MAXPATHLEN); |
strlcat(buf, of->dsec, PATH_MAX); |
if (filecheck(buf)) { |
if (filecheck(buf)) { |
if (warnings) |
if (warnings) |
say(base, of->file, "Man " |
say(base, of->file, "Man " |
|
|
dbclose(const char *base, int real) |
dbclose(const char *base, int real) |
{ |
{ |
size_t i; |
size_t i; |
char file[MAXPATHLEN]; |
char file[PATH_MAX]; |
|
|
if (nodb) |
if (nodb) |
return; |
return; |
Line 1891 dbclose(const char *base, int real) |
|
Line 1891 dbclose(const char *base, int real) |
|
if (real) |
if (real) |
return; |
return; |
|
|
strlcpy(file, MANDOC_DB, MAXPATHLEN); |
strlcpy(file, MANDOC_DB, PATH_MAX); |
strlcat(file, "~", MAXPATHLEN); |
strlcat(file, "~", PATH_MAX); |
if (-1 == rename(file, MANDOC_DB)) |
if (-1 == rename(file, MANDOC_DB)) |
perror(MANDOC_DB); |
perror(MANDOC_DB); |
} |
} |
Line 1908 dbclose(const char *base, int real) |
|
Line 1908 dbclose(const char *base, int real) |
|
static int |
static int |
dbopen(const char *base, int real) |
dbopen(const char *base, int real) |
{ |
{ |
char file[MAXPATHLEN]; |
char file[PATH_MAX]; |
const char *sql; |
const char *sql; |
int rc, ofl; |
int rc, ofl; |
size_t sz; |
size_t sz; |
Line 1916 dbopen(const char *base, int real) |
|
Line 1916 dbopen(const char *base, int real) |
|
if (nodb) |
if (nodb) |
return(1); |
return(1); |
|
|
sz = strlcpy(file, MANDOC_DB, MAXPATHLEN); |
sz = strlcpy(file, MANDOC_DB, PATH_MAX); |
if ( ! real) |
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); |
fprintf(stderr, "%s: Path too long\n", file); |
return(0); |
return(0); |
} |
} |