From 5fd83771641d15c418f747bd343ba6738d3875f7 Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Sun, 9 May 2021 14:20:58 -0400 Subject: Import macOS userland adv_cmds-176 basic_cmds-55 bootstrap_cmds-116.100.1 developer_cmds-66 diskdev_cmds-667.40.1 doc_cmds-53.60.1 file_cmds-321.40.3 mail_cmds-35 misc_cmds-34 network_cmds-606.40.1 patch_cmds-17 remote_cmds-63 shell_cmds-216.60.1 system_cmds-880.60.2 text_cmds-106 --- doc_cmds/checknr/checknr.1 | 163 ++++ doc_cmds/checknr/checknr.c | 607 +++++++++++++++ doc_cmds/colcrt/colcrt.1 | 124 +++ doc_cmds/colcrt/colcrt.c | 287 +++++++ doc_cmds/doc_cmds.plist | 72 ++ doc_cmds/doc_cmds.txt | 134 ++++ doc_cmds/doc_cmds.xcodeproj/project.pbxproj | 538 +++++++++++++ doc_cmds/intro.1 | 74 ++ doc_cmds/makewhatis/makewhatis.8 | 133 ++++ doc_cmds/makewhatis/makewhatis.c | 1094 +++++++++++++++++++++++++++ doc_cmds/makewhatis/makewhatis.local.8 | 69 ++ doc_cmds/makewhatis/makewhatis.local.sh | 64 ++ 12 files changed, 3359 insertions(+) create mode 100644 doc_cmds/checknr/checknr.1 create mode 100644 doc_cmds/checknr/checknr.c create mode 100644 doc_cmds/colcrt/colcrt.1 create mode 100644 doc_cmds/colcrt/colcrt.c create mode 100644 doc_cmds/doc_cmds.plist create mode 100644 doc_cmds/doc_cmds.txt create mode 100644 doc_cmds/doc_cmds.xcodeproj/project.pbxproj create mode 100644 doc_cmds/intro.1 create mode 100644 doc_cmds/makewhatis/makewhatis.8 create mode 100644 doc_cmds/makewhatis/makewhatis.c create mode 100644 doc_cmds/makewhatis/makewhatis.local.8 create mode 100644 doc_cmds/makewhatis/makewhatis.local.sh (limited to 'doc_cmds') diff --git a/doc_cmds/checknr/checknr.1 b/doc_cmds/checknr/checknr.1 new file mode 100644 index 0000000..871730e --- /dev/null +++ b/doc_cmds/checknr/checknr.1 @@ -0,0 +1,163 @@ +.\" Copyright (c) 1980, 1990, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)checknr.1 8.1 (Berkeley) 6/6/93 +.\" $FreeBSD: src/usr.bin/checknr/checknr.1,v 1.10 2004/07/02 22:22:23 ru Exp $ +.\" +.Dd June 6, 1993 +.Dt CHECKNR 1 +.Os +.Sh NAME +.Nm checknr +.Nd check nroff/troff files +.Sh SYNOPSIS +.Nm +.Op Fl a Ns Ar \&.x1.y1.x2.y2. ... \&.xn.yn +.Op Fl c Ns Ar \&.x1.x2.x3 ... \&.xn +.Op Fl s +.Op Fl f +.Ar file +.Sh DESCRIPTION +The +.Nm +utility checks a list of +.Xr nroff 1 +or +.Xr troff 1 +input files for certain kinds of errors +involving mismatched opening and closing delimiters +and unknown commands. +If no files are specified, +.Nm +checks the standard input. +.Pp +The following options are available: +.Bl -tag -width indent +.It Fl a +Add additional pairs of macros to the list of known macros. +This must be followed by groups of six characters, each group defining +a pair of macros. +The six characters are +a period, +the first macro name, +another period, +and the second macro name. +For example, to define a pair .BS and .ES, use +.Sq Li \-a.BS.ES +.It Fl c +Define commands which would otherwise be complained about +as undefined. +.It Fl f +Request +.Nm +to ignore +.Ql \ef +font changes. +.It Fl s +Ignore +.Ql \es +size changes. +.El +.Pp +Delimiters checked are: +.Bl -enum +.It +Font changes using \efx ...\& \efP. +.It +Size changes using \esx ...\& \es0. +.It +Macros that come in open ...\& close forms, for example, +the .TS and .TE macros which must always come in pairs. +.El +.Pp +The +.Nm +utility is intended for use on documents that are prepared with +.Nm +in mind, much the same as +.Xr lint 1 . +It expects a certain document writing style for +.Ql \ef +and +.Ql \es +commands, +in that each +.Ql \efx +must be terminated with +.Ql \efP +and +each +.Ql \esx +must be terminated with +.Ql \es0 . +While it will work to directly go into the next font or explicitly +specify the original font or point size, +and many existing documents actually do this, +such a practice will produce complaints from +.Nm . +Since it is probably better to use the +.Ql \efP +and +.Ql \es0 +forms anyway, +you should think of this as a contribution to your document +preparation style. +.Pp +The +.Nm +utility knows about the +.Xr ms 7 +and +.Xr me 7 +macro packages. +.Sh SEE ALSO +.Xr nroff 1 , +.Xr troff 1 , +.Xr me 7 , +.Xr ms 7 +.\" .Xr checkeq 1 , +.Sh DIAGNOSTICS +.Bd -ragged -compact +Complaints about unmatched delimiters. +Complaints about unrecognized commands. +Various complaints about the syntax of commands. +.Ed +.Sh BUGS +There is no way to define a 1 character macro name using +.Fl a . +.Pp +Does not correctly recognize certain reasonable constructs, +such as conditionals. +.Sh HISTORY +The +.Nm +command appeared in +.Bx 4.0 . diff --git a/doc_cmds/checknr/checknr.c b/doc_cmds/checknr/checknr.c new file mode 100644 index 0000000..ae1f847 --- /dev/null +++ b/doc_cmds/checknr/checknr.c @@ -0,0 +1,607 @@ +/* + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static const char copyright[] = +"@(#) Copyright (c) 1980, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#if 0 +#ifndef lint +static char sccsid[] = "@(#)checknr.c 8.1 (Berkeley) 6/6/93"; +#endif /* not lint */ +#endif + +#include +__FBSDID("$FreeBSD: src/usr.bin/checknr/checknr.c,v 1.9 2004/07/15 04:42:47 tjr Exp $"); + +/* + * checknr: check an nroff/troff input file for matching macro calls. + * we also attempt to match size and font changes, but only the embedded + * kind. These must end in \s0 and \fP resp. Maybe more sophistication + * later but for now think of these restrictions as contributions to + * structured typesetting. + */ +#include +#include +#include +#include +#include + +#define MAXSTK 100 /* Stack size */ +#define MAXBR 100 /* Max number of bracket pairs known */ +#define MAXCMDS 500 /* Max number of commands known */ + +void addcmd(char *); +void addmac(const char *); +int binsrch(const char *); +void checkknown(const char *); +void chkcmd(const char *, const char *); +void complain(int); +int eq(const char *, const char *); +void nomatch(const char *); +void pe(int); +void process(FILE *); +void prop(int); +static void usage(void); + +/* + * The stack on which we remember what we've seen so far. + */ +struct stkstr { + int opno; /* number of opening bracket */ + int pl; /* '+', '-', ' ' for \s, 1 for \f, 0 for .ft */ + int parm; /* parm to size, font, etc */ + int lno; /* line number the thing came in in */ +} stk[MAXSTK]; +int stktop; + +/* + * The kinds of opening and closing brackets. + */ +struct brstr { + const char *opbr; + const char *clbr; +} br[MAXBR] = { + /* A few bare bones troff commands */ +#define SZ 0 + {"sz", "sz"}, /* also \s */ +#define FT 1 + {"ft", "ft"}, /* also \f */ + /* the -mm package */ + {"AL", "LE"}, + {"AS", "AE"}, + {"BL", "LE"}, + {"BS", "BE"}, + {"DF", "DE"}, + {"DL", "LE"}, + {"DS", "DE"}, + {"FS", "FE"}, + {"ML", "LE"}, + {"NS", "NE"}, + {"RL", "LE"}, + {"VL", "LE"}, + /* the -ms package */ + {"AB", "AE"}, + {"BD", "DE"}, + {"CD", "DE"}, + {"DS", "DE"}, + {"FS", "FE"}, + {"ID", "DE"}, + {"KF", "KE"}, + {"KS", "KE"}, + {"LD", "DE"}, + {"LG", "NL"}, + {"QS", "QE"}, + {"RS", "RE"}, + {"SM", "NL"}, + {"XA", "XE"}, + {"XS", "XE"}, + /* The -me package */ + {"(b", ")b"}, + {"(c", ")c"}, + {"(d", ")d"}, + {"(f", ")f"}, + {"(l", ")l"}, + {"(q", ")q"}, + {"(x", ")x"}, + {"(z", ")z"}, + /* Things needed by preprocessors */ + {"EQ", "EN"}, + {"TS", "TE"}, + /* Refer */ + {"[", "]"}, + {0, 0} +}; + +/* + * All commands known to nroff, plus macro packages. + * Used so we can complain about unrecognized commands. + */ +const char *knowncmds[MAXCMDS] = { +"$c", "$f", "$h", "$p", "$s", "(b", "(c", "(d", "(f", "(l", "(q", "(t", +"(x", "(z", ")b", ")c", ")d", ")f", ")l", ")q", ")t", ")x", ")z", "++", +"+c", "1C", "1c", "2C", "2c", "@(", "@)", "@C", "@D", "@F", "@I", "@M", +"@c", "@e", "@f", "@h", "@m", "@n", "@o", "@p", "@r", "@t", "@z", "AB", +"AE", "AF", "AI", "AL", "AM", "AS", "AT", "AU", "AX", "B", "B1", "B2", +"BD", "BE", "BG", "BL", "BS", "BT", "BX", "C1", "C2", "CD", "CM", "CT", +"D", "DA", "DE", "DF", "DL", "DS", "DT", "EC", "EF", "EG", "EH", "EM", +"EN", "EQ", "EX", "FA", "FD", "FE", "FG", "FJ", "FK", "FL", "FN", "FO", +"FQ", "FS", "FV", "FX", "H", "HC", "HD", "HM", "HO", "HU", "I", "ID", +"IE", "IH", "IM", "IP", "IX", "IZ", "KD", "KE", "KF", "KQ", "KS", "LB", +"LC", "LD", "LE", "LG", "LI", "LP", "MC", "ME", "MF", "MH", "ML", "MR", +"MT", "ND", "NE", "NH", "NL", "NP", "NS", "OF", "OH", "OK", "OP", "P", +"P1", "PF", "PH", "PP", "PT", "PX", "PY", "QE", "QP", "QS", "R", "RA", +"RC", "RE", "RL", "RP", "RQ", "RS", "RT", "S", "S0", "S2", "S3", "SA", +"SG", "SH", "SK", "SM", "SP", "SY", "T&", "TA", "TB", "TC", "TD", "TE", +"TH", "TL", "TM", "TP", "TQ", "TR", "TS", "TX", "UL", "US", "UX", "VL", +"WC", "WH", "XA", "XD", "XE", "XF", "XK", "XP", "XS", "[", "[-", "[0", +"[1", "[2", "[3", "[4", "[5", "[<", "[>", "[]", "]", "]-", "]<", "]>", +"][", "ab", "ac", "ad", "af", "am", "ar", "as", "b", "ba", "bc", "bd", +"bi", "bl", "bp", "br", "bx", "c.", "c2", "cc", "ce", "cf", "ch", "cs", +"ct", "cu", "da", "de", "di", "dl", "dn", "ds", "dt", "dw", "dy", "ec", +"ef", "eh", "el", "em", "eo", "ep", "ev", "ex", "fc", "fi", "fl", "fo", +"fp", "ft", "fz", "hc", "he", "hl", "hp", "ht", "hw", "hx", "hy", "i", +"ie", "if", "ig", "in", "ip", "it", "ix", "lc", "lg", "li", "ll", "ln", +"lo", "lp", "ls", "lt", "m1", "m2", "m3", "m4", "mc", "mk", "mo", "n1", +"n2", "na", "ne", "nf", "nh", "nl", "nm", "nn", "np", "nr", "ns", "nx", +"of", "oh", "os", "pa", "pc", "pi", "pl", "pm", "pn", "po", "pp", "ps", +"q", "r", "rb", "rd", "re", "rm", "rn", "ro", "rr", "rs", "rt", "sb", +"sc", "sh", "sk", "so", "sp", "ss", "st", "sv", "sz", "ta", "tc", "th", +"ti", "tl", "tm", "tp", "tr", "u", "uf", "uh", "ul", "vs", "wh", "xp", +"yr", 0 +}; + +int lineno; /* current line number in input file */ +const char *cfilename; /* name of current file */ +int nfiles; /* number of files to process */ +int fflag; /* -f: ignore \f */ +int sflag; /* -s: ignore \s */ +int ncmds; /* size of knowncmds */ +int slot; /* slot in knowncmds found by binsrch */ + +int +main(int argc, char **argv) +{ + FILE *f; + int i; + char *cp; + char b1[4]; + + /* Figure out how many known commands there are */ + while (knowncmds[ncmds]) + ncmds++; + while (argc > 1 && argv[1][0] == '-') { + switch(argv[1][1]) { + + /* -a: add pairs of macros */ + case 'a': + i = strlen(argv[1]) - 2; + if (i % 6 != 0) + usage(); + /* look for empty macro slots */ + for (i=0; br[i].opbr; i++) + ; + for (cp=argv[1]+3; cp[-1]; cp += 6) { + br[i].opbr = strncpy(malloc(3), cp, 2); + br[i].clbr = strncpy(malloc(3), cp+3, 2); + addmac(br[i].opbr); /* knows pairs are also known cmds */ + addmac(br[i].clbr); + i++; + } + break; + + /* -c: add known commands */ + case 'c': + i = strlen(argv[1]) - 2; + if (i % 3 != 0) + usage(); + for (cp=argv[1]+3; cp[-1]; cp += 3) { + if (cp[2] && cp[2] != '.') + usage(); + strncpy(b1, cp, 2); + b1[2] = '\0'; + addmac(b1); + } + break; + + /* -f: ignore font changes */ + case 'f': + fflag = 1; + break; + + /* -s: ignore size changes */ + case 's': + sflag = 1; + break; + default: + usage(); + } + argc--; argv++; + } + + nfiles = argc - 1; + + if (nfiles > 0) { + for (i=1; i=0; i--) { + complain(i); + } +} + +void +complain(int i) +{ + pe(stk[i].lno); + printf("Unmatched "); + prop(i); + printf("\n"); +} + +void +prop(int i) +{ + if (stk[i].pl == 0) + printf(".%s", br[stk[i].opno].opbr); + else switch(stk[i].opno) { + case SZ: + printf("\\s%c%d", stk[i].pl, stk[i].parm); + break; + case FT: + printf("\\f%c", stk[i].parm); + break; + default: + printf("Bug: stk[%d].opno = %d = .%s, .%s", + i, stk[i].opno, br[stk[i].opno].opbr, br[stk[i].opno].clbr); + } +} + +void +chkcmd(const char *line __unused, const char *mac) +{ + int i; + + /* + * Check to see if it matches top of stack. + */ + if (stktop >= 0 && eq(mac, br[stk[stktop].opno].clbr)) + stktop--; /* OK. Pop & forget */ + else { + /* No. Maybe it's an opener */ + for (i=0; br[i].opbr; i++) { + if (eq(mac, br[i].opbr)) { + /* Found. Push it. */ + stktop++; + stk[stktop].opno = i; + stk[stktop].pl = 0; + stk[stktop].parm = 0; + stk[stktop].lno = lineno; + break; + } + /* + * Maybe it's an unmatched closer. + * NOTE: this depends on the fact + * that none of the closers can be + * openers too. + */ + if (eq(mac, br[i].clbr)) { + nomatch(mac); + break; + } + } + } +} + +void +nomatch(const char *mac) +{ + int i, j; + + /* + * Look for a match further down on stack + * If we find one, it suggests that the stuff in + * between is supposed to match itself. + */ + for (j=stktop; j>=0; j--) + if (eq(mac,br[stk[j].opno].clbr)) { + /* Found. Make a good diagnostic. */ + if (j == stktop-2) { + /* + * Check for special case \fx..\fR and don't + * complain. + */ + if (stk[j+1].opno==FT && stk[j+1].parm!='R' + && stk[j+2].opno==FT && stk[j+2].parm=='R') { + stktop = j -1; + return; + } + /* + * We have two unmatched frobs. Chances are + * they were intended to match, so we mention + * them together. + */ + pe(stk[j+1].lno); + prop(j+1); + printf(" does not match %d: ", stk[j+2].lno); + prop(j+2); + printf("\n"); + } else for (i=j+1; i <= stktop; i++) { + complain(i); + } + stktop = j-1; + return; + } + /* Didn't find one. Throw this away. */ + pe(lineno); + printf("Unmatched .%s\n", mac); +} + +/* eq: are two strings equal? */ +int +eq(const char *s1, const char *s2) +{ + return (strcmp(s1, s2) == 0); +} + +/* print the first part of an error message, given the line number */ +void +pe(int linen) +{ + if (nfiles > 1) + printf("%s: ", cfilename); + printf("%d: ", linen); +} + +void +checkknown(const char *mac) +{ + + if (eq(mac, ".")) + return; + if (binsrch(mac) >= 0) + return; + if (mac[0] == '\\' && mac[1] == '"') /* comments */ + return; + + pe(lineno); + printf("Unknown command: .%s\n", mac); +} + +/* + * We have a .de xx line in "line". Add xx to the list of known commands. + */ +void +addcmd(char *line) +{ + char *mac; + + /* grab the macro being defined */ + mac = line+4; + while (isspace(*mac)) + mac++; + if (*mac == 0) { + pe(lineno); + printf("illegal define: %s\n", line); + return; + } + mac[2] = 0; + if (isspace(mac[1]) || mac[1] == '\\') + mac[1] = 0; + if (ncmds >= MAXCMDS) { + printf("Only %d known commands allowed\n", MAXCMDS); + exit(1); + } + addmac(mac); +} + +/* + * Add mac to the list. We should really have some kind of tree + * structure here but this is a quick-and-dirty job and I just don't + * have time to mess with it. (I wonder if this will come back to haunt + * me someday?) Anyway, I claim that .de is fairly rare in user + * nroff programs, and the register loop below is pretty fast. + */ +void +addmac(const char *mac) +{ + const char **src, **dest, **loc; + + if (binsrch(mac) >= 0){ /* it's OK to redefine something */ +#ifdef DEBUG + printf("binsrch(%s) -> already in table\n", mac); +#endif + return; + } + /* binsrch sets slot as a side effect */ +#ifdef DEBUG +printf("binsrch(%s) -> %d\n", mac, slot); +#endif + loc = &knowncmds[slot]; + src = &knowncmds[ncmds-1]; + dest = src+1; + while (dest > loc) + *dest-- = *src--; + *loc = strcpy(malloc(3), mac); + ncmds++; +#ifdef DEBUG +printf("after: %s %s %s %s %s, %d cmds\n", knowncmds[slot-2], knowncmds[slot-1], knowncmds[slot], knowncmds[slot+1], knowncmds[slot+2], ncmds); +#endif +} + +/* + * Do a binary search in knowncmds for mac. + * If found, return the index. If not, return -1. + */ +int +binsrch(const char *mac) +{ + const char *p; /* pointer to current cmd in list */ + int d; /* difference if any */ + int mid; /* mid point in binary search */ + int top, bot; /* boundaries of bin search, inclusive */ + + top = ncmds-1; + bot = 0; + while (top >= bot) { + mid = (top+bot)/2; + p = knowncmds[mid]; + d = p[0] - mac[0]; + if (d == 0) + d = p[1] - mac[1]; + if (d == 0) + return mid; + if (d < 0) + bot = mid + 1; + else + top = mid - 1; + } + slot = bot; /* place it would have gone */ + return -1; +} diff --git a/doc_cmds/colcrt/colcrt.1 b/doc_cmds/colcrt/colcrt.1 new file mode 100644 index 0000000..cc2df02 --- /dev/null +++ b/doc_cmds/colcrt/colcrt.1 @@ -0,0 +1,124 @@ +.\" Copyright (c) 1980, 1990, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)colcrt.1 8.1 (Berkeley) 6/30/93 +.\" $FreeBSD: src/usr.bin/colcrt/colcrt.1,v 1.13 2004/07/31 06:22:01 tjr Exp $ +.\" +.Dd July 31, 2004 +.Dt COLCRT 1 +.Os +.Sh NAME +.Nm colcrt +.Nd filter nroff output for CRT previewing +.Sh SYNOPSIS +.Nm +.Op Fl +.Op Fl \&2 +.Op Ar +.Sh DESCRIPTION +The +.Nm +utility provides virtual half-line and reverse line feed sequences +for terminals without such capability, and on which overstriking +is destructive. +Half-line characters and underlining (changed to dashing `\-') +are placed on new lines in between the normal output lines. +.Pp +The following options are available: +.Bl -tag -width indent +.It Fl +Suppress all underlining. +This option is especially useful for previewing +.Em allboxed +tables from +.Xr tbl 1 . +.It Fl 2 +Cause all half-lines to be printed, effectively double spacing the output. +Normally, a minimal space output format is used which will suppress empty +lines. +The program never suppresses two consecutive empty lines, however. +The +.Fl 2 +option is useful for sending output to the line printer when the output +contains superscripts and subscripts which would otherwise be invisible. +.El +.Sh ENVIRONMENT +The +.Ev LANG , LC_ALL +and +.Ev LC_CTYPE +environment variables affect the execution of +.Nm +as described in +.Xr environ 7 . +.Sh EXAMPLES +A typical use of +.Nm +would be +.Bd -literal +tbl exum2.n \&| nroff \-ms \&| colcrt \- \&| more +.Ed +.Sh DIAGNOSTICS +.Ex -std +.Sh SEE ALSO +.Xr col 1 , +.Xr more 1 , +.Xr nroff 1 , +.Xr troff 1 , +.Xr ul 1 +.Sh BUGS +Should fold underlines onto blanks even with the +.Sq Fl +option so that +a true underline character would show. +.Pp +Can't back up more than 102 lines. +.Pp +General overstriking is lost; +as a special case +.Ql \&| +overstruck with +.Ql \- +or underline becomes +.Ql \&+ . +.Pp +Lines are trimmed to 132 characters. +.Pp +Some provision should be made for processing superscripts and subscripts +in documents which are already double-spaced. +.Pp +Characters that take up more than one column position may not be +underlined correctly. +.Sh HISTORY +The +.Nm +command appeared in +.Bx 3.0 . diff --git a/doc_cmds/colcrt/colcrt.c b/doc_cmds/colcrt/colcrt.c new file mode 100644 index 0000000..2e5570b --- /dev/null +++ b/doc_cmds/colcrt/colcrt.c @@ -0,0 +1,287 @@ +/* + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static const char copyright[] = +"@(#) Copyright (c) 1980, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif + +#if 0 +#ifndef lint +static char sccsid[] = "@(#)colcrt.c 8.1 (Berkeley) 6/6/93"; +#endif +#endif + +#include +__FBSDID("$FreeBSD: src/usr.bin/colcrt/colcrt.c,v 1.18 2004/07/31 06:22:57 tjr Exp $"); + +#include +#include +#include +#include +#include +#include +#include + +/* + * colcrt - replaces col for crts with new nroff esp. when using tbl. + * Bill Joy UCB July 14, 1977 + * + * This filter uses a screen buffer, 267 half-lines by 132 columns. + * It interprets the up and down sequences generated by the new + * nroff when used with tbl and by \u \d and \r. + * General overstriking doesn't work correctly. + * Underlining is split onto multiple lines, etc. + * + * Option - suppresses all underlining. + * Option -2 forces printing of all half lines. + */ + +wchar_t page[267][132]; + +int outline = 1; +int outcol; + +char suppresul; +char printall; + +static void move(int, int); +static void pflush(int); +static int plus(wchar_t, wchar_t); +static void usage(void); + +int +main(int argc, char *argv[]) +{ + wint_t c; + wchar_t *cp, *dp; + int ch, i, w; + + setlocale(LC_ALL, ""); + + while ((ch = getopt(argc, argv, "-2")) != -1) + switch (ch) { + case '-': + suppresul = 1; + break; + case '2': + printall = 1; + break; + default: + usage(); + } + argc -= optind; + argv += optind; + + do { + if (argc > 0) { + if (freopen(argv[0], "r", stdin) == NULL) { + fflush(stdout); + err(1, "%s", argv[0]); + } + argc--; + argv++; + } + for (;;) { + c = getwc(stdin); + if (c == WEOF) { + pflush(outline); + fflush(stdout); + break; + } + switch (c) { + case '\n': + if (outline >= 265) + pflush(62); + outline += 2; + outcol = 0; + continue; + case '\016': + case '\017': + continue; + case 033: + c = getwc(stdin); + switch (c) { + case '9': + if (outline >= 266) + pflush(62); + outline++; + continue; + case '8': + if (outline >= 1) + outline--; + continue; + case '7': + outline -= 2; + if (outline < 0) + outline = 0; + continue; + default: + continue; + } + case '\b': + if (outcol) + outcol--; + continue; + case '\t': + outcol += 8; + outcol &= ~7; + outcol--; + c = ' '; + default: + if ((w = wcwidth(c)) <= 0) + w = 1; /* XXX */ + if (outcol + w > 132) { + outcol += w; + continue; + } + cp = &page[outline][outcol]; + outcol += w; + if (c == '_') { + if (suppresul) + continue; + cp += 132; + c = '-'; + } + if (*cp == 0) { + for (i = 0; i < w; i++) + cp[i] = c; + dp = cp - (outcol - w); + for (cp--; cp >= dp && *cp == 0; cp--) + *cp = ' '; + } else { + if (plus(c, *cp) || plus(*cp, c)) + *cp = '+'; + else if (*cp == ' ' || *cp == 0) { + for (i = 1; i < w; i++) + if (cp[i] != ' ' && + cp[i] != 0) + goto cont; + for (i = 0; i < w; i++) + cp[i] = c; + } + } +cont: + continue; + } + } + if (ferror(stdin)) + err(1, NULL); + } while (argc > 0); + fflush(stdout); + exit(0); +} + +static void +usage(void) +{ + fprintf(stderr, "usage: colcrt [-] [-2] [file ...]\n"); + exit(1); +} + +static int +plus(wchar_t c, wchar_t d) +{ + + return ((c == '|' && d == '-') || d == '_'); +} + +static void +pflush(int ol) +{ + static int first; + int i; + wchar_t *cp; + char lastomit; + int l, w; + + l = ol; + lastomit = 0; + if (l > 266) + l = 266; + else + l |= 1; + for (i = first | 1; i < l; i++) { + move(i, i - 1); + move(i, i + 1); + } + for (i = first; i < l; i++) { + cp = page[i]; + if (printall == 0 && lastomit == 0 && *cp == 0) { + lastomit = 1; + continue; + } + lastomit = 0; + while (*cp != L'\0') { + if ((w = wcwidth(*cp)) > 0) { + putwchar(*cp); + cp += w; + } else + cp++; + } + putwchar(L'\n'); + } + wmemcpy(page[0], page[ol], (267 - ol) * 132); + wmemset(page[267- ol], L'\0', ol * 132); + outline -= ol; + outcol = 0; + first = 1; +} + +static void +move(int l, int m) +{ + wchar_t *cp, *dp; + + for (cp = page[l], dp = page[m]; *cp; cp++, dp++) { + switch (*cp) { + case '|': + if (*dp != ' ' && *dp != '|' && *dp != 0) + return; + break; + case ' ': + break; + default: + return; + } + } + if (*cp == 0) { + for (cp = page[l], dp = page[m]; *cp; cp++, dp++) + if (*cp == '|') + *dp = '|'; + else if (*dp == 0) + *dp = ' '; + page[l][0] = 0; + } +} diff --git a/doc_cmds/doc_cmds.plist b/doc_cmds/doc_cmds.plist new file mode 100644 index 0000000..a9ea197 --- /dev/null +++ b/doc_cmds/doc_cmds.plist @@ -0,0 +1,72 @@ + + + + OpenSourceProject + checknr + OpenSourceVersion + 2004-09-18 + OpenSourceWebsiteURL + http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.bin/checknr/ + OpenSourceCVS + cvs -d freebsdanoncvs@anoncvs.FreeBSD.org:/home/ncvs co checknr + OpenSourceImportDate + 2004-09-18 + OpenSourceLicense + BSD + OpenSourceLicenseFile + doc_cmds.txt + + + OpenSourceProject + colcrt + OpenSourceVersion + 2004-09-18 + OpenSourceWebsiteURL + http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.bin/colcrt/ + OpenSourceCVS + cvs -d freebsdanoncvs@anoncvs.FreeBSD.org:/home/ncvs co colcrt + OpenSourceImportDate + 2004-09-18 + OpenSourceLicense + BSD + OpenSourceLicenseFile + doc_cmds.txt + + + OpenSourceProject + getNAME + OpenSourceVersion + 2004-09-18 + OpenSourceWebsiteURL + http://www.freebsd.org/cgi/cvsweb.cgi/src/libexec/getNAME/ + OpenSourceCVS + cvs -d freebsdanoncvs@anoncvs.FreeBSD.org:/home/ncvs co getNAME + OpenSourceImportDate + 2004-09-18 + OpenSourceLicense + BSD + OpenSourceLicenseFile + doc_cmds.txt + + + OpenSourceProject + makewhatis + OpenSourceVersion + 2004-09-18 + OpenSourceWebsiteURL + http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.bin/makewhatis/ + OpenSourceCVS + cvs -d freebsdanoncvs@anoncvs.FreeBSD.org:/home/ncvs co makewhatis + OpenSourceImportDate + 2004-09-18 + OpenSourceModifications + + 3806865 + + OpenSourceLicense + BSD + OpenSourceLicenseFile + doc_cmds.txt + + + diff --git a/doc_cmds/doc_cmds.txt b/doc_cmds/doc_cmds.txt new file mode 100644 index 0000000..873a785 --- /dev/null +++ b/doc_cmds/doc_cmds.txt @@ -0,0 +1,134 @@ +checknr: + +/* + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +colcrt: + +/* + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +getNAME: + +/*- + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +makewhatis: + +/*- + * Copyright (c) 2002 John Rochester + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff --git a/doc_cmds/doc_cmds.xcodeproj/project.pbxproj b/doc_cmds/doc_cmds.xcodeproj/project.pbxproj new file mode 100644 index 0000000..ec9533d --- /dev/null +++ b/doc_cmds/doc_cmds.xcodeproj/project.pbxproj @@ -0,0 +1,538 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 45; + objects = { + +/* Begin PBXAggregateTarget section */ + FD91BA470FC2319F00643D04 /* Build All */ = { + isa = PBXAggregateTarget; + buildConfigurationList = FD91BA500FC231AB00643D04 /* Build configuration list for PBXAggregateTarget "Build All" */; + buildPhases = ( + ); + dependencies = ( + FD91BA6B0FC231C500643D04 /* PBXTargetDependency */, + FD91BA690FC231C500643D04 /* PBXTargetDependency */, + FD91BA650FC231C500643D04 /* PBXTargetDependency */, + FD91BA930FC2330000643D04 /* PBXTargetDependency */, + ); + name = "Build All"; + productName = "Build All"; + }; + FD91BA900FC232FB00643D04 /* Other Files */ = { + isa = PBXAggregateTarget; + buildConfigurationList = FD91BAA00FC2331400643D04 /* Build configuration list for PBXAggregateTarget "Other Files" */; + buildPhases = ( + FD91BA8F0FC232FB00643D04 /* man1 */, + FD91BAA60FC2338D00643D04 /* OpenSourceVersions */, + FD91BAA70FC2338D00643D04 /* OpenSourceLicenses */, + ); + dependencies = ( + ); + name = "Other Files"; + productName = Other; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + FD91BA6C0FC231D500643D04 /* checknr.c in Sources */ = {isa = PBXBuildFile; fileRef = FD91BA270FC2311E00643D04 /* checknr.c */; }; + FD91BA6D0FC231DA00643D04 /* colcrt.c in Sources */ = {isa = PBXBuildFile; fileRef = FD91BA2C0FC2311E00643D04 /* colcrt.c */; }; + FD91BA6F0FC231EA00643D04 /* makewhatis.c in Sources */ = {isa = PBXBuildFile; fileRef = FD91BA3E0FC2311E00643D04 /* makewhatis.c */; }; + FD91BA830FC2328800643D04 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = FD91BA820FC2328800643D04 /* libz.dylib */; }; + FD91BAA10FC2332800643D04 /* intro.1 in man1 */ = {isa = PBXBuildFile; fileRef = FD91BA440FC2316200643D04 /* intro.1 */; }; + FD91BAA30FC2335800643D04 /* doc_cmds.plist in OpenSourceVersions */ = {isa = PBXBuildFile; fileRef = FD91BA2F0FC2311E00643D04 /* doc_cmds.plist */; }; + FD91BAA50FC2336F00643D04 /* doc_cmds.txt in OpenSourceLicenses */ = {isa = PBXBuildFile; fileRef = FD91BA300FC2311E00643D04 /* doc_cmds.txt */; }; + FD91BAAD0FC233BB00643D04 /* checknr.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD91BA260FC2311E00643D04 /* checknr.1 */; }; + FD91BAB00FC233DD00643D04 /* colcrt.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD91BA2B0FC2311E00643D04 /* colcrt.1 */; }; + FD91BAB60FC2346F00643D04 /* makewhatis.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD91BA3D0FC2311E00643D04 /* makewhatis.8 */; }; + FD91BAB70FC2346F00643D04 /* makewhatis.local.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD91BA3F0FC2311E00643D04 /* makewhatis.local.8 */; }; + FDB4EC3B0FC32F8D00F23EE6 /* makewhatis.local.sh in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD91BA400FC2311E00643D04 /* makewhatis.local.sh */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + FD91BA640FC231C500643D04 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = FD91BA090FC2310A00643D04 /* Project object */; + proxyType = 1; + remoteGlobalIDString = FD91BA600FC231BE00643D04; + remoteInfo = makewhatis; + }; + FD91BA680FC231C500643D04 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = FD91BA090FC2310A00643D04 /* Project object */; + proxyType = 1; + remoteGlobalIDString = FD91BA540FC231B200643D04; + remoteInfo = colcrt; + }; + FD91BA6A0FC231C500643D04 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = FD91BA090FC2310A00643D04 /* Project object */; + proxyType = 1; + remoteGlobalIDString = FD91BA4B0FC231AB00643D04; + remoteInfo = checknr; + }; + FD91BA920FC2330000643D04 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = FD91BA090FC2310A00643D04 /* Project object */; + proxyType = 1; + remoteGlobalIDString = FD91BA900FC232FB00643D04; + remoteInfo = Other; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + FD91BA8F0FC232FB00643D04 /* man1 */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 8; + dstPath = /usr/share/man/man1; + dstSubfolderSpec = 0; + files = ( + FD91BAA10FC2332800643D04 /* intro.1 in man1 */, + ); + name = man1; + runOnlyForDeploymentPostprocessing = 1; + }; + FD91BAA60FC2338D00643D04 /* OpenSourceVersions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 8; + dstPath = /usr/local/OpenSourceVersions; + dstSubfolderSpec = 0; + files = ( + FD91BAA30FC2335800643D04 /* doc_cmds.plist in OpenSourceVersions */, + ); + name = OpenSourceVersions; + runOnlyForDeploymentPostprocessing = 1; + }; + FD91BAA70FC2338D00643D04 /* OpenSourceLicenses */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 8; + dstPath = /usr/local/OpenSourceLicenses; + dstSubfolderSpec = 0; + files = ( + FD91BAA50FC2336F00643D04 /* doc_cmds.txt in OpenSourceLicenses */, + ); + name = OpenSourceLicenses; + runOnlyForDeploymentPostprocessing = 1; + }; + FD91BAAC0FC233B600643D04 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 8; + dstPath = /usr/share/man/man1; + dstSubfolderSpec = 0; + files = ( + FD91BAAD0FC233BB00643D04 /* checknr.1 in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 1; + }; + FD91BAAF0FC233D600643D04 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 8; + dstPath = /usr/share/man/man1; + dstSubfolderSpec = 0; + files = ( + FD91BAB00FC233DD00643D04 /* colcrt.1 in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 1; + }; + FD91BAB50FC2346000643D04 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 8; + dstPath = /usr/share/man/man8; + dstSubfolderSpec = 0; + files = ( + FD91BAB60FC2346F00643D04 /* makewhatis.8 in CopyFiles */, + FD91BAB70FC2346F00643D04 /* makewhatis.local.8 in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 1; + }; + FDB4EC3D0FC32FA700F23EE6 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 8; + dstPath = /usr/libexec; + dstSubfolderSpec = 0; + files = ( + FDB4EC3B0FC32F8D00F23EE6 /* makewhatis.local.sh in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + FD91BA260FC2311E00643D04 /* checknr.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; path = checknr.1; sourceTree = ""; }; + FD91BA270FC2311E00643D04 /* checknr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = checknr.c; sourceTree = ""; }; + FD91BA2B0FC2311E00643D04 /* colcrt.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; path = colcrt.1; sourceTree = ""; }; + FD91BA2C0FC2311E00643D04 /* colcrt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = colcrt.c; sourceTree = ""; }; + FD91BA2F0FC2311E00643D04 /* doc_cmds.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = doc_cmds.plist; sourceTree = ""; }; + FD91BA300FC2311E00643D04 /* doc_cmds.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = doc_cmds.txt; sourceTree = ""; }; + FD91BA3D0FC2311E00643D04 /* makewhatis.8 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = makewhatis.8; sourceTree = ""; }; + FD91BA3E0FC2311E00643D04 /* makewhatis.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = makewhatis.c; sourceTree = ""; }; + FD91BA3F0FC2311E00643D04 /* makewhatis.local.8 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = makewhatis.local.8; sourceTree = ""; }; + FD91BA400FC2311E00643D04 /* makewhatis.local.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = makewhatis.local.sh; sourceTree = ""; }; + FD91BA440FC2316200643D04 /* intro.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; path = intro.1; sourceTree = ""; }; + FD91BA4C0FC231AB00643D04 /* checknr */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = checknr; sourceTree = BUILT_PRODUCTS_DIR; }; + FD91BA550FC231B200643D04 /* colcrt */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = colcrt; sourceTree = BUILT_PRODUCTS_DIR; }; + FD91BA610FC231BE00643D04 /* makewhatis */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = makewhatis; sourceTree = BUILT_PRODUCTS_DIR; }; + FD91BA820FC2328800643D04 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = /usr/lib/libz.dylib; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + FD91BA4A0FC231AB00643D04 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + FD91BA530FC231B200643D04 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + FD91BA5F0FC231BE00643D04 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + FD91BA830FC2328800643D04 /* libz.dylib in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + FD91BA070FC2310A00643D04 = { + isa = PBXGroup; + children = ( + FD91BA150FC2311E00643D04 /* Source */, + FD91BA4D0FC231AB00643D04 /* Products */, + FD91BA820FC2328800643D04 /* libz.dylib */, + ); + sourceTree = ""; + }; + FD91BA150FC2311E00643D04 /* Source */ = { + isa = PBXGroup; + children = ( + FD91BA250FC2311E00643D04 /* checknr */, + FD91BA2A0FC2311E00643D04 /* colcrt */, + FD91BA3A0FC2311E00643D04 /* makewhatis */, + FD91BA2F0FC2311E00643D04 /* doc_cmds.plist */, + FD91BA300FC2311E00643D04 /* doc_cmds.txt */, + FD91BA440FC2316200643D04 /* intro.1 */, + ); + name = Source; + sourceTree = ""; + }; + FD91BA250FC2311E00643D04 /* checknr */ = { + isa = PBXGroup; + children = ( + FD91BA260FC2311E00643D04 /* checknr.1 */, + FD91BA270FC2311E00643D04 /* checknr.c */, + ); + path = checknr; + sourceTree = ""; + }; + FD91BA2A0FC2311E00643D04 /* colcrt */ = { + isa = PBXGroup; + children = ( + FD91BA2B0FC2311E00643D04 /* colcrt.1 */, + FD91BA2C0FC2311E00643D04 /* colcrt.c */, + ); + path = colcrt; + sourceTree = ""; + }; + FD91BA3A0FC2311E00643D04 /* makewhatis */ = { + isa = PBXGroup; + children = ( + FD91BA3D0FC2311E00643D04 /* makewhatis.8 */, + FD91BA3E0FC2311E00643D04 /* makewhatis.c */, + FD91BA3F0FC2311E00643D04 /* makewhatis.local.8 */, + FD91BA400FC2311E00643D04 /* makewhatis.local.sh */, + ); + path = makewhatis; + sourceTree = ""; + }; + FD91BA4D0FC231AB00643D04 /* Products */ = { + isa = PBXGroup; + children = ( + FD91BA4C0FC231AB00643D04 /* checknr */, + FD91BA550FC231B200643D04 /* colcrt */, + FD91BA610FC231BE00643D04 /* makewhatis */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + FD91BA4B0FC231AB00643D04 /* checknr */ = { + isa = PBXNativeTarget; + buildConfigurationList = FD91BA510FC231AB00643D04 /* Build configuration list for PBXNativeTarget "checknr" */; + buildPhases = ( + FD91BA490FC231AB00643D04 /* Sources */, + FD91BA4A0FC231AB00643D04 /* Frameworks */, + FD91BAAC0FC233B600643D04 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = checknr; + productName = checknr; + productReference = FD91BA4C0FC231AB00643D04 /* checknr */; + productType = "com.apple.product-type.tool"; + }; + FD91BA540FC231B200643D04 /* colcrt */ = { + isa = PBXNativeTarget; + buildConfigurationList = FD91BA720FC2320800643D04 /* Build configuration list for PBXNativeTarget "colcrt" */; + buildPhases = ( + FD91BA520FC231B200643D04 /* Sources */, + FD91BA530FC231B200643D04 /* Frameworks */, + FD91BAAF0FC233D600643D04 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = colcrt; + productName = colcrt; + productReference = FD91BA550FC231B200643D04 /* colcrt */; + productType = "com.apple.product-type.tool"; + }; + FD91BA600FC231BE00643D04 /* makewhatis */ = { + isa = PBXNativeTarget; + buildConfigurationList = FD91BA740FC2320800643D04 /* Build configuration list for PBXNativeTarget "makewhatis" */; + buildPhases = ( + FD91BA5E0FC231BE00643D04 /* Sources */, + FD91BA5F0FC231BE00643D04 /* Frameworks */, + FDB4EC3D0FC32FA700F23EE6 /* CopyFiles */, + FD91BAC90FC2359F00643D04 /* ShellScript */, + FD91BAB50FC2346000643D04 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = makewhatis; + productName = makewhatis; + productReference = FD91BA610FC231BE00643D04 /* makewhatis */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + FD91BA090FC2310A00643D04 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = FD91BA0C0FC2310A00643D04 /* Build configuration list for PBXProject "doc_cmds" */; + compatibilityVersion = "Xcode 3.1"; + hasScannedForEncodings = 0; + mainGroup = FD91BA070FC2310A00643D04; + productRefGroup = FD91BA4D0FC231AB00643D04 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + FD91BA470FC2319F00643D04 /* Build All */, + FD91BA4B0FC231AB00643D04 /* checknr */, + FD91BA540FC231B200643D04 /* colcrt */, + FD91BA600FC231BE00643D04 /* makewhatis */, + FD91BA900FC232FB00643D04 /* Other Files */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXShellScriptBuildPhase section */ + FD91BAC90FC2359F00643D04 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 8; + files = ( + ); + inputPaths = ( + "$(DSTROOT)/usr/libexec/makewhatis.local.sh", + ); + outputPaths = ( + "$(DSTROOT)/usr/libexec/makewhatis.local", + ); + runOnlyForDeploymentPostprocessing = 1; + shellPath = /bin/sh; + shellScript = "set -x\n/bin/mv ${SCRIPT_INPUT_FILE_0} ${SCRIPT_OUTPUT_FILE_0}\n/bin/chmod +x ${SCRIPT_OUTPUT_FILE_0}"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + FD91BA490FC231AB00643D04 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + FD91BA6C0FC231D500643D04 /* checknr.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + FD91BA520FC231B200643D04 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + FD91BA6D0FC231DA00643D04 /* colcrt.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + FD91BA5E0FC231BE00643D04 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + FD91BA6F0FC231EA00643D04 /* makewhatis.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + FD91BA650FC231C500643D04 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = FD91BA600FC231BE00643D04 /* makewhatis */; + targetProxy = FD91BA640FC231C500643D04 /* PBXContainerItemProxy */; + }; + FD91BA690FC231C500643D04 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = FD91BA540FC231B200643D04 /* colcrt */; + targetProxy = FD91BA680FC231C500643D04 /* PBXContainerItemProxy */; + }; + FD91BA6B0FC231C500643D04 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = FD91BA4B0FC231AB00643D04 /* checknr */; + targetProxy = FD91BA6A0FC231C500643D04 /* PBXContainerItemProxy */; + }; + FD91BA930FC2330000643D04 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = FD91BA900FC232FB00643D04 /* Other Files */; + targetProxy = FD91BA920FC2330000643D04 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + FD91BA0B0FC2310A00643D04 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD)"; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = YES; + CURRENT_PROJECT_VERSION = "$(RC_ProjectSourceVersion)"; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + GCC_MODEL_TUNING = ""; + PREBINDING = NO; + USE_HEADERMAP = NO; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = __; + ZERO_LINK = NO; + }; + name = Release; + }; + FD91BA480FC2319F00643D04 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + PRODUCT_NAME = "Build All"; + ZERO_LINK = NO; + }; + name = Release; + }; + FD91BA4F0FC231AB00643D04 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PREPROCESSOR_DEFINITIONS = "__FBSDID=__RCSID"; + INSTALL_PATH = /usr/bin; + PRODUCT_NAME = checknr; + }; + name = Release; + }; + FD91BA570FC231B200643D04 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PREPROCESSOR_DEFINITIONS = "__FBSDID=__RCSID"; + INSTALL_PATH = /usr/bin; + PRODUCT_NAME = colcrt; + }; + name = Release; + }; + FD91BA630FC231BF00643D04 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PREPROCESSOR_DEFINITIONS = "__FBSDID=__RCSID"; + INSTALL_PATH = /usr/libexec; + PRODUCT_NAME = makewhatis; + }; + name = Release; + }; + FD91BA910FC232FB00643D04 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + PRODUCT_NAME = Other; + ZERO_LINK = NO; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + FD91BA0C0FC2310A00643D04 /* Build configuration list for PBXProject "doc_cmds" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + FD91BA0B0FC2310A00643D04 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + FD91BA500FC231AB00643D04 /* Build configuration list for PBXAggregateTarget "Build All" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + FD91BA480FC2319F00643D04 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + FD91BA510FC231AB00643D04 /* Build configuration list for PBXNativeTarget "checknr" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + FD91BA4F0FC231AB00643D04 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + FD91BA720FC2320800643D04 /* Build configuration list for PBXNativeTarget "colcrt" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + FD91BA570FC231B200643D04 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + FD91BA740FC2320800643D04 /* Build configuration list for PBXNativeTarget "makewhatis" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + FD91BA630FC231BF00643D04 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + FD91BAA00FC2331400643D04 /* Build configuration list for PBXAggregateTarget "Other Files" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + FD91BA910FC232FB00643D04 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = FD91BA090FC2310A00643D04 /* Project object */; +} diff --git a/doc_cmds/intro.1 b/doc_cmds/intro.1 new file mode 100644 index 0000000..98c603c --- /dev/null +++ b/doc_cmds/intro.1 @@ -0,0 +1,74 @@ +.\" $NetBSD: intro.1,v 1.4 1994/11/30 08:35:00 jtc Exp $ +.\" +.\" Copyright (c) 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)intro.1 8.2 (Berkeley) 12/30/93 +.\" +.Dd December 30, 1993 +.Dt INTRO 1 +.Os +.Sh NAME +.Nm intro +.Nd introduction to general commands (tools and utilities) +.Sh DESCRIPTION +Section one of the manual contains most of the commands +which comprise the +.Bx +user environment. +Some of the commands included in section one are +text editors, command shell interpreters, +searching and sorting tools, +file manipulation commands +system status commands, +remote file copy commands, mail commands, +compilers and compiler tools, +formatted output tools, +and line printer commands. +.Pp +All commands set a status value upon exit which may be tested +to see if the command completed normally. +The exit values and their meanings are explained in the individual +manuals. Traditionally, the value 0 signifies successful +completion of the command. +.Sh SEE ALSO +.Xr man 1 , +.Xr intro 2 , +.Xr intro 4 , +.Xr intro 8 , +.Pp +Tutorials in the +.%T "UNIX User's Manual Supplementary Documents" . +.Sh HISTORY +A +.Nm intro +manual appeared in +.At v6 . diff --git a/doc_cmds/makewhatis/makewhatis.8 b/doc_cmds/makewhatis/makewhatis.8 new file mode 100644 index 0000000..5c59b96 --- /dev/null +++ b/doc_cmds/makewhatis/makewhatis.8 @@ -0,0 +1,133 @@ +.\" Copyright (c) 2002 John Rochester +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD: src/usr.bin/makewhatis/makewhatis.1,v 1.3 2002/05/18 15:39:56 ru Exp $ +.\" +.Dd May 12, 2002 +.Dt MAKEWHATIS 8 +.Os +.Sh NAME +.Nm makewhatis +.Nd "create whatis database" +.Sh SYNOPSIS +.Nm +.Op Fl a +.Op Fl i Ar column +.Op Fl n Ar name +.Op Fl o Ar file +.Op Fl v +.Op Fl L +.Op Ar directories ... +.Sh DESCRIPTION +The +.Nm +utility collects the names and short descriptions from all the unformatted +man pages in the +.Ar directories +and puts them into a file used by the +.Xr whatis 1 +and +.Xr apropos 1 +commands. +Directories may be separated by colons instead of spaces. +If no +.Ar directories +are specified, the contents of the +.Ev MANPATH +environment variable will be used, or if that is not set, the default directory +.Pa /usr/share/man +will be processed. +.Pp +The options are as follows: +.Bl -tag -width ".Fl i Ar column" +.It Fl a +Appends to the output file(s) instead of replacing them. +The output +will be sorted with duplicate lines removed, but may have obsolete +entries. +.It Fl i Ar column +Indents the description by +.Ar column +characters. +The default value is 24. +.It Fl n Ar name +Uses +.Ar name +instead of +.Pa whatis . +.It Fl o Ar file +Outputs all lines to the +.Ar file +instead of +.Pa */man/whatis . +.It Fl v +Makes +.Nm +more verbose about what it is doing. +.It Fl L +Process only localized subdirectories corresponding to the locale specified +in the standard environment variables. +.El +.Sh ENVIRONMENT +.Bl -tag -width ".Ev MANPATH" +.It Ev LC_ALL , LC_CTYPE , LANG +These variables control what subdirectories will be processed if the +.Fl L +option is used. +.It Ev MACHINE +If set, its value is used to override the current +machine type when searching machine specific subdirectories. +.It Ev MANPATH +Determines the set of directories to be processed if none are given on +the command line. +.El +.Sh FILES +.Bl -tag -width ".Pa /usr/share/man" -compact +.It Pa /usr/share/man +Default directory to process if the +.Ev MANPATH +environment variable is not set. +.It Pa */man/whatis +The default output file. +.El +.Sh DIAGNOSTICS +.Ex -std +.Sh SEE ALSO +.Xr apropos 1 , +.Xr whatis 1 +.Sh HISTORY +The +.Nm +command appeared in +.Fx 2.1 . +.Sh AUTHORS +.An -nosplit +The +.Nm +program was originally written in Perl and was contributed by +.An Wolfram Schneider . +The current version of +.Nm +was rewritten in C by +.An John Rochester . diff --git a/doc_cmds/makewhatis/makewhatis.c b/doc_cmds/makewhatis/makewhatis.c new file mode 100644 index 0000000..1a98842 --- /dev/null +++ b/doc_cmds/makewhatis/makewhatis.c @@ -0,0 +1,1094 @@ +/*- + * Copyright (c) 2002 John Rochester + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD: src/usr.bin/makewhatis/makewhatis.c,v 1.9 2002/09/04 23:29:04 dwmalone Exp $"); + +#include +#include +#include +#include + +/* Workaround for missing #define in sys/queue.h (3806865) */ +#ifndef SLIST_HEAD_INITIALIZER +#define SLIST_HEAD_INITIALIZER(head) { NULL } +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEFAULT_MANPATH "/usr/share/man" +#define LINE_ALLOC 4096 + +static char blank[] = ""; + +/* + * Information collected about each man page in a section. + */ +struct page_info { + char * filename; + char * name; + char * suffix; + int gzipped; + ino_t inode; +}; + +/* + * An entry kept for each visited directory. + */ +struct visited_dir { + dev_t device; + ino_t inode; + SLIST_ENTRY(visited_dir) next; +}; + +/* + * an expanding string + */ +struct sbuf { + char * content; /* the start of the buffer */ + char * end; /* just past the end of the content */ + char * last; /* the last allocated character */ +}; + +/* + * Removes the last amount characters from the sbuf. + */ +#define sbuf_retract(sbuf, amount) \ + ((sbuf)->end -= (amount)) +/* + * Returns the length of the sbuf content. + */ +#define sbuf_length(sbuf) \ + ((sbuf)->end - (sbuf)->content) + +typedef char *edited_copy(char *from, char *to, int length); + +static int append; /* -a flag: append to existing whatis */ +static int verbose; /* -v flag: be verbose with warnings */ +static int indent = 24; /* -i option: description indentation */ +static const char *whatis_name="whatis";/* -n option: the name */ +static char *common_output; /* -o option: the single output file */ +static char *locale; /* user's locale if -L is used */ +static char *lang_locale; /* short form of locale */ +#ifndef __APPLE__ +static const char *machine; +#endif /* !__APPLE__ */ + +static int exit_code; /* exit code to use when finished */ +static SLIST_HEAD(, visited_dir) visited_dirs = + SLIST_HEAD_INITIALIZER(visited_dirs); + +/* + * While the whatis line is being formed, it is stored in whatis_proto. + * When finished, it is reformatted into whatis_final and then appended + * to whatis_lines. + */ +static struct sbuf *whatis_proto; +static struct sbuf *whatis_final; +static StringList *whatis_lines; /* collected output lines */ + +static char tmp_file[MAXPATHLEN]; /* path of temporary file, if any */ +static char tmp_rel_file[MAXPATHLEN]; + +/* A set of possible names for the NAME man page section */ +static const char *name_section_titles[] = { + "NAME", "Name", "NAMN", "BEZEICHNUNG", "\xcc\xbe\xbe\xce", + "\xee\xe1\xfa\xf7\xe1\xee\xe9\xe5", NULL +}; + +/* A subset of the mdoc(7) commands to ignore */ +static char mdoc_commands[] = "ArDvErEvFlLiNmPa"; + +/* + * Frees a struct page_info and its content. + */ +static void +free_page_info(struct page_info *info) +{ + free(info->filename); + free(info->name); + free(info->suffix); + free(info); +} + +/* + * Allocates and fills in a new struct page_info given the + * name of the man section directory and the dirent of the file. + * If the file is not a man page, returns NULL. + */ +static struct page_info * +new_page_info(char *dir, struct dirent *dirent) +{ + struct page_info *info; + int basename_length; + char *suffix; + struct stat st; + + info = (struct page_info *) malloc(sizeof(struct page_info)); + if (info == NULL) + err(1, "malloc"); + basename_length = strlen(dirent->d_name); + suffix = &dirent->d_name[basename_length]; + asprintf(&info->filename, "%s/%s", dir, dirent->d_name); + if ((info->gzipped = basename_length >= 4 && strcmp(&dirent->d_name[basename_length - 3], ".gz") == 0)) { + suffix -= 3; + *suffix = '\0'; + } + for (;;) { + if (--suffix == dirent->d_name || !isalnum(*suffix)) { + if (*suffix == '.') + break; + if (verbose) + warnx("%s: invalid man page name", info->filename); + free(info->filename); + free(info); + return NULL; + } + } + *suffix++ = '\0'; + info->name = strdup(dirent->d_name); + info->suffix = strdup(suffix); + if (stat(info->filename, &st) < 0) { + warn("%s", info->filename); + free_page_info(info); + return NULL; + } + if (!S_ISREG(st.st_mode)) { + if (verbose && !S_ISDIR(st.st_mode)) + warnx("%s: not a regular file", info->filename); + free_page_info(info); + return NULL; + } + info->inode = st.st_ino; + return info; +} + +/* + * Reset an sbuf's length to 0. + */ +static void +sbuf_clear(struct sbuf *sbuf) +{ + sbuf->end = sbuf->content; +} + +/* + * Allocate a new sbuf. + */ +static struct sbuf * +new_sbuf(void) +{ + struct sbuf *sbuf = (struct sbuf *) malloc(sizeof(struct sbuf)); + sbuf->content = (char *) malloc(LINE_ALLOC); + sbuf->last = sbuf->content + LINE_ALLOC - 1; + sbuf_clear(sbuf); + return sbuf; +} + +/* + * Ensure that there is enough room in the sbuf for nchars more characters. + */ +static void +sbuf_need(struct sbuf *sbuf, int nchars) +{ + char *new_content; + size_t size, cntsize; + + /* double the size of the allocation until the buffer is big enough */ + while (sbuf->end + nchars > sbuf->last) { + size = sbuf->last + 1 - sbuf->content; + size *= 2; + cntsize = sbuf->end - sbuf->content; + + new_content = (char *)malloc(size); + memcpy(new_content, sbuf->content, cntsize); + free(sbuf->content); + sbuf->content = new_content; + sbuf->end = new_content + cntsize; + sbuf->last = new_content + size - 1; + } +} + +/* + * Appends a string of a given length to the sbuf. + */ +static void +sbuf_append(struct sbuf *sbuf, const char *text, int length) +{ + if (length > 0) { + sbuf_need(sbuf, length); + memcpy(sbuf->end, text, length); + sbuf->end += length; + } +} + +/* + * Appends a null-terminated string to the sbuf. + */ +static void +sbuf_append_str(struct sbuf *sbuf, char *text) +{ + sbuf_append(sbuf, text, strlen(text)); +} + +/* + * Appends an edited null-terminated string to the sbuf. + */ +static void +sbuf_append_edited(struct sbuf *sbuf, char *text, edited_copy copy) +{ + int length = strlen(text); + if (length > 0) { + sbuf_need(sbuf, length); + sbuf->end = copy(text, sbuf->end, length); + } +} + +/* + * Strips any of a set of chars from the end of the sbuf. + */ +static void +sbuf_strip(struct sbuf *sbuf, const char *set) +{ + while (sbuf->end > sbuf->content && strchr(set, sbuf->end[-1]) != NULL) + sbuf->end--; +} + +/* + * Returns the null-terminated string built by the sbuf. + */ +static char * +sbuf_content(struct sbuf *sbuf) +{ + *sbuf->end = '\0'; + return sbuf->content; +} + +/* + * Returns true if no man page exists in the directory with + * any of the names in the StringList. + */ +static int +no_page_exists(char *dir, StringList *names, char *suffix) +{ + char path[MAXPATHLEN]; + size_t i; + + for (i = 0; i < names->sl_cur; i++) { + snprintf(path, sizeof path, "%s/%s.%s.gz", dir, names->sl_str[i], suffix); + if (access(path, F_OK) < 0) { + path[strlen(path) - 3] = '\0'; + if (access(path, F_OK) < 0) + continue; + } + return 0; + } + return 1; +} + +static void +trap_signal(int sig __unused) +{ + if (tmp_file[0] != '\0') + unlink(tmp_file); + exit(1); +} + +/* + * Attempts to open an output file. Returns NULL if unsuccessful. + */ +static FILE * +open_output(char *name, int dir_fd, char *rel_name) +{ + FILE *output; + int output_fd; + struct stat statbuf; + + whatis_lines = sl_init(); + if (append) { + char line[LINE_ALLOC]; + + output_fd = openat(dir_fd, rel_name, O_RDONLY); + if (output_fd == -1) { + warn("%s", name); + exit_code = 1; + return NULL; + } + output = fdopen(output_fd, "r"); + if (output == NULL) { + warn("%s", name); + exit_code = 1; + return NULL; + } + while (fgets(line, sizeof line, output) != NULL) { + line[strlen(line) - 1] = '\0'; + sl_add(whatis_lines, strdup(line)); + } + fclose(output); + } + if (common_output == NULL) { + snprintf(tmp_file, sizeof tmp_file, "%s.tmp", name); + snprintf(tmp_rel_file, sizeof tmp_rel_file, "%s.tmp", rel_name); + name = tmp_file; + rel_name = tmp_rel_file; + } + /* Bail out if the file is actually a symlink or has another link. + * This script can run as root and we don't want to risk writing + * into a random location. + * See rdar://problem/55280616 + */ + output_fd = openat(dir_fd, rel_name, O_WRONLY | O_NOFOLLOW | O_CREAT | O_TRUNC, 0644); + if (output_fd == -1) { + warn("%s", name); + exit_code = 1; + return NULL; + } + if (fstat(output_fd, &statbuf) == -1) { + warn("%s: unable to stat", name); + close(output_fd); + exit_code = 1; + return NULL; + } + if (statbuf.st_nlink > 1) { + warnx("%s: is a hardlink", name); + close(output_fd); + exit_code = 1; + return NULL; + } + output = fdopen(output_fd, "w"); + if (output == NULL) { + warn("%s", name); + exit_code = 1; + return NULL; + } + return output; +} + +static int +linesort(const void *a, const void *b) +{ + return strcmp((*(const char * const *)a), (*(const char * const *)b)); +} + +/* + * Writes the unique sorted lines to the output file. + */ +static void +finish_output(FILE *output, char *name, int dir_fd, char *rel_name) +{ + size_t i; + char *prev = NULL; + + qsort(whatis_lines->sl_str, whatis_lines->sl_cur, sizeof(char *), linesort); + for (i = 0; i < whatis_lines->sl_cur; i++) { + char *line = whatis_lines->sl_str[i]; + if (i > 0 && strcmp(line, prev) == 0) + continue; + prev = line; + fputs(line, output); + putc('\n', output); + } + fclose(output); + sl_free(whatis_lines, 1); + if (common_output == NULL) { + renameat(dir_fd, tmp_rel_file, dir_fd, rel_name); + unlinkat(dir_fd, tmp_rel_file, 0); + } +} + +static FILE * +open_whatis(char *mandir, int mandir_fd) +{ + char filename[MAXPATHLEN]; + + snprintf(filename, sizeof filename, "%s/%s", mandir, whatis_name); + return open_output(filename, mandir_fd, whatis_name); +} + +static void +finish_whatis(FILE *output, char *mandir, int mandir_fd) +{ + char filename[MAXPATHLEN]; + + snprintf(filename, sizeof filename, "%s/%s", mandir, whatis_name); + finish_output(output, filename, mandir_fd, whatis_name); +} + +/* + * Tests to see if the given directory has already been visited. + */ +static int +already_visited(char *dir) +{ + struct stat st; + struct visited_dir *visit; + + if (stat(dir, &st) < 0) { + warn("%s", dir); + exit_code = 1; + return 1; + } + SLIST_FOREACH(visit, &visited_dirs, next) { + if (visit->inode == st.st_ino && + visit->device == st.st_dev) { + warnx("already visited %s", dir); + return 1; + } + } + visit = (struct visited_dir *) malloc(sizeof(struct visited_dir)); + visit->device = st.st_dev; + visit->inode = st.st_ino; + SLIST_INSERT_HEAD(&visited_dirs, visit, next); + return 0; +} + +/* + * Removes trailing spaces from a string, returning a pointer to just + * beyond the new last character. + */ +static char * +trim_rhs(char *str) +{ + char *rhs = &str[strlen(str)]; + while (--rhs > str && isspace(*rhs)) + ; + *++rhs = '\0'; + return rhs; +} + +/* + * Returns a pointer to the next non-space character in the string. + */ +static char * +skip_spaces(char *s) +{ + while (*s != '\0' && isspace(*s)) + s++; + return s; +} + +/* + * Returns whether the string contains only digits. + */ +static int +only_digits(char *line) +{ + if (!isdigit(*line++)) + return 0; + while (isdigit(*line)) + line++; + return *line == '\0'; +} + +/* + * Returns whether the line is of one of the forms: + * .Sh NAME + * .Sh "NAME" + * etc. + * assuming that section_start is ".Sh". + */ +static int +name_section_line(char *line, const char *section_start) +{ + char *rhs; + const char **title; + + if (strncmp(line, section_start, 3) != 0) + return 0; + line = skip_spaces(line + 3); + rhs = trim_rhs(line); + if (*line == '"') { + line++; + if (*--rhs == '"') + *rhs = '\0'; + } + for (title = name_section_titles; *title != NULL; title++) + if (strcmp(*title, line) == 0) + return 1; + return 0; +} + +/* + * Copies characters while removing the most common nroff/troff + * markup: + * \(em, \(mi, \s[+-N], \& + * \fF, \f(fo, \f[font] + * \*s, \*(st, \*[stringvar] + */ +static char * +de_nroff_copy(char *from, char *to, int fromlen) +{ + char *from_end = &from[fromlen]; + while (from < from_end) { + switch (*from) { + case '\\': + switch (*++from) { + case '(': + if (strncmp(&from[1], "em", 2) == 0 || + strncmp(&from[1], "mi", 2) == 0) { + from += 3; + continue; + } + break; + case 's': + if (*++from == '-') + from++; + while (isdigit(*from)) + from++; + continue; + case 'f': + case '*': + if (*++from == '(') + from += 3; + else if (*from == '[') { + while (*++from != ']' && from < from_end); + from++; + } else + from++; + continue; + case '&': + from++; + continue; + } + break; + } + *to++ = *from++; + } + return to; +} + +/* + * Appends a string with the nroff formatting removed. + */ +static void +add_nroff(char *text) +{ + sbuf_append_edited(whatis_proto, text, de_nroff_copy); +} + +/* + * Appends "name(suffix), " to whatis_final. + */ +static void +add_whatis_name(char *name, char *suffix) +{ + if (*name != '\0') { + sbuf_append_str(whatis_final, name); + sbuf_append(whatis_final, "(", 1); + sbuf_append_str(whatis_final, suffix); + sbuf_append(whatis_final, "), ", 3); + } +} + +/* + * Processes an old-style man(7) line. This ignores commands with only + * a single number argument. + */ +static void +process_man_line(char *line) +{ + if (*line == '.') { + while (isalpha(*++line)) + ; + line = skip_spaces(line); + if (only_digits(line)) + return; + } else + line = skip_spaces(line); +#ifdef __APPLE__ + /* 4454557 */ + if (*line == '"') + ++line; +#endif /* __APPLE__ */ + if (*line != '\0') { + add_nroff(line); + sbuf_append(whatis_proto, " ", 1); + } +} + +/* + * Processes a new-style mdoc(7) line. + */ +static void +process_mdoc_line(char *line) +{ + int xref; + int arg = 0; + char *line_end = &line[strlen(line)]; + int orig_length = sbuf_length(whatis_proto); + char *next; + + if (*line == '\0') + return; + if (line[0] != '.' || !isupper(line[1]) || !islower(line[2])) { + add_nroff(skip_spaces(line)); + sbuf_append(whatis_proto, " ", 1); + return; + } + xref = strncmp(line, ".Xr", 3) == 0; + line += 3; + while ((line = skip_spaces(line)) < line_end) { + if (*line == '"') { + next = ++line; + for (;;) { + next = strchr(next, '"'); + if (next == NULL) + break; + memmove(next, next + 1, strlen(next)); + line_end--; + if (*next != '"') + break; + next++; + } + } else + next = strpbrk(line, " \t"); + if (next != NULL) + *next++ = '\0'; + else + next = line_end; + if (isupper(*line) && islower(line[1]) && line[2] == '\0') { + if (strcmp(line, "Ns") == 0) { + arg = 0; + line = next; + continue; + } + if (strstr(mdoc_commands, line) != NULL) { + line = next; + continue; + } + } + if (arg > 0 && strchr(",.:;?!)]", *line) == 0) { + if (xref) { + sbuf_append(whatis_proto, "(", 1); + add_nroff(line); + sbuf_append(whatis_proto, ")", 1); + xref = 0; + line = blank; + } else + sbuf_append(whatis_proto, " ", 1); + } + add_nroff(line); + arg++; + line = next; + } + if (sbuf_length(whatis_proto) > orig_length) + sbuf_append(whatis_proto, " ", 1); +} + +/* + * Collects a list of comma-separated names from the text. + */ +static void +collect_names(StringList *names, char *text) +{ + char *arg; + + for (;;) { + arg = text; + text = strchr(text, ','); + if (text != NULL) + *text++ = '\0'; + sl_add(names, arg); + if (text == NULL) + return; + if (*text == ' ') + text++; + } +} + +enum { STATE_UNKNOWN, STATE_MANSTYLE, STATE_MDOCNAME, STATE_MDOCDESC }; + +/* + * Processes a man page source into a single whatis line and adds it + * to whatis_lines. + */ +static void +process_page(struct page_info *page, char *section_dir) +{ + gzFile *in; + char buffer[4096]; + char *line; + StringList *names; + char *descr; + int state = STATE_UNKNOWN; + size_t i; + + sbuf_clear(whatis_proto); + if ((in = gzopen(page->filename, "r")) == NULL) { + warn("%s", page->filename); + exit_code = 1; + return; + } + while (gzgets(in, buffer, sizeof buffer) != NULL) { + line = buffer; + if (strncmp(line, ".\\\"", 3) == 0) /* ignore comments */ + continue; + switch (state) { + /* + * haven't reached the NAME section yet. + */ + case STATE_UNKNOWN: + if (name_section_line(line, ".SH")) + state = STATE_MANSTYLE; + else if (name_section_line(line, ".Sh")) + state = STATE_MDOCNAME; + continue; + /* + * Inside an old-style .SH NAME section. + */ + case STATE_MANSTYLE: + if ((strncmp(line, ".SH", 3) == 0) || (strncmp(line, ".SS", 3) == 0)) + break; + trim_rhs(line); + if (strcmp(line, ".") == 0) + continue; + if (strncmp(line, ".IX", 3) == 0) { + line += 3; + line = skip_spaces(line); + } + process_man_line(line); + continue; + /* + * Inside a new-style .Sh NAME section (the .Nm part). + */ + case STATE_MDOCNAME: + trim_rhs(line); + if (strncmp(line, ".Nm", 3) == 0) { + process_mdoc_line(line); + continue; + } else { + if (strcmp(line, ".") == 0) + continue; + sbuf_append(whatis_proto, "- ", 2); + state = STATE_MDOCDESC; + } + /* fall through */ + /* + * Inside a new-style .Sh NAME section (after the .Nm-s). + */ + case STATE_MDOCDESC: + if (strncmp(line, ".Sh", 3) == 0) + break; + trim_rhs(line); + if (strcmp(line, ".") == 0) + continue; + process_mdoc_line(line); + continue; + } + break; + } + gzclose(in); + sbuf_strip(whatis_proto, " \t.-"); + line = sbuf_content(whatis_proto); + /* + * line now contains the appropriate data, but without + * the proper indentation or the section appended to each name. + */ + descr = strstr(line, " - "); + if (descr == NULL) { + descr = strchr(line, ' '); + if (descr == NULL) { + if (verbose) + fprintf(stderr, " ignoring junk description \"%s\"\n", line); + return; + } + *descr++ = '\0'; + } else { + *descr = '\0'; + descr += 3; + } + names = sl_init(); + collect_names(names, line); + sbuf_clear(whatis_final); + if (!sl_find(names, page->name) && no_page_exists(section_dir, names, page->suffix)) { + /* + * Add the page name since that's the only thing that + * man(1) will find. + */ + add_whatis_name(page->name, page->suffix); + } + for (i = 0; i < names->sl_cur; i++) + add_whatis_name(names->sl_str[i], page->suffix); + sl_free(names, 0); + sbuf_retract(whatis_final, 2); /* remove last ", " */ + while (sbuf_length(whatis_final) < indent) + sbuf_append(whatis_final, " ", 1); + sbuf_append(whatis_final, " - ", 3); + sbuf_append_str(whatis_final, skip_spaces(descr)); + sl_add(whatis_lines, strdup(sbuf_content(whatis_final))); +} + +/* + * Sorts pages first by inode number, then by name. + */ +static int +pagesort(const void *a, const void *b) +{ + const struct page_info *p1 = *(struct page_info * const *) a; + const struct page_info *p2 = *(struct page_info * const *) b; + if (p1->inode == p2->inode) + return strcmp(p1->name, p2->name); + return p1->inode - p2->inode; +} + +/* + * Processes a single man section. + */ +static void +process_section(char *section_dir) +{ + struct dirent **entries; + int nentries; + struct page_info **pages; + int npages = 0; + int i; + ino_t prev_inode = 0; + + if (verbose) + fprintf(stderr, " %s\n", section_dir); + + /* + * scan the man section directory for pages + */ + nentries = scandir(section_dir, &entries, NULL, alphasort); + if (nentries < 0) { + warn("%s", section_dir); + exit_code = 1; + return; + } + /* + * collect information about man pages + */ + pages = (struct page_info **) calloc(nentries, sizeof(struct page_info *)); + for (i = 0; i < nentries; i++) { + struct page_info *info = new_page_info(section_dir, entries[i]); + if (info != NULL) + pages[npages++] = info; + free(entries[i]); + } + free(entries); + qsort(pages, npages, sizeof(struct page_info *), pagesort); + /* + * process each unique page + */ + for (i = 0; i < npages; i++) { + struct page_info *page = pages[i]; + if (page->inode != prev_inode) { + prev_inode = page->inode; + if (verbose) + fprintf(stderr, " reading %s\n", page->filename); + process_page(page, section_dir); + } else if (verbose) + fprintf(stderr, " skipping %s, duplicate\n", page->filename); + free_page_info(page); + } + free(pages); +} + +/* + * Returns whether the directory entry is a man page section. + */ +static int +select_sections(struct dirent *entry) +{ + char *p = &entry->d_name[3]; + + if (strncmp(entry->d_name, "man", 3) != 0) + return 0; + while (*p != '\0') { + if (!isalnum(*p++)) + return 0; + } + return 1; +} + +/* + * Processes a single top-level man directory by finding all the + * sub-directories named man* and processing each one in turn. + */ +static void +process_mandir(char *dir_name) +{ + int dir_fd; + DIR *dir; + FILE *fp = NULL; + struct dirent *entry; + struct stat st; + + if (already_visited(dir_name)) + return; + if (verbose) + fprintf(stderr, "man directory %s\n", dir_name); + + dir_fd = open(dir_name, O_RDONLY | O_DIRECTORY | O_NOFOLLOW); + if (dir_fd == -1) { + warn("%s", dir_name); + exit_code = 1; + return; + } + dir = fdopendir(dir_fd); + if (dir == NULL) { + warn("%s", dir_name); + close(dir_fd); + exit_code = 1; + return; + } + if (common_output == NULL && (fp = open_whatis(dir_name, dir_fd)) == NULL) { + closedir(dir); + return; + } + while ((entry = readdir(dir)) != NULL) { + char section_dir[MAXPATHLEN]; + if (select_sections(entry) == 0) + continue; + snprintf(section_dir, sizeof section_dir, "%s/%s", dir_name, entry->d_name); + process_section(section_dir); +#ifndef __APPLE__ + snprintf(section_dir, sizeof section_dir, "%s/%s/%s", dir_name, + entry->d_name, machine); + if (stat(section_dir, &st) == 0 && S_ISDIR(st.st_mode)) + process_section(section_dir); +#endif /* !__APPLE__ */ + } + if (common_output == NULL) + finish_whatis(fp, dir_name, dir_fd); + closedir(dir); +} + +/* + * Processes one argument, which may be a colon-separated list of + * directories. + */ +static void +process_argument(const char *arg) +{ + char *dir; + char *mandir; + char *parg; + + parg = strdup(arg); + if (parg == NULL) + err(1, "out of memory"); + while ((dir = strsep(&parg, ":")) != NULL) { + if (locale != NULL) { + asprintf(&mandir, "%s/%s", dir, locale); + process_mandir(mandir); + free(mandir); + if (lang_locale != NULL) { + asprintf(&mandir, "%s/%s", dir, lang_locale); + process_mandir(mandir); + free(mandir); + } + } else { + process_mandir(dir); + } + } + free(parg); +} + + +int +main(int argc, char **argv) +{ + int opt; + FILE *fp = NULL; + + while ((opt = getopt(argc, argv, "ai:n:o:vL")) != -1) { + switch (opt) { + case 'a': + append++; + break; + case 'i': + indent = atoi(optarg); + break; + case 'n': + whatis_name = optarg; + break; + case 'o': + common_output = optarg; + break; + case 'v': + verbose++; + break; + case 'L': + locale = getenv("LC_ALL"); + if (locale == NULL) + locale = getenv("LC_CTYPE"); + if (locale == NULL) + locale = getenv("LANG"); + if (locale != NULL) { + char *sep = strchr(locale, '_'); + if (sep != NULL && isupper(sep[1]) && + isupper(sep[2])) { + asprintf(&lang_locale, "%.*s%s", sep - locale, locale, &sep[3]); + } + } + break; + default: + fprintf(stderr, "usage: %s [-a] [-i indent] [-n name] [-o output_file] [-v] [-L] [directories...]\n", argv[0]); + exit(1); + } + } + + signal(SIGINT, trap_signal); + signal(SIGHUP, trap_signal); + signal(SIGQUIT, trap_signal); + signal(SIGTERM, trap_signal); + SLIST_INIT(&visited_dirs); + whatis_proto = new_sbuf(); + whatis_final = new_sbuf(); + +#ifndef __APPLE__ + if ((machine = getenv("MACHINE")) == NULL) + machine = MACHINE; +#endif /* !__APPLE__ */ + + if (common_output != NULL && (fp = open_output(common_output, AT_FDCWD, common_output)) == NULL) + err(1, "%s", common_output); + if (optind == argc) { + const char *manpath = getenv("MANPATH"); + if (manpath == NULL) + manpath = DEFAULT_MANPATH; + process_argument(manpath); + } else { + while (optind < argc) + process_argument(argv[optind++]); + } + if (common_output != NULL) + finish_output(fp, common_output, AT_FDCWD, common_output); + exit(exit_code); +} diff --git a/doc_cmds/makewhatis/makewhatis.local.8 b/doc_cmds/makewhatis/makewhatis.local.8 new file mode 100644 index 0000000..597d78b --- /dev/null +++ b/doc_cmds/makewhatis/makewhatis.local.8 @@ -0,0 +1,69 @@ +.\" Copyright (c) April 1996 Wolfram Schneider . Berlin. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD: src/usr.bin/makewhatis/makewhatis.local.8,v 1.15 2004/07/02 22:22:28 ru Exp $ +.Dd April 26, 1996 +.Dt MAKEWHATIS.LOCAL 8 +.Os +.Sh NAME +.Nm makewhatis.local +.Nd start makewhatis for local file systems +.Sh SYNOPSIS +.Nm /usr/libexec/makewhatis.local +.Op options +.Ar directories ... +.Sh DESCRIPTION +The +.Nm +utility starts +.Xr makewhatis 8 +only for file systems physically mounted on the system +where the +.Nm +is being executed. +Running makewhatis +by +.Pa periodic weekly +for rw nfs-mounted /usr may kill +your NFS server -- all NFS clients start makewhatis at the same time! +So use this wrapper for +.Xr cron 8 +instead of calling makewhatis directly. +.Sh FILES +.Bl -tag -width /etc/periodic/weekly/320.whatis.XXX -compact +.It Pa /etc/periodic/weekly/320.whatis +run +.Nm +every week +.El +.Sh SEE ALSO +.Xr find 1 , +.Xr makewhatis 8 , +.Xr cron 8 , +.Xr periodic 8 +.Sh HISTORY +The +.Nm +utility appeared in +.Fx 2.2 . diff --git a/doc_cmds/makewhatis/makewhatis.local.sh b/doc_cmds/makewhatis/makewhatis.local.sh new file mode 100644 index 0000000..6baedcb --- /dev/null +++ b/doc_cmds/makewhatis/makewhatis.local.sh @@ -0,0 +1,64 @@ +#!/bin/sh +# +# Copyright (c) April 1996 Wolfram Schneider . Berlin. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# makewhatis.local - start makewhatis(1) only for file systems +# physically mounted on the system +# +# Running makewhatis from /etc/periodic/weekly/320.whatis for rw nfs-mounted +# /usr may kill your NFS server -- all clients start makewhatis at the same +# time! So use this wrapper instead calling makewhatis directly. +# +# PS: this wrapper works also for catman(1) +# +# $FreeBSD: src/usr.bin/makewhatis/makewhatis.local.sh,v 1.7 1999/08/27 23:36:10 peter Exp $ +PATH=/bin:/usr/bin:/usr/libexec:$PATH; export PATH +opt= dirs= localdirs= stdout= + +for arg +do + case "$arg" in + "-o /dev/fd/1") + opt="$opt $arg" + stdout=1;; + -*) opt="$opt $arg";; + *) dirs="$dirs $arg";; + esac +done + +if [[ -z "$stdout" ]]; then + dirs=`echo $dirs | awk -F: '{ for (i = 1; i <= NF; i++) { if ($i !~ "\\.app/" && $i !~ "/CommandLineTools/") { printf $i " " } } printf "\n" }'` +else + dirs=`echo $dirs | sed 's/:/ /g'` +fi +case X"$dirs" in X) echo "usage: $0 [options] directories ..."; exit 1;; esac + +localdirs=`find -H $dirs -fstype local -type d -prune -print` + +case X"$localdirs" in + X) echo "$0: no local-mounted manual directories found: $dirs" + exit 1;; + *) exec `basename $0 .local` $opt $localdirs;; +esac -- cgit v1.2.3-56-ge451