version 1.16, 2001/01/31 19:26:51 |
version 1.17, 2001/04/10 02:32:33 |
|
|
if (!*argv) |
if (!*argv) |
usage(); |
usage(); |
|
|
if (!f_cat && !f_how && !f_where) |
if (!f_cat && !f_how && !f_where) { |
if (!isatty(1)) |
if (!isatty(1)) |
f_cat = 1; |
f_cat = 1; |
else if ((pager = getenv("PAGER")) != NULL && (*pager != '\0')) |
else if ((pager = getenv("PAGER")) != NULL && (*pager != '\0')) |
pager = check_pager(pager); |
pager = check_pager(pager); |
else |
else |
pager = _PATH_PAGER; |
pager = _PATH_PAGER; |
|
} |
|
|
/* Read the configuration file. */ |
/* Read the configuration file. */ |
config(conffile); |
config(conffile); |
|
|
/* |
/* |
* 3: If the user set the -m option, insert the user's list before |
* 3: If the user set the -m option, insert the user's list before |
* whatever list we have, again appending the _subdir list and |
* whatever list we have, again appending the _subdir list and |
* the machine. |
* the machine. |
*/ |
*/ |
if (p_add != NULL) { |
if (p_add != NULL) { |
e_sectp = NULL; |
e_sectp = NULL; |
|
|
err(1, NULL); |
err(1, NULL); |
/* puts it at the end, should be at the top, but then the added |
/* puts it at the end, should be at the top, but then the added |
entries would be in reverse order, fix later when all are added*/ |
entries would be in reverse order, fix later when all are added*/ |
TAILQ_INSERT_TAIL(&defp->list, ep, q); |
TAILQ_INSERT_TAIL(&defp->list, ep, q); |
if (e_sectp == NULL) /* save first added, to-be the new top */ |
if (e_sectp == NULL) /* save first added, to-be the new top */ |
e_sectp = ep; |
e_sectp = ep; |
} |
} |
|
|
defp->list.tqh_first = e_sectp; /* first added entry, new top */ |
defp->list.tqh_first = e_sectp; /* first added entry, new top */ |
*e_sectp->q.tqe_prev = NULL; /* terminate list */ |
*e_sectp->q.tqe_prev = NULL; /* terminate list */ |
} |
} |
} |
} |
/* |
/* |
* 4: If no -m was specified, and a section was, rewrite the section's |
* 4: If no -m was specified, and a section was, rewrite the section's |
* paths (if they have a trailing slash) to append the _subdir list |
* paths (if they have a trailing slash) to append the _subdir list |
|
|
for (ap = pg.gl_pathv; *ap != NULL; ++ap) { |
for (ap = pg.gl_pathv; *ap != NULL; ++ap) { |
if (**ap == '\0') |
if (**ap == '\0') |
continue; |
continue; |
(void)printf("%s\n", *ap); |
(void)puts(*ap); |
} |
} |
exit(cleanup()); |
exit(cleanup()); |
} |
} |
|
|
/* |
/* |
* 8: We display things in a single command; build a list of things |
* 8: We display things in a single command; build a list of things |
* to display. |
* to display. |
|
|
} |
} |
p = cmd; |
p = cmd; |
len = strlen(pager); |
len = strlen(pager); |
memmove(p, pager, len); |
memcpy(p, pager, len); |
p += len; |
p += len; |
*p++ = ' '; |
*p++ = ' '; |
for (ap = pg.gl_pathv; *ap != NULL; ++ap) { |
for (ap = pg.gl_pathv; *ap != NULL; ++ap) { |
if (**ap == '\0') |
if (**ap == '\0') |
continue; |
continue; |
len = strlen(*ap); |
len = strlen(*ap); |
memmove(p, *ap, len); |
memcpy(p, *ap, len); |
p += len; |
p += len; |
*p++ = ' '; |
*p++ = ' '; |
} |
} |
|
|
return (anyfound); |
return (anyfound); |
} |
} |
|
|
/* |
/* |
* build_page -- |
* build_page -- |
* Build a man page for display. |
* Build a man page for display. |
*/ |
*/ |
|
|
} |
} |
|
|
/* |
/* |
* Historically man chdir'd to the root of the man tree. |
* Historically man chdir'd to the root of the man tree. |
* This was used in man pages that contained relative ".so" |
* This was used in man pages that contained relative ".so" |
* directives (including other man pages for command aliases etc.) |
* directives (including other man pages for command aliases etc.) |
* It even went one step farther, by examining the first line |
* It even went one step farther, by examining the first line |
|
|
* make hard(?) links to the cat'ted man pages for space savings. |
* make hard(?) links to the cat'ted man pages for space savings. |
* (We don't do that here, but we could). |
* (We don't do that here, but we could). |
*/ |
*/ |
|
|
/* copy and find the end */ |
/* copy and find the end */ |
for (b = buf, p = *pathp; (*b++ = *p++) != '\0';) |
for (b = buf, p = *pathp; (*b++ = *p++) != '\0';) |
continue; |
continue; |
|
|
/* skip the last two path components, page name and man[n] */ |
/* skip the last two path components, page name and man[n] */ |
for (--b, n = 2; b != buf; b--) |
for (--b, n = 2; b != buf; b--) |
if (*b == '/') |
if (*b == '/') |
|
|
if (*buf == '\n') |
if (*buf == '\n') |
++lcnt; |
++lcnt; |
else { |
else { |
for(; lcnt; --lcnt) |
while (lcnt) { |
|
--lcnt; |
(void)putchar('\n'); |
(void)putchar('\n'); |
for (p = buf; isspace(*p); ++p); |
} |
|
for (p = buf; isspace(*p); ++p) |
|
; |
(void)fputs(p, stdout); |
(void)fputs(p, stdout); |
} |
} |
} |
} |
|
|
|
|
/* |
/* |
* if the user uses "more", we make it "more -s"; watch out for |
* if the user uses "more", we make it "more -s"; watch out for |
* PAGER = "mypager /usr/ucb/more" |
* PAGER = "mypager /usr/bin/more" |
*/ |
*/ |
for (p = name; *p && !isspace(*p); ++p) |
for (p = name; *p && !isspace(*p); ++p) |
; |
; |
|
|
save = name; |
save = name; |
/* allocate space to add the "-s" */ |
/* allocate space to add the "-s" */ |
if (!(name = |
if (!(name = |
malloc((u_int)(strlen(save) + 1 + sizeof("-s"))))) |
malloc(strlen(save) + 1 + sizeof("-s")))) |
err(1, NULL); |
err(1, NULL); |
(void)sprintf(name, "%s %s", save, "-s"); |
(void)sprintf(name, "%s %s", save, "-s"); |
} |
} |
|
|
exit(1); |
exit(1); |
} |
} |
|
|
/* |
/* |
* onsig -- |
* onsig -- |
* If signaled, delete the temporary files. |
* If signaled, delete the temporary files. |
*/ |
*/ |