From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (schwarze@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.5/8.14.5) with ESMTP id s7KL4cN4009243 for ; Wed, 20 Aug 2014 17:04:38 -0400 (EDT) Received: (from schwarze@localhost) by krisdoz.my.domain (8.14.5/8.14.3/Submit) id s7KL4Z82020893; Wed, 20 Aug 2014 17:04:35 -0400 (EDT) Date: Wed, 20 Aug 2014 17:04:35 -0400 (EDT) Message-Id: <201408202104.s7KL4Z82020893@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Parse the new -a, -i, and -w options. X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 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