From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: do not spawn a pager when there is no output; issue pointed out
Date: Tue, 13 Jan 2015 08:22:52 -0500 (EST) [thread overview]
Message-ID: <17616355456730260747.enqueue@fantadrom.bsd.lv> (raw)
Log Message:
-----------
do not spawn a pager when there is no output; issue pointed out by deraadt@
Modified Files:
--------------
mdocml:
main.c
Revision Data
-------------
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/main.c,v
retrieving revision 1.211
retrieving revision 1.212
diff -Lmain.c -Lmain.c -u -p -r1.211 -r1.212
--- main.c
+++ main.c
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -405,9 +405,6 @@ main(int argc, char *argv[])
if (search.argmode == ARG_FILE && ! moptions(&options, auxpaths))
return((int)MANDOCLEVEL_BADARG);
- if (use_pager && isatty(STDOUT_FILENO))
- spawn_pager();
-
curp.mchars = mchars_alloc();
curp.mp = mparse_alloc(options, curp.wlevel, mmsg,
curp.mchars, defos);
@@ -418,15 +415,29 @@ main(int argc, char *argv[])
if (OUTT_MAN == curp.outtype)
mparse_keep(curp.mp);
- if (argc == 0)
+ if (argc == 0) {
+ if (use_pager && isatty(STDOUT_FILENO))
+ spawn_pager();
parse(&curp, STDIN_FILENO, "<stdin>", &rc);
+ }
while (argc) {
+ rc = mparse_open(curp.mp, &fd,
+#if HAVE_SQLITE3
+ resp != NULL ? resp->file :
+#endif
+ *argv);
+
+ if (fd != -1) {
+ if (use_pager && isatty(STDOUT_FILENO))
+ spawn_pager();
+ use_pager = 0;
+
+#if HAVE_SQLITE3
+ if (resp == NULL)
+#endif
+ parse(&curp, fd, *argv, &rc);
#if HAVE_SQLITE3
- if (resp != NULL) {
- rc = mparse_open(curp.mp, &fd, resp->file);
- if (fd == -1)
- /* nothing */;
else if (resp->form & FORM_SRC) {
/* For .so only; ignore failure. */
chdir(paths.paths[resp->ipath]);
@@ -434,23 +445,26 @@ main(int argc, char *argv[])
} else
rc = passthrough(resp->file, fd,
synopsis_only);
- resp++;
- } else
#endif
- {
- rc = mparse_open(curp.mp, &fd, *argv++);
- if (fd != -1)
- parse(&curp, fd, argv[-1], &rc);
- }
- if (mparse_wait(curp.mp) != MANDOCLEVEL_OK)
- rc = MANDOCLEVEL_SYSERR;
+ if (mparse_wait(curp.mp) != MANDOCLEVEL_OK)
+ rc = MANDOCLEVEL_SYSERR;
+
+ if (argc > 1 && curp.outtype <= OUTT_UTF8)
+ ascii_sepline(curp.outdata);
+ }
if (MANDOCLEVEL_OK != rc && curp.wstop)
break;
- if (--argc && curp.outtype <= OUTT_UTF8)
- ascii_sepline(curp.outdata);
+#if HAVE_SQLITE3
+ if (resp != NULL)
+ resp++;
+ else
+#endif
+ argv++;
+ if (--argc)
+ mparse_reset(curp.mp);
}
if (curp.outfree)
@@ -616,10 +630,7 @@ parse(struct curparse *curp, int fd, con
if (mdoc && curp->outmdoc)
(*curp->outmdoc)(curp->outdata, mdoc);
- cleanup:
-
- mparse_reset(curp->mp);
-
+cleanup:
if (*level < rc)
*level = rc;
}
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
reply other threads:[~2015-01-13 13:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=17616355456730260747.enqueue@fantadrom.bsd.lv \
--to=schwarze@mdocml.bsd.lv \
--cc=source@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).