From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Parse the new -a, -i, and -w options.
Date: Wed, 20 Aug 2014 17:04:35 -0400 (EDT) [thread overview]
Message-ID: <201408202104.s7KL4Z82020893@krisdoz.my.domain> (raw)
Log Message:
-----------
Parse the new -a, -i, and -w options.
Implement -w (list manual page filenames).
Modified Files:
--------------
mdocml:
main.c
Revision Data
-------------
Index: main.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/main.c,v
retrieving revision 1.180
retrieving revision 1.181
diff -Lmain.c -Lmain.c -u -p -r1.180 -r1.181
--- main.c
+++ main.c
@@ -41,6 +41,15 @@
# endif
#endif /* !defined(__GNUC__) || (__GNUC__ < 2) */
+enum outmode {
+ OUTMODE_DEF = 0,
+ OUTMODE_FLN,
+ OUTMODE_LST,
+ OUTMODE_ALL,
+ OUTMODE_INT,
+ OUTMODE_ONE
+};
+
typedef void (*out_mdoc)(void *, const struct mdoc *);
typedef void (*out_man)(void *, const struct man *);
typedef void (*out_free)(void *);
@@ -96,6 +105,7 @@ main(int argc, char *argv[])
size_t i, sz;
#endif
enum mandoclevel rc;
+ enum outmode outmode;
int show_usage;
int options;
int c;
@@ -132,8 +142,12 @@ main(int argc, char *argv[])
defos = NULL;
show_usage = 0;
- while (-1 != (c = getopt(argc, argv, "C:fI:kM:m:O:S:s:T:VW:"))) {
+ outmode = OUTMODE_DEF;
+ while (-1 != (c = getopt(argc, argv, "aC:fI:ikM:m:O:S:s:T:VW:w"))) {
switch (c) {
+ case 'a':
+ outmode = OUTMODE_ALL;
+ break;
case 'C':
conf_file = optarg;
break;
@@ -155,6 +169,9 @@ main(int argc, char *argv[])
}
defos = mandoc_strdup(optarg + 3);
break;
+ case 'i':
+ outmode = OUTMODE_INT;
+ break;
case 'k':
search.argmode = ARG_EXPR;
break;
@@ -183,6 +200,9 @@ main(int argc, char *argv[])
if ( ! woptions(&curp, optarg))
return((int)MANDOCLEVEL_BADARG);
break;
+ case 'w':
+ outmode = OUTMODE_FLN;
+ break;
case 'V':
version();
/* NOTREACHED */
@@ -195,6 +215,20 @@ main(int argc, char *argv[])
if (show_usage)
usage(search.argmode);
+ if (outmode == OUTMODE_DEF) {
+ switch (search.argmode) {
+ case ARG_FILE:
+ outmode = OUTMODE_ALL;
+ break;
+ case ARG_NAME:
+ outmode = OUTMODE_ONE;
+ break;
+ default:
+ outmode = OUTMODE_LST;
+ break;
+ }
+ }
+
argc -= optind;
argv += optind;
@@ -209,9 +243,14 @@ main(int argc, char *argv[])
if( ! mansearch(&search, &paths, argc, argv, &res, &sz))
usage(search.argmode);
manpath_free(&paths);
- for (i = 0; i < sz; i++)
- printf("%s - %s\n", res[i].names,
- res[i].output == NULL ? "" : res[i].output);
+ for (i = 0; i < sz; i++) {
+ if (outmode == OUTMODE_FLN)
+ puts(res[i].file);
+ else
+ printf("%s - %s\n", res[i].names,
+ res[i].output == NULL ? "" :
+ res[i].output);
+ }
mansearch_free(res, sz);
mansearch_setup(0);
return((int)MANDOCLEVEL_OK);
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
reply other threads:[~2014-08-20 21:04 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=201408202104.s7KL4Z82020893@krisdoz.my.domain \
--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).