version 1.315, 2018/12/30 00:49:55 |
version 1.322, 2019/03/06 10:18:58 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2010-2012, 2014-2018 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010-2012, 2014-2019 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org> |
* Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/ioctl.h> |
#include <sys/ioctl.h> |
#include <sys/param.h> /* MACHINE */ |
#include <sys/param.h> /* MACHINE */ |
#include <sys/termios.h> |
|
#include <sys/wait.h> |
#include <sys/wait.h> |
|
|
#include <assert.h> |
#include <assert.h> |
|
|
#include <stdint.h> |
#include <stdint.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
#include <termios.h> |
#include <time.h> |
#include <time.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
Line 123 main(int argc, char *argv[]) |
|
Line 123 main(int argc, char *argv[]) |
|
struct manpage *res, *resp; |
struct manpage *res, *resp; |
const char *progname, *sec, *thisarg; |
const char *progname, *sec, *thisarg; |
char *conf_file, *defpaths, *auxpaths; |
char *conf_file, *defpaths, *auxpaths; |
char *oarg; |
char *oarg, *tagarg; |
unsigned char *uc; |
unsigned char *uc; |
size_t i, sz; |
size_t i, sz; |
int prio, best_prio; |
int prio, best_prio; |
Line 148 main(int argc, char *argv[]) |
|
Line 148 main(int argc, char *argv[]) |
|
setprogname(progname); |
setprogname(progname); |
#endif |
#endif |
|
|
|
mandoc_msg_setoutfile(stderr); |
if (strncmp(progname, "mandocdb", 8) == 0 || |
if (strncmp(progname, "mandocdb", 8) == 0 || |
strcmp(progname, BINM_MAKEWHATIS) == 0) |
strcmp(progname, BINM_MAKEWHATIS) == 0) |
return mandocdb(argc, argv); |
return mandocdb(argc, argv); |
Line 368 main(int argc, char *argv[]) |
|
Line 369 main(int argc, char *argv[]) |
|
#endif |
#endif |
} |
} |
|
|
|
/* |
|
* Use the first argument for -O tag in addition to |
|
* using it as a search term for man(1) or apropos(1). |
|
*/ |
|
|
|
if (conf.output.tag != NULL && *conf.output.tag == '\0') { |
|
tagarg = argc > 0 && search.argmode == ARG_EXPR ? |
|
strchr(*argv, '=') : NULL; |
|
conf.output.tag = tagarg == NULL ? *argv : tagarg + 1; |
|
} |
|
|
/* man(1), whatis(1), apropos(1) */ |
/* man(1), whatis(1), apropos(1) */ |
|
|
if (search.argmode != ARG_FILE) { |
if (search.argmode != ARG_FILE) { |
Line 480 main(int argc, char *argv[]) |
|
Line 492 main(int argc, char *argv[]) |
|
curp.mp = mparse_alloc(options, curp.os_e, curp.os_s); |
curp.mp = mparse_alloc(options, curp.os_e, curp.os_s); |
|
|
if (argc < 1) { |
if (argc < 1) { |
if (use_pager) |
if (use_pager) { |
tag_files = tag_init(); |
tag_files = tag_init(); |
|
tag_files->tagname = conf.output.tag; |
|
} |
thisarg = "<stdin>"; |
thisarg = "<stdin>"; |
mandoc_msg_setinfilename(thisarg); |
mandoc_msg_setinfilename(thisarg); |
parse(&curp, STDIN_FILENO, thisarg); |
parse(&curp, STDIN_FILENO, thisarg); |
Line 518 main(int argc, char *argv[]) |
|
Line 532 main(int argc, char *argv[]) |
|
if (use_pager) { |
if (use_pager) { |
use_pager = 0; |
use_pager = 0; |
tag_files = tag_init(); |
tag_files = tag_init(); |
if (conf.output.tag != NULL && |
tag_files->tagname = conf.output.tag; |
tag_files->tagname == NULL) |
|
tag_files->tagname = |
|
*conf.output.tag != '\0' ? |
|
conf.output.tag : *argv; |
|
} |
} |
|
|
mandoc_msg_setinfilename(thisarg); |
mandoc_msg_setinfilename(thisarg); |
Line 551 main(int argc, char *argv[]) |
|
Line 561 main(int argc, char *argv[]) |
|
} |
} |
} else |
} else |
mandoc_msg(MANDOCERR_FILE, 0, 0, |
mandoc_msg(MANDOCERR_FILE, 0, 0, |
"%s", strerror(errno)); |
"%s: %s", thisarg, strerror(errno)); |
|
|
if (curp.wstop && mandoc_msg_getrc() != MANDOCLEVEL_OK) |
if (curp.wstop && mandoc_msg_getrc() != MANDOCLEVEL_OK) |
break; |
break; |
Line 787 fs_search(const struct mansearch *cfg, const struct ma |
|
Line 797 fs_search(const struct mansearch *cfg, const struct ma |
|
} |
} |
if (res != NULL && *ressz == lastsz && |
if (res != NULL && *ressz == lastsz && |
strchr(*argv, '/') == NULL) { |
strchr(*argv, '/') == NULL) { |
if (cfg->sec == NULL) |
if (cfg->arch != NULL && |
|
arch_valid(cfg->arch, OSENUM) == 0) |
|
warnx("Unknown architecture \"%s\".", |
|
cfg->arch); |
|
else if (cfg->sec == NULL) |
warnx("No entry for %s in the manual.", |
warnx("No entry for %s in the manual.", |
*argv); |
*argv); |
else |
else |
Line 825 parse(struct curparse *curp, int fd, const char *file) |
|
Line 839 parse(struct curparse *curp, int fd, const char *file) |
|
|
|
if (curp->outdata == NULL) |
if (curp->outdata == NULL) |
outdata_alloc(curp); |
outdata_alloc(curp); |
|
else if (curp->outtype == OUTT_HTML) |
|
html_reset(curp); |
|
|
mandoc_xr_reset(); |
mandoc_xr_reset(); |
meta = mparse_result(curp->mp); |
meta = mparse_result(curp->mp); |
Line 1145 spawn_pager(struct tag_files *tag_files) |
|
Line 1161 spawn_pager(struct tag_files *tag_files) |
|
char *argv[MAX_PAGER_ARGS]; |
char *argv[MAX_PAGER_ARGS]; |
const char *pager; |
const char *pager; |
char *cp; |
char *cp; |
|
#if HAVE_LESS_T |
size_t cmdlen; |
size_t cmdlen; |
|
#endif |
int argc, use_ofn; |
int argc, use_ofn; |
pid_t pager_pid; |
pid_t pager_pid; |
|
|
Line 1177 spawn_pager(struct tag_files *tag_files) |
|
Line 1195 spawn_pager(struct tag_files *tag_files) |
|
/* For less(1), use the tag file. */ |
/* For less(1), use the tag file. */ |
|
|
use_ofn = 1; |
use_ofn = 1; |
|
#if HAVE_LESS_T |
if ((cmdlen = strlen(argv[0])) >= 4) { |
if ((cmdlen = strlen(argv[0])) >= 4) { |
cp = argv[0] + cmdlen - 4; |
cp = argv[0] + cmdlen - 4; |
if (strcmp(cp, "less") == 0) { |
if (strcmp(cp, "less") == 0) { |
Line 1189 spawn_pager(struct tag_files *tag_files) |
|
Line 1208 spawn_pager(struct tag_files *tag_files) |
|
} |
} |
} |
} |
} |
} |
|
#endif |
if (use_ofn) |
if (use_ofn) |
argv[argc++] = tag_files->ofn; |
argv[argc++] = tag_files->ofn; |
argv[argc] = NULL; |
argv[argc] = NULL; |