-
- while (argc > 0) {
-
- /*
- * Changing directories is not needed in ARG_FILE mode.
- * Do it on a best-effort basis. Even in case of
- * failure, some functionality may still work.
- */
- if (resp != NULL) {
- if (resp->ipath != SIZE_MAX)
- (void)chdir(conf.manpath.paths[resp->ipath]);
- else if (startdir != -1)
- (void)fchdir(startdir);
- thisarg = resp->file;
- } else
- thisarg = *argv;
-
- mandoc_msg_setinfilename(thisarg);
- fd = mparse_open(mp, thisarg);
- if (fd != -1) {
- if (use_pager) {
- use_pager = 0;
- tag_files = tag_init();
- if (tag_files != NULL)
- tag_files->tagname = conf.output.tag;
- }
-
- if (resp == NULL || resp->form == FORM_SRC)
- parse(mp, fd, thisarg, &outst, &conf.output);
- else
- passthrough(fd, conf.output.synopsisonly);
-
- if (ferror(stdout)) {
- if (tag_files != NULL) {
- mandoc_msg(MANDOCERR_WRITE, 0, 0,
- "%s: %s", tag_files->ofn,
- strerror(errno));
- tag_unlink();
- tag_files = NULL;
- } else
- mandoc_msg(MANDOCERR_WRITE, 0, 0,
- "%s", strerror(errno));
- break;
- }
-
- if (argc > 1 && outst.outtype <= OUTT_UTF8) {
- if (outst.outdata == NULL)
- outdata_alloc(&outst, &conf.output);
- terminal_sepline(outst.outdata);
- }
- } else
- mandoc_msg(resp == NULL ? MANDOCERR_BADARG_BAD :
- MANDOCERR_OPEN, 0, 0, "%s", strerror(errno));
-
- mandoc_msg_setinfilename(NULL);
-