version 1.191, 2014/09/03 18:09:14 |
version 1.193, 2014/10/18 15:57:34 |
Line 87 static void mmsg(enum mandocerr, enum mandoclevel, |
|
Line 87 static void mmsg(enum mandocerr, enum mandoclevel, |
|
const char *, int, int, const char *); |
const char *, int, int, const char *); |
static void parse(struct curparse *, int, |
static void parse(struct curparse *, int, |
const char *, enum mandoclevel *); |
const char *, enum mandoclevel *); |
static enum mandoclevel passthrough(const char *); |
static enum mandoclevel passthrough(const char *, int); |
static void spawn_pager(void); |
static void spawn_pager(void); |
static int toptions(struct curparse *, char *); |
static int toptions(struct curparse *, char *); |
static void usage(enum argmode) __attribute__((noreturn)); |
static void usage(enum argmode) __attribute__((noreturn)); |
Line 114 main(int argc, char *argv[]) |
|
Line 114 main(int argc, char *argv[]) |
|
#endif |
#endif |
enum mandoclevel rc; |
enum mandoclevel rc; |
enum outmode outmode; |
enum outmode outmode; |
|
pid_t child_pid; |
|
int fd; |
int show_usage; |
int show_usage; |
int use_pager; |
int use_pager; |
int options; |
int options; |
Line 370 main(int argc, char *argv[]) |
|
Line 372 main(int argc, char *argv[]) |
|
while (argc) { |
while (argc) { |
#if HAVE_SQLITE3 |
#if HAVE_SQLITE3 |
if (resp != NULL) { |
if (resp != NULL) { |
if (resp->form & FORM_SRC) { |
rc = mparse_open(curp.mp, &fd, resp->file, |
|
&child_pid); |
|
if (fd == -1) |
|
/* nothing */; |
|
else if (resp->form & FORM_SRC) { |
/* For .so only; ignore failure. */ |
/* For .so only; ignore failure. */ |
chdir(paths.paths[resp->ipath]); |
chdir(paths.paths[resp->ipath]); |
parse(&curp, -1, resp->file, &rc); |
parse(&curp, fd, resp->file, &rc); |
} else |
} else |
rc = passthrough(resp->file); |
rc = passthrough(resp->file, fd); |
resp++; |
resp++; |
} else |
} else |
#endif |
#endif |
parse(&curp, -1, *argv++, &rc); |
{ |
|
rc = mparse_open(curp.mp, &fd, *argv++, |
|
&child_pid); |
|
if (fd != -1) |
|
parse(&curp, fd, argv[-1], &rc); |
|
} |
|
|
|
if (child_pid && |
|
mparse_wait(curp.mp, child_pid) != MANDOCLEVEL_OK) |
|
rc = MANDOCLEVEL_SYSERR; |
|
|
if (MANDOCLEVEL_OK != rc && curp.wstop) |
if (MANDOCLEVEL_OK != rc && curp.wstop) |
break; |
break; |
argc--; |
argc--; |
Line 555 parse(struct curparse *curp, int fd, const char *file, |
|
Line 571 parse(struct curparse *curp, int fd, const char *file, |
|
} |
} |
|
|
static enum mandoclevel |
static enum mandoclevel |
passthrough(const char *file) |
passthrough(const char *file, int fd) |
{ |
{ |
char buf[BUFSIZ]; |
char buf[BUFSIZ]; |
const char *syscall; |
const char *syscall; |
ssize_t nr, nw, off; |
ssize_t nr, nw, off; |
int fd; |
|
|
|
fd = open(file, O_RDONLY); |
|
if (fd == -1) { |
|
syscall = "open"; |
|
goto fail; |
|
} |
|
|
|
while ((nr = read(fd, buf, BUFSIZ)) != -1 && nr != 0) |
while ((nr = read(fd, buf, BUFSIZ)) != -1 && nr != 0) |
for (off = 0; off < nr; off += nw) |
for (off = 0; off < nr; off += nw) |
if ((nw = write(STDOUT_FILENO, buf + off, |
if ((nw = write(STDOUT_FILENO, buf + off, |
(size_t)(nr - off))) == -1 || nw == 0) { |
(size_t)(nr - off))) == -1 || nw == 0) { |
|
close(fd); |
syscall = "write"; |
syscall = "write"; |
goto fail; |
goto fail; |
} |
} |
|
|
if (nr == 0) { |
close(fd); |
close(fd); |
|
|
if (nr == 0) |
return(MANDOCLEVEL_OK); |
return(MANDOCLEVEL_OK); |
} |
|
|
|
syscall = "read"; |
syscall = "read"; |
fail: |
fail: |