man.c revision 1.17 1 /* $NetBSD: man.c,v 1.17 1999/06/19 05:25:31 itohy Exp $ */
2
3 /*
4 * Copyright (c) 1987, 1993, 1994, 1995
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36 #include <sys/cdefs.h>
37
38 #ifndef lint
39 __COPYRIGHT("@(#) Copyright (c) 1987, 1993, 1994, 1995\n\
40 The Regents of the University of California. All rights reserved.\n");
41 #endif /* not lint */
42
43 #ifndef lint
44 #if 0
45 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95";
46 #else
47 __RCSID("$NetBSD: man.c,v 1.17 1999/06/19 05:25:31 itohy Exp $");
48 #endif
49 #endif /* not lint */
50
51 #include <sys/param.h>
52 #include <sys/queue.h>
53
54 #include <ctype.h>
55 #include <err.h>
56 #include <errno.h>
57 #include <fcntl.h>
58 #include <fnmatch.h>
59 #include <glob.h>
60 #include <signal.h>
61 #include <stdio.h>
62 #include <stdlib.h>
63 #include <string.h>
64 #include <unistd.h>
65
66 #include "config.h"
67 #include "pathnames.h"
68
69 #ifndef MACHINE
70 #define MACHINE __ARCHITECTURE__
71 #endif
72
73 int f_all, f_where;
74
75 int main __P((int, char **));
76 static void build_page __P((char *, char **));
77 static void cat __P((char *));
78 static char *check_pager __P((char *));
79 static int cleanup __P((void));
80 static void how __P((char *));
81 static void jump __P((char **, char *, char *));
82 static int manual __P((char *, TAG *, glob_t *));
83 static void onsig __P((int));
84 static void usage __P((void));
85
86 int
87 main(argc, argv)
88 int argc;
89 char *argv[];
90 {
91 TAG *defp, *defnewp, *section, *sectnewp, *subp;
92 ENTRY *e_defp, *e_sectp, *e_subp, *ep;
93 glob_t pg;
94 size_t len;
95 int ch, f_cat, f_how, found;
96 char **ap, *cmd, *machine, *p, *p_add, *p_path, *pager, *slashp;
97 char *conffile, buf[MAXPATHLEN * 2];
98
99 #ifdef __GNUC__
100 pager = NULL; /* XXX gcc -Wuninitialized */
101 #endif
102
103 f_cat = f_how = 0;
104 conffile = p_add = p_path = NULL;
105 while ((ch = getopt(argc, argv, "-aC:cfhkM:m:P:w")) != -1)
106 switch (ch) {
107 case 'a':
108 f_all = 1;
109 break;
110 case 'C':
111 conffile = optarg;
112 break;
113 case 'c':
114 case '-': /* Deprecated. */
115 f_cat = 1;
116 break;
117 case 'h':
118 f_how = 1;
119 break;
120 case 'm':
121 p_add = optarg;
122 break;
123 case 'M':
124 case 'P': /* Backward compatibility. */
125 p_path = optarg;
126 break;
127 /*
128 * The -f and -k options are backward compatible,
129 * undocumented ways of calling whatis(1) and apropos(1).
130 */
131 case 'f':
132 jump(argv, "-f", "whatis");
133 /* NOTREACHED */
134 case 'k':
135 jump(argv, "-k", "apropos");
136 /* NOTREACHED */
137 case 'w':
138 f_all = f_where = 1;
139 break;
140 case '?':
141 default:
142 usage();
143 }
144 argc -= optind;
145 argv += optind;
146
147 if (!*argv)
148 usage();
149
150 if (!f_cat && !f_how && !f_where) {
151 if (!isatty(STDOUT_FILENO)) {
152 f_cat = 1;
153 } else {
154 if ((pager = getenv("PAGER")) != NULL &&
155 pager[0] != '\0')
156 pager = check_pager(pager);
157 else
158 pager = _PATH_PAGER;
159 }
160 }
161 /* Read the configuration file. */
162 config(conffile);
163
164 /* Get the machine type. */
165 if ((machine = getenv("MACHINE")) == NULL)
166 machine = MACHINE;
167
168 /* If there's no _default list, create an empty one. */
169 if ((defp = getlist("_default")) == NULL)
170 defp = addlist("_default");
171
172 /*
173 * 1: If the user specified a MANPATH variable, or set the -M
174 * option, we replace the _default list with the user's list,
175 * appending the entries in the _subdir list and the machine.
176 */
177 if (p_path == NULL)
178 p_path = getenv("MANPATH");
179 if (p_path != NULL) {
180 while ((e_defp = defp->list.tqh_first) != NULL) {
181 free(e_defp->s);
182 TAILQ_REMOVE(&defp->list, e_defp, q);
183 }
184 for (p = strtok(p_path, ":");
185 p != NULL; p = strtok(NULL, ":")) {
186 slashp = p[strlen(p) - 1] == '/' ? "" : "/";
187 e_subp = (subp = getlist("_subdir")) == NULL ?
188 NULL : subp->list.tqh_first;
189 for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) {
190 (void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,}",
191 p, slashp, e_subp->s, machine);
192 if ((ep = malloc(sizeof(ENTRY))) == NULL ||
193 (ep->s = strdup(buf)) == NULL)
194 err(1, "malloc");
195 TAILQ_INSERT_TAIL(&defp->list, ep, q);
196 }
197 }
198 }
199
200 /*
201 * 2: If the user did not specify MANPATH, -M or a section, rewrite
202 * the _default list to include the _subdir list and the machine.
203 */
204 if (argv[1] == NULL)
205 section = NULL;
206 else if ((section = getlist(*argv)) != NULL)
207 ++argv;
208 if (p_path == NULL && section == NULL) {
209 defnewp = addlist("_default_new");
210 e_defp =
211 defp->list.tqh_first == NULL ? NULL : defp->list.tqh_first;
212 for (; e_defp != NULL; e_defp = e_defp->q.tqe_next) {
213 slashp =
214 e_defp->s[strlen(e_defp->s) - 1] == '/' ? "" : "/";
215 e_subp = (subp = getlist("_subdir")) == NULL ?
216 NULL : subp->list.tqh_first;
217 for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) {
218 (void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,}",
219 e_defp->s, slashp, e_subp->s, machine);
220 if ((ep = malloc(sizeof(ENTRY))) == NULL ||
221 (ep->s = strdup(buf)) == NULL)
222 err(1, "malloc");
223 TAILQ_INSERT_TAIL(&defnewp->list, ep, q);
224 }
225 }
226 defp = getlist("_default");
227 while ((e_defp = defp->list.tqh_first) != NULL) {
228 free(e_defp->s);
229 TAILQ_REMOVE(&defp->list, e_defp, q);
230 }
231 free(defp->s);
232 TAILQ_REMOVE(&head, defp, q);
233 defnewp = getlist("_default_new");
234 free(defnewp->s);
235 defnewp->s = "_default";
236 defp = defnewp;
237 }
238
239 /*
240 * 3: If the user set the -m option, insert the user's list before
241 * whatever list we have, again appending the _subdir list and
242 * the machine.
243 */
244 if (p_add != NULL)
245 for (p = strtok(p_add, ":"); p != NULL; p = strtok(NULL, ":")) {
246 slashp = p[strlen(p) - 1] == '/' ? "" : "/";
247 e_subp = (subp = getlist("_subdir")) == NULL ?
248 NULL : subp->list.tqh_first;
249 for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) {
250 (void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,}",
251 p, slashp, e_subp->s, machine);
252 if ((ep = malloc(sizeof(ENTRY))) == NULL ||
253 (ep->s = strdup(buf)) == NULL)
254 err(1, "malloc");
255 TAILQ_INSERT_HEAD(&defp->list, ep, q);
256 }
257 }
258
259 /*
260 * 4: If no -m was specified, and a section was, rewrite the section's
261 * paths (if they have a trailing slash) to append the _subdir list
262 * and the machine. This then becomes the _default list.
263 */
264 if (p_add == NULL && section != NULL) {
265 sectnewp = addlist("_section_new");
266 for (e_sectp = section->list.tqh_first;
267 e_sectp != NULL; e_sectp = e_sectp->q.tqe_next) {
268 if (e_sectp->s[strlen(e_sectp->s) - 1] != '/') {
269 (void)snprintf(buf, sizeof(buf),
270 "%s{/%s,}", e_sectp->s, machine);
271 if ((ep = malloc(sizeof(ENTRY))) == NULL ||
272 (ep->s = strdup(buf)) == NULL)
273 err(1, "malloc");
274 TAILQ_INSERT_TAIL(§newp->list, ep, q);
275 continue;
276 }
277 e_subp = (subp = getlist("_subdir")) == NULL ?
278 NULL : subp->list.tqh_first;
279 for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) {
280 (void)snprintf(buf, sizeof(buf), "%s%s{/%s,}",
281 e_sectp->s, e_subp->s, machine);
282 if ((ep = malloc(sizeof(ENTRY))) == NULL ||
283 (ep->s = strdup(buf)) == NULL)
284 err(1, "malloc");
285 TAILQ_INSERT_TAIL(§newp->list, ep, q);
286 }
287 }
288 sectnewp->s = section->s;
289 defp = sectnewp;
290 TAILQ_REMOVE(&head, section, q);
291 }
292
293 /*
294 * 5: Search for the files. Set up an interrupt handler, so the
295 * temporary files go away.
296 */
297 (void)signal(SIGINT, onsig);
298 (void)signal(SIGHUP, onsig);
299 (void)signal(SIGPIPE, onsig);
300
301 memset(&pg, 0, sizeof(pg));
302 for (found = 0; *argv; ++argv)
303 if (manual(*argv, defp, &pg))
304 found = 1;
305
306 /* 6: If nothing found, we're done. */
307 if (!found) {
308 (void)cleanup();
309 exit (1);
310 }
311
312 /* 7: If it's simple, display it fast. */
313 if (f_cat) {
314 for (ap = pg.gl_pathv; *ap != NULL; ++ap) {
315 if (**ap == '\0')
316 continue;
317 cat(*ap);
318 }
319 exit (cleanup());
320 }
321 if (f_how) {
322 for (ap = pg.gl_pathv; *ap != NULL; ++ap) {
323 if (**ap == '\0')
324 continue;
325 how(*ap);
326 }
327 exit(cleanup());
328 }
329 if (f_where) {
330 for (ap = pg.gl_pathv; *ap != NULL; ++ap) {
331 if (**ap == '\0')
332 continue;
333 (void)printf("%s\n", *ap);
334 }
335 exit(cleanup());
336 }
337
338 /*
339 * 8: We display things in a single command; build a list of things
340 * to display.
341 */
342 for (ap = pg.gl_pathv, len = strlen(pager) + 1; *ap != NULL; ++ap) {
343 if (**ap == '\0')
344 continue;
345 len += strlen(*ap) + 1;
346 }
347 if ((cmd = malloc(len)) == NULL) {
348 warn("malloc");
349 (void)cleanup();
350 exit(1);
351 }
352 p = cmd;
353 len = strlen(pager);
354 memmove(p, pager, len);
355 p += len;
356 *p++ = ' ';
357 for (ap = pg.gl_pathv; *ap != NULL; ++ap) {
358 if (**ap == '\0')
359 continue;
360 len = strlen(*ap);
361 memmove(p, *ap, len);
362 p += len;
363 *p++ = ' ';
364 }
365 *--p = '\0';
366
367 /* Use system(3) in case someone's pager is "pager arg1 arg2". */
368 (void)system(cmd);
369
370 exit(cleanup());
371 }
372
373 /*
374 * manual --
375 * Search the manuals for the pages.
376 */
377 static int
378 manual(page, tag, pg)
379 char *page;
380 TAG *tag;
381 glob_t *pg;
382 {
383 ENTRY *ep, *e_sufp, *e_tag;
384 TAG *missp, *sufp;
385 int anyfound, cnt, error, found;
386 char *p, buf[MAXPATHLEN];
387
388 anyfound = 0;
389 buf[0] = '*';
390
391 /* For each element in the list... */
392 e_tag = tag == NULL ? NULL : tag->list.tqh_first;
393 for (; e_tag != NULL; e_tag = e_tag->q.tqe_next) {
394 (void)snprintf(buf, sizeof(buf), "%s/%s.*", e_tag->s, page);
395 if ((error = glob(buf,
396 GLOB_APPEND | GLOB_BRACE | GLOB_NOSORT, NULL, pg)) != 0) {
397 if (error == GLOB_NOMATCH)
398 continue;
399 else {
400 warn("globbing");
401 (void)cleanup();
402 exit(1);
403 }
404 }
405 if (pg->gl_matchc == 0)
406 continue;
407
408 /* Find out if it's really a man page. */
409 for (cnt = pg->gl_pathc - pg->gl_matchc;
410 cnt < pg->gl_pathc; ++cnt) {
411
412 /*
413 * Try the _suffix key words first.
414 *
415 * XXX
416 * Older versions of man.conf didn't have the suffix
417 * key words, it was assumed that everything was a .0.
418 * We just test for .0 first, it's fast and probably
419 * going to hit.
420 */
421 (void)snprintf(buf, sizeof(buf), "*/%s.0", page);
422 if (!fnmatch(buf, pg->gl_pathv[cnt], 0))
423 goto next;
424
425 e_sufp = (sufp = getlist("_suffix")) == NULL ?
426 NULL : sufp->list.tqh_first;
427 for (found = 0;
428 e_sufp != NULL; e_sufp = e_sufp->q.tqe_next) {
429 (void)snprintf(buf,
430 sizeof(buf), "*/%s%s", page, e_sufp->s);
431 if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) {
432 found = 1;
433 break;
434 }
435 }
436 if (found)
437 goto next;
438
439 /* Try the _build key words next. */
440 e_sufp = (sufp = getlist("_build")) == NULL ?
441 NULL : sufp->list.tqh_first;
442 for (found = 0;
443 e_sufp != NULL; e_sufp = e_sufp->q.tqe_next) {
444 for (p = e_sufp->s;
445 *p != '\0' && !isspace((unsigned char)*p); ++p);
446 if (*p == '\0')
447 continue;
448 *p = '\0';
449 (void)snprintf(buf,
450 sizeof(buf), "*/%s%s", page, e_sufp->s);
451 if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) {
452 if (!f_where)
453 build_page(p + 1,
454 &pg->gl_pathv[cnt]);
455 *p = ' ';
456 found = 1;
457 break;
458 }
459 *p = ' ';
460 }
461 if (found) {
462 next: anyfound = 1;
463 if (!f_all) {
464 /* Delete any other matches. */
465 while (++cnt< pg->gl_pathc)
466 pg->gl_pathv[cnt] = "";
467 break;
468 }
469 continue;
470 }
471
472 /* It's not a man page, forget about it. */
473 pg->gl_pathv[cnt] = "";
474 }
475
476 if (anyfound && !f_all)
477 break;
478 }
479
480 /* If not found, enter onto the missing list. */
481 if (!anyfound) {
482 if ((missp = getlist("_missing")) == NULL)
483 missp = addlist("_missing");
484 if ((ep = malloc(sizeof(ENTRY))) == NULL ||
485 (ep->s = strdup(page)) == NULL) {
486 warn("malloc");
487 (void)cleanup();
488 exit(1);
489 }
490 TAILQ_INSERT_TAIL(&missp->list, ep, q);
491 }
492 return (anyfound);
493 }
494
495 /*
496 * build_page --
497 * Build a man page for display.
498 */
499 static void
500 build_page(fmt, pathp)
501 char *fmt, **pathp;
502 {
503 static int warned;
504 ENTRY *ep;
505 TAG *intmpp;
506 int fd, n;
507 char *p, *b;
508 char buf[MAXPATHLEN], cmd[MAXPATHLEN], tpath[sizeof(_PATH_TMP)];
509
510 /* Let the user know this may take awhile. */
511 if (!warned) {
512 warned = 1;
513 warnx("Formatting manual page...");
514 }
515
516 /*
517 * Historically man chdir'd to the root of the man tree.
518 * This was used in man pages that contained relative ".so"
519 * directives (including other man pages for command aliases etc.)
520 * It even went one step farther, by examining the first line
521 * of the man page and parsing the .so filename so it would
522 * make hard(?) links to the cat'ted man pages for space savings.
523 * (We don't do that here, but we could).
524 */
525
526 /* copy and find the end */
527 for (b = buf, p = *pathp; (*b++ = *p++) != '\0';)
528 continue;
529
530 /* skip the last two path components, page name and man[n] */
531 for (--b, --p, n = 2; b != buf; b--, p--)
532 if (*b == '/')
533 if (--n == 0) {
534 *b = '\0';
535 (void) chdir(buf);
536 p++;
537 break;
538 }
539
540
541 /* Add a remove-when-done list. */
542 if ((intmpp = getlist("_intmp")) == NULL)
543 intmpp = addlist("_intmp");
544
545 /* Move to the printf(3) format string. */
546 for (; *fmt && isspace((unsigned char)*fmt); ++fmt)
547 continue;
548
549 /*
550 * Get a temporary file and build a version of the file
551 * to display. Replace the old file name with the new one.
552 */
553 (void)strcpy(tpath, _PATH_TMP);
554 if ((fd = mkstemp(tpath)) == -1) {
555 warn("%s", tpath);
556 (void)cleanup();
557 exit(1);
558 }
559 (void)snprintf(buf, sizeof(buf), "%s > %s", fmt, tpath);
560 (void)snprintf(cmd, sizeof(cmd), buf, p);
561 (void)system(cmd);
562 (void)close(fd);
563 if ((*pathp = strdup(tpath)) == NULL) {
564 warn("malloc");
565 (void)cleanup();
566 exit(1);
567 }
568
569 /* Link the built file into the remove-when-done list. */
570 if ((ep = malloc(sizeof(ENTRY))) == NULL) {
571 warn("malloc");
572 (void)cleanup();
573 exit(1);
574 }
575 ep->s = *pathp;
576 TAILQ_INSERT_TAIL(&intmpp->list, ep, q);
577 }
578
579 /*
580 * how --
581 * display how information
582 */
583 static void
584 how(fname)
585 char *fname;
586 {
587 FILE *fp;
588
589 int lcnt, print;
590 char *p, buf[256];
591
592 if (!(fp = fopen(fname, "r"))) {
593 warn("%s", fname);
594 (void)cleanup();
595 exit (1);
596 }
597 #define S1 "SYNOPSIS"
598 #define S2 "S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS"
599 #define D1 "DESCRIPTION"
600 #define D2 "D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN"
601 for (lcnt = print = 0; fgets(buf, sizeof(buf), fp);) {
602 if (!strncmp(buf, S1, sizeof(S1) - 1) ||
603 !strncmp(buf, S2, sizeof(S2) - 1)) {
604 print = 1;
605 continue;
606 } else if (!strncmp(buf, D1, sizeof(D1) - 1) ||
607 !strncmp(buf, D2, sizeof(D2) - 1))
608 return;
609 if (!print)
610 continue;
611 if (*buf == '\n')
612 ++lcnt;
613 else {
614 for(; lcnt; --lcnt)
615 (void)putchar('\n');
616 for (p = buf; isspace((unsigned char)*p); ++p)
617 continue;
618 (void)fputs(p, stdout);
619 }
620 }
621 (void)fclose(fp);
622 }
623
624 /*
625 * cat --
626 * cat out the file
627 */
628 static void
629 cat(fname)
630 char *fname;
631 {
632 int fd, n;
633 char buf[2048];
634
635 if ((fd = open(fname, O_RDONLY, 0)) < 0) {
636 warn("%s", fname);
637 (void)cleanup();
638 exit(1);
639 }
640 while ((n = read(fd, buf, sizeof(buf))) > 0)
641 if (write(STDOUT_FILENO, buf, n) != n) {
642 warn("write");
643 (void)cleanup();
644 exit (1);
645 }
646 if (n == -1) {
647 warn("read");
648 (void)cleanup();
649 exit(1);
650 }
651 (void)close(fd);
652 }
653
654 /*
655 * check_pager --
656 * check the user supplied page information
657 */
658 static char *
659 check_pager(name)
660 char *name;
661 {
662 char *p, *save;
663
664 /*
665 * if the user uses "more", we make it "more -s"; watch out for
666 * PAGER = "mypager /usr/ucb/more"
667 */
668 for (p = name; *p && !isspace((unsigned char)*p); ++p)
669 continue;
670 for (; p > name && *p != '/'; --p);
671 if (p != name)
672 ++p;
673
674 /* make sure it's "more", not "morex" */
675 if (!strncmp(p, "more", 4) && (!p[4] || isspace((unsigned char)p[4]))){
676 save = name;
677 /* allocate space to add the "-s" */
678 if (!(name =
679 malloc((u_int)(strlen(save) + sizeof("-s") + 1))))
680 err(1, "malloc");
681 (void)sprintf(name, "%s %s", save, "-s");
682 }
683 return(name);
684 }
685
686 /*
687 * jump --
688 * strip out flag argument and jump
689 */
690 static void
691 jump(argv, flag, name)
692 char **argv, *flag, *name;
693 {
694 char **arg;
695
696 argv[0] = name;
697 for (arg = argv + 1; *arg; ++arg)
698 if (!strcmp(*arg, flag))
699 break;
700 for (; *arg; ++arg)
701 arg[0] = arg[1];
702 execvp(name, argv);
703 (void)fprintf(stderr, "%s: Command not found.\n", name);
704 exit(1);
705 }
706
707 /*
708 * onsig --
709 * If signaled, delete the temporary files.
710 */
711 static void
712 onsig(signo)
713 int signo;
714 {
715 (void)cleanup();
716
717 (void)signal(signo, SIG_DFL);
718 (void)kill(getpid(), signo);
719
720 /* NOTREACHED */
721 exit (1);
722 }
723
724 /*
725 * cleanup --
726 * Clean up temporary files, show any error messages.
727 */
728 static int
729 cleanup()
730 {
731 TAG *intmpp, *missp;
732 ENTRY *ep;
733 int rval;
734
735 rval = 0;
736 ep = (missp = getlist("_missing")) == NULL ?
737 NULL : missp->list.tqh_first;
738 if (ep != NULL)
739 for (; ep != NULL; ep = ep->q.tqe_next) {
740 warnx("no entry for %s in the manual.", ep->s);
741 rval = 1;
742 }
743
744 ep = (intmpp = getlist("_intmp")) == NULL ?
745 NULL : intmpp->list.tqh_first;
746 for (; ep != NULL; ep = ep->q.tqe_next)
747 (void)unlink(ep->s);
748 return (rval);
749 }
750
751 /*
752 * usage --
753 * print usage message and die
754 */
755 static void
756 usage()
757 {
758 extern char *__progname;
759 (void)fprintf(stderr,
760 "Usage: %s [-achw] [-C file] [-M path] [-m path] [section] title ...\n",
761 __progname);
762 exit(1);
763 }
764