Index: vendor/heirloom-doctools/dist/checknr/checknr.c =================================================================== --- vendor/heirloom-doctools/dist/checknr/checknr.c (revision 310549) +++ vendor/heirloom-doctools/dist/checknr/checknr.c (revision 310550) @@ -1,637 +1,637 @@ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* from OpenSolaris "checknr.c 1.8 05/06/02 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany */ #if __GNUC__ >= 3 && __GNUC_MINOR__ >= 4 || __GNUC__ >= 4 #define USED __attribute__ ((used)) #elif defined __GNUC__ #define USED __attribute__ ((unused)) #else #define USED #endif static const char sccsid[] USED = "@(#)/usr/ucb/checknr.sl 1.3 (gritter) 11/6/05"; /* * 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 #include "global.h" static int maxstk; /* Stack size */ #define MAXBR 100 /* Max number of bracket pairs known */ #define MAXCMDS 500 /* Max number of commands known */ /* * The stack on which we remember what we've seen so far. */ static 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; static int stktop; /* * The kinds of opening and closing brackets. */ static struct brstr { char *opbr; 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 */ { "[", "]" }, { NULL, NULL } }; /* * All commands known to nroff, plus macro packages. * Used so we can complain about unrecognized commands. */ static 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", "chop", "cs", "ct", "cu", "da", "de", "di", "dl", "dn", "do", "ds", "dt", "dw", "dy", "ec", "ef", "eh", "el", "em", "eo", "ep", "ev", "evc", "ex", "fallback", "fc", "feature", "fi", "fl", "flig", "fo", "fp", "ft", "ftr", "fz", "fzoom", "hc", "he", "hidechar", "hl", "hp", "ht", "hw", "hx", "hy", "hylang", "i", "ie", "if", "ig", "in", "ip", "it", "ix", "kern", "kernafter", "kernbefore", "kernpair", "lc", "lg", "lhang", "lc_ctype", "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", "papersize", "pc", "pi", "pl", "pm", "pn", "po", "pp", "ps", "q", "r", "rb", "rd", "re", "recursionlimit", "return", "rhang", "rm", "rn", "ro", "rr", "rs", "rt", "sb", "sc", "sh", "shift", "sk", "so", "sp", "ss", "st", "sv", "sz", "ta", "tc", "th", "ti", "tl", "tm", "tp", "tr", "track", "u", "uf", "uh", "ul", "vs", "wh", "xflag", "xp", "yr", 0 }; static int lineno; /* current line number in input file */ static char *line; /* the current line */ static size_t linesize; /* allocated size of current line */ static char *cfilename; /* name of current file */ static int nfiles; /* number of files to process */ static int fflag; /* -f: ignore \f */ static int sflag; /* -s: ignore \s */ static int ncmds; /* size of knowncmds */ static int slot; /* slot in knowncmds found by binsrch */ static void growstk(void); static void usage(void); static void process(FILE *f); static void complain(int i); static void prop(int i); static void chkcmd(char *line, char *mac); static void nomatch(char *mac); static int eq(char *s1, char *s2); static void pe(int lineno); static void checkknown(char *mac); static void addcmd(char *line); static void addmac(char *mac); static int binsrch(char *mac); static void growstk(void) { stktop++; if (stktop >= maxstk) { maxstk *= 2; stk = realloc(stk, sizeof *stk * maxstk); } } int main(int argc, char **argv) { FILE *f; int i; char *cp, *cq, c; stk = calloc(sizeof *stk, maxstk = 100); /* 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': /* look for empty macro slots */ for (i = 0; br[i].opbr; i++) ; cp = &argv[1][3]; while (*cp) { size_t s; if (i >= MAXBR - 3) { printf("Only %d known pairs allowed\n", MAXBR/2); exit(1); } for (cq = cp; *cq && *cq != '.'; cq++); if (*cq != '.') usage(); *cq = 0; s = cq - cp + 1; br[i].opbr = malloc(s); n_strcpy(br[i].opbr, cp, s); *cq = '.'; cp = &cq[1]; for (cq = cp; *cq && *cq != '.'; cq++); c = *cq; *cq = 0; s = cq - cp + 1; br[i].clbr = malloc(s); n_strcpy(br[i].clbr, cp, s); *cq = c; cp = c ? &cq[1] : cq; /* knows pairs are also known cmds */ addmac(br[i].opbr); addmac(br[i].clbr); i++; } break; /* -c: add known commands */ case 'c': cp = &argv[1][3]; while (*cp) { for (cq = cp; *cq && *cq != '.'; cq++); c = *cq; *cq = 0; addmac(cp); *cq = c; cp = c ? &cq[1] : cq; } 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 < argc; i++) { cfilename = argv[i]; f = fopen(cfilename, "r"); if (f == NULL) { perror(cfilename); exit(1); } else { process(f); fclose(f); } } } else { cfilename = "stdin"; process(stdin); } return (0); } static void usage(void) { printf("Usage: checknr -s -f -a.xx.yy.xx.yy... -c.xx.xx.xx...\n"); exit(1); } static void process(FILE *f) { int i, n; char mac[512]; /* The current macro or nroff command */ int pl; stktop = -1; for (lineno = 1; getline(&line, &linesize, f) > 0; lineno++) { if (line[0] == '.') { /* * find and isolate the macro/command name. */ strncpy(mac, line+1, sizeof mac-1)[sizeof mac-1] = 0; if (isspace(mac[0]&0377)) { pe(lineno); printf("Empty command\n"); } else { for (i = 1; mac[i]; i++) if (isspace(mac[i]&0377)) { mac[i] = 0; break; } } /* * Is it a known command? */ checkknown(mac); /* * Should we add it? */ if (eq(mac, "de")) addcmd(line); chkcmd(line, mac); } /* * At this point we process the line looking * for \s and \f. */ for (i = 0; line[i]; i++) if (line[i] == '\\' && (i == 0 || line[i-1] != '\\')) { if (!sflag && line[++i] == 's') { pl = line[++i]&0377; if (isdigit(pl)) { n = pl - '0'; pl = ' '; } else n = 0; while (isdigit(line[++i]&0377)) n = 10 * n + line[i] - '0'; i--; if (n == 0) { if (stk[stktop].opno == SZ) { stktop--; } else { pe(lineno); printf( "unmatched \\s0\n"); } } else { growstk(); stk[stktop].opno = SZ; stk[stktop].pl = pl; stk[stktop].parm = n; stk[stktop].lno = lineno; } } else if (!fflag && line[i] == 'f') { n = line[++i]; if (n == 'P') { if (stk[stktop].opno == FT) { stktop--; } else { pe(lineno); printf( "unmatched \\fP\n"); } } else { growstk(); stk[stktop].opno = FT; stk[stktop].pl = 1; stk[stktop].parm = n; stk[stktop].lno = lineno; } } } } /* * We've hit the end and look at all this stuff that hasn't been * matched yet! Complain, complain. */ for (i = stktop; i >= 0; i--) { complain(i); } } static void complain(int i) { pe(stk[i].lno); printf("Unmatched "); prop(i); printf("\n"); } static 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); } } /* ARGSUSED */ static void -chkcmd(char *line, char *mac) +chkcmd(char *line __unused, 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. */ growstk(); 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; } } } } static void nomatch(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? */ static int eq(char *s1, char *s2) { return (strcmp(s1, s2) == 0); } /* print the first part of an error message, given the line number */ static void pe(int lineno) { if (nfiles > 1) printf("%s: ", cfilename); printf("%d: ", lineno); } static void checkknown(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. */ static void addcmd(char *line) { char *mac; /* grab the macro being defined */ mac = line+4; while (isspace(*mac&0377)) mac++; if (*mac == 0) { pe(lineno); printf("illegal define: %s\n", line); return; } mac[2] = 0; if (isspace(mac[1]&0377) || mac[1] == '\\') mac[1] = 0; 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 loop below is pretty fast. */ static void addmac(char *mac) { char **src, **dest, **loc; size_t s; 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 if (ncmds >= MAXCMDS) { printf("Only %d known commands allowed\n", MAXCMDS); exit(1); } loc = &knowncmds[slot]; src = &knowncmds[ncmds-1]; dest = src+1; while (dest > loc) *dest-- = *src--; s = strlen(mac) + 1; *loc = malloc(s); n_strcpy(*loc, mac, s); 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. */ static int binsrch(char *mac) { 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 = strcmp(&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); } Index: vendor/heirloom-doctools/dist/eqn/eqn.d/eqnchar.7 =================================================================== --- vendor/heirloom-doctools/dist/eqn/eqn.d/eqnchar.7 (revision 310549) +++ vendor/heirloom-doctools/dist/eqn/eqn.d/eqnchar.7 (nonexistent) @@ -1,212 +0,0 @@ -'\" e -.\" Sccsid @(#)eqnchar.7b 1.2 (gritter) 12/9/05 -.\" Derived from eqnchar(7), Unix 7th edition: -.\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" Redistributions of source code and documentation must retain the -.\" above copyright notice, this list of conditions and the following -.\" disclaimer. -.\" 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. -.\" All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed or owned by Caldera -.\" International, Inc. -.\" Neither the name of Caldera International, Inc. nor the names of -.\" other contributors may be used to endorse or promote products -.\" derived from this software without specific prior written permission. -.\" -.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA -.\" INTERNATIONAL, INC. 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 CALDERA INTERNATIONAL, INC. 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. -.TH EQNCHAR 7 "12/9/05" "Heirloom Documentation Tools" "BSD System Compatibility" -.EQ -tdefine ciplus % "\o'\(pl\(ci'" % -ndefine ciplus % O+ % -tdefine citimes % "\o'\(mu\(ci'" % -ndefine citimes % Ox % -tdefine =wig % "\(eq\h'-\w'\(eq'u-\w'\s-2\(ap'u/2u'\v'-.4m'\s-2\z\(ap\(ap\s+2\v'.4m'\h'\w'\(eq'u-\w'\s-2\(ap'u/2u'" % -ndefine =wig % ="~" % -tdefine bigstar % "\o'\(pl\(mu'" % -ndefine bigstar % X|- % -tdefine =dot % "\z\(eq\v'-.6m'\h'.2m'\s+2.\s-2\v'.6m'\h'.1m'" % -ndefine =dot % = dot % -tdefine orsign % "\s-2\v'-.15m'\z\e\e\h'-.05m'\z\(sl\(sl\v'.15m'\s+2" % -ndefine orsign % \e/ % -tdefine andsign % "\s-2\v'-.15m'\z\(sl\(sl\h'-.05m'\z\e\e\v'.15m'\s+2" % -ndefine andsign % /\e % -tdefine =del % "\v'.3m'\z=\v'-.6m'\h'.3m'\s-1\(*D\s+1\v'.3m'" % -ndefine =del % = to DELTA % -tdefine oppA % "\s-2\v'-.15m'\z\e\e\h'-.05m'\z\(sl\(sl\v'-.15m'\h'-.75m'\z-\z-\h'.2m'\z-\z-\v'.3m'\h'.4m'\s+2" % -ndefine oppA % V- % -tdefine oppE %"\s-3\v'.2m'\z\(em\v'-.5m'\z\(em\v'-.5m'\z\(em\v'.55m'\h'.9m'\z\(br\z\(br\v'.25m'\s+3" % -ndefine oppE % E/ % -tdefine incl % "\s-1\z\(or\h'-.1m'\v'-.45m'\z\(em\v'.7m'\z\(em\v'.2m'\(em\v'-.45m'\s+1" % -ndefine incl % C_ % -tdefine nomem % "\o'\(mo\(sl'" % -ndefine nomem % C-/ % -tdefine angstrom % "\fR\zA\v'-.3m'\h'.2m'\(de\v'.3m'\fP\h'.2m'" % -ndefine angstrom % A to o % -tdefine star %{ roman "\v'.5m'\s+3*\s-3\v'-.5m'"}% -ndefine star % * % -tdefine || % \(or\(or % -tdefine wig % "\z>\v'.4m'\(ap\v'-.4m'" % -ndefine >wig %{ > from "~" }% -tdefine langle % "\s-3\b'\(sl\e'\s0" % -ndefine langle %<% -tdefine rangle % "\s-3\b'\e\(sl'\s0" % -ndefine rangle %>% -tdefine hbar % "\zh\v'-.6m'\h'.05m'\(ru\v'.6m'" % -ndefine hbar % h\u-\d % -ndefine ppd % _| % -tdefine ppd % "\o'\(ru\s-2\(or\s+2'" % -tdefine <-> % "\o'\(<-\(->'" % -ndefine <-> % "<-->" % -tdefine <=> % "\s-2\z<\v'.05m'\h'.2m'\z=\h'.55m'=\h'-.6m'\v'-.05m'>\s+2" % -ndefine <=> % "<=>" % -tdefine |< % "\o'<\(or'" % -ndefine |< % <| % -tdefine |> % "\o'>\(or'" % -ndefine |> % |> % -tdefine ang % "\v'-.15m'\z\s-2\(sl\s+2\v'.15m'\(ru" % -ndefine ang % /_ % -tdefine rang % "\z\(or\h'.15m'\(ru" % -ndefine rang % L % -tdefine 3dot % "\v'-.8m'\z.\v'.5m'\z.\v'.5m'.\v'-.2m'" % -ndefine 3dot % .\u.\u.\d\d % -tdefine thf % ".\v'-.5m'.\v'.5m'." % -ndefine thf % ..\u.\d % -tdefine quarter % roman \(14 % -ndefine quarter % 1/4 % -tdefine 3quarter % roman \(34 % -ndefine 3quarter % 3/4 % -tdefine degree % \(de % -ndefine degree % nothing sup o % -tdefine square % \(sq % -ndefine square % [] % -tdefine circle % \(ci % -ndefine circle % O % -tdefine blot % "\fB\(sq\fP" % -ndefine blot % HIX % -tdefine bullet % \(bu % -ndefine bullet % oxe % -tdefine -wig % "\(~=" % -ndefine -wig % - to "~" % -tdefine wig % \(ap % -ndefine wig % "~" % -tdefine prop % \(pt % -ndefine prop % oc % -tdefine empty % \(es % -ndefine empty % O/ % -tdefine member % \(mo % -ndefine member % C- % -tdefine cup % \(cu % -ndefine cup % U % -define cap % \(ca % -define subset % \(sb % -define supset % \(sp % -define !subset % \(ib % -define !supset % \(ip % -.EN -.SH NAME -eqnchar \- special character definitions for eqn -.SH SYNOPSIS -.HP -.ad l -.nh -.B eqn /usr/pub/eqnchar -.RB [ files ] -.B | troff -.RB [ options ] -.HP -.B neqn /usr/pub/eqnchar -.RB [ files ] -.B | nroff -.RB [ options ] -.br -.hy 1 -.ad b -.SH DESCRIPTION -.I Eqnchar -contains -.I troff -and -.I nroff -character definitions for constructing characters that are not -available on the Graphic Systems typesetter. -These definitions are primarily intended for use with -.I eqn -and -.IR neqn . -It contains -definitions for the following characters -.PP -.nf -.ta \w'angstrom 'u \n(.lu/3u +\w'angstrom 'u \n(.lu*2u/3u +\w'angstrom 'u -.EQ -"ciplus" ciplus "|\||" || "square" square -.EN -.EQ -"citimes" citimes "langle" langle "circle" circle -.EN -.EQ -"wig" wig "rangle" rangle "blot" blot -.EN -.EQ -"-wig" -wig "hbar" hbar "bullet" bullet -.EN -.EQ -">wig" >wig "ppd" ppd "prop" prop -.EN -.EQ -"" <-> "empty" empty -.EN -.EQ -"=wig" =wig "<=>" <=> "member" member -.EN -.EQ -"star" star "|\|" |< "nomem" nomem -.EN -.EQ -"bigstar" bigstar "|\|>" |> "cup" cup -.EN -.EQ -"=dot" =dot "ang" ang "cap" cap -.EN -.EQ -"orsign" orsign "rang" rang "incl" incl -.EN -.EQ -"andsign" andsign "3dot" 3dot "subset" subset -.EN -.EQ -"=del" =del "thf" thf "supset" supset -.EN -.EQ -"oppA" oppA "quarter" quarter "!subset" !subset -.EN -.EQ -"oppE" oppE "3quarter" 3quarter "!supset" !supset -.EN -.EQ -"angstrom" angstrom "degree" degree -.EN -.SH FILES -/usr/pub/eqnchar -.SH SEE ALSO -troff(1), eqn(1) Property changes on: vendor/heirloom-doctools/dist/eqn/eqn.d/eqnchar.7 ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/eqn/eqn.d/Makefile.mk =================================================================== --- vendor/heirloom-doctools/dist/eqn/eqn.d/Makefile.mk (revision 310549) +++ vendor/heirloom-doctools/dist/eqn/eqn.d/Makefile.mk (revision 310550) @@ -1,56 +1,59 @@ VPATH=.. OBJ = diacrit.o e.o eqnbox.o font.o fromto.o funny.o glob.o integral.o \ io.o lex.o lookup.o mark.o matrix.o move.o over.o paren.o pile.o \ shift.o size.o sqrt.o text.o version.o FLAGS = -I. -I.. -I../../include $(DEFINES) .c.o: $(CC) $(_CFLAGS) $(FLAGS) -c $< -all: eqn +all: eqn eqnchar.7 eqn: $(OBJ) $(CC) $(_CFLAGS) $(_LDFLAGS) $(OBJ) $(LIBS) -o eqn e.c: e.y $(YACC) -d ../e.y sed -f ../yyval.sed $@ y.tab.h: e.c install: test -d $(ROOT)$(BINDIR) || mkdir -p $(ROOT)$(BINDIR) $(INSTALL) -c eqn $(ROOT)$(BINDIR)/eqn $(STRIP) $(ROOT)$(BINDIR)/eqn test -d $(ROOT)$(MANDIR)/man1 || mkdir -p $(ROOT)$(MANDIR)/man1 test -d $(ROOT)$(MANDIR)/man7 || mkdir -p $(ROOT)$(MANDIR)/man7 $(INSTALL) -c -m 644 eqn.1 $(ROOT)$(MANDIR)/man1/eqn.1 $(INSTALL) -c -m 644 eqnchar.7 $(ROOT)$(MANDIR)/man7/eqnchar.7 clean: - rm -f $(OBJ) eqn e.c y.tab.* core log *~ + rm -f $(OBJ) eqn e.c y.tab.* core log *~ eqnchar.7 mrproper: clean + +eqnchar.7: eqnchar.7.in + sed 's"/usr/pub/"$(ROOT)$(PUBDIR)/"' eqnchar.7.in > $@ diacrit.o: ../diacrit.c ../e.h y.tab.h eqnbox.o: ../eqnbox.c ../e.h font.o: ../font.c ../e.h fromto.o: ../fromto.c ../e.h funny.o: ../funny.c ../e.h y.tab.h glob.o: ../glob.c ../e.h integral.o: ../integral.c ../e.h y.tab.h io.o: ../io.c ../e.h lex.o: ../lex.c ../e.h y.tab.h lookup.o: ../lookup.c ../e.h y.tab.h mark.o: ../mark.c ../e.h matrix.o: ../matrix.c ../e.h move.o: ../move.c ../e.h y.tab.h over.o: ../over.c ../e.h paren.o: ../paren.c ../e.h pile.o: ../pile.c ../e.h shift.o: ../shift.c ../e.h y.tab.h size.o: ../size.c ../e.h sqrt.o: ../sqrt.c ../e.h text.o: ../text.c ../e.h y.tab.h e.o: e.c ../e.h Index: vendor/heirloom-doctools/dist/eqn/eqn.d/eqnchar.7.in =================================================================== --- vendor/heirloom-doctools/dist/eqn/eqn.d/eqnchar.7.in (nonexistent) +++ vendor/heirloom-doctools/dist/eqn/eqn.d/eqnchar.7.in (revision 310550) @@ -0,0 +1,212 @@ +'\" e +.\" Sccsid @(#)eqnchar.7b 1.2 (gritter) 12/9/05 +.\" Derived from eqnchar(7), Unix 7th edition: +.\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" Redistributions of source code and documentation must retain the +.\" above copyright notice, this list of conditions and the following +.\" disclaimer. +.\" 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. +.\" All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" Neither the name of Caldera International, Inc. nor the names of +.\" other contributors may be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. 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 CALDERA INTERNATIONAL, INC. 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. +.TH EQNCHAR 7 "12/9/05" "Heirloom Documentation Tools" "BSD System Compatibility" +.EQ +tdefine ciplus % "\o'\(pl\(ci'" % +ndefine ciplus % O+ % +tdefine citimes % "\o'\(mu\(ci'" % +ndefine citimes % Ox % +tdefine =wig % "\(eq\h'-\w'\(eq'u-\w'\s-2\(ap'u/2u'\v'-.4m'\s-2\z\(ap\(ap\s+2\v'.4m'\h'\w'\(eq'u-\w'\s-2\(ap'u/2u'" % +ndefine =wig % ="~" % +tdefine bigstar % "\o'\(pl\(mu'" % +ndefine bigstar % X|- % +tdefine =dot % "\z\(eq\v'-.6m'\h'.2m'\s+2.\s-2\v'.6m'\h'.1m'" % +ndefine =dot % = dot % +tdefine orsign % "\s-2\v'-.15m'\z\e\e\h'-.05m'\z\(sl\(sl\v'.15m'\s+2" % +ndefine orsign % \e/ % +tdefine andsign % "\s-2\v'-.15m'\z\(sl\(sl\h'-.05m'\z\e\e\v'.15m'\s+2" % +ndefine andsign % /\e % +tdefine =del % "\v'.3m'\z=\v'-.6m'\h'.3m'\s-1\(*D\s+1\v'.3m'" % +ndefine =del % = to DELTA % +tdefine oppA % "\s-2\v'-.15m'\z\e\e\h'-.05m'\z\(sl\(sl\v'-.15m'\h'-.75m'\z-\z-\h'.2m'\z-\z-\v'.3m'\h'.4m'\s+2" % +ndefine oppA % V- % +tdefine oppE %"\s-3\v'.2m'\z\(em\v'-.5m'\z\(em\v'-.5m'\z\(em\v'.55m'\h'.9m'\z\(br\z\(br\v'.25m'\s+3" % +ndefine oppE % E/ % +tdefine incl % "\s-1\z\(or\h'-.1m'\v'-.45m'\z\(em\v'.7m'\z\(em\v'.2m'\(em\v'-.45m'\s+1" % +ndefine incl % C_ % +tdefine nomem % "\o'\(mo\(sl'" % +ndefine nomem % C-/ % +tdefine angstrom % "\fR\zA\v'-.3m'\h'.2m'\(de\v'.3m'\fP\h'.2m'" % +ndefine angstrom % A to o % +tdefine star %{ roman "\v'.5m'\s+3*\s-3\v'-.5m'"}% +ndefine star % * % +tdefine || % \(or\(or % +tdefine wig % "\z>\v'.4m'\(ap\v'-.4m'" % +ndefine >wig %{ > from "~" }% +tdefine langle % "\s-3\b'\(sl\e'\s0" % +ndefine langle %<% +tdefine rangle % "\s-3\b'\e\(sl'\s0" % +ndefine rangle %>% +tdefine hbar % "\zh\v'-.6m'\h'.05m'\(ru\v'.6m'" % +ndefine hbar % h\u-\d % +ndefine ppd % _| % +tdefine ppd % "\o'\(ru\s-2\(or\s+2'" % +tdefine <-> % "\o'\(<-\(->'" % +ndefine <-> % "<-->" % +tdefine <=> % "\s-2\z<\v'.05m'\h'.2m'\z=\h'.55m'=\h'-.6m'\v'-.05m'>\s+2" % +ndefine <=> % "<=>" % +tdefine |< % "\o'<\(or'" % +ndefine |< % <| % +tdefine |> % "\o'>\(or'" % +ndefine |> % |> % +tdefine ang % "\v'-.15m'\z\s-2\(sl\s+2\v'.15m'\(ru" % +ndefine ang % /_ % +tdefine rang % "\z\(or\h'.15m'\(ru" % +ndefine rang % L % +tdefine 3dot % "\v'-.8m'\z.\v'.5m'\z.\v'.5m'.\v'-.2m'" % +ndefine 3dot % .\u.\u.\d\d % +tdefine thf % ".\v'-.5m'.\v'.5m'." % +ndefine thf % ..\u.\d % +tdefine quarter % roman \(14 % +ndefine quarter % 1/4 % +tdefine 3quarter % roman \(34 % +ndefine 3quarter % 3/4 % +tdefine degree % \(de % +ndefine degree % nothing sup o % +tdefine square % \(sq % +ndefine square % [] % +tdefine circle % \(ci % +ndefine circle % O % +tdefine blot % "\fB\(sq\fP" % +ndefine blot % HIX % +tdefine bullet % \(bu % +ndefine bullet % oxe % +tdefine -wig % "\(~=" % +ndefine -wig % - to "~" % +tdefine wig % \(ap % +ndefine wig % "~" % +tdefine prop % \(pt % +ndefine prop % oc % +tdefine empty % \(es % +ndefine empty % O/ % +tdefine member % \(mo % +ndefine member % C- % +tdefine cup % \(cu % +ndefine cup % U % +define cap % \(ca % +define subset % \(sb % +define supset % \(sp % +define !subset % \(ib % +define !supset % \(ip % +.EN +.SH NAME +eqnchar \- special character definitions for eqn +.SH SYNOPSIS +.HP +.ad l +.nh +.B eqn /usr/pub/eqnchar +.RB [ files ] +.B | troff +.RB [ options ] +.HP +.B neqn /usr/pub/eqnchar +.RB [ files ] +.B | nroff +.RB [ options ] +.br +.hy 1 +.ad b +.SH DESCRIPTION +.I Eqnchar +contains +.I troff +and +.I nroff +character definitions for constructing characters that are not +available on the Graphic Systems typesetter. +These definitions are primarily intended for use with +.I eqn +and +.IR neqn . +It contains +definitions for the following characters +.PP +.nf +.ta \w'angstrom 'u \n(.lu/3u +\w'angstrom 'u \n(.lu*2u/3u +\w'angstrom 'u +.EQ +"ciplus" ciplus "|\||" || "square" square +.EN +.EQ +"citimes" citimes "langle" langle "circle" circle +.EN +.EQ +"wig" wig "rangle" rangle "blot" blot +.EN +.EQ +"-wig" -wig "hbar" hbar "bullet" bullet +.EN +.EQ +">wig" >wig "ppd" ppd "prop" prop +.EN +.EQ +"" <-> "empty" empty +.EN +.EQ +"=wig" =wig "<=>" <=> "member" member +.EN +.EQ +"star" star "|\|" |< "nomem" nomem +.EN +.EQ +"bigstar" bigstar "|\|>" |> "cup" cup +.EN +.EQ +"=dot" =dot "ang" ang "cap" cap +.EN +.EQ +"orsign" orsign "rang" rang "incl" incl +.EN +.EQ +"andsign" andsign "3dot" 3dot "subset" subset +.EN +.EQ +"=del" =del "thf" thf "supset" supset +.EN +.EQ +"oppA" oppA "quarter" quarter "!subset" !subset +.EN +.EQ +"oppE" oppE "3quarter" 3quarter "!supset" !supset +.EN +.EQ +"angstrom" angstrom "degree" degree +.EN +.SH FILES +/usr/pub/eqnchar +.SH SEE ALSO +troff(1), eqn(1) Property changes on: vendor/heirloom-doctools/dist/eqn/eqn.d/eqnchar.7.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/eqn/io.c =================================================================== --- vendor/heirloom-doctools/dist/eqn/io.c (revision 310549) +++ vendor/heirloom-doctools/dist/eqn/io.c (revision 310550) @@ -1,318 +1,319 @@ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * Copyright (c) 1983-1988, 2001 by Sun Microsystems, Inc. * All rights reserved. */ /* from OpenSolaris "io.c 1.10 05/06/02 SMI" SVr4.0 1.1 */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)io.c 1.13 (gritter) 1/13/08 */ # include "e.h" #include #include #include +#include "global.h" static char *in; /* input buffer */ static size_t insize; /* input buffer size */ static int noeqn; int main(int argc,char **argv) { progname = basename(argv[0]); eqnexit(eqn(argc, argv)); /*NOTREACHED*/ return 0; } void eqnexit(int n) { #ifdef gcos if (n) fprintf(stderr, "run terminated due to eqn error\n"); exit(0); #endif exit(n); } int eqn(int argc,char **argv) { int i, type; setfile(argc,argv); init_tbl(); /* install keywords in tables */ while ((type=getline(&in, &insize)) != EOF) { eqline = linect; if (type == lefteq) do_inline(); else if (*in == '.') { char *p; printf("%s",in); for (p = in + 1; *p == ' ' || *p == '\t'; p++); if (!*p || *p != 'E' || p[1] != 'Q') continue; for (i=11; i<100; used[i++]=0); printf(".nr 99 \\n(.s\n.nr 98 \\n(.f\n"); printf(".if \\n(.X .nrf 99 \\n(.s\n"); markline = 0; init(); yyparse(); if (eqnreg>0) { printf(".nr %d \\w'\\*(%d'\n", eqnreg, eqnreg); /* printf(".if \\n(%d>\\n(.l .tm too-long eqn, file %s, between lines %d-%d\n", */ /* eqnreg, svargv[ifile], eqline, linect); */ printf(".nr MK %d\n", markline); /* for -ms macros */ printf(".if %d>\\n(.v .ne %du\n", eqnht, eqnht); printf(".rn %d 10\n", eqnreg); if(!noeqn)printf("\\*(10\n"); } printf(".ps \\n(99\n.ft \\n(98\n"); printf(".EN"); if (lastchar == EOF) { putchar('\n'); break; } if (putchar(lastchar) != '\n') while (putchar(gtc()) != '\n'); } else printf("%s",in); } return(0); } int getline(char **sp, size_t *np) { register int c, esc = 0, par = 0, brack = 0; size_t n = 0; char *xp; for (;;) { c = gtc(); if (n+1 >= *np) { xp = realloc(*sp, *np += 128); if (xp == NULL) { error( !FATAL, "input line too long: %.20s\n", in); xp[--n] = '\0'; break; } *sp = xp; } (*sp)[n++] = c; if (c=='\\') esc++; else { if (c=='\n' || c==EOF || (c==lefteq && !esc && !par && !brack)) break; if (par) par--; if (brack && c == ']') brack = 0; if (esc) { switch (c) { case '*': case 'f': case 'g': case 'k': case 'n': case 'P': case 'V': case 'Y': break; case '(': par += 2; break; case '[': brack++; break; default: esc = 0; } } } } if (c==lefteq && !esc) n--; (*sp)[n++] = '\0'; return(c); } void do_inline(void) { int ds; printf(".nr 99 \\n(.s\n.nr 98 \\n(.f\n"); printf(".if \\n(.X .nrf 99 \\n(.s\n"); ds = oalloc(); printf(".rm %d \n", ds); do{ if (*in) printf(".as %d \"%s\n", ds, in); init(); yyparse(); if (eqnreg > 0) { printf(".as %d \\*(%d\n", ds, eqnreg); ofree(eqnreg); } printf(".ps \\n(99\n.ft \\n(98\n"); } while (getline(&in, &insize) == lefteq); if (*in) printf(".as %d \"%s", ds, in); printf(".ps \\n(99\n.ft \\n(98\n"); printf("\\*(%d\n", ds); ofree(ds); } void putout(int p1) { #ifndef NEQN float before, after; if(dbg)printf(".\tanswer <- S%d, h=%g,b=%g\n",p1, eht[p1], ebase[p1]); #else /* NEQN */ int before, after; if(dbg)printf(".\tanswer <- S%d, h=%d,b=%d\n",p1, eht[p1], ebase[p1]); #endif /* NEQN */ eqnht = eht[p1]; printf(".ds %d ", p1); /* suppposed to leave room for a subscript or superscript */ #ifndef NEQN before = eht[p1] - ebase[p1] - VERT(EM(1.2, ps)); #else /* NEQN */ before = eht[p1] - ebase[p1] - VERT(3); /* 3 = 1.5 lines */ #endif /* NEQN */ if (spaceval != NULL) printf("\\x'0-%s'", spaceval); else if (before > 0) #ifndef NEQN printf("\\x'0-%gp'", before); #else /* NEQN */ printf("\\x'0-%du'", before); #endif /* NEQN */ printf("\\f%c\\s%s\\*(%d%s\n", gfont, tsize(gsize), p1, ital(rfont[p1]) ? "\\|" : ""); printf(".ie \\n(.X=0 .as %d \\s\\n(99\n", p1); printf(".el .as %d \\s[\\n(99]\n", p1); printf(".as %d \\f\\n(98", p1); #ifndef NEQN after = ebase[p1] - VERT(EM(0.2, ps)); #else /* NEQN */ after = ebase[p1] - VERT(1); #endif /* NEQN */ if (spaceval == NULL && after > 0) #ifndef NEQN printf("\\x'%gp'", after); #else /* NEQN */ printf("\\x'%du'", after); #endif /* NEQN */ putchar('\n'); eqnreg = p1; if (spaceval != NULL) { free(spaceval); spaceval = NULL; } } int oalloc(void) { int i; for (i=11; i<100; i++) if (used[i]++ == 0) return(i); error( FATAL, "no eqn strings left", i); return(0); } void ofree(int n) { used[n] = 0; } void setps(float p) { printf(".ps %g\n", EFFPS(p)); } void nrwid(int n1, float p, int n2) { printf(".nr %d \\w'\\s%s\\*(%d'\n", n1, tsize(EFFPS(p)), n2); } void setfile(int argc, char **argv) { static char *nullstr = "-"; svargc = --argc; svargv = argv; while (svargc > 0 && svargv[1][0] == '-') { switch (svargv[1][1]) { case 'd': lefteq=svargv[1][2]; righteq=svargv[1][3]; break; case 's': gsize = atof(&svargv[1][2]); break; case 'p': deltaps = atof(&svargv[1][2]); break; case 'f': gfont = svargv[1][2]; break; case 'e': noeqn++; break; case 'r': /*resolution = atoi(&svargv[1][2]);*/ break; case 0: goto endargs; default: dbg = 1; } svargc--; svargv++; } endargs: ifile = 1; linect = 1; if (svargc <= 0) { curfile = stdin; svargv[1] = nullstr; } else openinfile(); /* opens up the first input file */ } void -yyerror(char *unused) {;} +yyerror(char *unused __unused) {;} void init(void) { ct = 0; ps = gsize; ft = gfont; setps(ps); printf(".ft %c\n", ft); } void error(int fatal, const char *s1, ...) { va_list ap; if (fatal>0) printf("%s fatal error: ", progname); va_start(ap, s1); vfprintf(stdout, s1, ap); va_end(ap); printf("\nfile %s, between lines %d and %d\n", svargv[ifile], eqline, linect); fprintf(stderr, "%s: ", progname); if (fatal>0) fprintf(stderr, "fatal error: "); va_start(ap, s1); vfprintf(stderr, s1, ap); va_end(ap); fprintf(stderr, "\nfile %s, between lines %d and %d\n", svargv[ifile], eqline, linect); if (fatal > 0) eqnexit(1); } Index: vendor/heirloom-doctools/dist/grap/grap.1 =================================================================== --- vendor/heirloom-doctools/dist/grap/grap.1 (revision 310549) +++ vendor/heirloom-doctools/dist/grap/grap.1 (nonexistent) @@ -1,430 +0,0 @@ -.\" -.\" Changes by Gunnar Ritter, Freiburg i. Br., Germany, October 2005. -.\" -.\" Derived from Plan 9 v4 /opt/unix/plan9v4/sys/man/1/grap -.\" -.\" Copyright (C) 2003, Lucent Technologies Inc. and others. -.\" All Rights Reserved. -.\" -.\" Distributed under the terms of the Lucent Public License Version 1.02. -.\" -.\" Sccsid @(#)grap.1 1.5 (gritter) 2/2/07 -.TH GRAP 1 "2/2/07" "Heirloom Documentation Tools" "User Commands" -.SH NAME -grap \- pic preprocessor for drawing graphs -.SH SYNOPSIS -\fBgrap\fR [\fB\-SU\fR] [\fIfile\fR] -.SH DESCRIPTION -.I Grap -is a -.IR pic (1) -preprocessor for drawing graphs on a typesetter. -Graphs are surrounded by the -.I troff -`commands' -.B \&.G1 -and -.BR \&.G2 . -Data are scaled and plotted, -with tick marks supplied automatically. -Commands exist to modify the frame, -add labels, override the default ticks, -change the plotting style, -define coordinate ranges and transformations, -and include data from files. -In addition, -.I grap -provides the same loops, conditionals, and macro processing that -.I pic -does. -.PP -.BI frame -.B ht -.I e -.B wid -.I e -.B top -.B dotted -.IR ... : -Set the frame around the graph to specified -.B ht -and -.BR wid ; -default is 2 by 3 (inches). -The line -.I styles -.RB ( dotted , -.BR dashed , -.BR invis , -.BR solid -(default)) -of the -.I sides -.RB ( top , -.BR bot , -.BR left , -.BR right ) -of the frame can be set -independently. -.PP -.B label -.I side -.B \&"a label" -.B \&"as a set of strings" -.IR adjust : -Place label on specified side; default side is bottom. -.I adjust -is -.B up -(or -.B down -.B left -.BR right ) -.I expr -to shift default position; -.B width -.I expr -sets the width explicitly. -.PP -.BI ticks -.I side -.B in -.B at -.IR "optname expr, expr, ..." : -Put ticks on -.I side -at -.I "expr, ..., -and label with -.I \&"expr"\f1. -If any -.I expr -is followed by "...", label tick with "...", -and turn off all automatic labels. -If "..." contains -.BR %f 's, -they will be interpreted as -.B printf -formatting instructions for the tick value. -Ticks point -.B in -or -.B out -(default out). -Tick iterator: instead of -.B at -.IR \&... , -use -.BI from -.I expr -.B to -.I expr -.B by -.I "op expr -where -.I op -is optionally -.B +\-*/ -for additive or multiplicative steps. -.B by -can be omitted, to give steps of size 1. -If no ticks are requested, they are supplied automatically; -suppress this with -.B ticks -.BR off . -Automatic ticks normally -leave a margin of 7% on each side; set this to anything by -.B margin -.B = -.IR expr . -.PP -.B grid -.I "side linedesc" -.B at -.IR "optname expr, expr, ..." : -Draw grids perpendicular to -.I side -in style -.I linedesc -at -.I "expr, ....\& -Iterators and labels work as with ticks. -.PP -.B coord -.I optname -.B x -.I "min, max" -.B y -.I "min, max" -.B "log x -.BR " log y" : -Set range of coords and optional log scaling on either or both. -This overrides computation of data range. -Default value of -.I optname -is current coordinate system -(each -.B coord -defines a new coordinate system). -.PP -.B plot -.I \&"str" -.B at -.IR point ; -.B -.I \&"str" -.B at -.IR point : -Put -.I str -at -.IR point . -Text position can be qualified with -.BR rjust , -.BR ljust , -.BR above , -.BR below -after "...". -.PP -.B line -.B from -.I point -.B to -.IR "point linedesc" : -Draw line from here to there. -.B arrow -works in place of -.BR line . -.PP -.B next -.I optname -.B at -.IR "point linedesc" : -Continue plot of data in -.I optname to -.IR point ; -default is current. -.PP -.BI draw -.IR "optname linedesc ..." : -Set mode for -.BR next : -use this style from now on, -and plot "..." at each point (if given). -.PP -.BI new -.IR "optname linedesc ..." : -Set mode for -.BR next , -but disconnect from previous. -.PP -A list of numbers -.I "x y1 y2 y3 ... -is treated as -.B plot -.B bullet -.B at -.IR x,y1 ; -.B plot -.B bullet -.B at -.IR x,y2 ; -etc., or as -.B next -.B at -.I x,y1 -etc., if -.B draw -is specified. -Abscissae of 1,2,3,... are provided if there is only one input number per line. -.PP -A -point -.I "optname expr, expr -maps the point to the named coordinate system. -A -.I linedesc -is one of -.B dot -.B dash -.B invis -.B solid -optionally followed by an expression. -.PP -.BI define -.I name -.BI { whatever } \f1: -Define a macro. -There are macros already defined for standard plotting -symbols like -.BR bullet , -.BR circle , -.BR star , -.BR plus , -etc., in -.BR /sys/lib/grap.defines , -which is included if it exists. -.PP -.I var -.B = -.IR expr : -Evaluate an expression. -Operators are -.B= -.B + -.B \- -.B * -and -.BR / . -Functions are -.B log -and -.B exp -(both base 10), -.BR sin , -.BR cos , -.BR sqrt ; -.B rand -returns random number on [0,1); -.BI max( e , e )\f1, -.BI min( e , e )\f1, -.BI int( e )\f1. -.PP -.B print -.IR expr ; -.B print -\fR"\f2...\fR"\f1: -As a debugging aid, print -.I expr -or -.I string -on the standard error. -.PP -.B copy -\fR"\fIfile name\fR"\fR: -Include this file right here. -.PP -.B copy -.B thru -.IR macro : -Pass rest of input (until -.BR \&.G2 ) -through -.IR macro , -treating each field (non-blank, or "...") as an argument. -.I macro -can be the name of a macro previously defined, -or the body of one in place, like -.BR "/plot $1 at $2,$3/" . -.PP -.B copy -.B thru -.I macro -.B until -\fR"\fIstring\fR"\fR: -Stop copy when input is -.I string -(left-justified). -.PP -.BI pic -.IR "remainder of line" : -Copy to output with leading blanks removed. -.PP -.BI graph -.IR "Name pic-position" : -Start a new frame, place it at specified position, -e.g., -.B graph -.B Thing2 -.BR "with .sw at Thing1.se + (0.1,0)" . -.I Name -must be capitalized to keep -.I pic -happy. -.PP -.BI \&. "anything at beginning of -.IR line : -Copied verbatim. -.PP -.B sh -.BI % anything -.BR % : -Pass everything between the -.BR % 's -to the shell; -as with macros, -.B % -may be any character and -.I anything -may include newlines. -The -.B \-S -option disables execution of the shell command; -the -.B \-U -option reverts the effect of a previous -.IR \-S . -.PP -.B # -.IR anything : -A comment, which is discarded. -.PP -Order is mostly irrelevant; no category is mandatory. -Any arguments on the -.B \&.G1 -line are placed on the generated -.B \&.PS -line for -.IR pic . -.\".SH EXAMPLES -.\".EX -.\".ps -1 -.\".vs -1 -.\"\&.G1 -.\"frame ht 1 top invis right invis -.\"coord x 0, 10 y 1, 3 log y -.\"ticks left in at 1 "bottommost tick", 2,3 "top tick" -.\"ticks bot in from 0 to 10 by 2 -.\"label bot "silly graph" -.\"label left "left side label" "here" -.\"grid left dashed at 2.5 -.\"copy thru / circle at $1,$2 / -.\"1 1 -.\"2 1.5 -.\"3 2 -.\"4 1.5 -.\"10 3 -.\"\&.G2 -.\".G1 -.\"frame ht 1 top invis right invis -.\"coord x 0, 10 y 1, 3 log y -.\"ticks left in at 1 "bottommost tick", 2,3 "top tick" -.\"ticks bot in from 0 to 10 by 2 -.\"label bot "silly graph" -.\"label left "left side label" "here" -.\"grid left dashed at 2.5 -.\"copy thru / circle at $1,$2 / -.\"1 1 -.\"2 1.5 -.\"3 2 -.\"4 1.5 -.\"10 3 -.\".G2 -.\".ps -.\".vs -.\".EE -.SH FILES -.TP -.B /usr/ucblib/grap.defines -definitions of standard plotting characters, e.g., bullet -.\".SH SOURCE -.\".B /sys/src/cmd/grap -.SH "SEE ALSO" -.IR pic (1), -.IR troff (1) -.br -J. L. Bentley and B. W. Kernighan, -``GRAP\(emA Language for Typesetting Graphs'', -.I -Unix Research System Programmer's Manual, -Tenth Edition, Volume 2. Property changes on: vendor/heirloom-doctools/dist/grap/grap.1 ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/grap/Makefile.mk =================================================================== --- vendor/heirloom-doctools/dist/grap/Makefile.mk (revision 310549) +++ vendor/heirloom-doctools/dist/grap/Makefile.mk (revision 310550) @@ -1,41 +1,44 @@ OBJ = coord.o for.o frame.o grap.o grapl.o input.o label.o main.o misc.o \ plot.o print.o ticks.o version.o FLAGS = -DLIBDIR='"$(LIBDIR)"' $(DEFINES) -I../include YFLAGS = -d .c.o: $(CC) $(_CFLAGS) $(FLAGS) -c $< -all: grap.c grapl.c grap +all: grap.c grapl.c grap grap.1 grap: $(OBJ) $(CC) $(_CFLAGS) $(_LDFLAGS) $(OBJ) $(LIBS) -lm -o grap y.tab.h: grap.c install: $(INSTALL) -c grap $(ROOT)$(BINDIR)/grap $(STRIP) $(ROOT)$(BINDIR)/grap test -d $(ROOT)$(LIBDIR) || mkdir -p $(ROOT)$(LIBDIR) $(INSTALL) -c -m 644 grap.defines $(ROOT)$(LIBDIR)/grap.defines $(INSTALL) -c -m 644 grap.1 $(ROOT)$(MANDIR)/man1/grap.1 clean: - rm -f $(OBJ) grapl.c grap.c y.tab.h grap core log *~ + rm -f $(OBJ) grapl.c grap.c y.tab.h grap core log *~ grap.1 mrproper: clean + +grap.1: grap.1.in + sed 's"/usr/ucblib/"$(ROOT)$(LIBDIR)/"' grap.1.in > $@ coord.o: coord.c grap.h y.tab.h for.o: for.c grap.h y.tab.h frame.o: frame.c grap.h y.tab.h grap.o: grap.c grap.h grapl.o: grapl.c grap.h y.tab.h input.o: input.c grap.h y.tab.h label.o: label.c grap.h y.tab.h main.o: main.c grap.h y.tab.h misc.o: misc.c grap.h y.tab.h plot.o: plot.c grap.h y.tab.h print.o: print.c grap.h y.tab.h ticks.o: ticks.c grap.h y.tab.h Index: vendor/heirloom-doctools/dist/grap/grap.1.in =================================================================== --- vendor/heirloom-doctools/dist/grap/grap.1.in (nonexistent) +++ vendor/heirloom-doctools/dist/grap/grap.1.in (revision 310550) @@ -0,0 +1,430 @@ +.\" +.\" Changes by Gunnar Ritter, Freiburg i. Br., Germany, October 2005. +.\" +.\" Derived from Plan 9 v4 /opt/unix/plan9v4/sys/man/1/grap +.\" +.\" Copyright (C) 2003, Lucent Technologies Inc. and others. +.\" All Rights Reserved. +.\" +.\" Distributed under the terms of the Lucent Public License Version 1.02. +.\" +.\" Sccsid @(#)grap.1 1.5 (gritter) 2/2/07 +.TH GRAP 1 "2/2/07" "Heirloom Documentation Tools" "User Commands" +.SH NAME +grap \- pic preprocessor for drawing graphs +.SH SYNOPSIS +\fBgrap\fR [\fB\-SU\fR] [\fIfile\fR] +.SH DESCRIPTION +.I Grap +is a +.IR pic (1) +preprocessor for drawing graphs on a typesetter. +Graphs are surrounded by the +.I troff +`commands' +.B \&.G1 +and +.BR \&.G2 . +Data are scaled and plotted, +with tick marks supplied automatically. +Commands exist to modify the frame, +add labels, override the default ticks, +change the plotting style, +define coordinate ranges and transformations, +and include data from files. +In addition, +.I grap +provides the same loops, conditionals, and macro processing that +.I pic +does. +.PP +.BI frame +.B ht +.I e +.B wid +.I e +.B top +.B dotted +.IR ... : +Set the frame around the graph to specified +.B ht +and +.BR wid ; +default is 2 by 3 (inches). +The line +.I styles +.RB ( dotted , +.BR dashed , +.BR invis , +.BR solid +(default)) +of the +.I sides +.RB ( top , +.BR bot , +.BR left , +.BR right ) +of the frame can be set +independently. +.PP +.B label +.I side +.B \&"a label" +.B \&"as a set of strings" +.IR adjust : +Place label on specified side; default side is bottom. +.I adjust +is +.B up +(or +.B down +.B left +.BR right ) +.I expr +to shift default position; +.B width +.I expr +sets the width explicitly. +.PP +.BI ticks +.I side +.B in +.B at +.IR "optname expr, expr, ..." : +Put ticks on +.I side +at +.I "expr, ..., +and label with +.I \&"expr"\f1. +If any +.I expr +is followed by "...", label tick with "...", +and turn off all automatic labels. +If "..." contains +.BR %f 's, +they will be interpreted as +.B printf +formatting instructions for the tick value. +Ticks point +.B in +or +.B out +(default out). +Tick iterator: instead of +.B at +.IR \&... , +use +.BI from +.I expr +.B to +.I expr +.B by +.I "op expr +where +.I op +is optionally +.B +\-*/ +for additive or multiplicative steps. +.B by +can be omitted, to give steps of size 1. +If no ticks are requested, they are supplied automatically; +suppress this with +.B ticks +.BR off . +Automatic ticks normally +leave a margin of 7% on each side; set this to anything by +.B margin +.B = +.IR expr . +.PP +.B grid +.I "side linedesc" +.B at +.IR "optname expr, expr, ..." : +Draw grids perpendicular to +.I side +in style +.I linedesc +at +.I "expr, ....\& +Iterators and labels work as with ticks. +.PP +.B coord +.I optname +.B x +.I "min, max" +.B y +.I "min, max" +.B "log x +.BR " log y" : +Set range of coords and optional log scaling on either or both. +This overrides computation of data range. +Default value of +.I optname +is current coordinate system +(each +.B coord +defines a new coordinate system). +.PP +.B plot +.I \&"str" +.B at +.IR point ; +.B +.I \&"str" +.B at +.IR point : +Put +.I str +at +.IR point . +Text position can be qualified with +.BR rjust , +.BR ljust , +.BR above , +.BR below +after "...". +.PP +.B line +.B from +.I point +.B to +.IR "point linedesc" : +Draw line from here to there. +.B arrow +works in place of +.BR line . +.PP +.B next +.I optname +.B at +.IR "point linedesc" : +Continue plot of data in +.I optname to +.IR point ; +default is current. +.PP +.BI draw +.IR "optname linedesc ..." : +Set mode for +.BR next : +use this style from now on, +and plot "..." at each point (if given). +.PP +.BI new +.IR "optname linedesc ..." : +Set mode for +.BR next , +but disconnect from previous. +.PP +A list of numbers +.I "x y1 y2 y3 ... +is treated as +.B plot +.B bullet +.B at +.IR x,y1 ; +.B plot +.B bullet +.B at +.IR x,y2 ; +etc., or as +.B next +.B at +.I x,y1 +etc., if +.B draw +is specified. +Abscissae of 1,2,3,... are provided if there is only one input number per line. +.PP +A +point +.I "optname expr, expr +maps the point to the named coordinate system. +A +.I linedesc +is one of +.B dot +.B dash +.B invis +.B solid +optionally followed by an expression. +.PP +.BI define +.I name +.BI { whatever } \f1: +Define a macro. +There are macros already defined for standard plotting +symbols like +.BR bullet , +.BR circle , +.BR star , +.BR plus , +etc., in +.BR /sys/lib/grap.defines , +which is included if it exists. +.PP +.I var +.B = +.IR expr : +Evaluate an expression. +Operators are +.B= +.B + +.B \- +.B * +and +.BR / . +Functions are +.B log +and +.B exp +(both base 10), +.BR sin , +.BR cos , +.BR sqrt ; +.B rand +returns random number on [0,1); +.BI max( e , e )\f1, +.BI min( e , e )\f1, +.BI int( e )\f1. +.PP +.B print +.IR expr ; +.B print +\fR"\f2...\fR"\f1: +As a debugging aid, print +.I expr +or +.I string +on the standard error. +.PP +.B copy +\fR"\fIfile name\fR"\fR: +Include this file right here. +.PP +.B copy +.B thru +.IR macro : +Pass rest of input (until +.BR \&.G2 ) +through +.IR macro , +treating each field (non-blank, or "...") as an argument. +.I macro +can be the name of a macro previously defined, +or the body of one in place, like +.BR "/plot $1 at $2,$3/" . +.PP +.B copy +.B thru +.I macro +.B until +\fR"\fIstring\fR"\fR: +Stop copy when input is +.I string +(left-justified). +.PP +.BI pic +.IR "remainder of line" : +Copy to output with leading blanks removed. +.PP +.BI graph +.IR "Name pic-position" : +Start a new frame, place it at specified position, +e.g., +.B graph +.B Thing2 +.BR "with .sw at Thing1.se + (0.1,0)" . +.I Name +must be capitalized to keep +.I pic +happy. +.PP +.BI \&. "anything at beginning of +.IR line : +Copied verbatim. +.PP +.B sh +.BI % anything +.BR % : +Pass everything between the +.BR % 's +to the shell; +as with macros, +.B % +may be any character and +.I anything +may include newlines. +The +.B \-S +option disables execution of the shell command; +the +.B \-U +option reverts the effect of a previous +.IR \-S . +.PP +.B # +.IR anything : +A comment, which is discarded. +.PP +Order is mostly irrelevant; no category is mandatory. +Any arguments on the +.B \&.G1 +line are placed on the generated +.B \&.PS +line for +.IR pic . +.\".SH EXAMPLES +.\".EX +.\".ps -1 +.\".vs -1 +.\"\&.G1 +.\"frame ht 1 top invis right invis +.\"coord x 0, 10 y 1, 3 log y +.\"ticks left in at 1 "bottommost tick", 2,3 "top tick" +.\"ticks bot in from 0 to 10 by 2 +.\"label bot "silly graph" +.\"label left "left side label" "here" +.\"grid left dashed at 2.5 +.\"copy thru / circle at $1,$2 / +.\"1 1 +.\"2 1.5 +.\"3 2 +.\"4 1.5 +.\"10 3 +.\"\&.G2 +.\".G1 +.\"frame ht 1 top invis right invis +.\"coord x 0, 10 y 1, 3 log y +.\"ticks left in at 1 "bottommost tick", 2,3 "top tick" +.\"ticks bot in from 0 to 10 by 2 +.\"label bot "silly graph" +.\"label left "left side label" "here" +.\"grid left dashed at 2.5 +.\"copy thru / circle at $1,$2 / +.\"1 1 +.\"2 1.5 +.\"3 2 +.\"4 1.5 +.\"10 3 +.\".G2 +.\".ps +.\".vs +.\".EE +.SH FILES +.TP +.B /usr/ucblib/grap.defines +definitions of standard plotting characters, e.g., bullet +.\".SH SOURCE +.\".B /sys/src/cmd/grap +.SH "SEE ALSO" +.IR pic (1), +.IR troff (1) +.br +J. L. Bentley and B. W. Kernighan, +``GRAP\(emA Language for Typesetting Graphs'', +.I +Unix Research System Programmer's Manual, +Tenth Edition, Volume 2. Property changes on: vendor/heirloom-doctools/dist/grap/grap.1.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/grap/grapl.l =================================================================== --- vendor/heirloom-doctools/dist/grap/grapl.l (revision 310549) +++ vendor/heirloom-doctools/dist/grap/grapl.l (revision 310550) @@ -1,246 +1,240 @@ %{ /* * Changes by Gunnar Ritter, Freiburg i. Br., Germany, October 2005. * * Derived from Plan 9 v4 /sys/src/cmd/grap/ * * Copyright (C) 2003, Lucent Technologies Inc. and others. * All Rights Reserved. * * Distributed under the terms of the Lucent Public License Version 1.02. */ /* Sccsid @(#)grapl.l 1.4 (gritter) 11/22/05 */ %} +%option nounput %Start A str def thru sh %{ #ifndef FLEX_SCANNER #undef input #undef unput #endif /* !FLEX_SCANNER */ #include #include #include #include #include "grap.h" #include "y.tab.h" #ifdef FLEX_SCANNER #undef YY_INPUT #define YY_INPUT(buf, result, max_size) { \ int c = xxinput(); \ result = (c == EOF || c == 0) ? YY_NULL : (buf[0] = c, 1); \ } #define witchcraft YY_START #else /* !FLEX_SCANNER */ #define witchcraft yybgin-yysvec-1 #endif /* !FLEX_SCANNER */ int yyback(int *, int); int yylook(void); int yywrap(void); void shell_init(void), shell_exec(void), shell_text(char *); #define CADD cbuf[clen++] = yytext[0]; \ if (clen >= CBUFLEN-1) { \ WARNING("string too long", cbuf); BEGIN A; } #define CBUFLEN 1500 char cbuf[CBUFLEN]; int clen, cflag; int c, delim, shcnt; %} A [a-zA-Z_] B [a-zA-Z0-9_] D [0-9] WS [ \t] %% if (witchcraft == 0) { BEGIN A; } {WS} ; "\\"\n ; \n return(ST); ";" return(ST); line return(yylval.i = LINE); arrow { yylval.i = ARROW; return(LINE); } circle return(yylval.i = CIRCLE); frame return(FRAME); tick(s)? return(TICKS); grid(line)?(s)? return(GRID); coord(s)? return(COORD); log return(LOG); exp return(EXP); sin return(SIN); cos return(COS); atan2 return(ATAN2); sqrt return(SQRT); rand return(RAND); max return(MAX); min return(MIN); int return(INT); print return(PRINT); sprintf return(SPRINTF); pic{WS}.* { yylval.p = tostring(yytext+3); return(PIC); } graph{WS}.* { yylval.p = tostring(yytext+5); return(GRAPH); } for return(FOR); ^Endfor\n { endfor(); } do { yylval.p = delimstr("loop body"); BEGIN A; return(DOSTR); } copy|include { return(COPY); } thru|through { BEGIN thru; return(THRU); } {WS}+ ; {A}{B}*|. { yylval.op = copythru(yytext); BEGIN A; return(DEFNAME); } until return(UNTIL); if return(IF); then { yylval.p = delimstr("then part"); BEGIN A; return(THEN); } else { yylval.p = delimstr("else part"); BEGIN A; return(ELSE); } next return(NEXT); draw return(yylval.i = DRAW); new return(yylval.i = NEW); plot return(yylval.i = PLOT); label(s)? return(LABEL); x return(X); y return(Y); top { yylval.i = TOP; return SIDE; } bot(tom)? { yylval.i = BOT; return SIDE; } left { yylval.i = LEFT; return SIDE; } right { yylval.i = RIGHT; return SIDE; } up return(yylval.i = UP); down return(yylval.i = DOWN); across return(yylval.i = ACROSS); height|ht return(yylval.i = HEIGHT); wid(th)? return(yylval.i = WIDTH); rad(ius)? return(yylval.i = RADIUS); invis return(yylval.i = INVIS); dot(ted) return(yylval.i = DOT); dash(ed) return(yylval.i = DASH); solid return(yylval.i = SOLID); ljust { yylval.i = LJUST; return JUST; } rjust { yylval.i = RJUST; return JUST; } above { yylval.i = ABOVE; return JUST; } below { yylval.i = BELOW; return JUST; } size return(yylval.i = SIZE); from return(yylval.i = FROM); to return(yylval.i = TO); by|step return(yylval.i = BY); at return(yylval.i = AT); with return(yylval.i = WITH); in return(yylval.i = IN); out return(yylval.i = OUT); off return(yylval.i = OFF); sh{WS}+ { BEGIN sh; if ((delim = input()) == '{') { shcnt = 1; delim = '}'; } shell_init(); } {A}{B}* { int c; Obj *p; if (yytext[0] == delim) { shell_exec(); BEGIN A; } else { p = lookup(yytext, 0); if (p != NULL && p->type == DEFNAME) { c = input(); xxunput(c); if (c == '(') dodef(p); else pbstr(p->val); } else shell_text(yytext); } } "{" { shcnt++; shell_text(yytext); } "}" { if (delim != '}' || --shcnt > 0) shell_text(yytext); else { shell_exec(); BEGIN A; } } .|\n { if (yytext[0] == delim) { shell_exec(); BEGIN A; } else shell_text(yytext); } define{WS}+ { BEGIN def; } {A}{B}* { definition(yytext); BEGIN A; } ({D}+("."?){D}*|"."{D}+)((e|E)("+"|-)?{D}+)?i? { yylval.f = atof(yytext); return(NUMBER); } ^"."[^0-9].* { if (yytext[1] == 'G' && yytext[2] == '2') { yylval.i = yytext[2]; return(EOF); } else { yylval.p = tostring(yytext); return(PIC); } } {A}{B}* { int c; Obj *p; p = lookup(yytext, 1); if (p->type == DEFNAME) { c = input(); xxunput(c); if (c == '(') /* it's name(...) */ dodef(p); else /* no argument list */ pbstr(p->val); } else { yylval.op = p; return p->type; /* NAME or VARNAME */ } } "==" return(EQ); ">=" return(GE); "<=" return(LE); "!=" return(NE); ">" return(GT); "<" return(LT); "&&" return(AND); "||" return(OR); "!" return(NOT); \" { BEGIN str; clen = 0; } #.* ; . { yylval.i = yytext[0]; return(yytext[0]); } \" { BEGIN A; cbuf[clen] = 0; yylval.p = tostring(cbuf); return(STRING); } \n { WARNING("newline in string"); BEGIN A; return(ST); } "\\\"" { cbuf[clen++] = '\\'; cbuf[clen++] = '"'; } "\\\\" { cbuf[clen++] = '\\'; cbuf[clen++] = '\\'; } . { CADD; } %% - -#ifdef FLEX_SCANNER -void xxcruft(void) -{ - unput(0); -} -#endif /* FLEX_SCANNER */ Index: vendor/heirloom-doctools/dist/grap/main.c =================================================================== --- vendor/heirloom-doctools/dist/grap/main.c (revision 310549) +++ vendor/heirloom-doctools/dist/grap/main.c (revision 310550) @@ -1,186 +1,188 @@ /* * Changes by Gunnar Ritter, Freiburg i. Br., Germany, October 2005. * * Derived from Plan 9 v4 /sys/src/cmd/grap/ * * Copyright (C) 2003, Lucent Technologies Inc. and others. * All Rights Reserved. * * Distributed under the terms of the Lucent Public License Version 1.02. */ /* Sccsid @(#)main.c 1.5 (gritter) 12/5/05 */ #include #include #include #include #include #include #include "grap.h" +#include "global.h" #include "y.tab.h" +static void onintr(int n); +static void fpecatch(int n); + int dbg = 0; #define GRAPDEFINES LIBDIR "/grap.defines" char *lib_defines = GRAPDEFINES; int lib = 1; /* 1 to include lib_defines */ FILE *tfd = NULL; char tempfile[] = "/var/tmp/grapXXXXXX"; int Sflag; int synerr = 0; int codegen = 0; /* 1=>output for this picture; 0=>no output */ char *cmdname; Obj *objlist = NULL; /* all names stored here */ #define BIG 1e30 Point ptmin = { NULL, -BIG, -BIG }; Point ptmax = { NULL, BIG, BIG }; extern const char version[]; extern int yyparse(void); extern void setdefaults(void); extern void getdata(void); int main(int argc, char *argv[]) { - extern void onintr(int), fpecatch(int); - if (signal(SIGINT, SIG_IGN) != SIG_IGN) signal(SIGINT, onintr); signal(SIGFPE, fpecatch); cmdname = argv[0]; close(mkstemp(tempfile)); while (argc > 1 && *argv[1] == '-') { switch (argv[1][1]) { case 'd': dbg = 1; tfd = stdout; n_strcpy(tempfile, "grap.temp", sizeof(tempfile)); unlink(tempfile); fprintf(stderr, "%s\n", version); break; case 'l': /* turn off /usr/lib inclusion */ lib = 0; break; case 'S': Sflag = 1; break; case 'U': Sflag = 0; break; } argc--; argv++; } setdefaults(); curfile = infile; if (argc <= 1) { curfile->fin = stdin; curfile->fname = tostring("-"); pushsrc(File, curfile->fname); getdata(); } else while (argc-- > 1) { if ((curfile->fin = fopen(*++argv, "r")) == NULL) { fprintf(stderr, "grap: can't open %s\n", *argv); onintr(0); } curfile->fname = tostring(*argv); pushsrc(File, curfile->fname); getdata(); fclose(curfile->fin); free(curfile->fname); } if (!dbg) unlink(tempfile); exit(0); } /*ARGSUSED*/ -void onintr(int n) +static void onintr(int n __unused) { if (!dbg) unlink(tempfile); exit(1); } -void fpecatch(int n) +static void fpecatch(int n) { WARNING("floating point exception"); onintr(n); } char *grow(char *ptr, char *name, int num, int size) /* make array bigger */ { char *p; if (ptr == NULL) p = malloc(num * size); else p = realloc(ptr, num * size); if (p == NULL) FATAL("can't grow %s to %d", name, num * size); return p; } static struct { char *name; double val; } defaults[] ={ { "frameht" , FRAMEHT }, { "framewid", FRAMEWID }, { "ticklen" , TICKLEN }, { "slop" , SLOP }, { NULL , 0 } }; void setdefaults(void) /* set default sizes for variables */ { int i; Obj *p; for (i = 0; defaults[i].name != NULL; i++) { p = lookup(defaults[i].name, 1); setvar(p, defaults[i].val); } } void getdata(void) /* read input */ { register FILE *fin; char *buf = NULL, *buf1 = NULL; size_t size = 0; int ln; fin = curfile->fin; curfile->lineno = 0; printf(".lf 1 %s\n", curfile->fname); while (getline(&buf, &size, fin) > 0) { curfile->lineno++; if (*buf == '.' && *(buf+1) == 'G' && *(buf+2) == '1') { setup(); fprintf(stdout, ".PS%s", &buf[3]); /* maps .G1 [w] to .PS w */ printf("scale = 1\n"); /* defends against cip users */ printf(".lf %d\n", curfile->lineno+1); yyparse(); fprintf(stdout, ".PE\n"); printf(".lf %d\n", curfile->lineno+1); fflush(stdout); } else if (buf[0] == '.' && buf[1] == 'l' && buf[2] == 'f') { buf1 = realloc(buf1, size); if (sscanf(buf+3, "%d %s", &ln, buf1) == 2) { free(curfile->fname); printf(".lf %d %s\n", curfile->lineno = ln, curfile->fname = tostring(buf1)); } else printf(".lf %d\n", curfile->lineno = ln); } else fputs(buf, stdout); } free(buf); free(buf1); } Index: vendor/heirloom-doctools/dist/mpm/page.cc =================================================================== --- vendor/heirloom-doctools/dist/mpm/page.cc (revision 310549) +++ vendor/heirloom-doctools/dist/mpm/page.cc (revision 310550) @@ -1,628 +1,612 @@ /* * Changes by Gunnar Ritter, Freiburg i. Br., Germany, October 2005. * * Derived from Plan 9 source code published at the 9fans list by Rob Pike, * * * Copyright (C) 2003, Lucent Technologies Inc. and others. * All Rights Reserved. * * Distributed under the terms of the Lucent Public License Version 1.02. */ /* Sccsid @(#)page.cc 1.4 (gritter) 10/30/05 */ #include #include "misc.h" #include "slug.h" #include "range.h" #include "page.h" const int MAXRANGES = 1000; static range *ptemp[MAXRANGES]; // for movefloats() static void swapright(int n) // used by movefloats() { range *t = ptemp[n]; ptemp[n] = ptemp[n+1]; ptemp[n+1] = t; ptemp[n]->setaccum( ptemp[n+1]->accum() - ptemp[n+1]->rawht() + ptemp[n]->rawht() ); ptemp[n+1]->setaccum( ptemp[n]->accum() + ptemp[n+1]->rawht() ); } // Figure out the goal position for each floating range on scratch, // and move it past stream ranges until it's as close to its goal as possible. static void movefloats(stream *scratch, double scale) { const int Huge = 10000000; int nranges; for (nranges = 0; scratch->more(); scratch->advance()) ptemp[nranges++] = scratch->current(); scratch->freeall(); ufrange rtemp; ptemp[nranges] = &rtemp; rtemp.setgoal(Huge); int accumV = 0; // compute accum values and int i; for (i = 0; i < nranges; i++) { // pick closest goal for floats ptemp[i]->pickgoal(accumV, scale); ptemp[i]->setaccum(accumV += ptemp[i]->rawht()); } int j; // index for inner loop below: for (i = nranges; --i >= 0; ) // stably sort floats to bottom for (j = i; j < nranges; j++) if (ptemp[j]->goal() > ptemp[j+1]->goal()) swapright(j); else break; if (dbg & 16) printf("#movefloats: before floating, from bottom:\n"); for (i = nranges; --i >= 0; ) { // find topmost float if (ptemp[i]->goal() == NOGOAL) break; if (dbg & 16) printf("# serialno %d goal %d height %d\n", ptemp[i]->serialno(), ptemp[i]->goal(), ptemp[i]->rawht()); } // i+1 is topmost float for (i++ ; i < nranges; i++) // move each float up the page for (j = i; j > 0; j--) // as long as closer to its goal if (ptemp[j]->goal() <= ptemp[j-1]->accum() + ptemp[j]->rawht()/2 && ptemp[j-1]->goal() == NOGOAL) swapright(j-1); else break; if (ptemp[nranges] != &rtemp) FATAL("goal sentinel has disappeared from movefloats"); for (i = 0; i < nranges; i++) // copy sorted list back scratch->append(ptemp[i]); } // Traverse the leaves of a tree of ranges, filtering out only SP and VBOX. static range *filter(generator *g) { range *r; while ((r = g->next())) if (r->isvbox() || r->issp()) break; return r; } // Zero out leading and trailing spaces; coalesce adjacent SP's. static void trimspace(stream *scratch) { range *r, *prevr = 0; generator g; for (g = scratch; (r = filter(&g)) != 0 && r->issp(); prevr = r) r->setheight(0); // zap leading SP for ( ; (r = filter(&g)) != 0; prevr = r) if (r->issp()) { if (prevr && prevr->issp()) { // coalesce adjacent SPs r->setheight(max(r->rawht(), prevr->height())); prevr->setheight(0); } else // a VBOX intervened r->setheight(r->rawht()); } if (prevr && prevr->issp()) // zap *all* trailing space prevr->setheight(0); // (since it all coalesced // into the last one) } // Pad the non-zero SP's in scratch so the total height is wantht. // Note that the SP values in scratch are not the raw values, and // indeed may already have been padded. static void justify(stream *scratch, int wantht) { range *r; int nsp = 0, hsp = 0; int adjht = scratch->height(); // Find all the spaces. generator g; for (g = scratch; (r = g.next()); ) if (r->issp() && r->height() > 0) { nsp++; hsp += r->height(); } int excess = wantht - adjht; if (excess < 0) WARNING("something on page %d is oversize by %d\n", userpn, -excess); if (dbg & 16) printf("# justify %d: excess %d nsp %d hsp %d adjht %d\n", userpn, excess, nsp, hsp, adjht); if (excess <= 0 || nsp == 0) return; // Redistribute the excess space. for (g = scratch; (r = g.next()); ) if (r->issp() && r->height() > 0) { int delta = (int) ((float)(r->height()*excess)/hsp + 0.5); if (dbg & 16) printf("# pad space %d by %d: hsp %d excess %d\n", r->height(), delta, hsp, excess); r->setheight(r->height() + delta); } } -// If r were added to s, would the height of the composed result be at most maxht? -int wouldfit(range *r, stream *s, int maxht) -{ - if (r->rawht() + s->rawht() <= maxht) - return 1; // the conservative test succeeded - stream scratch; // local playground for costly test - for (stream cd = *s; cd.more(); cd.advance()) - scratch.append(cd.current()); - scratch.append(r); - movefloats(&scratch, ((double) scratch.rawht())/maxht); - trimspace(&scratch); - int retval = scratch.height() <= maxht; - scratch.freeall(); - return retval; -} - // If s1 were added to s, would the height of the composed result be at most maxht? // The computational structure is similar to that above. -int wouldfit(stream *s1, stream *s, int maxht) +static int wouldfit(stream *s1, stream *s, int maxht) { if (s1->rawht() + s->rawht() <= maxht) return 1; stream scratch, cd; for (cd = *s; cd.more(); cd.advance()) scratch.append(cd.current()); for (cd = *s1; cd.more(); cd.advance()) scratch.append(cd.current()); movefloats(&scratch, ((double) scratch.rawht())/maxht); trimspace(&scratch); int retval = scratch.height() <= maxht; scratch.freeall(); return retval; } // All of stream *s is destined for one column or the other; which is it to be? void multicol::choosecol(stream *s, int goalht) { stream *dest; if (!leftblocked && wouldfit(s, &(column[0]), goalht)) dest = &(column[0]); else { dest = &(column[1]); if (!s->current()->floatable()) // a stream item is going into the right // column, so no more can go into the left. leftblocked = 1; } for (stream cd = *s; cd.more(); cd.advance()) dest->append(cd.current()); } double coltol = 0.5; // Try, very hard, to put everything in the multicol into two columns // so that the total height is at most htavail. void multicol::compose(int defonly) { if (!nonempty()) { setheight(0); return; } scratch.freeall(); // fill scratch with everything destined // for either column stream cd; for (cd = definite; cd.more(); cd.advance()) scratch.append(cd.current()); if (!defonly) for (cd = *(currpage->stage); cd.more(); cd.advance()) if (cd.current()->numcol() == 2) scratch.append(cd.current()); scratch.restoreall(); // in particular, floatables' goals int rawht = scratch.rawht(); int halfheight = (int)(coltol*rawht); // choose a goal height int maxht = defonly ? halfheight : htavail; secondtry: int i; for (i = 0; i < 2; i++) column[i].freeall(); leftblocked = 0; cd = scratch; while (cd.more()) { queue ministage; // for the minimally acceptable chunks ministage.freeall(); // that are to be added to either column while (cd.more() && !cd.current()->issentinel()) { ministage.enqueue(cd.current()); cd.advance(); } choosecol(&ministage, maxht); if (cd.more() && cd.current()->issentinel()) cd.advance(); // past sentinel } if (height() > htavail && maxht != htavail) { // We tried to balance the columns, but // the result was too tall. Go back // and try again with the less ambitious // goal of fitting the space available. maxht = htavail; goto secondtry; } for (i = 0; i < 2; i++) { movefloats(&(column[i]), ((double) column[i].rawht())/currpage->pagesize); trimspace(&(column[i])); } if (dbg & 32) { printf("#multicol::compose: htavail %d maxht %d dv %d\n", htavail, maxht, height()); dump(); } if (defonly) stretch(height()); } // A sequence of two-column ranges waits on the stage. // So long as the page's skeleton hasn't changed--that is, the maximum height // available to the two-column chunk is the same--we just use the columns that // have been built up so far, and choose a column into which to put the stage. // If the skeleton has changed, however, then we may need to make entirely // new decisions about which column gets what, so we recompose the whole page. void multicol::tryout() { if (htavail == prevhtavail) choosecol(currpage->stage, htavail); else currpage->compose(DRAFT); prevhtavail = htavail; } // Make both columns the same height. // (Maybe this should also be governed by minfull, // to prevent padding very underfull columns.) void multicol::stretch(int wantht) { if (wantht < height()) FATAL("page %d: two-column chunk cannot shrink\n", userpn); for (int i = 0; i < 2; i++) justify(&(column[i]), wantht); if (dbg & 16) printf("#col hts: left %d right %d\n", column[0].height(), column[1].height()); } // Report an upper bound on how tall the current two-column object is. // The (possibly composed) heights of the two columns give a crude upper // bound on the total height. If the result is more than the height // available for the two-column object, then the columns are each // composed to give a better estimate of their heights. int multicol::height() { int retval = max(column[0].height(), column[1].height()); if (retval < htavail) return retval; for (int i = 0; i < 2; i++) { movefloats(&(column[i]), ((double) column[i].height())/currpage->pagesize); trimspace(&(column[i])); } return max(column[0].height(), column[1].height()); } void multicol::dump() { printf("####2COL dv %d\n", height()); printf("# left column:\n"); column[0].dump(); printf("# right column:\n"); column[1].dump(); } // From the head of queue qp, peel off a piece whose raw height is at most space. -int peeloff(stream *qp, int space) +static int peeloff(stream *qp, int space) { stream *s1 = qp->current()->children(); if (!(s1 && s1->more() && s1->current()->height() <= space)) // in other words, either qp's head is // not nested, or its first subrange return 0; // is also too big, so we give up qp->split(); s1 = qp->current()->children(); stream *s2 = qp->next()->children(); while (s2->more() && s2->current()->rawht() <= space) { s1->append(s2->current()); space -= s2->current()->rawht(); s2->advance(); } return 1; } // There are four possibilities for consecutive calls to tryout(). // If we're processing a sequence of single-column ranges, tryout() // uses the original algorithm: (1) conservative test; (2) costly test; // (3) split a breakable item. // If we're processing a sequence of double-column ranges, tryout() // defers to twocol->tryout(), which gradually builds up the contents // of the two columns until they're as tall as they can be without // exceeding twocol->htavail. // If we're processing a sequence of single-column ranges and we // get a double-column range, then we use compose() to build a // skeleton page and set twocol->htavail, the maximum height that // should be occupied by twocol. // If we're processing a sequence of double-column ranges and we // get a single-column range, then we should go back and squish // the double-column chunk as short as possible before we see if // we can fit the single-column range. void page::tryout() { if (!stage->more()) FATAL("empty stage in page::tryout()\n"); int curnumcol = stage->current()->numcol(); if (dbg & 32) { printf("#page::tryout(): ncol = %d, prevncol = %d; on stage:\n", curnumcol, prevncol); stage->dump(); printf("#END of stage contents\n"); } switch(curnumcol) { default: FATAL("unexpected number of columns in tryout(): %d\n", stage->current()->numcol()); break; case 1: if (prevncol == 2) compose(FINAL); if (wouldfit(stage, &definite, pagesize - twocol->height())) commit(); else if (stage->current()->breakable() || (blank() && peeloff(stage, pagesize - (definite.height() + twocol->height())))) { // first add the peeled-off part that fits adddef(stage->dequeue()); // then send the rest back for later stage->current()->setbreaking(); welsh(); } else if (blank()) { stage->current()->rdump(); FATAL("A %s is too big to continue.\n", stage->current()->typname()); } else welsh(); break; case 2: if (prevncol == 1) compose(DRAFT); else twocol->tryout(); if (scratch.height() <= pagesize) commit(); else welsh(); break; } prevncol = curnumcol; } // To compose the page, we (1) fill scratch with the stuff that's meant to // go on the page; (2) compose scratch as best we can; (3) set the maximum // height available to the two-column part of the page; (4) have the two- // column part compose itself. // In the computation of twocol->htavail, it does not matter that // twocol->height() is merely an upper bound, because it is merely being // subtracted out to give the exact total height of the single-column stuff. void page::compose(int final) { makescratch(final); int adjht = scratch.rawht(); if (dbg & 16) printf("# page %d measure %d\n", userpn, adjht); movefloats(&scratch, ((double) adjht)/pagesize); trimspace(&scratch); twocol->htavail = pagesize - (scratch.height() - twocol->height()); twocol->compose(final); adjht = scratch.height(); if (dbg & 16) printf("# page %d measure %d after trim\n", userpn, adjht); } // Fill the scratch area with ranges destined for the page. // If defonly == 0, then add anything that's on stage--this is a trial run. // If defonly != 0, use only what's definitely on the page. void page::makescratch(int defonly) { scratch.freeall(); stream cd; for (cd = definite; cd.more(); cd.advance()) scratch.append(cd.current()); if (!defonly) for (cd = *stage; cd.more(); cd.advance()) if (cd.current()->numcol() == 1) scratch.append(cd.current()); if (twocol->nonempty()) scratch.append(twocol); } // Accept the current contents of the stage. // If the stage contains two-column ranges, add a sentinel to indicate the end // of a chunk of stage contents. void page::commit() { if (dbg & 4) printf("#entering page::commit()\n"); int numcol = 0; while (stage->more()) { numcol = stage->current()->numcol(); adddef(stage->dequeue()); } if (numcol == 2) adddef(new sentrange); } // Send the current contents of the stage back to its source. void page::welsh() { if (dbg & 4) printf("#entering page::welsh()\n"); while (stage->more()) { range *r = stage->dequeue(); r->enqueue(ANDBLOCK); } } enum { USonly = 1 }; // So long as anything is eligible to go onto the page, keep trying. // Once nothing is eligible, compose and justify the page. void page::fill() { while (stage->prime()) stage->pend(); compose(FINAL); if (dbg & 16) scratch.dump(); if (anymore()) { int adjht = scratch.height(); if (adjht > minfull*pagesize) { justify(&scratch, pagesize); adjht = scratch.height(); int stretchamt = max(pagesize - adjht, 0); twocol->stretch(twocol->height() + stretchamt); // in case the page's stretchability lies // entirely in its two-column part } else WARNING("page %d only %.0f%% full; will not be adjusted\n", userpn, 100*(double) adjht/pagesize); } } void page::adddef(range *r) { if (dbg & 4) printf("#entering page::adddef()\n"); switch (r->numcol()) { case 1: definite.append(r); break; case 2: twocol->definite.append(r); break; default: FATAL("%d-column range unexpected\n", r->numcol()); } } int multicol::print(int cv, int col) { if (col != 0) FATAL("multicolumn output must start in left column\n"); int curv = cv, maxv = cv; // print left column for ( ; column[0].more(); column[0].advance()) { curv = column[0].current()->print(curv, 0); maxv = max(maxv, curv); } curv = cv; // print right column for ( ; column[1].more(); column[1].advance()) { curv = column[1].current()->print(curv, 1); maxv = max(maxv, curv); } return maxv; } void page::print() { static int tops = 1, bots = 1; if (!scratch.more()) { WARNING("## Here's what's left on squeue:\n"); squeue.dump(); WARNING("## Here's what's left on bfqueue:\n"); bfqueue.dump(); WARNING("## Here's what's left on ufqueue:\n"); ufqueue.dump(); WARNING("page %d appears to be empty\n", userpn); fflush(stderr), fflush(stdout), exit(0); // something is very wrong if this happens } printf("p%d\n", userpn); // print troff output page number if (ptlist.more()) { // print page header ptlist.current()->print(0, 0); ptlist.advance(); } else if (tops) { WARNING("ran out of page titles at %d\n", userpn); tops = 0; } int curv = 0; printf("V%d\n", curv = pagetop);// print page contents for ( ; scratch.more(); scratch.advance()) { curv = scratch.current()->print(curv, 0); } if (btlist.more()) { // print page footer btlist.current()->print(0, 0); btlist.advance(); } else if (bots) { WARNING("ran out of page bottoms at %d\n", userpn); bots = 0; } printf("V%d\n", physbot); // finish troff output page } int pagetop = 0; // top printing margin int pagebot = 0; // bottom printing margin int physbot = 0; // physical bottom of page double minfull = 0.9; // minimum fullness before padding int pn = 0; // cardinal page number int userpn = 0; // page number derived from PT slugs static void makepage() { page pg(pagebot - pagetop); ++pn; userpn = ptlist.more() ? ptlist.current()->pn() : pn; pg.fill(); pg.print(); } static void conv(FILE *fp) { startup(fp); // read slugs, etc. while (anymore()) makepage(); lastrange->print(0, 0); // trailer checkout(); // check that everything was printed } int main(int argc, char **argv) { static FILE *fp = stdin; setlocale(LC_CTYPE, ""); progname = argv[0]; while (argc > 1 && argv[1][0] == '-') { switch (argv[1][1]) { case 'd': dbg = atoi(&argv[1][2]); if (dbg == 0) dbg = ~0; break; case 'm': minfull = 0.01*atof(&argv[1][2]); break; case 'c': coltol = 0.01*atof(&argv[1][2]); break; case 'w': wantwarn = 1; break; } argc--; argv++; } if (argc <= 1) conv(stdin); else while (--argc > 0) { if (strcmp(*++argv, "-") == 0) fp = stdin; else if ((fp = fopen(*argv, "r")) == NULL) FATAL("can't open %s\n", *argv); conv(fp); fclose(fp); } exit(0); } Index: vendor/heirloom-doctools/dist/pic/input.c =================================================================== --- vendor/heirloom-doctools/dist/pic/input.c (revision 310549) +++ vendor/heirloom-doctools/dist/pic/input.c (revision 310550) @@ -1,606 +1,604 @@ /* * Changes by Gunnar Ritter, Freiburg i. Br., Germany, October 2005. * * Derived from Plan 9 v4 /sys/src/cmd/pic/ * * Copyright (C) 2003, Lucent Technologies Inc. and others. * All Rights Reserved. * * Distributed under the terms of the Lucent Public License Version 1.02. */ /* Sccsid @(#)input.c 1.8 (gritter) 12/25/06 */ #include #include #include #include #include #include "pic.h" #include "y.tab.h" Infile infile[10]; Infile *curfile = infile; #define MAXSRC 50 Src src[MAXSRC]; /* input source stack */ Src *srcp = src; void do_thru(void); int nextchar(void); int getarg(char *); int baldelim(int, const char *); static void popsrc(void); static char *addnewline(char *); void pushsrc(int type, const char *ptr) /* new input source */ { if (++srcp >= src + MAXSRC) FATAL("inputs nested too deep"); srcp->type = type; srcp->sp = ptr; if (dbg > 1) { printf("\n%3d ", (int)(srcp - src)); switch (srcp->type) { case File: printf("push file %s\n", ptr ? ((Infile *)ptr)->fname : "(null)"); break; case Macro: printf("push macro <%s>\n", ptr); break; case Char: printf("push char <%c>\n", *ptr); break; case Thru: printf("push thru\n"); break; case String: printf("push string <%s>\n", ptr); break; case Free: printf("push free <%s>\n", ptr); break; default: FATAL("pushed bad type %d", srcp->type); } } } static void popsrc(void) /* restore an old one */ { if (srcp <= src) FATAL("too many inputs popped"); if (dbg > 1) { printf("%3d ", (int)(srcp - src)); switch (srcp->type) { case File: printf("pop file\n"); break; case Macro: printf("pop macro\n"); break; case Char: printf("pop char <%c>\n", *srcp->sp); break; case Thru: printf("pop thru\n"); break; case String: printf("pop string\n"); break; case Free: printf("pop free\n"); break; default: FATAL("pop weird input %d", srcp->type); } } srcp--; } void definition(const char *s) /* collect definition for s and install */ /* definitions picked up lexically */ { char *p; struct symtab *stp; p = delimstr("definition"); stp = lookup(s); if (stp != NULL) { /* it's there before */ if (stp->s_type != DEFNAME) { WARNING("%s used as variable and definition", s); return; } free(stp->s_val.p); stp->s_val.p = p; } else { YYSTYPE u; u.p = p; makevar(tostring(s), DEFNAME, u); } dprintf("installing %s as `%s'\n", s, p); } char *delimstr(const char *s) /* get body of X ... X */ /* message if too big */ { int c, delim, rdelim, n, deep; static char *buf = NULL; static int nbuf = 0; char *p; if (buf == NULL) buf = grow(buf, "buf", nbuf += 1000, sizeof(buf[0])); while ((delim = input()) == ' ' || delim == '\t' || delim == '\n') ; rdelim = baldelim(delim, "{}"); /* could be "(){}[]`'" */ deep = 1; for (p = buf; ; ) { c = input(); if (c == rdelim) if (--deep == 0) break; if (c == delim) deep++; if (p >= buf + nbuf) { n = p - buf; buf = grow(buf, "buf", nbuf += 1000, sizeof(buf[0])); p = buf + n; } if (c == EOF) FATAL("end of file in %s %c %.20s... %c", s, delim, buf, delim); *p++ = c; } *p = '\0'; dprintf("delimstr %s %c <%s> %c\n", s, delim, buf, delim); return tostring(buf); } int baldelim(int c, const char *s) /* replace c by balancing entry in s */ { for ( ; *s; s += 2) if (*s == c) return s[1]; return c; } void undefine(char *s) /* undefine macro */ { while (*s != ' ' && *s != '\t') /* skip "undef..." */ s++; while (*s == ' ' || *s == '\t') s++; freedef(s); } static Arg args[10]; /* argument frames */ static Arg *argfp = args; /* frame pointer */ static int argcnt; /* number of arguments seen so far */ void dodef(struct symtab *stp) /* collect args and switch input to defn */ { int i, len; char *p; Arg *ap; ap = argfp+1; if (ap >= args+10) FATAL("arguments too deep"); argcnt = 0; if (input() != '(') FATAL("disaster in dodef"); if (ap->argval == 0) ap->argval = malloc(1000); for (p = ap->argval; (len = getarg(p)) != -1; p += len) { ap->argstk[argcnt++] = p; if (input() == ')') break; } for (i = argcnt; i < MAXARGS; i++) ap->argstk[i] = ""; if (dbg) for (i = 0; i < argcnt; i++) printf("arg %d.%d = <%s>\n", (int)(ap-args), i+1, ap->argstk[i]); argfp = ap; pushsrc(Macro, stp->s_val.p); } int getarg(char *p) /* pick up single argument, store in p, return length */ { int n, c, npar; n = npar = 0; for ( ;; ) { c = input(); if (c == EOF) FATAL("end of file in getarg"); if (npar == 0 && (c == ',' || c == ')')) break; if (c == '"') /* copy quoted stuff intact */ do { *p++ = c; n++; } while ((c = input()) != '"' && c != EOF); else if (c == '(') npar++; else if (c == ')') npar--; n++; *p++ = c; } *p = 0; unput(c); return(n + 1); } #define PBSIZE 2000 static char pbuf[PBSIZE]; /* pushback buffer */ static char *pb = pbuf-1; /* next pushed back character */ static char ebuf[200]; /* collect input here for error reporting */ static char *ep = ebuf; static int begin = 0; extern int thru; extern struct symtab *thrudef; extern char *untilstr; int input(void) { register int c; if (thru && begin) { do_thru(); begin = 0; } c = nextchar(); if (dbg > 1) printf(" <%c>", c); if (ep >= ebuf + sizeof ebuf) ep = ebuf; return (*ep++ = c) & 0377; } int nextchar(void) { register int c = 0; loop: switch (srcp->type) { case Free: /* free string */ free(srcp->sp); popsrc(); goto loop; case Thru: /* end of pushed back line */ begin = 1; popsrc(); c = '\n'; break; case Char: if (pb >= pbuf) { c = *pb--; popsrc(); break; } else { /* can't happen? */ popsrc(); goto loop; } case String: c = *srcp->sp++; if (c == '\0') { popsrc(); goto loop; } else { if (*srcp->sp == '\0') /* empty, so pop */ popsrc(); break; } case Macro: c = *srcp->sp++; if (c == '\0') { if (--argfp < args) FATAL("argfp underflow"); popsrc(); goto loop; } else if (c == '$' && isdigit((int)*srcp->sp)) { int n = 0; while (isdigit((int)*srcp->sp)) n = 10 * n + *srcp->sp++ - '0'; if (n > 0 && n <= MAXARGS) pushsrc(String, argfp->argstk[n-1]); goto loop; } break; case File: c = getc(curfile->fin); if (c == EOF) { if (curfile == infile) FATAL("end of file inside .PS/.PE"); if (curfile->fin != stdin) { fclose(curfile->fin); free(curfile->fname); /* assumes allocated */ } curfile--; printlf(curfile->lineno, curfile->fname); popsrc(); thru = 0; /* chicken out */ thrudef = 0; if (untilstr) { free(untilstr); untilstr = 0; } goto loop; } if (c == '\n') curfile->lineno++; break; } return c; } void do_thru(void) /* read one line, make into a macro expansion */ { int c, i; char *p; Arg *ap; ap = argfp+1; if (ap >= args+10) FATAL("arguments too deep"); if (ap->argval == NULL) ap->argval = malloc(1000); p = ap->argval; argcnt = 0; c = nextchar(); if (thru == 0) { /* end of file was seen, so thru is done */ unput(c); return; } for ( ; c != '\n' && c != EOF; ) { if (c == ' ' || c == '\t') { c = nextchar(); continue; } ap->argstk[argcnt++] = p; if (c == '"') { do { *p++ = c; if ((c = nextchar()) == '\\') { *p++ = c; *p++ = nextchar(); c = nextchar(); } } while (c != '"' && c != '\n' && c != EOF); *p++ = '"'; if (c == '"') c = nextchar(); } else { do { *p++ = c; } while ((c = nextchar())!=' ' && c!='\t' && c!='\n' && c!=',' && c!=EOF); if (c == ',') c = nextchar(); } *p++ = '\0'; } if (c == EOF) FATAL("unexpected end of file in do_thru"); if (argcnt == 0) { /* ignore blank line */ pushsrc(Thru, (char *) 0); return; } for (i = argcnt; i < MAXARGS; i++) ap->argstk[i] = ""; if (dbg) for (i = 0; i < argcnt; i++) printf("arg %d.%d = <%s>\n", (int)(ap-args), i+1, ap->argstk[i]); if (strcmp(ap->argstk[0], ".PE") == 0) { thru = 0; thrudef = 0; pushsrc(String, "\n.PE\n"); return; } if (untilstr && strcmp(ap->argstk[0], untilstr) == 0) { thru = 0; thrudef = 0; free(untilstr); untilstr = 0; return; } pushsrc(Thru, (char *) 0); dprintf("do_thru pushing back <%s>\n", thrudef->s_val.p); argfp = ap; pushsrc(Macro, thrudef->s_val.p); } int unput(int c) { if (++pb >= pbuf + sizeof pbuf) FATAL("pushback overflow"); if (--ep < ebuf) ep = ebuf + sizeof(ebuf) - 1; *pb = c; pushsrc(Char, pb); return c; } void pbstr(const char *s) { pushsrc(String, s); } double errcheck(double x, char *s) { if (errno == EDOM) { errno = 0; WARNING("%s argument out of domain", s); } else if (errno == ERANGE) { errno = 0; WARNING("%s result out of range", s); } return x; } void eprint(void); void yyerror(char *s) { int ern = errno; /* cause some libraries clobber it */ if (synerr) return; fflush(stdout); fprintf(stderr, "%s: %s", cmdname, s); if (ern > 0) { errno = ern; perror("???"); } fprintf(stderr, " near %s:%d\n", curfile->fname, curfile->lineno+1); eprint(); synerr = 1; errno = 0; } void eprint(void) /* try to print context around error */ { char *p, *q; p = ep - 1; if (p > ebuf && *p == '\n') p--; for ( ; p >= ebuf && *p != '\n'; p--) ; while (*p == '\n') p++; fprintf(stderr, " context is\n\t"); for (q=ep-1; q>=p && *q!=' ' && *q!='\t' && *q!='\n'; q--) ; while (p < q) putc(*p++, stderr); fprintf(stderr, " >>> "); while (p < ep) putc(*p++, stderr); fprintf(stderr, " <<< "); while (pb >= pbuf) putc(*pb--, stderr); fgets(ebuf, sizeof ebuf, curfile->fin); fprintf(stderr, "%s", ebuf); pbstr("\n.PE\n"); /* safety first */ ep = ebuf; } -void yywrap(void) {} - static char *newfile = 0; /* filename for file copy */ char *untilstr = 0; /* string that terminates a thru */ int thru = 0; /* 1 if copying thru macro */ struct symtab *thrudef = 0; /* macro being used */ void copyfile(char *s) /* remember file to start reading from */ { newfile = s; } void copydef(struct symtab *p) /* remember macro symtab ptr */ { thrudef = p; } struct symtab *copythru(const char *s) /* collect the macro name or body for thru */ { struct symtab *p; char *q, *addnewline(char *); p = lookup(s); if (p != NULL) { if (p->s_type == DEFNAME) { p->s_val.p = addnewline(p->s_val.p); return p; } else FATAL("%s used as define and name", s); } /* have to collect the definition */ pbstr(s); /* first char is the delimiter */ q = delimstr("thru body"); s = "nameless"; p = lookup(s); if (p != NULL) { if (p->s_val.p) free(p->s_val.p); p->s_val.p = q; } else { YYSTYPE u; u.p = q; p = makevar(tostring(s), DEFNAME, u); } p->s_val.p = addnewline(p->s_val.p); dprintf("installing %s as `%s'\n", s, p->s_val.p); return p; } static char *addnewline(char *p) /* add newline to end of p */ { int n; n = strlen(p); if (p[n-1] != '\n') { p = realloc(p, n+2); p[n] = '\n'; p[n+1] = '\0'; } return p; } void copyuntil(char *s) /* string that terminates a thru */ { untilstr = s; } void copy(void) /* begin input from file, etc. */ { FILE *fin; if (newfile) { if ((fin = fopen(newfile, "r")) == NULL) FATAL("can't open file %s", newfile); curfile++; curfile->fin = fin; curfile->fname = newfile; curfile->lineno = 0; printlf(1, curfile->fname); pushsrc(File, curfile->fname); newfile = 0; } if (thrudef) { thru = 1; begin = 1; /* wrong place */ } } static char shellbuf[1000], *shellp; void shell_init(void) /* set up to interpret a shell command */ { shellp = shellbuf; } void shell_text(char *s) /* add string to command being collected */ { while ((*shellp++ = *s++)) { if (shellp >= &shellbuf[sizeof shellbuf]) FATAL("shell command too long"); } shellp--; } void shell_exec(void) /* do it */ { *shellp = '\0'; if (Sflag) WARNING("-S inhibited execution of shell command"); else system(shellbuf); } Index: vendor/heirloom-doctools/dist/pic/main.c =================================================================== --- vendor/heirloom-doctools/dist/pic/main.c (revision 310549) +++ vendor/heirloom-doctools/dist/pic/main.c (revision 310550) @@ -1,309 +1,310 @@ /* * Changes by Gunnar Ritter, Freiburg i. Br., Germany, October 2005. * * Derived from Plan 9 v4 /sys/src/cmd/pic/ * * Copyright (C) 2003, Lucent Technologies Inc. and others. * All Rights Reserved. * * Distributed under the terms of the Lucent Public License Version 1.02. */ /* Sccsid @(#)main.c 1.6 (gritter) 12/5/05 */ #include #include #include #include #include "pic.h" #include "y.tab.h" +static void reset(void); extern const char version[]; obj **objlist = 0; /* store the elements here */ int nobjlist = 0; /* size of objlist array */ int nobj = 0; Attr *attr; /* attributes stored here as collected */ int nattrlist = 0; int nattr = 0; /* number of entries in attr_list */ Text *text = 0; /* text strings stored here as collected */ int ntextlist = 0; /* size of text[] array */ int ntext = 0; int ntext1 = 0; /* record ntext here on entry to each figure */ double curx = 0; double cury = 0; int hvmode = R_DIR; /* R => join left to right, D => top to bottom, etc. */ int codegen = 0; /* 1=>output for this picture; 0=>no output */ char *PEstring; /* "PS" or "PE" picked up by lexer */ double deltx = 6; /* max x value in output, for scaling */ double delty = 6; /* max y value in output, for scaling */ int dbg = 0; int lineno = 0; int synerr = 0; static int anyerr = 0; /* becomes 1 if synerr ever 1 */ char *cmdname; int Sflag; double xmin = 30000; /* min values found in actual data */ double ymin = 30000; double xmax = -30000; /* max */ double ymax = -30000; void fpecatch(int); void getdata(void), setdefaults(void); int getpid(void); int main(int argc, char *argv[]) { char buf[20]; signal(SIGFPE, fpecatch); cmdname = argv[0]; while (argc > 1 && *argv[1] == '-') { switch (argv[1][1]) { case 'd': dbg = atoi(&argv[1][2]); if (dbg == 0) dbg = 1; fprintf(stderr, "%s\n", version); break; case 'V': fprintf(stderr, "%s\n", version); return 0; case 'S': Sflag = 1; break; case 'U': Sflag = 0; break; } argc--; argv++; } setdefaults(); objlist = (obj **) grow((char *)objlist, "objlist", nobjlist += 1000, sizeof(obj *)); text = (Text *) grow((char *)text, "text", ntextlist += 1000, sizeof(Text)); attr = (Attr *) grow((char *)attr, "attr", nattrlist += 100, sizeof(Attr)); snprintf(buf, sizeof(buf), "/%d/", getpid()); pushsrc(String, buf); definition("pid"); curfile = infile; pushsrc(File, curfile->fname); if (argc <= 1) { curfile->fin = stdin; curfile->fname = tostring("-"); getdata(); } else while (argc-- > 1) { if ((curfile->fin = fopen(*++argv, "r")) == NULL) { fprintf(stderr, "%s: can't open %s\n", cmdname, *argv); exit(1); } curfile->fname = tostring(*argv); getdata(); fclose(curfile->fin); free(curfile->fname); } return anyerr; } void fpecatch(int n) { FATAL("floating point exception %d", n); } char *grow(char *ptr, const char *name, int num, int size) /* make array bigger */ { char *p; if (ptr == NULL) p = malloc(num * size); else p = realloc(ptr, num * size); if (p == NULL) FATAL("can't grow %s to %d", name, num * size); return p; } static struct { const char *name; double val; short scalable; /* 1 => adjust when "scale" changes */ } defaults[] ={ { "scale" , SCALE , 1 }, { "lineht" , HT , 1 }, { "linewid" , HT , 1 }, { "moveht" , HT , 1 }, { "movewid" , HT , 1 }, { "dashwid" , HT10 , 1 }, { "boxht" , HT , 1 }, { "boxwid" , WID , 1 }, { "circlerad" , HT2 , 1 }, { "arcrad" , HT2 , 1 }, { "ellipseht" , HT , 1 }, { "ellipsewid", WID , 1 }, { "arrowht" , HT5 , 1 }, { "arrowwid" , HT10 , 1 }, { "arrowhead" , 2 , 0 }, /* arrowhead style */ { "textht" , 0.0 , 1 }, /* 6 lines/inch is also a useful value */ { "textwid" , 0.0 , 1 }, { "maxpsht" , MAXHT , 0 }, { "maxpswid" , MAXWID, 0 }, { "fillval" , 0.7 , 0 }, /* gray value for filling boxes */ { NULL , 0 , 0 } }; void setdefaults(void) /* set default sizes for variables like boxht */ { int i; YYSTYPE v; for (i = 0; defaults[i].name != NULL; i++) { v.f = defaults[i].val; makevar(tostring(defaults[i].name), VARNAME, v); } } void resetvar(void) /* reset variables listed */ { int i, j; if (nattr == 0) { /* none listed, so do all */ setdefaults(); return; } for (i = 0; i < nattr; i++) { for (j = 0; defaults[j].name != NULL; j++) if (strcmp(defaults[j].name, attr[i].a_val.p) == 0) { setfval(defaults[j].name, defaults[j].val); free(attr[i].a_val.p); break; } } } void checkscale(char *s) /* if s is "scale", adjust default variables */ { int i; double scale; if (strcmp(s, "scale") == 0) { scale = getfval("scale"); for (i = 1; defaults[i].name != NULL; i++) if (defaults[i].scalable) setfval(defaults[i].name, defaults[i].val * scale); } } void getdata(void) { char *p, *buf = NULL, *buf1 = NULL; size_t size = 0; int ln; - void reset(void), openpl(char *), closepl(char *); + void openpl(char *), closepl(char *); int yyparse(void); curfile->lineno = 0; printlf(1, curfile->fname); while (getline(&buf, &size, curfile->fin) > 0) { curfile->lineno++; if (buf[0] == '.' && buf[1] == 'l' && buf[2] == 'f') { buf1 = realloc(buf1, size); if (sscanf(buf+3, "%d %s", &ln, buf1) == 2) { free(curfile->fname); printlf(curfile->lineno = ln, curfile->fname = tostring(buf1)); } else printlf(curfile->lineno = ln, NULL); } else if (*buf == '.') { for (p = buf + 1; *p == ' ' || *p == '\t'; p++); if (!*p || *p != 'P' || p[1] != 'S') { fputs(buf, stdout); continue; } for (p = &buf[3]; *p == ' '; p++) ; if (*p++ == '<') { Infile svfile; svfile = *curfile; buf1 = realloc(buf1, size); sscanf(p, "%s", buf1); if ((curfile->fin=fopen(buf1, "r")) == NULL) FATAL("can't open %s", buf1); curfile->fname = tostring(buf1); getdata(); fclose(curfile->fin); free(curfile->fname); *curfile = svfile; printlf(curfile->lineno, curfile->fname); continue; } reset(); yyparse(); anyerr += synerr; deltx = (xmax - xmin) / getfval("scale"); delty = (ymax - ymin) / getfval("scale"); if (buf[3] == ' ') { /* next things are wid & ht */ if (sscanf(&buf[4],"%lf %lf", &deltx, &delty) < 2) delty = deltx * (ymax-ymin) / (xmax-xmin); /* else { * double xfac, yfac; */ /* xfac = deltx / (xmax-xmin); * yfac = delty / (ymax-ymin); * if (xfac <= yfac) * delty = xfac * (ymax-ymin); * else * deltx = yfac * (xmax-xmin); *} */ } dprintf("deltx = %g, delty = %g\n", deltx, delty); if (codegen && !synerr) { openpl(&buf[3]); /* puts out .PS, with ht & wid stuck in */ printlf(curfile->lineno+1, NULL); print(); /* assumes \n at end */ closepl(PEstring); /* does the .PE/F */ free(PEstring); } printlf(curfile->lineno+1, NULL); fflush(stdout); } else fputs(buf, stdout); } free(buf); free(buf1); } -void reset(void) +static void reset(void) { obj *op; int i; extern int nstack; for (i = 0; i < nobj; i++) { op = objlist[i]; if (op->o_type == BLOCK) freesymtab(op->o_symtab); free((char *)objlist[i]); } nobj = 0; nattr = 0; for (i = 0; i < ntext; i++) if (text[i].t_val) free(text[i].t_val); ntext = ntext1 = 0; codegen = synerr = 0; nstack = 0; curx = cury = 0; PEstring = 0; hvmode = R_DIR; xmin = ymin = 30000; xmax = ymax = -30000; } Index: vendor/heirloom-doctools/dist/pic/picl.l =================================================================== --- vendor/heirloom-doctools/dist/pic/picl.l (revision 310549) +++ vendor/heirloom-doctools/dist/pic/picl.l (revision 310550) @@ -1,299 +1,300 @@ %{ /* * Changes by Gunnar Ritter, Freiburg i. Br., Germany, October 2005. * * Derived from Plan 9 v4 /sys/src/cmd/pic/ * * Copyright (C) 2003, Lucent Technologies Inc. and others. * All Rights Reserved. * * Distributed under the terms of the Lucent Public License Version 1.02. */ /* Sccsid @(#)picl.l 1.9 (gritter) 8/6/06 */ %} +%option noyywrap +%option nounput %Start A str def xsc br thru sh %e 1700 %k 150 %a 1800 %o 1600 %p 5000 %n 700 %{ #ifndef FLEX_SCANNER #undef input #undef unput #endif /* !FLEX_SCANNER */ /* #include lex puts one out for us */ #include #include #include #include "pic.h" #include "y.tab.h" #ifdef FLEX_SCANNER #undef YY_INPUT #define YY_INPUT(buf, result, max_size) { \ int c = xxinput(); \ result = (c == EOF || c == 0) ? YY_NULL : (buf[0] = c, 1); \ } #define witchcraft YY_START #else /* !FLEX_SCANNER */ #define witchcraft yybgin-yysvec-1 #endif /* !FLEX_SCANNER */ extern struct symtab symtab[]; int yyback(int *, int); int yylook(void); -int yywrap(void); #define CADD cbuf[clen++]=yytext[0]; \ if (clen>=CBUFLEN-1) { WARNING("string too long", cbuf); BEGIN A; } #define CBUFLEN 500 static char cbuf[CBUFLEN]; static int c, clen, delim; static int ifsw = 0; /* 1 if if statement in progress */ %} A [a-zA-Z_] B [a-zA-Z0-9_] D [0-9] WS [ \t] FWS ([ \t]|\\\n) %% switch (witchcraft) { case 0: BEGIN A; break; case xsc: BEGIN A; return('}'); case br: BEGIN A; return(']'); } {WS} ; "\\"\n ; \n { return(ST); } ";" { return(ST); } "}" { BEGIN xsc; return(ST); } "]" { BEGIN br; return(ST); } "{"{WS}*(#.*)?\n+ { return(yylval.i = yytext[0]); } ^"."{WS}*"PS".* { if (curfile == infile) WARNING(".PS found inside .PS/.PE"); } ^"."{WS}*"PE".* { if (curfile == infile) { yylval.p = PEstring = tostring(yytext); return(EOF); } } ^['.].* { yylval.p = tostring(yytext); return(TROFF); } print return(yylval.i = PRINT); box return(yylval.i = BOX); circle return(yylval.i = CIRCLE); arc return(yylval.i = ARC); ellipse return(yylval.i = ELLIPSE); arrow return(yylval.i = ARROW); spline return(yylval.i = SPLINE); line return(yylval.i = LINE); move return(yylval.i = MOVE); "[]" return(yylval.i = BLOCK); reset return(RESET); sprintf return(SPRINTF); same return(SAME); between return(BETWEEN); and return(AND); of ; the ; way ; "."(e|east) { yylval.i = EAST; return(CORNER); } "."(r|right) { yylval.i = EAST; return(CORNER); } "."(w|west) { yylval.i = WEST; return(CORNER); } "."(l|left) { yylval.i = WEST; return(CORNER); } "."(n|north) { yylval.i = NORTH; return(CORNER); } "."(t|top) { yylval.i = NORTH; return(CORNER); } "."(s|south) { yylval.i = SOUTH; return(CORNER); } "."(b|bot|bottom) { yylval.i = SOUTH; return(CORNER); } "."(c|center) { yylval.i = CENTER; return(CORNER); } ".start" { yylval.i = START; return(CORNER); } ".end" { yylval.i = END; return(CORNER); } ".ne" { yylval.i = NE; return(CORNER); } ".se" { yylval.i = SE; return(CORNER); } ".nw" { yylval.i = NW; return(CORNER); } ".sw" { yylval.i = SW; return(CORNER); } top{FWS}+of { yylval.i = NORTH; return(CORNER); } north{FWS}+of { yylval.i = NORTH; return(CORNER); } bottom{FWS}+of { yylval.i = SOUTH; return(CORNER); } south{FWS}+of { yylval.i = SOUTH; return(CORNER); } left{FWS}+of { yylval.i = WEST; return(CORNER); } west{FWS}+of { yylval.i = WEST; return(CORNER); } right{FWS}+of { yylval.i = EAST; return(CORNER); } east{FWS}+of { yylval.i = EAST; return(CORNER); } center{FWS}+of { yylval.i = CENTER; return(CORNER); } start{FWS}+of { yylval.i = START; return(CORNER); } end{FWS}+of { yylval.i = END; return(CORNER); } upper{FWS}right{FWS}+of { yylval.i = NE; return(CORNER); } lower{FWS}right{FWS}+of { yylval.i = SE; return(CORNER); } upper{FWS}left{FWS}+of { yylval.i = NW; return(CORNER); } lower{FWS}left{FWS}+of { yylval.i = SW; return(CORNER); } height|ht { yylval.i = HEIGHT; return(ATTR); } width|wid { yylval.i = WIDTH; return(ATTR); } radius|rad { yylval.i = RADIUS; return(ATTR); } diameter|diam { yylval.i = DIAMETER; return(ATTR); } size { yylval.i = SIZE; return(ATTR); } left { yylval.i = LEFT; return(DIR); } right { yylval.i = RIGHT; return(DIR); } up { yylval.i = UP; return(DIR); } down { yylval.i = DOWN; return(DIR); } cw { yylval.i = CW; return(ATTR); } clockwise { yylval.i = CW; return(ATTR); } ccw { yylval.i = CCW; return(ATTR); } invis(ible)? { yylval.i = INVIS; return(ATTR); } noedge { yylval.i = INVIS; return ATTR; } fill return(yylval.i = FILL); solid ; dot(ted)? return(yylval.i = DOT); dash(ed)? return(yylval.i = DASH); chop return(yylval.i = CHOP); spread { yylval.i = SPREAD; return TEXTATTR; } ljust { yylval.i = LJUST; return TEXTATTR; } rjust { yylval.i = RJUST; return TEXTATTR; } above { yylval.i = ABOVE; return TEXTATTR; } below { yylval.i = BELOW; return TEXTATTR; } center { yylval.i = CENTER; return TEXTATTR; } "<-" { yylval.i = HEAD1; return(HEAD); } "->" { yylval.i = HEAD2; return(HEAD); } "<->" { yylval.i = HEAD12; return(HEAD); } ".x" return(yylval.i = DOTX); ".y" return(yylval.i = DOTY); "."(ht|height) return(yylval.i = DOTHT); "."(wid|width) return(yylval.i = DOTWID); "."(rad|radius) return(yylval.i = DOTRAD); from return(yylval.i = FROM); to return(yylval.i = TO); at return(yylval.i = AT); by return(yylval.i = BY); with return(yylval.i = WITH); last return(yylval.i = LAST); log return(LOG); exp return(EXP); sin return(SIN); cos return(COS); atan2 return(ATAN2); sqrt return(SQRT); rand return(RAND); max return(MAX); min return(MIN); int return(INT); "==" return(EQ); ">=" return(GE); "<=" return(LE); "!=" return(NEQ); ">" return(GT); "<" return(LT); "&&" return(ANDAND); "||" return(OROR); "!" return(NOT); Here return(yylval.i = HERE); for return(FOR); ^Endfor\n { endfor(); } do { yylval.p = delimstr("loop body"); return(DOSTR); } copy|include return(COPY); (thru|through){WS}+ { BEGIN thru; return(THRU); } {A}{B}*|. { yylval.st = copythru(yytext); BEGIN A; return(DEFNAME); } until return(UNTIL); if { ifsw = 1; return(IF); } then { if (!ifsw) { yylval.i = THEN; return(ATTR); } yylval.p = delimstr("then part"); ifsw = 0; return(THENSTR); } else { yylval.p = delimstr("else part"); return(ELSESTR); } sh{WS}+ { BEGIN sh; if ((delim = input()) == '{') delim = '}'; /* no nested {} */ shell_init(); } {A}{B}* { struct symtab *p; if (yytext[0] == delim) { shell_exec(); BEGIN A; } else { p = lookup(yytext); if (p != NULL && p->s_type == DEFNAME) { c = input(); xxunput(c); if (c == '(') dodef(p); else pbstr(p->s_val.p); } else shell_text(yytext); } } .|\n { if (yytext[0] == delim) { shell_exec(); BEGIN A; } else shell_text(yytext); } define{WS}+ { BEGIN def; } {A}{B}* { definition(yytext); BEGIN A; } undef(ine)?{WS}+{A}{B}* { undefine(yytext); } first { yylval.i = 1; return(NTH); } {D}+(th|nd|rd|st) { yylval.i = atoi(yytext); return(NTH); } ({D}+("."?){D}*|"."{D}+)((e|E)("+"|-)?{D}+)?i? { yylval.f = atof(yytext); return(NUMBER); } {A}{B}* { struct symtab *p; p = lookup(yytext); if (p != NULL && p->s_type == DEFNAME) { c = input(); xxunput(c); if (c == '(') /* it's name(...) */ dodef(p); else { /* no argument list */ pbstr(p->s_val.p); dprintf("pushing back `%s'\n", p->s_val.p); } } else if (islower((int)yytext[0])) { yylval.p = tostring(yytext); return(VARNAME); } else { yylval.p = tostring(yytext); return(PLACENAME); } } \" { BEGIN str; clen=0; } \" { cbuf[clen]=0; yylval.p = tostring(cbuf); BEGIN A; return(TEXT); } \n { cbuf[clen]=0; WARNING("missing quote in string \"%s\"", cbuf); BEGIN A; return(ST); } "\\\"" { cbuf[clen++]='"'; } "\\"t { cbuf[clen++]='\t'; } "\\\\" { cbuf[clen++]='\\'; } . { CADD; } #.* ; . return(yylval.i = yytext[0]); %% Index: vendor/heirloom-doctools/dist/ptx/ptx.1 =================================================================== --- vendor/heirloom-doctools/dist/ptx/ptx.1 (revision 310549) +++ vendor/heirloom-doctools/dist/ptx/ptx.1 (nonexistent) @@ -1,158 +0,0 @@ -.\" -.\" Sccsid @(#)ptx.1 1.6 (gritter) 2/2/07 -.\" Parts taken from ptx(1), Unix 7th edition: -.\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" Redistributions of source code and documentation must retain the -.\" above copyright notice, this list of conditions and the following -.\" disclaimer. -.\" 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. -.\" All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed or owned by Caldera -.\" International, Inc. -.\" Neither the name of Caldera International, Inc. nor the names of -.\" other contributors may be used to endorse or promote products -.\" derived from this software without specific prior written permission. -.\" -.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA -.\" INTERNATIONAL, INC. 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 CALDERA INTERNATIONAL, INC. 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. -.Dd February 2, 2007 -.Dt PTX 1 -.Os -.Sh NAME -.Nm ptx -.Nd permuted index -.Sh SYNOPSIS -.Nm -.Op Fl ftr -.Op Fl w Ar n -.Op Fl g Ar n -.Op Fl o Ar only -.Op Fl i Ar ignore -.Op Fl b Ar break -.Op Ar input Op Ar output -.Sh DESCRIPTION -.Nm -generates a permuted index to file -.Ar input -on file -.Ar output -(standard input and output default). -It has three phases: the first does the permutation, generating -one line for each keyword in an input line. -The keyword is rotated to the front. -The permuted file is then -sorted. -Finally, the sorted lines are rotated so the keyword -comes at the middle of the page. -.Nm -produces output in the form: -.Bd -literal -offset XXXXX -\&.xx "tail" "before keyword" "keyword and after" "head" -.Ed -.Pp -where .xx may be an -.Cm nroff -or -.Xr troff 1 -macro -for user-defined formatting. -Once choice for this macro is supplied in the -.Sq Fl mptx -macro package. -The -.Em before keyword -and -.Em keyword and after -fields incorporate as much of the line as will fit -around the keyword when it is printed at the middle of the page. -.Em tail -and -.Em head -at least one of which is an empty string "", -are wrapped-around pieces small enough to fit -in the unused space at the opposite end of the line. -When original text must be discarded, `/' marks the spot. -.Pp -The following options can be applied: -.Bl -tag -width XXXXX -.It Fl f -Fold upper and lower case letters for sorting. -.It Fl t -Prepare the output for the phototypesetter, -i.e. set the default line length to 100 characters. -.It Fl w Ar n -Use the next argument, -.Ar n, -as the width of the output line. -The default line length is 72 characters. -.It Fl g Ar n -Use the next argument, -.Ar n, -as the number of characters to allow for each gap -among the four parts of the line as finally printed. -The default gap is 3 characters. -.It Fl o Ar only -Use as keywords only the words given in the -.Ar only -file. -.It Fl i Ar ignore -Do not use as keywords any words given in the -.Ar ignore -file. -If the -.Fl i -and -.Fl o -options are missing, use -.Pa /usr/ucblib/eign -as the -.Ar ignore -file. -.It Fl b Ar break -Use the characters in the -.Ar break -file to separate words. -In any case, tab, newline, and space characters are always used as break -characters. -.It Fl r -Take any leading nonblank characters of each input line to -be a reference identifier (as to a page or chapter) -separate from the text of the line. -Attach that identifier as a 5th field on each output line. -.El -.Sh ENVIRONMENT VARIABLES -.Bl -tag -width XXXXXXXXXXXX -.It Ev LANG , Ev LC_ALL -See -.Xr locale 7 . -.It Ev LC_COLLATE -Determines the sort order. -.It Ev LC_CTYPE -Determines the mapping of bytes to characters. -.El -.Sh FILES -.Bl -ohang -compact -.It Pa /usr/5bin/sort -.It Pa /usr/ucblib/eign -.It Pa /usr/ucblib/doctools/tmac/ptx -.El -.Sh NOTES -Line length counts do not account for overstriking or -proportional spacing. Property changes on: vendor/heirloom-doctools/dist/ptx/ptx.1 ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/ptx/Makefile.mk =================================================================== --- vendor/heirloom-doctools/dist/ptx/Makefile.mk (revision 310549) +++ vendor/heirloom-doctools/dist/ptx/Makefile.mk (revision 310550) @@ -1,23 +1,29 @@ OBJ = ptx.o FLAGS = -DLIBDIR='"$(LIBDIR)"' $(EUC) -I../include .c.o: $(CC) $(_CFLAGS) $(FLAGS) -c $< -all: ptx +all: ptx ptx.1 ptx: $(OBJ) $(CC) $(_CFLAGS) $(_LDFLAGS) $(OBJ) $(LIBS) -o ptx install: $(INSTALL) -c ptx $(ROOT)$(BINDIR)/ptx $(STRIP) $(ROOT)$(BINDIR)/ptx $(INSTALL) -c -m 644 ptx.1 $(ROOT)$(MANDIR)/man1/ptx.1 test -d $(ROOT)$(LIBDIR) || mkdir -p $(ROOT)$(LIBDIR) $(INSTALL) -c -m 644 eign $(ROOT)$(LIBDIR)/eign clean: - rm -f $(OBJ) ptx core log *~ + rm -f $(OBJ) ptx core log *~ ptx.1 mrproper: clean + +ptx.1: ptx.1.in + sed -e "s'/usr/5bin/sort'`which sort`'" \ + -e 's"/usr/ucblib/doctools/tmac/"$(ROOT)$(BINDIR)/"' \ + -e 's"/usr/ucblib/"$(ROOT)$(LIBDIR)/"' \ + ptx.1.in > $@ Index: vendor/heirloom-doctools/dist/ptx/ptx.1.in =================================================================== --- vendor/heirloom-doctools/dist/ptx/ptx.1.in (nonexistent) +++ vendor/heirloom-doctools/dist/ptx/ptx.1.in (revision 310550) @@ -0,0 +1,158 @@ +.\" +.\" Sccsid @(#)ptx.1 1.6 (gritter) 2/2/07 +.\" Parts taken from ptx(1), Unix 7th edition: +.\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" Redistributions of source code and documentation must retain the +.\" above copyright notice, this list of conditions and the following +.\" disclaimer. +.\" 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. +.\" All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" Neither the name of Caldera International, Inc. nor the names of +.\" other contributors may be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. 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 CALDERA INTERNATIONAL, INC. 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. +.Dd February 2, 2007 +.Dt PTX 1 +.Os +.Sh NAME +.Nm ptx +.Nd permuted index +.Sh SYNOPSIS +.Nm +.Op Fl ftr +.Op Fl w Ar n +.Op Fl g Ar n +.Op Fl o Ar only +.Op Fl i Ar ignore +.Op Fl b Ar break +.Op Ar input Op Ar output +.Sh DESCRIPTION +.Nm +generates a permuted index to file +.Ar input +on file +.Ar output +(standard input and output default). +It has three phases: the first does the permutation, generating +one line for each keyword in an input line. +The keyword is rotated to the front. +The permuted file is then +sorted. +Finally, the sorted lines are rotated so the keyword +comes at the middle of the page. +.Nm +produces output in the form: +.Bd -literal -offset XXXXX +\&.xx "tail" "before keyword" "keyword and after" "head" +.Ed +.Pp +where .xx may be an +.Cm nroff +or +.Xr troff 1 +macro +for user-defined formatting. +Once choice for this macro is supplied in the +.Sq Fl mptx +macro package. +The +.Em before keyword +and +.Em keyword and after +fields incorporate as much of the line as will fit +around the keyword when it is printed at the middle of the page. +.Em tail +and +.Em head +at least one of which is an empty string "", +are wrapped-around pieces small enough to fit +in the unused space at the opposite end of the line. +When original text must be discarded, `/' marks the spot. +.Pp +The following options can be applied: +.Bl -tag -width XXXXX +.It Fl f +Fold upper and lower case letters for sorting. +.It Fl t +Prepare the output for the phototypesetter, +i.e. set the default line length to 100 characters. +.It Fl w Ar n +Use the next argument, +.Ar n, +as the width of the output line. +The default line length is 72 characters. +.It Fl g Ar n +Use the next argument, +.Ar n, +as the number of characters to allow for each gap +among the four parts of the line as finally printed. +The default gap is 3 characters. +.It Fl o Ar only +Use as keywords only the words given in the +.Ar only +file. +.It Fl i Ar ignore +Do not use as keywords any words given in the +.Ar ignore +file. +If the +.Fl i +and +.Fl o +options are missing, use +.Pa /usr/ucblib/eign +as the +.Ar ignore +file. +.It Fl b Ar break +Use the characters in the +.Ar break +file to separate words. +In any case, tab, newline, and space characters are always used as break +characters. +.It Fl r +Take any leading nonblank characters of each input line to +be a reference identifier (as to a page or chapter) +separate from the text of the line. +Attach that identifier as a 5th field on each output line. +.El +.Sh ENVIRONMENT VARIABLES +.Bl -tag -width XXXXXXXXXXXX +.It Ev LANG , Ev LC_ALL +See +.Xr locale 7 . +.It Ev LC_COLLATE +Determines the sort order. +.It Ev LC_CTYPE +Determines the mapping of bytes to characters. +.El +.Sh FILES +.Bl -ohang -compact +.It Pa /usr/5bin/sort +.It Pa /usr/ucblib/eign +.It Pa /usr/ucblib/doctools/tmac/ptx +.El +.Sh NOTES +Line length counts do not account for overstriking or +proportional spacing. Property changes on: vendor/heirloom-doctools/dist/ptx/ptx.1.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/ptx/ptx.c =================================================================== --- vendor/heirloom-doctools/dist/ptx/ptx.c (revision 310549) +++ vendor/heirloom-doctools/dist/ptx/ptx.c (revision 310550) @@ -1,704 +1,705 @@ /* from Unix 7th Edition /usr/src/cmd/ptx.c */ /* * Changes by Gunnar Ritter, Freiburg i. Br., Germany, November 2005. */ /* * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * Redistributions of source code and documentation must retain the * above copyright notice, this list of conditions and the following * disclaimer. * 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. * All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed or owned by Caldera * International, Inc. * Neither the name of Caldera International, Inc. nor the names of * other contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA * INTERNATIONAL, INC. 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 CALDERA INTERNATIONAL, INC. 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. */ #if __GNUC__ >= 3 && __GNUC_MINOR__ >= 4 || __GNUC__ >= 4 #define USED __attribute__ ((used)) #elif defined __GNUC__ #define USED __attribute__ ((unused)) #else #define USED #endif static const char sccsid[] USED = "@(#)/usr/ucb/ptx.sl 1.5 (gritter) 11/6/05"; /* permuted title index ptx [-t] [-i ignore] [-o only] [-w num] [-f] [input] [output] Ptx reads the input file and permutes on words in it. It excludes all words in the ignore file. Alternately it includes words in the only file. if neither is given it excludes the words in /usr/lib/eign. The width of the output line can be changed to num characters. If omitted 72 is default unless troff than 100. the -f flag tells the program to fold the output the -t flag says the output is for troff and the output is then wider.  make: cc ptx.c -lS */ #include #include #ifdef EUC #include #include #endif #include #include #include #include #include #include #include #include #include #include "global.h" #define DEFLTX LIBDIR "/eign" #define TILDE 0177 #define SORT "sort" #define N 30 #define MAX N*BUFSIZ #define MAXT 2048 #define MASK 03777 #define SET 1 #define isabreak(c) (btable[c]) #define getline xxgetline static int status; #ifdef EUC #define NCHARS 0x110000 #else /* !EUC */ #define NCHARS 256 #define iswupper isupper #define towlower tolower #define iswspace isspace #define wchar_t unsigned char #endif /* !EUC */ static const wchar_t *hasht[MAXT]; static wchar_t *line; static wchar_t btable[NCHARS]; static int ignore; static int only; static int llen = 72; static int gap = 3; static int gutter = 3; static int mlen; static int wlen; static int rflag; static int halflen; static wchar_t *strtbufp, *endbufp; static const char *empty = ""; static char *infile; static FILE *inptr /*= stdin*/; static char *outfile; static FILE *outptr /*= stdout*/; static char *sortfile; /* output of sort program */ static char nofold[] = {'-', 'd', 't', TILDE, 0}; static char fold[] = {'-', 'd', 'f', 't', TILDE, 0}; static char *sortopt = nofold; static FILE *sortptr; static char *bfile; /*contains user supplied break chars */ static FILE *bptr; static void msg(const char *, const char *); static void diag(const char *, const char *); static wchar_t *getline(void); static void cmpline(const wchar_t *); static int cmpword(const wchar_t *, const wchar_t *, const wchar_t *); static void putline(const wchar_t *, const wchar_t *); static void getsort(void); static const wchar_t *rtrim(const wchar_t *, const wchar_t *, int); static const wchar_t *ltrim(const wchar_t *, const wchar_t *, int); static void putout(const wchar_t *, const wchar_t *); static void onintr(int); static int hash(const wchar_t *, const wchar_t *); static int storeh(int, const wchar_t *); #ifdef EUC static wint_t peekc = WEOF; static wint_t GETC(FILE *fp) { char mb[MB_LEN_MAX+1]; wchar_t wc; - int c, i, n; + int c, i; + size_t n; mbstate_t state; if (peekc != WEOF) { wc = peekc; peekc = WEOF; return wc; } bad: if ((c = getc(fp)) == EOF) return WEOF; if (c & 0200) { i = 0; for (;;) { mb[i++] = c; mb[i] = 0; memset(&state, 0, sizeof state); if ((n = mbrtowc(&wc, mb, i, &state)) == (size_t)-1) goto bad; if (n == (size_t)-2) { if ((c = getc(fp)) == EOF) return WEOF; continue; } if (wc >= NCHARS) goto bad; return wc; } } return c; } static void -UNGETC(int c, FILE *fp) +UNGETC(int c, FILE *fp __unused) { peekc = c; } static int PUTC(int c, FILE *fp) { char mb[MB_LEN_MAX]; int i, n; if ((n = wctomb(mb, c)) > 0) { for (i = 0; i < n; i++) putc(mb[i]&0377, fp); return c; } else if (n == 0) { putc(0, fp); return 0; } else return EOF; } #define L "l" #else /* !EUC */ #define GETC(f) getc(f) #define UNGETC(c, f) ungetc(c, f) #define PUTC(c, f) putc(c, f) #define L #endif /* !EUC */ int main(int argc,char **argv) { char template[] = "/tmp/ptxsXXXXXX"; register int c; register wchar_t *bufp; int pid; wchar_t *pend; const char *xfile; FILE *xptr; setlocale(LC_CTYPE, ""); inptr = stdin; outptr = stdout; if(signal(SIGHUP,onintr)==SIG_IGN) signal(SIGHUP,SIG_IGN); if(signal(SIGINT,onintr)==SIG_IGN) signal(SIGINT,SIG_IGN); signal(SIGPIPE,onintr); signal(SIGTERM,onintr); /* argument decoding */ xfile = DEFLTX; argv++; while(argc>1 && **argv == '-') { switch (*++*argv){ case 'r': rflag++; break; case 'f': sortopt = fold; break; case 'w': if(argc >= 2) { argc--; wlen++; llen = atoi(*++argv); if(llen == 0) diag("Wrong width:",*argv); break; } case 't': if(wlen == 0) llen = 100; break; case 'g': if(argc >=2) { argc--; gap = gutter = atoi(*++argv); } break; case 'i': if(only) diag("Only file already given.",empty); if (argc>=2){ argc--; ignore++; xfile = *++argv; } break; case 'o': if(ignore) diag("Ignore file already given",empty); if (argc>=2){ only++; argc--; xfile = *++argv; } break; case 'b': if(argc>=2) { argc--; bfile = *++argv; } break; default: msg("Illegal argument:",*argv); } argc--; argv++; } if(argc>3) diag("Too many filenames",empty); else if(argc==3){ infile = *argv++; outfile = *argv; if((outptr = fopen(outfile,"w")) == NULL) diag("Cannot open output file:",outfile); } else if(argc==2) { infile = *argv; outfile = 0; } /* Default breaks of blank, tab and newline */ btable[' '] = SET; btable['\t'] = SET; btable['\n'] = SET; if(bfile) { if((bptr = fopen(bfile,"r")) == NULL) diag("Cannot open break char file",bfile); while((c = GETC(bptr)) != EOF) btable[c] = SET; } /* Allocate space for a buffer. If only or ignore file present read it into buffer. Else read in default ignore file and put resulting words in buffer. */ if((strtbufp = calloc(N,BUFSIZ)) == NULL) diag("Out of memory space",empty); bufp = strtbufp; endbufp = strtbufp+MAX; if((xptr = fopen(xfile,"r")) == NULL) diag("Cannot open file",xfile); while(bufp < endbufp && (c = GETC(xptr)) != EOF) { if(isabreak(c)) { if(storeh(hash(strtbufp,bufp),strtbufp)) diag("Too many words",xfile); *bufp++ = '\0'; strtbufp = bufp; } else { *bufp++ = (iswupper(c)?towlower(c):c); } } if (bufp >= endbufp) diag("Too many words in file",xfile); endbufp = --bufp; /* open output file for sorting */ close(mkstemp(template)); sortfile = template; if((sortptr = fopen(sortfile, "w")) == NULL) diag("Cannot open output for sorting:",sortfile); /* get a line of data and compare each word for inclusion or exclusion in the sort phase */ if (infile!=0 && (inptr = fopen(infile,"r")) == NULL) diag("Cannot open data: ",infile); while((pend=getline())) cmpline(pend); fclose(sortptr); switch (pid = fork()){ case -1: /* cannot fork */ diag("Cannot fork",empty); case 0: /* child */ execlp(SORT, SORT, sortopt, "+0", "-1", "+1", sortfile, "-o", sortfile, NULL); default: /* parent */ while(wait(&status) != pid); } getsort(); onintr(0); /*NOTREACHED*/ return 0; } static void msg(const char *s,const char *arg) { fprintf(stderr,"%s %s\n",s,arg); return; } static void diag(const char *s,const char *arg) { msg(s,arg); exit(1); } static wchar_t * getline(void) { register int c; register int i = 0; if (line == NULL) line = calloc(1, mlen = 1); /* Throw away leading white space */ while(iswspace(c=GETC(inptr))) ; if(c==EOF) return(0); UNGETC(c,inptr); while(( c=GETC(inptr)) != EOF) { switch (c) { case '\n': while(iswspace(line[--i])); line[++i] = '\n'; return(&line[i]); case '\t': c = ' '; /*FALLTHRU*/ break; default: if (i+1 >= mlen) line = realloc(line, mlen += 200); line[i++] = c; } } return(0); } static void cmpline(const wchar_t *pend) { const wchar_t *pstrt, *pchar, *cp; const wchar_t **hp; int flag; pchar = line; if(rflag) while(pcharhalflen-1) p3b = p3a+halflen-1; p2a = ltrim(ref,p2b=linep,halflen-1); if(p2b-p2a>halflen-1) p2a = p2b-halflen-1; p1b = rtrim(p1a=p3b+(iswspace(p3b[0])!=0),tilde, w=halflen-(p2b-p2a)-gap); if(p1b-p1a>w) p1b = p1a; p4a = ltrim(ref,p4b=p2a-(iswspace(p2a[-1])!=0), w=halflen-(p3b-p3a)-gap); if(p4b-p4a>w) p4a = p4b; fprintf(outptr,".xx \""); putout(p1a,p1b); /* tilde-1 to account for extra space before TILDE */ if(p1b!=(tilde-1) && p1a!=p1b) fprintf(outptr,"/"); fprintf(outptr,"\" \""); if(p4a==p4b && p2a!=ref && p2a!=p2b) fprintf(outptr,"/"); putout(p2a,p2b); fprintf(outptr,"\" \""); putout(p3a,p3b); /* ++p3b to account for extra blank after TILDE */ /* ++p3b to account for extra space before TILDE */ if(p1a==p1b && ++p3b!=tilde) fprintf(outptr,"/"); fprintf(outptr,"\" \""); if(p1a==p1b && p4a!=ref && p4a!=p4b) fprintf(outptr,"/"); putout(p4a,p4b); if(rflag) fprintf(outptr,"\" %" L "s\n",tilde); else fprintf(outptr,"\"\n"); linep = line; break; case '"': /* put double " for " */ *linep++ = c; default: *linep++ = c; } } } static const wchar_t * rtrim(const wchar_t *a,const wchar_t *c,int d) { const wchar_t *b,*x; b = c; for(x=a+1; x<=c&&x-a<=d; x++) if((x==c||iswspace(x[0]))&&!isspace(x[-1])) b = x; if(b=c&&b-x<=d; x--) if(!iswspace(x[0])&&(x==c||isspace(x[-1]))) a = x; if(a>c&&!iswspace(a[-1])) a--; return(a); } static void putout(const wchar_t *strt,const wchar_t *end) { const wchar_t *cp; cp = strt; for(cp=strt; cp>2)) & MASK; return(k); } static int storeh(int num,const wchar_t *strtp) { int i; for(i=num; i 2000. -These parameters can be changed; see page 4 of the -.Cm Refer -document by Mike Lesk. -The second program, -.Cm inv, -creates an entry file (.ia), -a posting file (.ib), and a tag file (.ic), -all in the working directory. -.Pp -.Nm lookbib -uses an inverted index made by -.Nm -to find sets of bibliographic references. -It reads keywords typed after the ``>'' prompt on the terminal, -and retrieves records containing all these keywords. -If nothing matches, nothing is returned except another ``>'' prompt. -.Pp -.Nm lookbib -will ask if you need instructions, and will print some brief information if -you reply ``y''. -.Pp -It is possible to search multiple databases, -as long as they have a common index made by -.Nm . -In that case, only the first argument given to -.Nm -is specified to -.Nm lookbib . -.Pp -If -.Nm lookbib -does not find the index files (the .i[abc] files), -it looks for a reference file with the same name as the argument, -without the suffixes. -It creates a file with a `.ig' suffix, suitable for use with -.Cm fgrep . -It then uses this fgrep file to find references. -This method is simpler to use, but the .ig file is slower to use -than the .i[abc] files, and does not allow the use of multiple reference files. -.Sh FILES -.Pa x Ns .ia, -.Pa x Ns .ib, -.Pa x Ns .ic, -where -.Em x -is the first argument, or if these are not present, then -.Pa x Ns .ig, -.Pa x -.Sh SEE ALSO -.Xr addbib 1 , -.Xr lookbib 1 , -.Xr refer 1 , -.Xr roffbib 1 , -.Xr sortbib 1 -.Sh NOTES -Probably all dates should be indexed, -since many disciplines refer to literature -written in the 1800s or earlier. Property changes on: vendor/heirloom-doctools/dist/refer/lookbib.1 ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/refer/roffbib.1 =================================================================== --- vendor/heirloom-doctools/dist/refer/roffbib.1 (revision 310549) +++ vendor/heirloom-doctools/dist/refer/roffbib.1 (nonexistent) @@ -1,171 +0,0 @@ -.\" Copyright (c) 1983 Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code contains changes by -.\" Gunnar Ritter, Freiburg i. Br., Germany, 2005. All rights reserved. -.\" -.\" Conditions 1, 2, and 4 and the no-warranty notice below apply -.\" to these changes. -.\" -.\" 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 acknowedgement: -.\" 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. -.\" -.\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" Redistributions of source code and documentation must retain the -.\" above copyright notice, this list of conditions and the following -.\" disclaimer. -.\" 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. -.\" All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed or owned by Caldera -.\" International, Inc. -.\" Neither the name of Caldera International, Inc. nor the names of -.\" other contributors may be used to endorse or promote products -.\" derived from this software without specific prior written permission. -.\" -.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA -.\" INTERNATIONAL, INC. 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 CALDERA INTERNATIONAL, INC. 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. -.\" -.\" Sccsid @(#)roffbib.1b 1.4 (gritter) 12/12/05 -.\" -.\" -.\" from 4.3BSD-Tahoe roffbib.1 6.2 (Berkeley) 5/7/86 -.\" -.\".TH ROFFBIB 1 "May 7, 1986" -.Dd December 12, 2005 -.Dt ROFFBIB 1 -.Os -.Sh NAME -.Nm roffbib -.Nd run off bibliographic database -.Sh SYNOPSIS -.Nm -.Op Fl ehnorsxVQ -.Op Fl T Ns Ar term -.Op Fl m Ns Ar mac -.Op Ar -.Sh DESCRIPTION -.Nm -prints out all records in a bibliographic database, -in bibliography format rather than as footnotes or endnotes. -Generally it is used in conjunction with -.Cm sortbib : -.Bd -literal -sortbib database | roffbib -.Ed -.Nm -accepts most of the options understood by -.Xr nroff 1 , -most importantly the -.Fl T -flag to specify terminal type. -.Pp -If abstracts or comments are entered following the %X field key, -.Nm -will format them into paragraphs for an annotated bibliography. -Several %X fields may be given if several -annotation paragraphs are desired. -The -.Fl x -flag will suppress the printing of these abstracts. -.Pp -A user-defined set of macros -may be specified after the -.Fl m -option. -There should be a space between the -.Fl m -and the macro filename. -This set of macros will replace the ones -defined in -.Pa /usr/ucblib/doctools/tmac/bib . -The -.Fl V -flag will send output to the Versatec; the -.Fl Q -flag will queue output for the phototypesetter. -.Pp -Four command-line registers control formatting style -of the bibliography, much like the number registers of -.Xr ms 7 . -The command-line argument -.Fl r Ns Ar N1 -will number -the references starting at one (1). -The flag -.Fl r Ns Ar V2 -will double space the biblio\%graphy, -while -.Fl r Ns Ar V1 -will double space references -but single space annotation paragraphs. -The line length can be changed from the default 6.5 inches -to 6 inches with the -.Fl r Ns Ar L6i -argument, -and the page offset can be set from the default of 0 -to one inch by specifying -.Fl r Ns Ar O1i -(capital O, not zero). -Note: with the -.Fl V -and -.Fl Q -flags -the default page offset is already one inch. -.Sh FILES -.Bl -tag -width /usr/ucblib/doctools/tmac/bib -.It Pa /usr/ucblib/doctools/tmac/bib -file of macros used by -.Cm nroff Ns / Ns Cm troff -.El -.Sh SEE ALSO -.Xr addbib 1 , -.Xr indxbib 1 , -.Xr lookbib 1 , -.Xr refer 1 , -.Xr sortbib 1 -.Sh NOTES -Users have to rewrite macros -to create customized formats. Property changes on: vendor/heirloom-doctools/dist/refer/roffbib.1 ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/refer/Makefile.mk =================================================================== --- vendor/heirloom-doctools/dist/refer/Makefile.mk (revision 310549) +++ vendor/heirloom-doctools/dist/refer/Makefile.mk (revision 310550) @@ -1,132 +1,142 @@ ROBJ = glue1.o refer1.o refer2.o refer4.o refer5.o refer6.o mkey3.o \ refer7.o refer8.o hunt2.o hunt3.o deliv2.o hunt5.o hunt6.o \ hunt8.o glue3.o hunt7.o hunt9.o glue2.o glue4.o glue5.o refer0.o \ shell.o version.o AOBJ = addbib.o version.o LOBJ = lookbib.o version.o SOBJ = sortbib.o version.o MOBJ = mkey1.o mkey2.o mkey3.o deliv2.o version.o IOBJ = inv1.o inv2.o inv3.o inv5.o inv6.o deliv2.o version.o HOBJ = hunt1.o hunt2.o hunt3.o hunt5.o hunt6.o hunt7.o glue5.o refer3.o \ hunt9.o shell.o deliv2.o hunt8.o glue4.o tick.o version.o FLAGS = -DMACDIR='"$(MACDIR)"' -DREFDIR='"$(REFDIR)"' $(EUC) $(DEFINES) \ -I../include .c.o: $(CC) $(_CFLAGS) $(FLAGS) -c $< -all: refer addbib lookbib sortbib roffbib indxbib mkey inv hunt papers/runinv +all: refer addbib lookbib sortbib roffbib indxbib mkey inv hunt papers/runinv \ + lookbib.1 refer.1 roffbib.1 cd papers && PATH=..:$$PATH sh runinv refer: $(ROBJ) $(CC) $(_CFLAGS) $(_LDFLAGS) $(ROBJ) $(LIBS) -o $@ addbib: $(AOBJ) $(CC) $(_CFLAGS) $(_LDFLAGS) $(AOBJ) $(LIBS) -o $@ lookbib: $(LOBJ) $(CC) $(_CFLAGS) $(_LDFLAGS) $(LOBJ) $(LIBS) -o $@ sortbib: $(SOBJ) $(CC) $(_CFLAGS) $(_LDFLAGS) $(SOBJ) $(LIBS) -o $@ mkey: $(MOBJ) $(CC) $(_CFLAGS) $(_LDFLAGS) $(MOBJ) $(LIBS) -o $@ inv: $(IOBJ) $(CC) $(_CFLAGS) $(_LDFLAGS) $(IOBJ) $(LIBS) -o $@ hunt: $(HOBJ) $(CC) $(_CFLAGS) $(_LDFLAGS) $(HOBJ) $(LIBS) -o $@ indxbib: indxbib.sh rm -f $@ echo '#!$(SHELL)' >$@ sed 's:@REFDIR@:$(REFDIR):g' indxbib.sh >>$@ roffbib: roffbib.sh rm -f $@ echo '#!$(SHELL)' >$@ sed 's:@BINDIR@:$(BINDIR):g' roffbib.sh >>$@ papers/runinv: papers/runinv.sh rm -f $@ echo '#!$(SHELL)' >$@ sed 's:@REFDIR@:$(REFDIR):g' papers/runinv.sh >>$@ install: all for i in refer addbib lookbib sortbib; \ do \ $(INSTALL) -c $$i $(ROOT)$(BINDIR)/$$i || exit; \ $(STRIP) $(ROOT)$(BINDIR)/$$i || exit; \ done $(INSTALL) -c roffbib $(ROOT)$(BINDIR)/roffbib $(INSTALL) -c indxbib $(ROOT)$(BINDIR)/indxbib test -d $(ROOT)$(REFDIR) || mkdir -p $(ROOT)$(REFDIR) for i in hunt inv mkey; \ do \ $(INSTALL) -c $$i $(ROOT)$(REFDIR)/$$i || exit; \ $(STRIP) $(ROOT)$(REFDIR)/$$i || exit; \ done test -d $(ROOT)$(REFDIR)/papers || mkdir -p $(ROOT)$(REFDIR)/papers $(INSTALL) -c -m 644 \ papers/Rbstjissue $(ROOT)$(REFDIR)/papers/Rbstjissue $(INSTALL) -c -m 644 papers/Rv7man $(ROOT)$(REFDIR)/papers/Rv7man $(INSTALL) -c papers/runinv $(ROOT)$(REFDIR)/papers/runinv for i in a b c; do \ $(INSTALL) -m 644 papers/Ind.i$$i $(ROOT)$(REFDIR)/papers/; \ done for i in addbib.1 lookbib.1 refer.1 roffbib.1 sortbib.1; \ do \ $(INSTALL) -c -m 644 $$i $(ROOT)$(MANDIR)/man1/$$i || exit; \ done rm -f $(ROOT)$(MANDIR)/man1/indxbib.1 ln -s lookbib.1 $(ROOT)$(MANDIR)/man1/indxbib.1 clean: rm -f $(ROBJ) refer $(AOBJ) addbib $(LOBJ) lookbib \ $(SOBJ) sortbib roffbib indxbib $(MOBJ) mkey \ $(IOBJ) inv $(HOBJ) hunt papers/runinv core log *~ \ - papers/Ind.i? + papers/Ind.i? lookbib.1 refer.1 roffbib.1 mrproper: clean + +lookbib.1: lookbib.1.in + sed 's"/usr/ucblib/reftools/"$(ROOT)$(REFDIR)/"' lookbib.1.in > $@ + +refer.1: refer.1.in + sed 's"/usr/ucblib/reftools/"$(ROOT)$(REFDIR)/"' refer.1.in > $@ + +roffbib.1: roffbib.1.in + sed 's"/usr/ucblib/doctools/tmac/"$(ROOT)$(MACDIR)/"' roffbib.1.in > $@ addbib.o: addbib.c deliv2.o: deliv2.c refer..c glue1.o: glue1.c refer..c glue2.o: glue2.c refer..c glue3.o: glue3.c refer..c glue4.o: glue4.c refer..c glue5.o: glue5.c refer..c hunt1.o: hunt1.c refer..c hunt2.o: hunt2.c refer..c hunt3.o: hunt3.c refer..c hunt5.o: hunt5.c hunt6.o: hunt6.c refer..c hunt7.o: hunt7.c refer..c hunt8.o: hunt8.c refer..c hunt9.o: hunt9.c inv1.o: inv1.c refer..c inv2.o: inv2.c refer..c inv3.o: inv3.c inv5.o: inv5.c refer..c inv6.o: inv6.c refer..c lookbib.o: lookbib.c mkey1.o: mkey1.c refer..c mkey2.o: mkey2.c refer..c mkey3.o: mkey3.c refer..c refer0.o: refer0.c refer..c refer1.o: refer1.c refer..c refer2.o: refer2.c refer..c refer3.o: refer3.c refer..c refer4.o: refer4.c refer..c refer5.o: refer5.c refer..c refer6.o: refer6.c refer..c refer7.o: refer7.c refer..c refer8.o: refer8.c refer..c shell.o: shell.c sortbib.o: sortbib.c tick.o: tick.c version.o: version.c Index: vendor/heirloom-doctools/dist/refer/hunt2.c =================================================================== --- vendor/heirloom-doctools/dist/refer/hunt2.c (revision 310549) +++ vendor/heirloom-doctools/dist/refer/hunt2.c (revision 310550) @@ -1,306 +1,306 @@ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. * All Rights Reserved. */ /* from OpenSolaris "hunt2.c 1.4 05/06/02 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)hunt2.c 1.3 (gritter) 10/22/05 */ #include #include "refer..c" static int *coord = 0; static int hh[50]; union ptr { unsigned *a; long *b; }; int doquery(long *hpt, int nhash, FILE *fb, int nitem, char **qitem, unsigned *mptr) { long k; union ptr prevdrop, master; int nf = 0, best = 0, nterm = 0, i, g, j; int *prevcoord; long lp; extern int lmaster, colevel, reached; extern int iflong; if (iflong) { master.b = (long *) mptr; } else { master.a = mptr; } # if D1 fprintf(stderr, "entering doquery nitem %d\n",nitem); fprintf(stderr, "first few hashes are %ld %ld %ld %ld %ld\n", hpt[0],hpt[1],hpt[2],hpt[3],hpt[4]); fprintf(stderr, "and frequencies are %d %d %d %d %d\n",hfreq[0],hfreq[1],hfreq[2],hfreq[3],hfreq[4]); # endif assert (lmaster>0); if (coord==0) coord = zalloc(lmaster, sizeof(lmaster)); if (colevel>0) { if (iflong) prevdrop.b = zalloc(lmaster, sizeof(long)); else prevdrop.a = zalloc(lmaster, sizeof(int)); prevcoord = zalloc(lmaster, sizeof(lmaster)); } else { prevdrop.a=master.a; prevcoord=coord; } # if D1 fprintf(stderr, "nitem %d\n",nitem); # endif for(i=0; i0) { for(j=0; j=nf) break; if (j= nterm) { if (iflong) master.b[g]=k; else master.a[g]=k; coord[g++] = 1; } } # if D1 fprintf(stderr,"now have %d items\n",g); # endif if (colevel>0) for ( ; j nterm) { assert(g0) { best=0; for(j=0; jbest) best = coord[j]; # if D1 fprintf(stderr, "colevel %d best %d\n", colevel, best); # endif reached = best; for(g=j=0; j 2000. +These parameters can be changed; see page 4 of the +.Cm Refer +document by Mike Lesk. +The second program, +.Cm inv, +creates an entry file (.ia), +a posting file (.ib), and a tag file (.ic), +all in the working directory. +.Pp +.Nm lookbib +uses an inverted index made by +.Nm +to find sets of bibliographic references. +It reads keywords typed after the ``>'' prompt on the terminal, +and retrieves records containing all these keywords. +If nothing matches, nothing is returned except another ``>'' prompt. +.Pp +.Nm lookbib +will ask if you need instructions, and will print some brief information if +you reply ``y''. +.Pp +It is possible to search multiple databases, +as long as they have a common index made by +.Nm . +In that case, only the first argument given to +.Nm +is specified to +.Nm lookbib . +.Pp +If +.Nm lookbib +does not find the index files (the .i[abc] files), +it looks for a reference file with the same name as the argument, +without the suffixes. +It creates a file with a `.ig' suffix, suitable for use with +.Cm fgrep . +It then uses this fgrep file to find references. +This method is simpler to use, but the .ig file is slower to use +than the .i[abc] files, and does not allow the use of multiple reference files. +.Sh FILES +.Pa x Ns .ia, +.Pa x Ns .ib, +.Pa x Ns .ic, +where +.Em x +is the first argument, or if these are not present, then +.Pa x Ns .ig, +.Pa x +.Sh SEE ALSO +.Xr addbib 1 , +.Xr lookbib 1 , +.Xr refer 1 , +.Xr roffbib 1 , +.Xr sortbib 1 +.Sh NOTES +Probably all dates should be indexed, +since many disciplines refer to literature +written in the 1800s or earlier. Property changes on: vendor/heirloom-doctools/dist/refer/lookbib.1.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/refer/refer.1.in =================================================================== --- vendor/heirloom-doctools/dist/refer/refer.1.in (nonexistent) +++ vendor/heirloom-doctools/dist/refer/refer.1.in (revision 310550) @@ -0,0 +1,300 @@ +.\" from 4.3BSD-Tahoe refer.1 6.2 (Berkeley) 5/12/86 +.\" +.\" This code contains changes by +.\" Gunnar Ritter, Freiburg i. Br., Germany, 2005. All rights reserved. +.\" +.\" Conditions 1, 2, and 4 and the no-warranty notice below apply +.\" to these changes. +.\" +.\" 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 acknowedgement: +.\" 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. +.\" +.\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" Redistributions of source code and documentation must retain the +.\" above copyright notice, this list of conditions and the following +.\" disclaimer. +.\" 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. +.\" All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" Neither the name of Caldera International, Inc. nor the names of +.\" other contributors may be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. 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 CALDERA INTERNATIONAL, INC. 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. +.\" +.\" Sccsid @(#)refer.1b 1.4 (gritter) 12/12/05 +.\" +.\" +.\".TH REFER 1 "May 12, 1986" +.Dd December 12, 2005 +.Dt REFER 1 +.Os +.Sh NAME +.Nm refer +.Nd find and insert literature references in documents +.Sh SYNOPSIS +.Nm +.Op Fl abcenPS +.Op Fl f Ns Ar n +.Op Fl k Ns Ar x +.Op Fl l Ns Ar m , Ns Ar n +.Op Fl p Ar bib +.Op Fl s Ns Ar keys +.Op Fl B Ns Ar l , Ns Ar m +.Op Ar +.Sh DESCRIPTION +.Nm +is a preprocessor for +.Cm nroff +or +.Xr troff 1 +that finds and formats references for footnotes or endnotes. +It is also the base for a series of programs designed to +index, search, sort, and print stand-alone bibliographies, +or other data entered in the appropriate form. +.Pp +Given an incomplete citation with sufficiently precise keywords, +.Cm refer +will search a bibliographic database for references +containing these keywords anywhere in the title, author, journal, etc. +The input file (or standard input) +is copied to standard output, +except for lines between .[ and .] delimiters, +which are assumed to contain keywords, +and are replaced by information from the bibliographic database. +The user may also search different databases, +override particular fields, or add new fields. +The reference data, from whatever source, are assigned to a set of +.Cm troff +strings. +Macro packages such as +.Xr ms 7 +print the finished reference text from these strings. +By default references are flagged by footnote numbers. +.Pp +The following options are available: +.Bl -tag -width XXXXXXXX +.It Fl a Ns Ar n +Reverse the first +.Ar n +author names (Jones, J. A. instead of J. A. Jones). +If +.Ar n +is omitted all author names are reversed. +.It Fl b +Bare mode: do not put any flags in text (neither numbers nor labels). +.It Fl c Ns Ar keys +Capitalize (with C\s-2APS\s0 S\s-2MALL\s+2 C\s-2APS\s0) +the fields whose key-letters are in +.Ar keys . +.It Fl e +Instead of leaving the references where encountered, +accumulate them until a sequence of the form +.Bd -literal + .[ + $LIST$ + .] +.Ed +is encountered, and then write out all references collected so far. +Collapse references to same source. +.It Fl f Ns Ar n +Set the footnote number to +.Ar n +instead of the default of 1 (one). +With labels rather than numbers, +this flag is a no-op. +.It Fl k Ns Ar x +Instead of numbering references, use labels as specified in a +reference data line beginning +.Ar \&%x; +by default +.Ar x +is +.Em L. +.It Fl l Ns Ar m , Ns Ar n +Instead of numbering references, use labels made from +the senior author's last name and the year of publication. +Only the first +.Ar m +letters of the last name +and the last +.Ar n +digits of the date are used. +If either +.Ar m +or +.Ar n +is omitted the entire name or date respectively is used. +.It Fl n +Do not search the default file +.Pa /usr/ucblib/reftools/papers/Ind . +If there is a REFER environment variable, +the specified file will be searched instead of the default file; +in this case the +.Fl n +flag has no effect. +.It Fl p Ar bib +Take the next argument +.Ar bib +as a file of references to be searched. +The default file is searched last. +.It Fl s Ar keys +Sort references by fields whose key-letters are in the +.Ar keys +string; +permute reference numbers in text accordingly. +Implies +.Fl e . +The key-letters in +.Ar keys +may be followed by a number to indicate how many such fields +are used, with +.Em + +taken as a very large number. +The default is +.Em AD +which sorts on the senior author and then date; to sort, for example, +on all authors and then title, use +.Fl -s Ns Ar A+T . +.It Fl B Ns Ar l . Ns Ar m +Bibliography mode. +Take a file composed of records separated by blank lines, +and turn them into +.Cm troff +input. +Label +.Em l +will be turned into the macro +.Em .m +with +.Em l +defaulting to +.Em \&%X +and +.Em .m +defaulting to +.Em .AP +(annotation paragraph). +.It Fl P +Place punctuation marks .,:;?! after the reference signal, +rather than before. +(Periods and commas used to be done with strings.) +.It Fl S +Produce references in the Natural or Social Science format. +.El +.Pp +To use your own references, +put them in the format described below. +They can be searched more rapidly by running +.Xr indxbib 1 +on them before using +.Cm refer; +failure to index results in a linear search. +When +.Cm refer +is used with the +.Cm eqn , +.Cm neqn +or +.Cm tbl +preprocessors +.Cm refer +should be first, to minimize the volume +of data passed through pipes. +.Pp +The +.Cm refer +preprocessor and associated programs +expect input from a file of references +composed of records separated by blank lines. +A record is a set of lines (fields), +each containing one kind of information. +Fields start on a line beginning with a ``%'', +followed by a key-letter, then a blank, +and finally the contents of the field, +and continue until the next line starting with ``%''. +The output ordering and formatting of fields +is controlled by the macros specified for +.Cm nroff Ns / Ns Cm troff +(for footnotes and endnotes) or +.Cm roffbib +(for stand-alone bibliographies). +For a list of the most common key-letters +and their corresponding fields, see +.Xr addbib 1 . +An example of a +.Cm refer +entry is given below. +.Sh EXAMPLE +.Bd -literal +%A M. E. Lesk +%T Some Applications of Inverted Indexes on the \s-1UNIX\s0 System +%B \s-1UNIX\s0 Programmer's Manual +%V 2b +%I Bell Laboratories +%C Murray Hill, NJ +%D 1978 +.Ed +.Sh FILES +.Bl -tag -width /usr/ucblib/reftools/papers +.It Pa /usr/ucblib/reftools/papers +directory of default publication lists +.It Pa /usr/ucblib/reftools +directory of companion programs +.El +.Sh SEE ALSO +.Xr addbib 1 , +.Xr indxbib 1 , +.Xr lookbib 1 , +.Xr roffbib 1 , +.Xr sortbib 1 +.Sh NOTES +Blank spaces at the end of lines in bibliography fields +will cause the records to sort and reverse incorrectly. +Sorting large numbers of references causes a core dump. +.Pp +Written by Mike Lesk. Property changes on: vendor/heirloom-doctools/dist/refer/refer.1.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/refer/roffbib.1.in =================================================================== --- vendor/heirloom-doctools/dist/refer/roffbib.1.in (nonexistent) +++ vendor/heirloom-doctools/dist/refer/roffbib.1.in (revision 310550) @@ -0,0 +1,171 @@ +.\" Copyright (c) 1983 Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code contains changes by +.\" Gunnar Ritter, Freiburg i. Br., Germany, 2005. All rights reserved. +.\" +.\" Conditions 1, 2, and 4 and the no-warranty notice below apply +.\" to these changes. +.\" +.\" 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 acknowedgement: +.\" 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. +.\" +.\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" Redistributions of source code and documentation must retain the +.\" above copyright notice, this list of conditions and the following +.\" disclaimer. +.\" 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. +.\" All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" Neither the name of Caldera International, Inc. nor the names of +.\" other contributors may be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. 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 CALDERA INTERNATIONAL, INC. 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. +.\" +.\" Sccsid @(#)roffbib.1b 1.4 (gritter) 12/12/05 +.\" +.\" +.\" from 4.3BSD-Tahoe roffbib.1 6.2 (Berkeley) 5/7/86 +.\" +.\".TH ROFFBIB 1 "May 7, 1986" +.Dd December 12, 2005 +.Dt ROFFBIB 1 +.Os +.Sh NAME +.Nm roffbib +.Nd run off bibliographic database +.Sh SYNOPSIS +.Nm +.Op Fl ehnorsxVQ +.Op Fl T Ns Ar term +.Op Fl m Ns Ar mac +.Op Ar +.Sh DESCRIPTION +.Nm +prints out all records in a bibliographic database, +in bibliography format rather than as footnotes or endnotes. +Generally it is used in conjunction with +.Cm sortbib : +.Bd -literal +sortbib database | roffbib +.Ed +.Nm +accepts most of the options understood by +.Xr nroff 1 , +most importantly the +.Fl T +flag to specify terminal type. +.Pp +If abstracts or comments are entered following the %X field key, +.Nm +will format them into paragraphs for an annotated bibliography. +Several %X fields may be given if several +annotation paragraphs are desired. +The +.Fl x +flag will suppress the printing of these abstracts. +.Pp +A user-defined set of macros +may be specified after the +.Fl m +option. +There should be a space between the +.Fl m +and the macro filename. +This set of macros will replace the ones +defined in +.Pa /usr/ucblib/doctools/tmac/bib . +The +.Fl V +flag will send output to the Versatec; the +.Fl Q +flag will queue output for the phototypesetter. +.Pp +Four command-line registers control formatting style +of the bibliography, much like the number registers of +.Xr ms 7 . +The command-line argument +.Fl r Ns Ar N1 +will number +the references starting at one (1). +The flag +.Fl r Ns Ar V2 +will double space the biblio\%graphy, +while +.Fl r Ns Ar V1 +will double space references +but single space annotation paragraphs. +The line length can be changed from the default 6.5 inches +to 6 inches with the +.Fl r Ns Ar L6i +argument, +and the page offset can be set from the default of 0 +to one inch by specifying +.Fl r Ns Ar O1i +(capital O, not zero). +Note: with the +.Fl V +and +.Fl Q +flags +the default page offset is already one inch. +.Sh FILES +.Bl -tag -width /usr/ucblib/doctools/tmac/bib +.It Pa /usr/ucblib/doctools/tmac/bib +file of macros used by +.Cm nroff Ns / Ns Cm troff +.El +.Sh SEE ALSO +.Xr addbib 1 , +.Xr indxbib 1 , +.Xr lookbib 1 , +.Xr refer 1 , +.Xr sortbib 1 +.Sh NOTES +Users have to rewrite macros +to create customized formats. Property changes on: vendor/heirloom-doctools/dist/refer/roffbib.1.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/soelim/soelim.1 =================================================================== --- vendor/heirloom-doctools/dist/soelim/soelim.1 (revision 310549) +++ vendor/heirloom-doctools/dist/soelim/soelim.1 (nonexistent) @@ -1,74 +0,0 @@ -.\" -.\" Sccsid @(#)soelim.1b 1.2 (gritter) 8/13/05 -.\" Derived from 3BSD soelim(1) 2/24/79: -.\" 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 acknowedgement: -.\" 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. -.TH SOELIM 1 "8/13/05" "Heirloom Documentation Tools" "BSD System Compatibility" -.SH NAME -soelim \- eliminate \&.so's from nroff input -.SH SYNOPSIS -\fBsoelim\fR [\fIfile\fR] ... -.SH DESCRIPTION -.I Soelim -reads the specified files or the standard input and performs the textual -inclusion implied by the -.I nroff -directives of the form -.PP -.DT - \&.so somefile -.PP -when they appear at the beginning of input lines. -This is useful since programs such as -.I tbl -do not normally do this; -it allows the placement of individual tables -in separate files to be run as a part of a large document. -.PP -Note that inclusion can be suppressed by using -`\'' instead of `\.', i.e. -.PP -.DT - \'so /usr/ucblib/doctools/tmac/s -.PP -A sample usage of -.I soelim -would be -.PP - soelim exum?.n | tbl | nroff \-ms | col | lp -.SH SEE\ ALSO -more(1) -.SH NOTES -The format of the source commands must involve no strangeness \- -exactly one -blank must precede and no blanks follow the file name. -.sp -Written by William Joy. Property changes on: vendor/heirloom-doctools/dist/soelim/soelim.1 ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/soelim/Makefile.mk =================================================================== --- vendor/heirloom-doctools/dist/soelim/Makefile.mk (revision 310549) +++ vendor/heirloom-doctools/dist/soelim/Makefile.mk (revision 310550) @@ -1,21 +1,24 @@ OBJ = soelim.o FLAGS = .c.o: $(CC) $(_CFLAGS) $(FLAGS) -c $< -all: soelim +all: soelim soelim.1 soelim: $(OBJ) $(CC) $(_CFLAGS) $(_LDFLAGS) $(OBJ) $(LIBS) -o soelim install: $(INSTALL) -c soelim $(ROOT)$(BINDIR)/soelim $(STRIP) $(ROOT)$(BINDIR)/soelim $(INSTALL) -c -m 644 soelim.1 $(ROOT)$(MANDIR)/man1/soelim.1 clean: - rm -f $(OBJ) soelim core log *~ + rm -f $(OBJ) soelim core log *~ soelim.1 mrproper: clean + +soelim.1: soelim.1.in + sed 's"/usr/ucblib/doctools/tmac/"$(ROOT)$(MACDIR)/"' soelim.1.in > $@ Index: vendor/heirloom-doctools/dist/soelim/soelim.1.in =================================================================== --- vendor/heirloom-doctools/dist/soelim/soelim.1.in (nonexistent) +++ vendor/heirloom-doctools/dist/soelim/soelim.1.in (revision 310550) @@ -0,0 +1,74 @@ +.\" +.\" Sccsid @(#)soelim.1b 1.2 (gritter) 8/13/05 +.\" Derived from 3BSD soelim(1) 2/24/79: +.\" 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 acknowedgement: +.\" 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. +.TH SOELIM 1 "8/13/05" "Heirloom Documentation Tools" "BSD System Compatibility" +.SH NAME +soelim \- eliminate \&.so's from nroff input +.SH SYNOPSIS +\fBsoelim\fR [\fIfile\fR] ... +.SH DESCRIPTION +.I Soelim +reads the specified files or the standard input and performs the textual +inclusion implied by the +.I nroff +directives of the form +.PP +.DT + \&.so somefile +.PP +when they appear at the beginning of input lines. +This is useful since programs such as +.I tbl +do not normally do this; +it allows the placement of individual tables +in separate files to be run as a part of a large document. +.PP +Note that inclusion can be suppressed by using +\(oq\(aq\(cq instead of \(oq.\(cq, i.e. +.PP +.DT + \(aqso /usr/ucblib/doctools/tmac/s +.PP +A sample usage of +.I soelim +would be +.PP + soelim exum?.n | tbl | nroff \-ms | col | lp +.SH SEE\ ALSO +more(1) +.SH NOTES +The format of the source commands must involve no strangeness \- +exactly one +blank must precede and no blanks follow the file name. +.sp +Written by William Joy. Property changes on: vendor/heirloom-doctools/dist/soelim/soelim.1.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/soelim/soelim.c =================================================================== --- vendor/heirloom-doctools/dist/soelim/soelim.c (revision 310549) +++ vendor/heirloom-doctools/dist/soelim/soelim.c (revision 310550) @@ -1,151 +1,151 @@ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. * All Rights Reserved. */ /* from OpenSolaris "soelim.c 1.3 05/06/02 SMI" SVr4.0 1.1 */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany */ #if __GNUC__ >= 3 && __GNUC_MINOR__ >= 4 || __GNUC__ >= 4 #define USED __attribute__ ((used)) #elif defined __GNUC__ #define USED __attribute__ ((unused)) #else #define USED #endif static const char sccsid[] USED = "@(#)/usr/ucb/soelim.sl 5.1 (gritter) 10/25/05"; #include #include #include /* * soelim - a filter to process n/troff input eliminating .so's * * Author: Bill Joy UCB July 8, 1977 * * This program eliminates .so's from a n/troff input stream. * It can be used to prepare safe input for submission to the * phototypesetter since the software supporting the operator * doesn't let him do chdir. * * This is a kludge and the operator should be given the * ability to do chdir. * * This program is more generally useful, it turns out, because * the program tbl doesn't understand ".so" directives. */ #define STDIN_NAME "-" int process(char *); int main(int argc, char **argv) { argc--; argv++; if (argc == 0) { process(STDIN_NAME); exit(0); } do { process(argv[0]); argv++; argc--; } while (argc > 0); exit(0); } int process(char *file) { - register int n; + size_t n; register int c; static char *fname = NULL; static size_t fnsize = 0; FILE *soee; int isfile; if (!strcmp(file, STDIN_NAME)) { soee = stdin; } else { soee = fopen(file, "r"); if (soee == NULL) { perror(file); return(-1); } } for (;;) { c = getc(soee); if (c == EOF) break; if (c != '.') goto simple; c = getc(soee); if (c != 's') { putchar('.'); goto simple; } c = getc(soee); if (c != 'o') { printf(".s"); goto simple; } do c = getc(soee); while (c == ' ' || c == '\t'); n = 0; isfile = 0; for (;;) { switch (c) { case ' ': case '\t': case '\n': case EOF: goto donename; default: if (n+1 >= fnsize) fname = realloc(fname, fnsize += 128); fname[n++] = c; c = getc(soee); isfile++; continue; } } donename: if (n == 0) { printf(".so"); goto simple; } fname[n] = 0; if (process(fname) < 0) if (isfile) printf(".so %s\n", fname); continue; simple: if (c == EOF) break; putchar(c); if (c != '\n') { c = getc(soee); goto simple; } } if (soee != stdin) { fclose(soee); } return(0); } Index: vendor/heirloom-doctools/dist/troff/ext.h =================================================================== --- vendor/heirloom-doctools/dist/troff/ext.h (revision 310549) +++ vendor/heirloom-doctools/dist/troff/ext.h (revision 310550) @@ -1,602 +1,602 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2002 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* from OpenSolaris "ext.h 1.10 05/06/08 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)ext.h 1.111 (gritter) 10/23/09 */ /* * Changes Copyright (c) 2014 Carsten Kunze */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved * * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. */ #include extern char **argp; extern char *chname; extern char *eibuf; extern char *ibufp; extern char *obufp; extern char *xbufp; extern char *xeibuf; extern char *cfname[NSO+1]; extern char devname[20]; extern char ibuf[IBUFSZ]; extern char **mfiles; extern char *nextf; extern char obuf[], *obufp; extern char *termtab, *fontfile; extern char xbuf[IBUFSZ]; extern filep apptr; extern filep ip; extern filep nextb; extern filep offset; extern filep roff; extern filep woff; #ifdef NROFF extern long lvmot; extern size_t *chtab; #else extern short *chtab; extern int html; #endif extern int *pnp; extern int *pstab; extern int app; extern int ascii; extern int bd; extern int *bdtab; extern int blmac; extern int lsmac; extern int glss; extern int lsn; extern int ccs; extern int charf; extern tchar **chartab; extern struct charout *charout; extern int charoutsz; extern int clonef; extern int copyf; extern int cs; extern int defaultpl; extern int defcf; extern int dfact; extern int dfactd; extern int diflg; extern int dilev; extern int donef; extern int donep; extern int dotT; extern int dpn; extern int dl; extern int ds; extern int ecs; extern int ejf; extern int em; extern int eqflg; extern int error; extern int esc; -extern int eschar; +extern unsigned int eschar; extern int ev; extern int fc; extern char *fchartab; extern int flss; extern int fmtchar; extern int *fontlab; extern int gflag; extern int hflg; extern int ifi; extern int ifile; extern int ifl[NSO]; extern int iflg; extern int init; extern int lastkern; extern int lasttrack; extern int lead; extern int lg; extern int lgf; extern int macerr; extern int mb_cur_max; extern int mflg; extern int mfont; extern int minflg; extern int minspc; extern int mpts; extern int ndone; extern struct contab *newmn; extern int nflush; extern int nfo; extern int nfonts; extern int nform; extern int nhyp; extern int nlflg; extern int nmfi; extern int no_out; extern int nofeed; extern int nolt; extern int nonumb; extern int noscale; extern int npn; extern int npnflg; extern int nx; -extern int oldbits; +extern unsigned int oldbits; extern struct contab *oldmn; extern int *olt; extern int over; extern int padc; extern int padj; extern int pfont; extern int pfrom; extern pid_t pipeflg; extern int pl; extern int pnlist[]; extern int po1; extern int po; extern int ppts; extern int print; extern int ptid; extern int pto; extern int quiet; extern int ralss; extern int rargc; extern int raw; extern int rawwidth; extern long realpage; extern int res; extern int setwdf; extern int sfont; extern int smnt; extern int stdi; extern int stop; extern int sv; extern int tabch, ldrch; extern int tailflg; extern int tflg; extern int totout; extern int trap; extern int *trtab; extern int *trintab; extern int *trnttab; extern int tryglf; extern int tty; extern int ttyod; extern int Tflg; extern int ulfont; extern int vflag; extern int vpt; extern int wbfi; extern int widthp; extern int xflag; extern int xfont; extern int xpts; extern int no_out; extern int ejl; extern struct s *frame, *stk, *nxf; extern tchar **hyp; extern tchar *olinep; extern tchar *pbbuf; extern int pbsize; extern int pbp; extern int lastpbp; extern tchar ch; extern tchar nrbits; extern tchar *oline; extern size_t olinesz; extern struct widcache { /* width cache, indexed by character */ int fontpts; int rst; int rsb; int width; int track; char *evid; } *widcache; extern char *gchtab; extern struct d *d; extern struct d *dip; extern int initbdtab[]; #ifdef EUC #include extern int multi_locale; extern int csi_width[]; extern char mbbuf1[]; extern char *mbbuf1p; extern wchar_t twc; extern int (*wdbdg)(wchar_t, wchar_t, int); extern wchar_t *(*wddlm)(wchar_t, wchar_t, int); #endif /* EUC */ extern int **lhangtab; extern int **rhangtab; extern int **kernafter; extern int **kernbefore; extern int **ftrtab; extern char *lgmark; extern struct lgtab **lgtab; extern int ***lgrevtab; extern int spreadwarn; extern int spreadlimit; extern int lastrq; extern int noschr; extern int argdelim; extern int bol; extern int prdblesc; extern int gemu; extern int chomp; extern int chompend; /* n1.c */ extern void mainloop(void); extern int tryfile(const char *, char *, int); extern void catch(int); extern void kcatch(int); extern void init0(void); extern void init1(char); extern void init2(void); extern void cvtime(void); extern int ctoi(register char *); extern void mesg(int); extern void errprint(const char *, ...); #define fdprintf xxfdprintf extern void fdprintf(int, const char *, ...); extern char *roff_sprintf(char *, size_t, const char *, ...); extern int control(register int, register int); extern int getrq2(void); extern int getrq(int); extern tchar getch(void); extern void setxon(void); extern tchar getch0(void); extern void pushback(register tchar *); extern void cpushback(register const char *); extern tchar *growpbbuf(void); extern int nextfile(void); extern int popf(void); extern void flushi(void); extern int getach(void); extern int rgetach(void); extern void casenx(void); extern int getname(void); extern void caseso(void); extern void casepso(void); extern void caself(void); extern void casecf(void); extern void casesy(void); extern void getpn(register char *); extern void setrpt(void); extern void casedb(void); extern void casexflag(void); extern void casecp(void); extern void caserecursionlimit(void); extern void casechar(int); extern void casefchar(void); extern void caserchar(void); extern tchar setchar(tchar); extern tchar sfmask(tchar); extern int issame(tchar, tchar); /* n2.c */ extern int pchar(register tchar); extern void pchar1(register tchar); extern void outascii(tchar); extern void oputs(register const char *); extern void flusho(void); extern void caseoutput(void); extern void done(int); extern void done1(int); extern void done2(int); extern void done3(int); extern void edone(int); extern void casepi(void); /* n3.c */ extern void *growcontab(void); extern void *growblist(void); extern void caseig(void); extern void casern(void); extern void maddhash(register struct contab *); extern void munhash(register struct contab *); extern filep finds(register int, int, int); extern void caserm(void); extern void caseas(void); extern void caseds(void); extern void caseam(void); extern void casede(void); extern struct contab *findmn(register int); extern struct contab *findmx(register int); extern int skip(int); extern int copyb(void); extern void copys(void); extern filep alloc(void); extern void ffree(filep); extern void wbt(tchar); extern void wbf(register tchar); extern void wbfl(void); extern tchar rbf(void); extern tchar rbf0(register filep); extern filep incoff(register filep); extern tchar popi(void); extern int pushi(filep, int, enum flags); extern void sfree(struct s *); extern struct s *macframe(void); extern int getsn(int); extern int setstr(void); extern void collect(void); extern void seta(void); extern void casebox(void); extern void caseboxa(void); extern void caseda(int); extern void casedi(int); extern void casedt(void); extern void caseals(void); extern void casewatch(int); extern void caseunwatch(void); extern void prwatch(struct contab *, int, int); extern void casetl(void); extern void casepc(void); extern void casechop(void); extern void casepm(void); extern void stackdump(void); extern const char *macname(int); extern int maybemore(int, int); extern tchar setuc(void); extern int makerq(const char *); /* n4.c */ extern void *grownumtab(void); extern void setn(void); extern int wrc(tchar); extern void setn1(int, int, tchar); extern void nunhash(register struct numtab *); extern struct numtab *findr(register int); extern struct numtab *usedr(register int); extern int fnumb(register int, register int (*)(tchar)); extern int decml(register int, register int (*)(tchar)); extern int roman(int, int (*)(tchar)); extern int roman0(int, int (*)(tchar), const char *, const char *); extern int abc(int, int (*)(tchar)); extern int abc0(int, int (*)(tchar)); extern int hatoi(void); #undef atof #define atof xxatof extern float atof(void); extern long long atoi0(void); extern double atof0(void); extern void setnr(const char *, int, int); extern void setnrf(const char *, float, float); extern void caserr(void); extern void casernn(void); extern void casenr(void); extern void casenrf(void); extern void caselnr(void); extern void caselnrf(void); extern void setr(void); extern void caseaf(void); extern void setaf(void); extern void casealn(void); extern void casewatchn(int); extern void caseunwatchn(void); extern void prwatchn(struct numtab *); extern int vnumb(int *); extern int hnumb(int *); extern int inumb(int *); extern int inumb2(int *, int *); extern float atop(void); extern int quant(int, int); extern tchar moflo(int); /* n5.c */ extern void save_tty(void); extern void casead(void); extern void casena(void); extern void casefi(void); extern void casenf(void); extern void casepadj(void); extern void casers(void); extern void casens(void); extern void casespreadwarn(void); extern int chget(int); extern void casecc(void); extern void casec2(void); extern void casehc(void); extern void casetc(void); extern void caselc(void); extern void casehy(void); extern void casenh(void); extern void casehlm(void); extern void casehcode(void); extern void caseshc(void); extern void casehylen(void); extern void casehypp(void); extern void casepshape(void); extern void caselpfx(void); #undef min #undef max extern int max(int, int); extern int min(int, int); extern void casece(void); extern void caserj(void); extern void casebrnl(void); extern void casebrpnl(void); extern void casein(void); extern void casell(void); extern void caselt(void); extern void caseti(void); extern void casels(void); extern void casepo(void); extern void casepl(void); extern void casewh(void); extern void casedwh(void); extern void casech(void); extern void casedch(void); extern void casevpt(void); extern tchar setolt(void); extern int findn(struct d *, int); extern void casepn(void); extern void casebp(void); extern void casetm(int); extern void casetmc(void); extern void caseerrprint(void); extern void caseopen(void); extern void caseopena(void); extern void casewrite(void); extern void casewritec(void); extern void casewritem(void); extern void caseclose(void); extern void casesp(int); extern void casebrp(void); extern void caseblm(void); extern void caselsm(void); extern void casert(void); extern void caseem(void); extern void casefl(void); extern void caseev(void); extern void caseevc(void); extern void evc(struct env *, struct env *); extern void evcline(struct env *, struct env *); extern void relsev(struct env *); extern void caseel(void); extern void caseie(void); extern void caseif(int); extern void casenop(void); extern void casechomp(void); extern void casereturn(void); extern void casewhile(void); extern void casebreak(void); extern void casecontinue(int); extern void eatblk(int); extern int cmpstr(tchar); extern void caserd(void); extern int rdtty(void); extern void caseec(void); extern void caseeo(void); extern void caseecs(void); extern void caseecr(void); extern void caseescoff(void); extern void caseescon(void); extern void caseta(void); extern void casene(void); extern void casetr(int); extern void casetrin(void); extern void casetrnt(void); extern void casecu(void); extern void caseul(void); extern void caseuf(void); extern void caseit(int); extern void caseitc(void); extern void casemc(void); extern void casesentchar(void); extern void casetranschar(void); extern void casebreakchar(void); extern void casenhychar(void); extern void caseconnectchar(void); extern void casemk(void); extern void casesv(void); extern void caseos(void); extern void casenm(void); extern void getnm(int *, int); extern void casenn(void); extern void caseab(void); extern void restore_tty(void); extern void set_tty(void); extern void echo_off(void); extern void echo_on(void); /* n7.c */ extern int collectmb(tchar); extern void tbreak(void); extern void donum(void); extern void text(void); extern void nofill(void); extern void callsp(void); extern void ckul(void); extern int storeline(register tchar, int); extern void newline(int); extern int findn1(struct d *, int); extern void chkpn(void); extern int findt(struct d *, int); extern int findt1(void); extern void eject(struct s *); extern int movword(void); extern void horiz(int); extern void setnel(void); extern int getword(int); extern void storeword(register tchar, register int); extern void growpgsize(void); /* n8.c */ extern void hyphen(tchar *); extern int punct(tchar); extern int alph(tchar); extern void caseht(void); extern void casehw(void); extern int exword(void); extern int suffix(void); extern int maplow(tchar); extern int vowel(tchar); extern tchar *chkvow(tchar *); extern void digram(void); extern int dilook(tchar, tchar, const char [26][13]); extern void casehylang(void); /* n9.c */ extern tchar setz(void); extern void setline(void); extern tchar eat(tchar); extern void setov(void); extern void setbra(void); extern void setvline(void); extern void setdraw(void); extern void casefc(void); extern tchar setfield(int); extern tchar setpenalty(void); extern tchar setdpenal(void); extern tchar mkxfunc(int, int); extern void pushinlev(void); extern tchar popinlev(void); extern void localize(void); extern void caselc_ctype(void); extern void casepsbb(void); extern void casewarn(void); extern void nosuch(int); extern void illseq(int, const char *, int); extern void missing(void); extern void nodelim(int); extern void storerq(int); extern int fetchrq(tchar *); extern void morechars(int); #ifdef NROFF extern void caseutf8conv(void); extern int addch(char *); #endif Index: vendor/heirloom-doctools/dist/troff/libhnj/Makefile.mk =================================================================== --- vendor/heirloom-doctools/dist/troff/libhnj/Makefile.mk (revision 310549) +++ vendor/heirloom-doctools/dist/troff/libhnj/Makefile.mk (revision 310550) @@ -1,22 +1,22 @@ -FLAGS = +FLAGS = -I../../include .c.o: $(CC) $(_CFLAGS) $(FLAGS) -c $< OBJ = hnjalloc.o hyphen.o all: libhnj.a test libhnj.a: $(OBJ) $(AR) crs $@ $(OBJ) test: test.o libhnj.a $(CC) $(_CFLAGS) $(_LDFLAGS) test.o -L. -lhnj -o test install: clean: rm -f $(OBJ) test test.o core log *~ mrproper: clean rm -f libhnj.a Index: vendor/heirloom-doctools/dist/troff/libhnj/test.c =================================================================== --- vendor/heirloom-doctools/dist/troff/libhnj/test.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/libhnj/test.c (revision 310550) @@ -1,23 +1,24 @@ #include "hyphen.h" #include #include +#include "global.h" int -main(int argc, char **argv) +main(int argc __unused, char **argv) { HyphenDict *hd; char buf[512], hbuf[512]; int i, j; hd = hnj_hyphen_load(argv[1]); while (fgets(buf, sizeof buf, stdin) != NULL) { j = strlen(buf); buf[--j] = '\0'; hnj_hyphen_hyphenate(hd, buf, j, hbuf); for (i = 0; i < j; i++) if ((hbuf[i] - '0') & 1) printf("%c %.*s-%s\n", hbuf[i], i+1, buf, &buf[i+1]); } return 0; } Index: vendor/heirloom-doctools/dist/troff/n1.c =================================================================== --- vendor/heirloom-doctools/dist/troff/n1.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/n1.c (revision 310550) @@ -1,2491 +1,2488 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* from OpenSolaris "n1.c 1.25 05/06/08 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)n1.c 1.144 (gritter) 8/19/08 */ /* * Changes Copyright (c) 2014 Carsten Kunze */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved * * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. */ /* const char *xxxvers = "@(#)roff:n1.c 2.13"; */ /* * n1.c * * consume options, initialization, main loop, * input routines, escape function calling */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef EUC #include #include #include #include #endif /* EUC */ #include "tdef.h" #include "ext.h" #ifdef NROFF #include "tw.h" #include "draw.h" #endif #include "pt.h" #define MAX_RECURSION_DEPTH 512 static int max_recursion_depth = MAX_RECURSION_DEPTH; static int max_tail_depth; jmp_buf sjbuf; static filep ipl[NSO]; static long offl[NSO]; static long ioff; static const char *ttyp; char *cfname[NSO+1]; /*file name stack*/ static int cfline[NSO]; /*input line count stack*/ static int cfpid[NSO+1]; /* .pso process IDs */ char *progname; /* program name (troff) */ #ifdef EUC char mbbuf1[MB_LEN_MAX + 1]; char *mbbuf1p = mbbuf1; wchar_t twc = 0; #endif /* EUC */ static unsigned char escoff[126-31]; static void initg(void); -static void printlong(long, int); -static void printn(long, long); -static char *sprintlong(char *s, long, int); -static char *sprintn(char *s, long n, int b); #ifndef NROFF +static void printn(long, long); +static void printlong(long, int); #define vfdprintf xxvfdprintf static void vfdprintf(int fd, const char *fmt, va_list ap); #endif static tchar setyon(void); static void _setenv(void); static tchar setZ(void); static int setgA(void); static int setB(void); static void _caseesc(int); #ifdef DEBUG int debug = 0; /*debug flag*/ #endif /* DEBUG */ static int _xflag; int bol; int noschr; int prdblesc; int main(int argc, char **argv) { register char *p; register int j; char **oargv; - const char *s; size_t l; setlocale(LC_CTYPE, ""); mb_cur_max = MB_CUR_MAX; progname = argv[0]; nextf = calloc(1, NS = 1); d = calloc(NDI = 5, sizeof *d); growblist(); growcontab(); grownumtab(); growpbbuf(); morechars(1); initg(); for (j = 0; j <= NSO; j++) cfpid[j] = -1; if (signal(SIGHUP, SIG_IGN) != SIG_IGN) signal(SIGHUP, catch); if (signal(SIGINT, catch) == SIG_IGN) { signal(SIGHUP, SIG_IGN); signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); } signal(SIGPIPE, catch); signal(SIGTERM, kcatch); oargv = argv; cfname[0] = strdup(""); init0(); #ifdef EUC localize(); #endif /* EUC */ if ((p = getenv("TYPESETTER")) != 0) n_strcpy(devname, p, sizeof(devname)); while (--argc > 0 && (++argv)[0][0] == '-') switch (argv[0][1]) { case 'F': /* switch font tables from default */ if (argv[0][2] != '\0') { termtab = &argv[0][2]; fontfile = &argv[0][2]; } else { argv++; argc--; if (argv[0] != '\0') { termtab = argv[0]; fontfile = argv[0]; } else errprint("missing the font directory"); } continue; case 0: goto start; case 'i': stdi++; continue; case 'q': #ifdef NROFF quiet++; save_tty(); #else errprint("-q option ignored in troff"); #endif /* NROFF */ continue; case 'n': npn = ctoi(&argv[0][2]); continue; case 'u': /* set emboldening amount */ initbdtab[3] = ctoi(&argv[0][2]); if (initbdtab[3] < 0 || initbdtab[3] > 50) initbdtab[3] = 0; continue; case 's': if (!(stop = ctoi(&argv[0][2]))) stop++; continue; case 't': ptid = 1; continue; case 'r': case 'd': if (&argv[0][2] != '\0' && strlen(&argv[0][2]) >= 2 && &argv[0][3] != '\0') { if ((p = strchr(&argv[0][3], '=')) != NULL) { *p = 0; l = strlen(ibuf); eibuf = roff_sprintf(ibuf + l, sizeof(ibuf) - l, ".do %s %s %s%s\n", argv[0][1] == 'd' ? "ds" : "nr", &argv[0][2], argv[0][1] == 'd' ? "\"" : "", &p[1]); *p = '='; } else { l = strlen(ibuf); eibuf = roff_sprintf(ibuf + l, sizeof(ibuf) - l, ".%s %c %s%s\n", argv[0][1] == 'd' ? "ds" : "nr", argv[0][2], argv[0][1] == 'd' ? "\"" : "", &argv[0][3]); } } else errprint("wrong options"); continue; case 'c': case 'm': if (mflg++ >= NMF && (mfiles = realloc(mfiles, ++NMF * sizeof *mfiles)) == 0) { errprint("Too many macro packages: %s", argv[0]); continue; } if (argv[0][2] == '\0') { errprint("No library provided with -m"); done(02); } if (getenv("TROFFMACS") != '\0') { if (tryfile(getenv("TROFFMACS"), &argv[0][2], nmfi)) nmfi++; } else if (tryfile(MACDIR "/", &argv[0][2], nmfi) || tryfile(MACDIR "/tmac.", &argv[0][2], nmfi)) nmfi++; else { errprint("Cannot find library %s\n", argv[0]); done(02); } continue; case 'o': getpn(&argv[0][2]); continue; case 'T': n_strcpy(devname, &argv[0][2], sizeof(devname)); dotT++; continue; case 'x': if (argv[0][2]) xflag = strtol(&argv[0][2], NULL, 10); else xflag = 2; continue; case 'X': xflag = 0; continue; #ifdef NROFF case 'h': hflg++; continue; case 'z': no_out++; continue; case 'e': eqflg++; continue; #endif #ifndef NROFF case 'z': no_out++; case 'a': ascii = 1; nofeed++; continue; case 'f': nofeed++; continue; #endif case '#': #ifdef DEBUG debug = ctoi(&argv[0][2]); #else errprint("DEBUG not enabled"); #endif /* DEBUG */ continue; case 'V': fprintf(stdout, "Heirloom doctools %croff, " RELEASE "\n", #ifdef NROFF 'n' #else 't' #endif ); exit(0); default: errprint("unknown option %s", argv[0]); done(02); } start: init1(oargv[0][0]); argp = argv; rargc = argc; nmfi = 0; init2(); mainloop(); /*NOTREACHED*/ return(0); } void mainloop(void) { register int j; register tchar i; int eileenct; /*count to test for "Eileen's loop"*/ #ifdef NROFF int ndo = 0; #endif _xflag = xflag; setjmp(sjbuf); eileenct = 0; /*reset count for "Eileen's loop"*/ loop: #ifdef NROFF if (ndo) { ndo = 0; npic(0); } #endif xflag = _xflag; defcf = charf = clonef = copyf = lgf = nb = nflush = nlflg = 0; if (ip && rbf0(ip) == 0 && dip == d && ejf && frame->pframe->tail_cnt <= ejl) { nflush++; trap = 0; eject((struct s *)0); #ifdef DEBUG if (debug & DB_LOOP) fprintf(stderr, "loop: NL=%d, ejf=%d, lss=%d, " "eileenct=%d\n", numtab[NL].val, ejf, lss, eileenct); #endif /* DEBUG */ if (eileenct > 20) { errprint("job looping; check abuse of macros"); ejf = 0; /*try to break Eileen's loop*/ eileenct = 0; } else eileenct++; goto loop; } eileenct = 0; /*reset count for "Eileen's loop"*/ bol = 1; i = getch(); bol = 0; if (!i) /* CK: Bugfix: .bp followed by .. */ goto loop; if (pendt) goto Lt; if ((j = cbits(i)) == XPAR) { copyf++; tflg++; while (cbits(i) != '\n') pchar(i = getch()); tflg = 0; copyf--; goto loop; } if (j == cc || j == c2 || isxfunc(i, CC)) { if (gflag && isdi(i)) goto Lt; if (j == c2) nb++; copyf++; while ((j = cbits(i = getch())) == ' ' || j == '\t') ; ch = i; copyf--; j = getrq(4); #ifdef NROFF if (j == PAIR('P', 'S')) npic(1); else if (ndraw && j == PAIR('d', 'o')) ndo = 1; else #endif if (xflag != 0 && j == PAIR('d', 'o')) { xflag = 3; skip(1); j = getrq(4); } noschr = 1; control(j, 1); noschr = 0; flushi(); goto loop; } Lt: ch = i; text(); if (nlflg) numtab[HP].val = 0; goto loop; } int tryfile(register const char *pat, register char *fn, int idx) { size_t l = strlen(pat) + strlen(fn) + 1; mfiles[idx] = malloc(l); n_strcpy(mfiles[idx], pat, l); n_strcat(mfiles[idx], fn, l); if (access(mfiles[idx], 4) == -1) return(0); else return(1); } void catch(int unused __unused) { done3(01); } void kcatch(int unused __unused) { signal(SIGTERM, SIG_IGN); done3(01); } void init0(void) { eibuf = ibufp = ibuf; ibuf[0] = 0; numtab[NL].val = -1; } void init1(char a __unused) { register int i; for (i = NTRTAB; --i; ) trnttab[i] = trtab[i] = i; trnttab[UNPAD] = trtab[UNPAD] = ' '; trnttab[STRETCH] = trtab[STRETCH] = ' '; } void init2(void) { register int i, j; size_t l; ttyod = 2; if ((ttyp=ttyname(j=0)) != 0 || (ttyp=ttyname(j=1)) != 0 || (ttyp=ttyname(j=2)) != 0) ; else ttyp = "notty"; iflg = j; if (ascii) mesg(0); obufp = obuf; ptinit(); mchbits(); cvtime(); setnr(".g", gflag, 0); numtab[PID].val = getpid(); spreadlimit = 3*EM; olinesz = LNSIZE; oline = malloc(olinesz * sizeof *oline); olinep = oline; ioff = 0; numtab[HP].val = init = 0; numtab[NL].val = -1; nfo = 0; ifile = 0; copyf = raw = 0; l = strlen(ibuf); eibuf = roff_sprintf(ibuf + l, sizeof(ibuf) - l, ".ds .T %s\n", devname); numtab[CD].val = -1; /* compensation */ cpushback(ibuf); ibufp = ibuf; nx = mflg; frame = stk = calloc(1, sizeof *stk); stk->frame_cnt = 0; dip = &d[0]; nxf = calloc(1, sizeof *nxf); initenv = env; for (i = 0; i < NEV; i++) { extern tchar *corebuf; ((struct env *)corebuf)[i] = env; } } void cvtime(void) { time_t tt; register struct tm *tm; tt = time((time_t *) 0); tm = localtime(&tt); numtab[DY].val = tm->tm_mday; numtab[DW].val = tm->tm_wday + 1; numtab[YR].val = tm->tm_year; numtab[MO].val = tm->tm_mon + 1; setnr("hours", tm->tm_hour, 0); setnr("minutes", tm->tm_min, 0); setnr("seconds", tm->tm_sec, 0); setnr("year", tm->tm_year + 1900, 0); } int ctoi(register char *s) { register int n; while (*s == ' ') s++; n = 0; while (isdigit((unsigned char)*s)) n = 10 * n + *s++ - '0'; return n; } void mesg(int f) { static int mode; struct stat stbuf; if (!f) { stat(ttyp, &stbuf); mode = stbuf.st_mode; chmod(ttyp, mode & ~0122); /* turn off writing for others */ } else { if (ttyp && *ttyp && mode) chmod(ttyp, mode); } } static void verrprint(const char *s, va_list ap) { fprintf(stderr, "%s: ", progname); vfprintf(stderr, s, ap); if (numtab[CD].val > 0) fprintf(stderr, "; line %d, file %s", numtab[CD].val + (nlflg == 0 && frame == stk), cfname[ifi] ? cfname[ifi] : ""); if (xflag && realpage) fprintf(stderr, "; page %ld", realpage); fprintf(stderr, "\n"); stackdump(); #ifdef DEBUG if (debug & DB_ABRT) abort(); #endif /* DEBUG */ } void errprint(const char *s, ...) /* error message printer */ { va_list ap; va_start(ap, s); verrprint(s, ap); va_end(ap); } #ifndef NROFF /* * Scaled down version of C Library printf. * Only %s %u %d (==%u) %o %c %x %D are recognized. */ #undef putchar #define putchar(n) (*pfbp++ = (n)) /* NO CHECKING! */ static char pfbuf[NTM]; static char *pfbp = pfbuf; void fdprintf(int fd, const char *fmt, ...) { va_list ap; va_start(ap, fmt); vfdprintf(fd, fmt, ap); va_end(ap); } static void vfdprintf(int fd, const char *fmt, va_list ap) { register int c; char *s; - register int i; + size_t i; pfbp = pfbuf; loop: while ((c = *fmt++) != '%') { if (c == '\0') { if (fd == 2) write(STDERR_FILENO, pfbuf, pfbp - pfbuf); else { *pfbp = 0; pfbp = pfbuf; while (*pfbp) { *obufp++ = *pfbp++; if (obufp >= &obuf[OBUFSZ]) flusho(); } } return; } putchar(c); } c = *fmt++; if (c == 'd' || c == 'u' || c == 'o' || c == 'x') { i = va_arg(ap, int); printlong(i, c); } else if (c == 'c') { if (c > 0177 || c < 040) putchar('\\'); putchar(va_arg(ap, int) & 0177); } else if (c == 's') { s = va_arg(ap, char *); while ((c = *s++)) putchar(c); } else if (c == 'D') { printn(va_arg(ap, long), 10); } else if (c == 'O') { printn(va_arg(ap, long), 8); } else if (c == 'e' || c == 'E' || c == 'f' || c == 'F' || c == 'g' || c == 'G') { char tmp[40]; char fmt[] = "%%"; fmt[1] = c; snprintf(s = tmp, sizeof(tmp), fmt, va_arg(ap, double)); while ((c = *s++)) putchar(c); } else if (c == 'p') { i = (intptr_t)va_arg(ap, void *); putchar('0'); putchar('x'); printlong(i, 'x'); } else if (c == 'l') { c = *fmt++; if (c == 'd' || c == 'u' || c == 'o' || c == 'x') { i = va_arg(ap, long); printlong(i, c); } else if (c == 'c') { i = va_arg(ap, int); if (c & ~0177) { #ifdef EUC char mb[MB_LEN_MAX]; int j, n; n = wctomb(mb, i); for (j = 0; j < n; j++) putchar(mb[j]&0377); #endif /* EUC */ } else putchar(i); } } else if (c == 'C') { - extern int nchtab; + extern size_t nchtab; tchar t = va_arg(ap, tchar); if ((i = cbits(t)) < 0177) { putchar(i); } else if (i < 128 + nchtab) { putchar('\\'); putchar('('); putchar(chname[chtab[i-128]]); putchar(chname[chtab[i-128]+1]); } else if ((i = tr2un(i, fbits(t))) != -1) goto U; } else if (c == 'U') { i = va_arg(ap, int); U: putchar('U'); putchar('+'); if (i < 0x1000) putchar('0'); if (i < 0x100) putchar('0'); if (i < 0x10) putchar('0'); printn((long)i, 16); #ifdef EUC if (iswprint(i)) { char mb[MB_LEN_MAX]; int j, n; n = wctomb(mb, i); putchar(' '); putchar('('); for (j = 0; j < n; j++) putchar(mb[j]&0377); putchar(')'); } #endif /* EUC */ } goto loop; } -#endif /* !NROFF */ static void printlong(long i, int fmt) { switch (fmt) { case 'd': if (i < 0) { putchar('-'); i = -i; } /*FALLTHRU*/ case 'u': printn(i, 10); break; case 'o': printn(i, 8); break; case 'x': printn(i, 16); break; } } /* * Print an unsigned integer in base b. */ static void printn(register long n, register long b) { register long a; if (n < 0) { /* shouldn't happen */ putchar('-'); n = -n; } if ((a = n / b)) printn(a, b); putchar("0123456789ABCDEF"[(int)(n%b)]); } +#endif /* !NROFF */ /* returns pointer to \0 that ends the string */ /* VARARGS2 */ char *roff_sprintf(char *str, size_t size, const char *fmt, ...) { int ret; va_list ap; va_start(ap, fmt); ret = vsnprintf(str, size, fmt, ap); va_end(ap); return (str + ret); } int control(register int a, register int b) { struct contab *contp; int newip; struct s *p; if (a == 0 || (contp = findmx(a)) == NULL) { nosuch(a); return(0); } /* * Attempt to find endless recursion at runtime. Arbitrary * recursion limit of MAX_RECURSION_DEPTH was chosen as * it is extremely unlikely that a correct nroff/troff * invocation would exceed this value. * * The depth of tail-recursive macro calls is not limited * by default. */ if (max_recursion_depth > 0 && frame->frame_cnt > max_recursion_depth) { errprint( "Exceeded maximum stack size (%d) when " "executing macro %s. Stack dump follows", max_recursion_depth, macname(frame->mname)); edone(02); } if (max_tail_depth > 0 && frame->tail_cnt > max_tail_depth) { errprint( "Exceeded maximum recursion depth (%d) when " "executing macro %s. Stack dump follows", max_tail_depth, macname(frame->mname)); edone(02); } lastrq = a; #ifdef DEBUG if (debug & DB_MAC) fprintf(stderr, "control: macro %s, contab[%d]\n", macname(a), contp - contab); #endif /* DEBUG */ if (contp->f == 0) { nxf->nargs = 0; tailflg = 0; if (b) collect(); flushi(); newip = pushi((filep)contp->mx, a, contp->flags); p = frame->pframe; if (tailflg && b && p != stk && p->ppendt == 0 && p->pch == 0 && p->pip == frame->pip && p->lastpbp == frame->lastpbp) { frame->pframe = p->pframe; frame->frame_cnt--; sfree(p); *p = *frame; free(frame); frame = p; } contp->flags |= FLAG_USED; frame->contp = contp; tailflg = 0; return newip; } else if (b) { (*contp->f)(0); return 0; } else return(0); } int rgetach(void) { extern const char nmctab[]; int i; if ((i = getach()) == 0 || (xflag && i < ' ' && nmctab[i])) return(0); return(i); } int getrq2(void) { register int i, j; if (((i = rgetach()) == 0) || ((j = rgetach()) == 0)) goto rtn; i = PAIR(i, j); rtn: return(i); } int getrq(int flags) { int i; if ((i = getrq2()) >= 256) i = maybemore(i, flags); return(i); } /* * table encodes some special characters, to speed up tests * in getchar, viz FLSS, RPT, f, \b, \n, fc, tabch, ldrch */ static char _gchtab[] = { 000,004,000,000,010,000,000,000, /* fc, ldr */ 001,002,001,000,001,000,000,000, /* \b, tab, nl, RPT */ 000,000,000,000,000,000,000,000, 000,001,000,000,000,000,000,000, /* FLSS */ 000,000,000,000,000,000,000,000, 000,000,000,000,000,000,000,000, 000,000,000,000,000,000,000,000, 000,000,000,000,000,000,000,000, 000,000,000,000,000,000,000,000, 000,000,000,000,000,000,000,000, 000,000,000,000,000,000,000,000, 000,000,000,000,000,000,000,000, 000,000,000,000,000,000,001,000, /* f */ 000,000,000,000,000,000,000,000, 000,000,000,000,000,000,000,000, 000,000,000,000,000,000,000,000, }; static void initg(void) { memcpy(gchtab, _gchtab, sizeof _gchtab); } tchar getch(void) { register int k; register tchar i, j; struct numtab *np; g0: if ((i = ch)) { if (cbits(i) == '\n') { nlflg++; tailflg = istail(i); } ch = 0; return(i); } if (nlflg) return('\n'); i = getch0(); if (ismot(i)) return(i); k = cbits(i); if (k != ESC) { if (k >= NCHARS || gchtab[k]==0) return(i); if (k == '\n') { nl: if (cbits(i) == '\n') { nlflg++; tailflg = istail(i); } return(k); } if (k == FLSS) { copyf++; raw++; i = getch0(); if (!fi) flss = i; copyf--; raw--; goto g0; } if (k == RPT) { setrpt(); goto g0; } if (!copyf) { if (gchtab[k]&LGBIT && !isdi(i) && lg && !lgf) { k = cbits(i = getlg(i)); goto chartest; } if (k == fc || k == tabch || k == ldrch) { if ((i = setfield(k)) == 0) goto g0; else return(i); } if (k == '\b') { i = makem(-width(' ' | chbits)); return(i); } chartest: if ( #ifndef NROFF (!html || k < NCHARS) && #endif !lgf && !charf && chartab[trtab[k]] != NULL && !noschr && (!argdelim || k != argdelim) && !(bol && (k == cc || k == c2))) i = setchar(i); return(i); } return(i); } ge: k = cbits(j = getch0()); if (ismot(j)) return(j); if (k >= 32 && k <= 126 && escoff[k-32]) { if (clonef || copyf || tryglf) { pbbuf[pbp++] = j; return eschar; } return j; } switch (k) { case '\n': /* concealed newline */ if (fmtchar) goto nl; goto g0; case '{': /* LEFT */ i = LEFT; goto gx; case '}': /* RIGHT */ i = RIGHT; goto gx; case '#': /* comment including newline */ if (xflag == 0) break; /*FALLTHRU*/ case '"': /* comment */ while (cbits(i = getch0()) != '\n') ; if (k == '#') goto g0; nlflg++; tailflg = istail(i); return(i); case 'e': /* printable version of current eschar */ i = PRESC; goto gx; case ' ': /* unpaddable space */ i = UNPAD; goto gx; case '~': /* stretchable but unbreakable space */ if (xflag == 0) break; i = STRETCH; goto gx; case '\'': /* \(aa */ i = ACUTE; goto gx; case '`': /* \(ga */ i = GRAVE; goto gx; case '_': /* \(ul */ i = UNDERLINE; goto gx; case '-': /* current font minus */ i = MINUS; goto gx; case '&': /* filler */ i = FILLER; goto gx; case ')': /* transparent filler */ if (xflag == 0) break; i = FILLER|TRANBIT; goto gx; case 'c': /* to be continued */ i = CONT; goto gx; case '!': /* transparent indicator */ i = XPAR; goto gx; case 't': /* tab */ i = '\t'; return(i); case 'a': /* leader (SOH) */ i = LEADER; return(i); case '%': /* ohc */ i = OHC; return(i); case ':': /* optional line break but no hyphenation */ if (xflag == 0) break; i = OHC | BLBIT; return(i); } if (clonef) { pbbuf[pbp++] = j; return(eschar); } switch (k) { case 'n': /* number register */ setn(); goto g0; case '*': /* string indicator */ setstr(); goto g0; case '$': /* argument indicator */ seta(); goto g0; case ESC: /* double backslash */ if (prdblesc || dilev) i = PRESC; else i = eschar; goto gx; case 'g': /* return format of a number register */ setaf(); goto g0; case 'P': /* output line trap */ if (xflag == 0) break; i = setolt(); return(i); case 'V': /* environment variable */ if (xflag == 0) break; _setenv(); goto g0; case '.': /* . */ i = '.'; gx: setsfbits(i, sfbits(j)); return(i); } if (copyf) { copy: pbbuf[pbp++] = j; return(eschar); } switch (k) { case '[': if (defcf) goto copy; if (xflag == 0) goto dfl; /*FALLTHRU*/ case 'C': case '(': /* special char name */ if (defcf) goto copy; if ((i = setch(k)) == 0 && !tryglf) goto g0; k = cbits(i); goto chartest; case 'U': /* Unicode character */ if (xflag == 0) goto dfl; if ((i = setuc()) == 0 && !tryglf) goto g0; return(i); case 'N': /* absolute character number */ i = setabs(); goto gx; case 'E': /* eschar out of copy mode */ if (xflag == 0) goto dfl; goto ge; } if (tryglf) { pbbuf[pbp++] = j; return(eschar); } switch (k) { case 'X': /* \X'...' for copy through */ setxon(); goto g0; case 'Y': /* \Y(xx for indirect copy through */ if (xflag == 0) goto dfl; i = setyon(); return(i); case 'p': /* spread */ spread = 1; goto g0; case 's': /* size indicator */ setps(); goto g0; case 'H': /* character height */ return(setht()); case 'S': /* slant */ return(setslant()); case 'f': /* font indicator */ setfont(0); goto g0; case 'w': /* width function */ setwd(); goto g0; case 'v': /* vert mot */ if ((i = vmot())) return(i); goto g0; case 'h': /* horiz mot */ if ((i = hmot())) return(i); goto g0; case 'z': /* zero with char */ return(setz()); case 'l': /* hor line */ setline(); goto g0; case 'L': /* vert line */ setvline(); goto g0; case 'D': /* drawing function */ setdraw(); goto g0; case 'b': /* bracket */ setbra(); goto g0; case 'o': /* overstrike */ setov(); goto g0; case 'k': /* mark hor place */ if ((np = findr(getsn(1))) != NULL) { np->val = numtab[HP].val; prwatchn(np); } goto g0; case '0': /* number space */ return(makem(width('0' | chbits))); #ifdef NROFF case '/': case ',': if (!(gflag || gemu)) goto dfl; goto g0; case '|': case '^': goto g0; #else case '/': if (gflag == 0) goto dfl; return(makem((int)(EM)/12)); /* italic correction */ case ',': if (!(gflag || gemu)) goto dfl; return(makem(0)); /* left italic correction */ case '|': /* narrow space */ return(makem((int)(EM)/6)); case '^': /* half narrow space */ return(makem((int)(EM)/12)); #endif case 'x': /* extra line space */ if ((i = xlss())) return(i); goto g0; case 'u': /* half em up */ case 'r': /* full em up */ case 'd': /* half em down */ return(sethl(k)); case 'I': if (xflag) { i = setgA() + '0'; goto gx; } goto dfl; case 'A': /* set anchor */ if (gflag) { /* acceptable as name */ i = setgA() + '0'; goto gx; } if (xflag == 0) goto dfl; if ((j = setanchor()) == 0) goto g0; return(j); case 'B': /* acceptable as expression */ if (xflag) { i = setB() + '0'; goto gx; } goto dfl; case 'F': case 'm': case 'M': if (gflag || gemu) { /* font family, color */ if ((i = getsn(0)) > 0 && warn & WARN_ESCAPE) errprint("\\%c[%s] unimplemented", k, macname(i)); goto g0; } goto dfl; case 'T': if (xflag == 0) goto dfl; if ((j = setlink()) == 0) goto g0; return(j); case 'R': if (xflag) { setr(); goto g0; } goto dfl; case 'W': /* URI link */ if (xflag == 0) goto dfl; if ((j = setulink()) == 0) goto g0; return(j); case 'Z': if (xflag == 0) goto dfl; if ((j = setZ()) != 0) return(j); goto g0; case 'j': if (xflag == 0) goto dfl; if ((j = setpenalty()) != 0) return(j); goto g0; case 'J': if (xflag == 0) goto dfl; if ((j = setdpenal()) != 0) return(j); goto g0; case '@': if (xflag == 0) goto dfl; k = cbits(i = getch0()); switch (k) { case '{': pushinlev(); break; case '}': if ((i = popinlev()) != 0) return(i); break; default: if (warn & WARN_ESCAPE) errprint("undefined inline environment " "function \\@%c", k); pbbuf[pbp++] = i; goto dfl; } goto g0; case ';': /* ligature suppressor (only) */ if (xflag) goto g0; /*FALLTHRU*/ default: dfl: if (defcf) goto copy; if (warn & WARN_ESCAPE) errprint("undefined escape sequence \\%c", k); return(j); } /* NOTREACHED */ } void setxon(void) /* \X'...' for copy through */ { tchar _xbuf[NC]; register tchar *i; tchar c, delim; int k; if (ismot(c = getch())) return; delim = c; i = _xbuf; *i++ = XON; charf++; while (k = cbits(c = getch()), !issame(c, delim) && k != '\n' && i < _xbuf+NC-1) { if (k == ' ') setcbits(c, UNPAD); *i++ = c | ZBIT; } if (!issame(c, delim)) nodelim(delim); charf--; *i++ = XOFF; *i = 0; pushback(_xbuf); } static tchar setyon(void) /* \Y(xx for indirect copy through */ { storerq(getsn(0)); return mkxfunc(YON, 0); } char ifilt[32] = { 0, 001, 002, 003, 0, 005, 006, 007, 010, 011, 012}; tchar getch0(void) { register int j; register tchar i; #ifdef EUC size_t n; #endif /* EUC */ again: if (pbp > lastpbp) i = pbbuf[--pbp]; else if (ip) { extern tchar *corebuf; i = corebuf[ip]; if (i == 0) { /* CK: Bugfix: .bp followed by .. * The "<" is questionable */ if (ejf && frame->pframe->tail_cnt < ejl && dip == d) goto r; i = rbf(); } else { if ((++ip & (BLK - 1)) == 0) { --ip; (void)rbf(); } } } else { if (donef || ndone) done(0); if (nx || ibufp >= eibuf) { if (nfo==0) { g0: if (nextfile()) { if (ip) goto again; if (ibufp < eibuf) goto g2; } } nx = 0; if ((j = read(ifile, ibuf, IBUFSZ)) <= 0) goto g0; ibufp = ibuf; eibuf = ibuf + j; if (ip) goto again; } g2: #ifndef EUC i = *ibufp++ & 0177; ioff++; if (i >= 040 && i < 0177) #else /* EUC */ i = *ibufp++ & 0377; ioff++; *mbbuf1p++ = i; *mbbuf1p = 0; if (multi_locale && (*mbbuf1&~(wchar_t)0177)) { mbstate_t state; memset(&state, 0, sizeof state); if ((n = mbrtowc(&twc, mbbuf1, mbbuf1p-mbbuf1, &state)) - == -1 || + == (size_t)-1 || twc & ~(wchar_t)0x1FFFFF) { illseq(-1, mbbuf1, mbbuf1p-mbbuf1); mbbuf1p = mbbuf1; *mbbuf1p = 0; i &= 0177; - } else if (n == -2) + } else if (n == (size_t)-2) goto again; else { mbbuf1p = mbbuf1; *mbbuf1p = 0; i = twc | COPYBIT; goto g4; } } else { mbbuf1p = mbbuf1; *mbbuf1p = 0; if (!raw) i &= 0177; } if (i >= 040 && i < 0177) #endif /* EUC */ goto g4; if (i != 0177) { if (i != ifilt[i]) illseq(i, NULL, 0); i = ifilt[i]; } else illseq(i, NULL, 0); if (i == '\n') numtab[CD].val++; /* line number */ } if (cbits(i) == IMP && !raw) goto again; if ((i == 0 || i == 0177) && !init && !raw) { goto again; } g4: if (!copyf && iscopy(i)) i = setuc0(cbits(i)); if (copyf == 0 && (i & ~BYTEMASK) == 0) i |= chbits; if (cbits(i) == eschar && !raw) { if (gflag && isdi(i)) setcbits(i, PRESC); else setcbits(i, ESC); } r: return i; } void pushback(register tchar *b) { register tchar *ob = b; while (*b++) ; b--; while (b > ob) { if (pbp >= pbsize-3) if (growpbbuf() == NULL) { errprint("pushback overflow"); done(2); } pbbuf[pbp++] = *--b; } } void cpushback(register const char *b) { register const char *ob = b; while (*b++) ; b--; while (b > ob) { if (pbp >= pbsize-3) if (growpbbuf() == NULL) { errprint("cpushback overflow"); done(2); } pbbuf[pbp++] = *--b; } } tchar * growpbbuf(void) { tchar *npb; int inc = NC; if ((npb = realloc(pbbuf, (pbsize + inc) * sizeof *pbbuf)) == NULL) return NULL; pbsize += inc; return pbbuf = npb; } int nextfile(void) { register char *p; n0: if (ifile) close(ifile); if (nx || nmfi < mflg) { p = mfiles[nmfi++]; if (*p != 0) goto n1; } if (ifi > 0) { if (popf()) goto n0; /* popf error */ return(1); /* popf ok */ } if (rargc-- <= 0) { if ((nfo -= mflg) && !stdi) done(0); nfo++; numtab[CD].val = ifile = stdi = mflg = 0; free(cfname[ifi]); cfname[ifi] = strdup(""); ioff = 0; return(0); } p = (argp++)[0]; n1: numtab[CD].val = 0; if (p[0] == '-' && p[1] == 0) { ifile = 0; free(cfname[ifi]); cfname[ifi] = strdup(""); } else if ((ifile = open(p, O_RDONLY)) < 0) { errprint("cannot open file %s", p); nfo -= mflg; done(02); } else { free(cfname[ifi]); cfname[ifi] = strdup(p); } nfo++; ioff = 0; return(0); } int popf(void) { register int i; register char *p, *q; if (cfpid[ifi] != -1) { while (waitpid(cfpid[ifi], NULL, 0) != cfpid[ifi]); cfpid[ifi] = -1; } ioff = offl[--ifi]; numtab[CD].val = cfline[ifi]; /*restore line counter*/ ip = ipl[ifi]; if ((ifile = ifl[ifi]) == 0) { p = xbuf; q = ibuf; ibufp = xbufp; eibuf = xeibuf; while (q < eibuf) *q++ = *p++; return(0); } if (lseek(ifile, ioff & ~(IBUFSZ-1), SEEK_SET) == -1 || (i = read(ifile, ibuf, IBUFSZ)) < 0) return(1); eibuf = ibuf + i; ibufp = ibuf; if (ttyname(ifile) == 0) /* was >= ... */ if ((ibufp = ibuf + (ioff & (IBUFSZ - 1))) > eibuf) return(1); return(0); } void flushi(void) { if (nflush) return; ch = 0; copyf++; while (!nlflg) { if (donef && (frame == stk)) break; getch(); } copyf--; } int getach(void) { register tchar i; register int j; lgf++; i = getch(); while (isxfunc(i, CHAR)) i = charout[sbits(i)].ch; j = cbits(i); if (ismot(i) || (j == XFUNC && fbits(i)) || j == ' ' || j == '\n' || j & 0200) { if (!ismot(i) && j >= 0200) illseq(j, NULL, -3); else if (WARN_INPUT) { if (ismot(i) && !isadjmot(i)) errprint("motion terminates name"); else if (j == XFUNC && fbits(i)) errprint("illegal character terminates name"); } ch = i; j = 0; } lgf--; return(j & 0177); } void casenx(void) { struct s *pp; lgf++; skip(0); getname(); nx++; if (nmfi > 0) nmfi--; if (mfiles == NULL) mfiles = calloc(1, sizeof *mfiles); free(mfiles[nmfi]); mfiles[nmfi] = malloc(NS); n_strcpy(mfiles[nmfi], nextf, NS); nextfile(); nlflg++; tailflg = 0; ip = 0; pendt = 0; while (frame != stk) { pp = frame; frame = frame->pframe; sfree(pp); free(pp); } nxf = calloc(1, sizeof *nxf); } int getname(void) { register int j, k; tchar i; int delim = ' '; lgf++; k = 0; while (1) { if ((j = cbits(i = getch())) < 32 || j == delim || (!xflag && j > 0176)) break; if (xflag && !k && j == '"') { delim = j; continue; } if (k + 1 >= NS) nextf = realloc(nextf, NS += 14); nextf[k++] = j & BYTEMASK; } nextf[k] = 0; ch = i; lgf--; return(nextf[0]); } tchar setuc(void) { char c, _d, b[NC], *bp; int n; size_t i = 0; tchar r = 0; #ifndef NROFF - extern int nchtab; + extern size_t nchtab; #endif _d = getach(); do { c = getach(); if (i >= sizeof b) goto rtn; b[i++] = c; } while (c && c != _d); b[--i] = 0; if (i == 0 || c != _d) goto rtn; n = strtol(b, &bp, 16); if (n == 0 || *bp != '\0') goto rtn; #ifndef NROFF switch (n) { case '\'': bp = "aq"; break; case '`': bp = "ga"; break; case '-': r = MINUS; goto rtn; default: goto uc; } for (i = 0; i < nchtab; i++) if (strcmp(&chname[chtab[i]], bp) == 0) { r = (i + 128) | chbits; break; } goto rtn; uc: #endif r = setuc0(n); rtn: return r; } static void _setenv(void) { int a = 0, i = 0, c, delim; char *np = NULL, *vp; if ((delim = getach()) == 0) return; switch (delim) { case '[': for (;;) { if (i + 1 >= a) np = realloc(np, a += 32); if ((c = getach()) == 0) { nodelim(']'); break; } if (c == ']') break; np[i++] = c; } np[i] = 0; break; case '(': np = malloc(a = 3); np[0] = delim; np[1] = getach(); np[2] = 0; break; default: np = malloc(a = 2); np[0] = delim; np[1] = 0; } if ((vp = getenv(np)) != NULL) cpushback(vp); free(np); } static void sopso(int i, pid_t pid) { register char *p, *q; free(cfname[ifi+1]); cfname[ifi+1] = malloc(NS); n_strcpy(cfname[ifi+1], nextf, NS); cfline[ifi] = numtab[CD].val; /*hold line counter*/ numtab[CD].val = 0; flushi(); cfpid[ifi+1] = pid; ifl[ifi] = ifile; ifile = i; offl[ifi] = ioff; ioff = 0; ipl[ifi] = ip; ip = 0; nx++; nflush++; if (!ifl[ifi++]) { p = ibuf; q = xbuf; xbufp = ibufp; xeibuf = eibuf; while (p < eibuf) *q++ = *p++; } } void caseso(void) { register int i = 0; lgf++; nextf[0] = 0; if (skip(1)) done(02); if (!getname() || ((i = open(nextf, O_RDONLY)) < 0) || (ifi >= NSO)) { errprint("can't open file %s", nextf); if (gflag) return; done(02); } sopso(i, -1); } void casepso(void) { int pd[2]; int c, i, k; pid_t pid; lgf++; nextf[0] = 0; if (skip(1)) done(02); if (ifi >= NSO || pipe(pd) < 0) { errprint("can't .pso"); done(02); } for (k = 0; ; k++) { if ((c = cbits(i = getch())) == '\n' || c == 0) break; if (k + 1 >= NS) nextf = realloc(nextf, NS += 14); nextf[k] = c & BYTEMASK; } nextf[k] = 0; switch (pid = fork()) { case 0: close(pd[0]); close(1); dup(pd[1]); close(pd[1]); execl(SHELL, "sh", "-c", nextf, NULL); _exit(0177); /*NOTREACHED*/ case -1: errprint("can't fork"); done(02); /*NOTREACHED*/ } close(pd[1]); sopso(pd[0], pid); } void caself(void) /* set line number and file */ { int n; if (skip(1)) return; n = hatoi(); cfline[ifi] = numtab[CD].val = n - 2; if (skip(0)) return; if (getname()) { free(cfname[ifi]); cfname[ifi] = malloc(NS); n_strcpy(cfname[ifi], nextf, NS); } } void casecf(void) { /* copy file without change */ #ifndef NROFF int fd = -1, n; char buf[512]; extern int hpos, esc, po; nextf[0] = 0; if (skip(1)) return; if (!getname() || (fd = open(nextf, O_RDONLY)) < 0) { errprint("can't open file %s", nextf); done(02); } tbreak(); /* make it into a clean state, be sure that everything is out */ hpos = po; esc = un; ptesc(); ptlead(); ptps(); ptfont(); flusho(); while ((n = read(fd, buf, sizeof buf)) > 0) write(ptid, buf, n); close(fd); #endif } void casesy(void) /* call system */ { char sybuf[NTM]; int i; lgf++; copyf++; skip(1); for (i = 0; i < NTM - 2; i++) if ((sybuf[i] = getch()) == '\n') break; sybuf[i] = 0; system(sybuf); copyf--; lgf--; } void getpn(register char *a) { register int n, neg; if (*a == 0) return; neg = 0; for ( ; *a; a++) switch (*a) { case '+': case ',': continue; case '-': neg = 1; continue; default: n = 0; if (isdigit((unsigned char)*a)) { do n = 10 * n + *a++ - '0'; while (isdigit((unsigned char)*a)); a--; } else n = 9999; *pnp++ = neg ? -n : n; neg = 0; if (pnp >= &pnlist[NPN-2]) { errprint("too many page numbers"); done3(-3); } } if (neg) *pnp++ = -9999; *pnp = -32767; print = 0; pnp = pnlist; if (*pnp != -32767) chkpn(); } void setrpt(void) { tchar i, j; copyf++; raw++; i = getch0(); copyf--; raw--; if (i < 0 || cbits(j = getch0()) == RPT) return; i &= BYTEMASK; while (i>0) { if (pbp >= pbsize-3) if (growpbbuf() == NULL) break; i--; pbbuf[pbp++] = j; } } void casedb(void) { #ifdef DEBUG debug = 0; if (skip(1)) return; noscale++; debug = max(hatoi(), 0); noscale = 0; #endif /* DEBUG */ } void casexflag(void) { int i; #ifndef NROFF if (gflag == 1) zapwcache(1); #endif gflag = 0; setnr(".g", gflag, 0); gemu = 0; skip(1); noscale++; i = hatoi(); noscale--; if (!nonumb) _xflag = xflag = i & 3; } void casecp(void) { if (xflag) { #ifndef NROFF if (gflag == 0) zapwcache(1); #endif gflag = 1; noscale++; if (skip(1) || (hatoi() && !nonumb)) xflag = 1; else xflag = 3; noscale--; _xflag = xflag; setnr(".g", gflag, 0); setnr(".C", xflag == 1, 0); setnr(".x", 1, 0); setnr(".y", 18, 0); } } void caserecursionlimit(void) { skip(1); noscale++; max_recursion_depth = hatoi(); skip(0); max_tail_depth = hatoi(); noscale--; } void casechar(int flag __unused) { #ifndef NROFF extern int ps2cc(const char *); - extern int nchtab; + extern size_t nchtab; #endif char name[NC]; - int i, k, size = 0; + size_t i, k, size = 0; tchar c, *tp = NULL; defcf++; charf++; lgf++; if (skip(1)) return; c = getch(); while (isxfunc(c, CHAR)) c = charout[sbits(c)].ch; if ((k = cbits(c)) == eschar || k == WORDSP) { switch (cbits(c = getch())) { case '(': name[0] = getch(); name[1] = getch(); name[2] = 0; break; case '[': for (i = 0; cbits(c = getch()) != ']'; i++) if (i < sizeof name - 1) name[i] = c; name[i] = 0; break; default: errprint("mapping of escape sequences not permitted"); return; } #ifndef NROFF k = ps2cc(name) + nchtab + 128 + 32 + 128 - 32 + nchtab; #else if (!(k = findch(name))) k = addch(name); #endif } else if (iscopy(c)) k = cbits(c = setuc0(k)); if (k <= ' ') { errprint("mapping of special characters not permitted"); return; } defcf--; charf--; copyf++; size = 10; tp = malloc(size * sizeof *tp); i = 0; if (skip(0)) tp[i++] = FILLER; else { if (cbits(c = getch()) != '"') ch = c; while (c = getch(), !nlflg) { if (i + 3 >= size) { size += 10; tp = realloc(tp, size * sizeof *tp); } tp[i++] = c; } } tp[i++] = '\n'; tp[i] = 0; i = k; - if (++i >= NCHARS) + if (++i >= (size_t)NCHARS) morechars(i); free(chartab[k]); chartab[k] = tp; gchtab[k] |= CHBIT; copyf--; #ifndef NROFF if (flag) fchartab[k] = 1; else fchartab[k] = 0; #endif } void casefchar(void) { #ifndef NROFF casechar(1); #endif } void caserchar(void) { tchar c; int k; lgf++; if (skip(1)) return; do { c = getch(); k = cbits(c); free(chartab[k]); chartab[k] = NULL; gchtab[k] &= ~CHBIT; } while (!skip(0)); } struct fmtchar { struct d newd, *savedip; struct env saveev; int savvflag; int savvpt; int savhp; int savnflush; tchar *csp; int charcount; }; static int prepchar(struct fmtchar *fp) { static int charcount; filep startb; tchar _t; if ((startb = alloc()) == 0) { errprint("out of space"); return -1; } _t = 0; setsbits(_t, charcount); charcount = sbits(_t); if (dip != d) wbt(0); if (charcount >= charoutsz) { charoutsz += 32; charout = realloc(charout, charoutsz * sizeof *charout); } memset(&charout[charcount], 0, sizeof *charout); fp->savedip = dip; memset(&fp->newd, 0, sizeof fp->newd); dip = &fp->newd; offset = dip->op = startb; charout[charcount].op = startb; fp->savnflush = nflush; fp->savvflag = vflag; vflag = 0; fp->savvpt = vpt; vpt = 0; fp->savhp = numtab[HP].val; fp->saveev = env; evc(&env, &env); in = in1 = 0; fi = 0; return charcount++; } static void restchar(struct fmtchar *fp, int keepf) { wbt(0); dip = fp->savedip; offset = dip->op; relsev(&env); if (keepf) { fp->saveev._apts = apts; fp->saveev._apts1 = apts1; fp->saveev._pts = pts; fp->saveev._pts1 = pts1; fp->saveev._font = font; fp->saveev._font1 = font1; fp->saveev._chbits = chbits; fp->saveev._spbits = spbits; } env = fp->saveev; nflush = fp->savnflush; vflag = fp->savvflag; vpt = fp->savvpt; numtab[HP].val = fp->savhp; } tchar setchar(tchar c) { struct fmtchar f; int k = trtab[cbits(c)]; tchar *csp; int charcount; int savxflag; int saveschar; #ifndef NROFF if (fchartab[k] && onfont(c)) return c; #endif if (iszbit(c)) return c; if ((charcount = prepchar(&f)) < 0) return ' '; fmtchar++; savxflag = xflag; xflag = 3; saveschar = eschar; eschar = '\\'; csp = chartab[k]; chartab[k] = NULL; pushback(csp); text(); tbreak(); nlflg = 0; charout[charcount].ch = c; if (iszbit(c)) charout[charcount].width = 0; else { charout[charcount].width = dip->maxl - lasttrack; width(' ' | sfmask(c)); charout[charcount].width += lasttrack; } charout[charcount].height = maxcht; charout[charcount].depth = maxcdp; restchar(&f, 0); chartab[k] = csp; eschar = saveschar; xflag = savxflag; fmtchar--; return mkxfunc(CHAR, charcount); } static tchar setZ(void) { struct fmtchar f; int charcount; tchar i; if (ismot(i = getch())) return 0; if ((charcount = prepchar(&f)) < 0) return 0; stopch = i; charout[charcount].ch = FILLER | sfmask(stopch); text(); if (nlflg) nodelim(stopch); charout[charcount].ch = 0; restchar(&f, 1); return mkxfunc(CHAR, charcount); } tchar sfmask(tchar _t) { while (isxfunc(_t, CHAR)) _t = charout[sbits(_t)].ch; if (_t == XFUNC || _t == SLANT || (_t & SFMASK) == 0) return chbits; return _t & SFMASK; } int issame(tchar c, tchar _d) { if (ismot(c) || ismot(_d)) return 0; while (isxfunc(c, CHAR)) c = charout[sbits(c)].ch; while (isxfunc(_d, CHAR)) _d = charout[sbits(_d)].ch; if (cbits(c) != cbits(_d)) return 0; if (cbits(c) == XFUNC && cbits(_d) == XFUNC) return fbits(c) == fbits(_d); return 1; } static int setgA(void) { extern const char nmctab[]; tchar c, delim; int k, y = 1; lgf++; delim = getch(); if (ismot(delim)) { lgf--; return 0; } while (k = cbits(c = getch()), !issame(c, delim) && !nlflg) if (ismot(c) || (k < ' ' && nmctab[k]) || k == ' ' || k >= 0200) y = 0; if (nlflg) y = 0; lgf--; return y; } static int setB(void) { tchar c, delim; int y = 1; lgf++; delim = getch(); if (ismot(delim)) { lgf--; return 0; } atoi0(); if (nonumb) y = 0; do { c = getch(); if (!ismot(c) && issame(c, delim)) break; y = 0; } while (!nlflg); lgf--; return y; } void caseescoff(void) { _caseesc(1); } void caseescon(void) { _caseesc(0); } static void _caseesc(int off) { int c; if (skip(1)) return; while (1) { c = cbits(getch()); if (c < 32 || c > 126) errprint("Invalid character '%c' for .esc%s\n", c, off ? "off" : "on"); else escoff[c-32] = (unsigned char)off; if (skip(0)) return; } } Index: vendor/heirloom-doctools/dist/troff/n2.c =================================================================== --- vendor/heirloom-doctools/dist/troff/n2.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/n2.c (revision 310550) @@ -1,511 +1,511 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 1989 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* from OpenSolaris "n2.c 1.9 05/06/08 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)n2.c 1.47 (gritter) 5/25/08 */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved * * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. */ /* * n2.c * * output, cleanup */ #include #include #include #include #ifdef EUC #include #include #include #endif /* EUC */ #include "tdef.h" #ifdef NROFF #include "tw.h" #endif #include "pt.h" #include "ext.h" extern jmp_buf sjbuf; static int toolate; int error; static void outtp(tchar); int pchar(register tchar i) { register int j; static int hx = 0; /* records if have seen HX */ static int xon = 0; /* records if have seen XON */ static int drawfcn = 0; /* records if have seen DRAWFCN */ if (hx) { hx = 0; j = absmot(i); if (isnmot(i)) { if (j > dip->blss) dip->blss = j; } else { if (j > dip->alss) dip->alss = j; ralss = dip->alss; } return 1; } if (ismot(i)) { pchar1(i); return 1; } switch (j = cbits(i)) { case 0: case IMP: case RIGHT: case LEFT: if (xflag) { i = j = FILLER; /* avoid kerning in output routine */ goto dfl; } return 1; case HX: hx = 1; if (xflag) { i = j = FILLER; /* avoid kerning in output routine */ goto dfl; } return 1; case XON: xon = 1; goto dfl; case XOFF: xon = 0; goto dfl; case DRAWFCN: drawfcn = !drawfcn; goto dfl; case PRESC: if (dip == &d[0]) j = eschar; /* fall through */ default: dfl: #ifndef NROFF if (html) { if (!xflag || !isdi(i)) { setcbits(i, j >= NCHARS ? j : tflg ? trnttab[j] : trtab[j]); if (xon == 0 && drawfcn == 0 && i < NCHARS) setcbits(i, ftrans(fbits(i), cbits(i))); } } else #endif if (!xflag || !isdi(i)) { setcbits(i, tflg ? trnttab[j] : trtab[j]); if (xon == 0 && drawfcn == 0) setcbits(i, ftrans(fbits(i), cbits(i))); } } #ifdef NROFF if (xon && xflag) return 1; #endif /* NROFF */ pchar1(i); return 1; } void pchar1(register tchar i) { static int _olt; tchar _olp[1]; register int j; filep savip; - extern void ptout(tchar); - j = cbits(i); if (dip != &d[0]) { if (i == FLSS) dip->flss++; else if (dip->flss > 0) dip->flss--; else if (!ismot(i) && (cbits(i) > 32 || cbits(i) == XFUNC) && !tflg) i |= DIBIT; wbf(i); dip->op = offset; return; } if (!tflg && !print) { if (j == '\n') dip->alss = dip->blss = 0; return; } if (no_out) return; if (tflg) { /* transparent mode, undiverted */ outtp(i); return; } if (cbits(i) == XFUNC) { switch (fbits(i)) { case OLT: olt = realloc(olt, (nolt + 1) * sizeof *olt); _olt = 1; return; case CHAR: #ifndef NROFF if (!ascii) break; #endif /* !NROFF */ savip = ip; ip = charout[sbits(i)].op; app++; fmtchar++; while ((i = rbf()) != 0 && cbits(i) != '\n' && cbits(i) != FLSS) pchar(i); fmtchar--; app--; ip = savip; return; } } /* if (cbits(i) == 'x') fmtchar = fmtchar; */ if (_olt) { _olp[0] = i; olt[nolt++] = fetchrq(_olp); _olt = 0; } #ifndef NROFF if (ascii) outascii(i); else #endif ptout(i); } static void outtp(tchar i) { #ifndef NROFF int j = cbits(i); #ifdef EUC if (iscopy(i)) fdprintf(ptid, "%lc", j); else #endif /* EUC */ fdprintf(ptid, "%c", j); +#else + (void)i; #endif } #ifndef NROFF static void outmb(tchar i) { extern int nchtab; int j = cbits(i); #ifdef EUC wchar_t wc; char mb[MB_LEN_MAX+1]; int n; int f; #endif /* EUC */ if (j < 0177) { oput(j); return; } #ifdef EUC if (iscopy(i)) wc = cbits(i); else { if ((f = fbits(i)) == 0) f = font; wc = tr2un(j, f); } if (wc != -1 && (n = wctomb(mb, wc)) > 0) { mb[n] = 0; oputs(mb); } else #endif /* EUC */ if (j < 128 + nchtab) { oput('\\'); oput('('); oput(chname[chtab[j-128]]); oput(chname[chtab[j-128]+1]); } } void outascii ( /* print i in best-guess ascii */ tchar i ) { int j = cbits(i); int f = fbits(i); int k; if (j == FILLER) return; if (isadjspc(i)) return; if (ismot(i)) { oput(' '); return; } if ((j < 0177 && j >= ' ') || j == '\n') { oput(j); return; } if (f == 0) f = xfont; if (j == DRAWFCN) oputs("\\D"); else if (j == HYPHEN || j == MINUS) oput('-'); else if (j == XON) oputs("\\X"); else if (islig(i) && lgrevtab && lgrevtab[f] && lgrevtab[f][j]) { for (k = 0; lgrevtab[f][j][k]; k++) outmb(sfmask(i) | lgrevtab[f][j][k]); } else if (j == WORDSP) ; /* nothing at all */ else if (j > 0177) outmb(i); } #endif /* * now a macro oput(i) register int i; { *obufp++ = i; if (obufp >= &obuf[OBUFSZ]) flusho(); } */ void oputs(register const char *i) { while (*i != 0) oput(*i++&0377); } void flusho(void) { if (obufp == obuf) return; if (no_out == 0) { if (!toolate) { toolate++; #ifdef NROFF set_tty(); { char *p = t.twinit; while (*p++) ; if (p - t.twinit > 1) write(ptid, t.twinit, p - t.twinit - 1); } #endif } toolate += write(ptid, obuf, obufp - obuf); } obufp = obuf; } void caseoutput(void) { tchar i; copyf++; if (!skip(0)) { if (cbits(i = getch()) == '"') i = getch(); while (i != 0) { outtp(i); if (cbits(i) == '\n') break; i = getch(); } } copyf--; } void done(int x) { register int i; error |= x; dl = app = ds = lgf = 0; if (pgchars && !pglines) { donep = 1; tbreak(); donep = 0; } if ((i = em)) { donef = -1; em = 0; if (control(i, 0)) longjmp(sjbuf, 1); } if (!nfo) done3(0); mflg = 0; dip = &d[0]; if (woff) wbt((tchar)0); if (pendw) getword(1); pendnf = 0; if (donef == 1) done1(0); donef = 1; ip = 0; frame = stk; nxf = calloc(1, sizeof *nxf); if (!ejf) tbreak(); nflush++; eject((struct s *)0); longjmp(sjbuf, 1); } void done1(int x) { error |= x; if (numtab[NL].val) { trap = 0; eject((struct s *)0); longjmp(sjbuf, 1); } if (nofeed) { ptlead(); flusho(); done3(0); } else { pttrailer(); done2(0); } } void done2(int x) { ptlead(); #ifndef NROFF if (!ascii) ptstop(); #endif flusho(); done3(x); } void done3(int x) { error |= x; signal(SIGINT, SIG_IGN); signal(SIGTERM, SIG_IGN); #ifdef NROFF twdone(); #endif if (ascii) mesg(1); exit(error); } void edone(int x) { frame = stk; nxf = calloc(1, sizeof *nxf); ip = 0; done(x); } void casepi(void) { register pid_t i; int id[2]; if (skip(1)) return; if (toolate || !getname() || pipe(id) == -1 || (i = fork()) == -1) { errprint("Pipe not created."); return; } ptid = id[1]; if (i > 0) { close(id[0]); toolate++; pipeflg = i; return; } close(0); dup(id[0]); close(id[1]); execl(nextf, nextf, NULL); errprint("Cannot exec %s", nextf); exit(-4); } Index: vendor/heirloom-doctools/dist/troff/n3.c =================================================================== --- vendor/heirloom-doctools/dist/troff/n3.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/n3.c (revision 310550) @@ -1,2356 +1,2357 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* from OpenSolaris "n3.c 1.11 05/06/08 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)n3.c 1.181 (gritter) 10/23/09 */ /* * Changes Copyright (c) 2014 Steffen Nurpmeso */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved * * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. */ /* * troff3.c * * macro and string routines, storage allocation */ #include #include #include #include #include #include "tdef.h" #ifdef NROFF #include "tw.h" #endif #include "pt.h" #include "ext.h" #include #define MHASH(x) ((x>>6)^x)&0177 static struct contab **mhash; /* size must be 128 == the 0177 on line above */ #define blisti(i) (((i)-ENV_BLK*BLK) / BLK) static filep *blist; static int nblist; -static int pagech = '%'; +static size_t pagech = '%'; static int strflg; static tchar *wbuf; tchar *corebuf; struct contab *oldmn; struct contab *newmn; static void mrehash(struct contab *, int, struct contab **); static void _collect(int); static struct contab *_findmn(int, int, int); static void clrmn(struct contab *); static void caselds(void); static void casewatchlength(void); static void caseshift(void); static void casesubstring(void); static void caselength(void); static void caseindex(void); static void caseasciify(void); static void caseunformat(int); static int getls(int, int *, int); static void addcon(int, const char *, void(*)(int)); static const struct { const char *n; void (*f)(int); } longrequests[] = { { "aln", (void(*)(int))casealn }, { "als", (void(*)(int))caseals }, { "asciify", (void(*)(int))caseasciify }, { "bleedat", (void(*)(int))casebleedat }, { "blm", (void(*)(int))caseblm }, { "brnl", (void(*)(int))casebrnl }, { "brpnl", (void(*)(int))casebrpnl }, { "box", (void(*)(int))casebox}, { "boxa", (void(*)(int))caseboxa}, { "break", (void(*)(int))casebreak}, { "breakchar", (void(*)(int))casebreakchar }, { "brp", (void(*)(int))casebrp }, { "char", (void(*)(int))casechar }, { "chomp", (void(*)(int))casechomp }, { "chop", (void(*)(int))casechop }, { "close", (void(*)(int))caseclose }, { "connectchar", (void(*)(int))caseconnectchar }, { "continue", (void(*)(int))casecontinue }, { "cropat", (void(*)(int))casecropat }, { "dch", (void(*)(int))casedch }, { "dwh", (void(*)(int))casedwh }, { "ecs", (void(*)(int))caseecs }, { "ecr", (void(*)(int))caseecr }, { "errprint", (void(*)(int))caseerrprint }, { "escoff", (void(*)(int))caseescoff }, { "escon", (void(*)(int))caseescon }, { "evc", (void(*)(int))caseevc }, { "fallback", (void(*)(int))casefallback }, { "fchar", (void(*)(int))casefchar }, { "fdeferlig", (void(*)(int))casefdeferlig }, { "feature", (void(*)(int))casefeature }, { "fkern", (void(*)(int))casefkern }, { "flig", (void(*)(int))caseflig }, { "fps", (void(*)(int))casefps }, { "fspacewidth", (void(*)(int))casefspacewidth }, { "ftr", (void(*)(int))caseftr }, { "fzoom", (void(*)(int))casefzoom }, { "hcode", (void(*)(int))casehcode }, { "hidechar", (void(*)(int))casehidechar }, { "hlm", (void(*)(int))casehlm }, { "hylang", (void(*)(int))casehylang }, { "hylen", (void(*)(int))casehylen }, { "hypp", (void(*)(int))casehypp }, { "index", (void(*)(int))caseindex }, { "itc", (void(*)(int))caseitc }, { "kern", (void(*)(int))casekern }, { "kernafter", (void(*)(int))casekernafter }, { "kernbefore", (void(*)(int))casekernbefore }, { "kernpair", (void(*)(int))casekernpair }, { "lc_ctype", (void(*)(int))caselc_ctype }, { "lds", (void(*)(int))caselds }, { "length", (void(*)(int))caselength }, { "letadj", (void(*)(int))caseletadj }, { "lhang", (void(*)(int))caselhang }, { "lnr", (void(*)(int))caselnr }, { "lnrf", (void(*)(int))caselnrf }, { "lpfx", (void(*)(int))caselpfx }, { "lsm", (void(*)(int))caselsm }, { "mediasize", (void(*)(int))casemediasize }, { "minss", (void(*)(int))caseminss }, { "nhychar", (void(*)(int))casenhychar }, { "nop", (void(*)(int))casenop }, { "nrf", (void(*)(int))casenrf }, { "open", (void(*)(int))caseopen }, { "opena", (void(*)(int))caseopena }, { "output", (void(*)(int))caseoutput }, { "padj", (void(*)(int))casepadj }, { "papersize", (void(*)(int))casepapersize }, { "psbb", (void(*)(int))casepsbb }, { "pshape", (void(*)(int))casepshape }, { "pso", (void(*)(int))casepso }, { "rchar", (void(*)(int))caserchar }, { "recursionlimit", (void(*)(int))caserecursionlimit }, { "return", (void(*)(int))casereturn }, { "rhang", (void(*)(int))caserhang }, { "rnn", (void(*)(int))casernn }, { "sentchar", (void(*)(int))casesentchar }, { "shc", (void(*)(int))caseshc }, { "shift", (void(*)(int))caseshift }, { "spacewidth", (void(*)(int))casespacewidth }, { "spreadwarn", (void(*)(int))casespreadwarn }, { "substring", (void(*)(int))casesubstring }, { "tmc", (void(*)(int))casetmc }, { "track", (void(*)(int))casetrack }, { "transchar", (void(*)(int))casetranschar }, { "trimat", (void(*)(int))casetrimat }, { "trin", (void(*)(int))casetrin }, { "trnt", (void(*)(int))casetrnt }, { "unformat", (void(*)(int))caseunformat }, { "unwatch", (void(*)(int))caseunwatch }, { "unwatchn", (void(*)(int))caseunwatchn }, #ifdef NROFF { "utf8conv", (void(*)(int))caseutf8conv }, #endif { "vpt", (void(*)(int))casevpt }, { "warn", (void(*)(int))casewarn }, { "watch", (void(*)(int))casewatch }, { "watchlength", (void(*)(int))casewatchlength }, { "watchn", (void(*)(int))casewatchn }, { "while", (void(*)(int))casewhile }, { "write", (void(*)(int))casewrite }, { "writec", (void(*)(int))casewritec }, { "writem", (void(*)(int))casewritem }, { "xflag", (void(*)(int))casexflag }, { NULL, NULL } }; static void * _growcontab(struct contab **contp, int *NMp, struct contab ***hashp) { int i, j, inc = 256; ptrdiff_t sft; struct contab *onc; struct s *s; onc = *contp; if ((*contp = realloc(*contp, (*NMp+inc) * sizeof **contp)) == NULL) return NULL; memset(&(*contp)[*NMp], 0, inc * sizeof **contp); if (*NMp == 0) { if (contp == &contab) { for (i = 0; initcontab[i].f; i++) (*contp)[i] = initcontab[i]; for (j = 0; longrequests[j].f; j++) addcon(i++, longrequests[j].n, longrequests[j].f); } *hashp = calloc(128, sizeof **hashp); mrehash(*contp, inc, *hashp); } else { sft = (char *)*contp - (char *)onc; for (i = 0; i < 128; i++) if ((*hashp)[i]) (*hashp)[i] = (struct contab *) ((char *)((*hashp)[i]) + sft); for (i = 0; i < *NMp; i++) if ((*contp)[i].link) (*contp)[i].link = (struct contab *) ((char *)((*contp)[i].link) + sft); for (s = frame; s != stk; s = s->pframe) if (s->contp >= onc && s->contp < &onc[*NMp]) s->contp = (struct contab *) ((char *)(s->contp) + sft); for (i = 0; i <= dilev; i++) if (d[i].soff >= onc && d[i].soff < &onc[*NMp]) d[i].soff = (struct contab *) ((char *)(d[i].soff) + sft); } *NMp += inc; return *contp; } void * growcontab(void) { return _growcontab(&contab, &NM, &mhash); } void * growblist(void) { static tchar *_corebuf; int inc = 512; tchar *ocb; if ((blist = realloc(blist, (nblist+inc) * sizeof *blist)) == NULL) return NULL; memset(&blist[nblist], 0, inc * sizeof *blist); ocb = _corebuf; if ((_corebuf = realloc(_corebuf, ((ENV_BLK+nblist+inc+1) * BLK + 1) * sizeof *_corebuf)) == NULL) return NULL; if (ocb == NULL) memset(_corebuf, 0, ((ENV_BLK+1) * BLK + 1) * sizeof *_corebuf); corebuf = &_corebuf[1]; memset(&corebuf[(ENV_BLK+nblist+1) * BLK], 0, inc * BLK * sizeof *corebuf); if (wbuf) wbuf = (tchar *)((char *)wbuf + ((char *)corebuf-(char *)ocb)); nblist += inc; return blist; } void caseig(void) { register int i; register filep oldoff; oldoff = offset; offset = 0; i = copyb(); offset = oldoff; if (i != '.') control(i, 1); } void casern(void) { register int i, j; lgf++; skip(1); if ((i = getrq(0)) == 0) return; if ((oldmn = _findmn(i, 0, 0)) == NULL) { nosuch(i); return; } skip(1); j = getrq(1); clrmn(_findmn(j, 0, oldmn->flags & FLAG_LOCAL)); if (j) { munhash(oldmn); oldmn->rq = j; maddhash(oldmn); if (oldmn->flags & FLAG_WATCH) errprint("%s: %s%s renamed to %s", macname(lastrq), oldmn->flags & FLAG_LOCAL ? "local " : "", macname(i), macname(j)); } } static struct contab ** gethash(struct contab *mp) { struct s *sp; struct contab **mh; if (mp >= contab && mp < &contab[NM]) mh = mhash; else { sp = macframe(); if (mp >= sp->contab && mp < &sp->contab[sp->NM]) mh = sp->mhash; else mh = NULL; } return mh; } void maddhash(register struct contab *rp) { register struct contab **hp; struct contab **mh; if (rp->rq == 0) return; if ((mh = gethash(rp)) == NULL) return; hp = &mh[MHASH(rp->rq)]; rp->link = *hp; *hp = rp; } void munhash(register struct contab *mp) { register struct contab *p; register struct contab **lp; struct contab **mh; if (mp->rq == 0) return; if ((mh = gethash(mp)) == NULL) return; lp = &mh[MHASH(mp->rq)]; p = *lp; while (p) { if (p == mp) { *lp = p->link; p->link = 0; return; } lp = &p->link; p = p->link; } } static void mrehash(struct contab *contp, int n, struct contab **hashp) { register struct contab *p; register int i; for (i=0; i<128; i++) hashp[i] = 0; for (p=contp; p < &contp[n]; p++) p->link = 0; for (p=contp; p < &contp[n]; p++) { if (p->rq == 0) continue; i = MHASH(p->rq); p->link = hashp[i]; hashp[i] = p; } } void caserm(void) { struct contab *contp, *contt; int j, cnt = 0; lgf++; while (!skip(!cnt++)) { if ((j = getrq(2)) <= 0) continue; if ((contp = _findmn(j, 0, 0)) == NULL) continue; if (contp->als) { contt = _findmn(j, 1, contp->flags & FLAG_LOCAL); /* bugfix by S.N. */ if (contt != NULL && --contt->nlink <= 0) clrmn(contt); } if (contp->nlink > 0) contp->nlink--; if (contp->flags & FLAG_WATCH) errprint("%s: %s%s removed", macname(lastrq), contp->flags & FLAG_LOCAL ? "local " : "", macname(j)); if (contp->nlink <= 0) clrmn(contp); } lgf--; } void caseas(void) { app++; caseds(); } void caseds(void) { ds++; casede(); } void caseam(void) { app++; casede(); } static void caselds(void) { dl += macframe() != stk; caseds(); } void casede(void) { register int i, req; register filep savoff; int k, nlink; if (dip != d) wbfl(); req = '.'; lgf++; skip(1); if ((i = getrq(1)) == 0) goto de1; if ((offset = finds(i, 1, !ds)) == 0) goto de1; if (ds) copys(); else req = copyb(); wbfl(); if (oldmn != NULL && (nlink = oldmn->nlink) > 0) k = oldmn->rq; else { k = i; nlink = 0; } clrmn(oldmn); if (newmn != NULL) { if (newmn->rq) munhash(newmn); newmn->rq = k; newmn->nlink = nlink; newmn->flags &= ~FLAG_DIVERSION; if (ds) newmn->flags |= FLAG_STRING; else newmn->flags &= ~FLAG_STRING; maddhash(newmn); prwatch(newmn, i, 1); } else if (apptr) prwatch(findmn(i), i, 1); if (apptr) { savoff = offset; offset = apptr; wbt((tchar) IMP); offset = savoff; } offset = dip->op; if (req != '.') control(req, 1); de1: ds = app = 0; return; } static struct contab * -findmn1(struct contab **hashp, register int i, int als) +findmn1(struct contab **hashp, size_t i, int als) { register struct contab *p; for (p = hashp[MHASH(i)]; p; p = p->link) if (i == p->rq) { if (als && p->als) return(findmn1(hashp, p->als, als)); return(p); } return(NULL); } static struct contab * _findmn(register int i, int als, int forcelocal) { struct s *s; struct contab *contp; s = macframe(); if (forcelocal || (s != stk && s->mhash)) { if (s->mhash == NULL) return NULL; if ((contp = findmn1(s->mhash, i, als)) != NULL) return contp; if (forcelocal) return NULL; } return findmn1(mhash, i, als); } struct contab * findmn(int i) { return _findmn(i, 1, 0); } struct contab * findmx(int i) { return findmn1(mhash, i, 1); } void clrmn(struct contab *contp) { struct s *s; if (contp != NULL) { if (contp->flags & FLAG_USED) { if (warn & WARN_MAC) errprint("Macro %s removed while in use", macname(contp->rq)); for (s = frame; s != stk; s = s->pframe) if (s->contp == contp) s->contp = NULL; } else if (contp->mx) ffree((filep)contp->mx); munhash(contp); memset(contp, 0, sizeof *contp); contp->rq = 0; contp->mx = 0; contp->f = 0; contp->als = 0; contp->nlink = 0; } } /* * Note: finds() may invalidate the result of a previous findmn() * for another macro since it may call growcontab(). */ filep finds(register int mn, int als, int globonly) { register tchar i; register filep savip; enum flags flags = 0; struct s *s; struct contab **contp, ***hashp; int *NMp; oldmn = _findmn(mn, als, dl); newmn = NULL; apptr = (filep)0; if (oldmn != NULL) flags = oldmn->flags; if (globonly && (dl || (oldmn && oldmn->flags & FLAG_LOCAL))) { errprint("refusing to create local %s %s", diflg || (oldmn && oldmn->flags & FLAG_DIVERSION) ? "diversion" : "macro", macname(mn)); app = 0; return(0); } if (app && oldmn != NULL && oldmn->mx) { savip = ip; ip = (filep)oldmn->mx; oldmn = NULL; while ((i = rbf()) != 0) { if (!diflg && istail(i)) corebuf[ip - 1] &= ~(tchar)TAILBIT; } apptr = ip; if (!diflg) ip = incoff(ip); nextb = ip; ip = savip; } else { if (oldmn && oldmn->flags & FLAG_LOCAL) dl++; if (dl && (s = macframe()) != stk) { contp = &s->contab; NMp = &s->NM; hashp = &s->mhash; } else { dl = 0; contp = &contab; NMp = &NM; hashp = &mhash; } for (i = 0; i < *NMp; i++) { if ((*contp)[i].rq == 0) break; } nextb = 0; if ((i == *NMp && _growcontab(contp, NMp, hashp) == NULL) || (als && (nextb = alloc()) == 0)) { app = 0; if (macerr++ > 1) done2(02); errprint("Too many (%d) string/macro names", NM); edone(04); return(als ? offset = 0 : 0); } oldmn = _findmn(mn, als, dl); (*contp)[i].mx = (unsigned) nextb; newmn = &(*contp)[i]; if (!diflg) { if (oldmn == NULL) newmn->rq = -1; } else { newmn->rq = mn; maddhash(newmn); } newmn->flags = flags&(FLAG_WATCH|FLAG_STRING|FLAG_DIVERSION); if (dl) newmn->flags |= FLAG_LOCAL; } dl = app = 0; return(als ? offset = nextb : 1); } int skip (int required) /*skip over blanks; return nlflg*/ { register tchar i; while (cbits(i = getch()) == ' ') ; ch = i; if (nlflg && required) missing(); return(nlflg); } int copyb(void) { register int i, j, state; register tchar ii; int req; filep savoff = 0, tailoff = 0; tchar tailc = 0; const char *contp; char *mn; if (skip(0) || !(j = getrq(1))) j = '.'; req = j; contp = macname(req); mn = strdup(contp); copyf++; flushi(); nlflg = 0; state = 1; /* state 0 eat up * state 1 look for . * state 2 look for chars of end macro */ while (1) { i = cbits(ii = getch()); if (state == 2 && mn[j] == 0) { ch = ii; if (!getach()) break; state = 0; goto c0; } if (i == '\n') { state = 1; nlflg = 0; tailoff = offset; tailc = ii; ii &= ~(tchar)TAILBIT; goto c0; } if (state == 1 && i == '.') { state++; savoff = offset; j = 0; goto c0; } if (state == 2) { if (i == mn[j]) { j++; goto c0; } else if (i == ' ' || i == '\t') { goto c0; } } state = 0; c0: if (offset) wbf(ii); } if (offset) { wbfl(); offset = savoff; wbt((tchar)0); if (tailoff) { offset = tailoff; wbt(tailc | TAILBIT); } } copyf--; free(mn); return(req); } void copys(void) { register tchar i; copyf++; if (skip(0)) goto c0; if (cbits(i = getch()) != '"') wbf(i); while (cbits(i = getch()) != '\n') wbf(i); c0: wbt((tchar)0); copyf--; } filep alloc (void) /*return free blist[] block in nextb*/ { register int i; register filep j; do { for (i = 0; i < nblist; i++) { if (blist[i] == 0) break; } } while (i == nblist && growblist() != NULL); if (i == nblist) { j = 0; } else { blist[i] = -1; j = (filep)i * BLK + ENV_BLK * BLK; } #ifdef DEBUG if (debug & DB_ALLC) { char cc1, cc2; fprintf(stderr, "alloc: "); if (oldmn != NULL) { cc1 = oldmn->rq & 0177; if ((cc2 = (oldmn->rq >> BYTE) & 0177) == 0) cc2 = ' '; fprintf(stderr, "oldmn %p %c%c, ", oldmn, cc1, cc2); } fprintf(stderr, "newmn %p; nextb was %lx, will be %lx\n", newmn, (long)nextb, (long)j); } #endif /* DEBUG */ return(nextb = j); } void ffree ( /*free blist[i] and blocks pointed to*/ filep i ) { register int j; while (blist[j = blisti(i)] != (int) ~0) { i = (filep) blist[j]; blist[j] = 0; } blist[j] = 0; } void wbt(tchar i) { wbf(i); wbfl(); } void wbf ( /*store i into blist[offset] (?) */ register tchar i ) { register int j; if (!offset) return; if (!woff) { woff = offset; wbuf = &corebuf[woff]; wbfi = 0; } wbuf[wbfi++] = i; if (!((++offset) & (BLK - 1))) { wbfl(); j = blisti(--offset); if (j < 0 || (j >= nblist && growblist() == NULL)) { errprint("Out of temp file space"); done2(01); } if (blist[j] == (int) ~0) { if (alloc() == 0) { errprint("Out of temp file space"); done2(01); } blist[j] = (unsigned)(nextb); } offset = ((filep)blist[j]); } if (wbfi >= BLK) wbfl(); } void wbfl (void) /*flush current blist[] block*/ { if (woff == 0) return; if ((woff & (~(BLK - 1))) == (roff & (~(BLK - 1)))) roff = -1; woff = 0; } tchar rbf (void) /*return next char from blist[] block*/ { register tchar i; register filep j, p; if (ip == -1) { /* for rdtty */ if ((j = rdtty())) return(j); else return(popi()); } if (ip == -2) { errprint("Bad storage while processing paragraph"); ip = 0; done2(-5); } /* this is an inline expansion of rbf0: dirty! */ i = corebuf[ip]; /* end of rbf0 */ if (i == 0) { if (!app) i = popi(); return(i); } /* this is an inline expansion of incoff: also dirty */ p = ++ip; if ((p & (BLK - 1)) == 0) { if ((ip = blist[blisti(p-1)]) == (int) ~0) { errprint("Bad storage allocation"); ip = 0; done2(-5); } /* this was meant to protect against people removing * the macro they were standing on, but it's too * sensitive to block boundaries. * if (ip == 0) { * errprint("Block removed while in use"); * done2(-6); * } */ } return(i); } tchar rbf0(register filep p) { return(corebuf[p]); } filep incoff ( /*get next blist[] block*/ register filep p ) { p++; if ((p & (BLK - 1)) == 0) { if ((p = blist[blisti(p-1)]) == (int) ~0) { errprint("Bad storage allocation"); done2(-5); } } return(p); } tchar popi(void) { register struct s *p; tchar c, _d; if (frame == stk) return(0); if (strflg) strflg--; p = frame; sfree(p); if (p->contp != NULL) p->contp->flags &= ~FLAG_USED; frame = p->pframe; ip = p->pip; pendt = p->ppendt; lastpbp = p->lastpbp; c = p->pch; if (p->loopf & LOOP_NEXT) { _d = ch; ch = c; pushi(p->newip, p->mname, p->flags); c = 0; ch = _d; } else if (p->loopf & LOOP_FREE) ffree(p->newip); free(p); if (frame->flags & FLAG_PARAGRAPH) longjmp(*frame->jmp, 1); return(c); } int pushi(filep newip, int mname, enum flags flags) { register struct s *p; p = nxf; p->pframe = frame; p->pip = ip; p->ppendt = pendt; p->pch = ch; p->lastpbp = lastpbp; p->mname = mname; p->flags = flags; if (mname != LOOP) { p->frame_cnt = frame->frame_cnt + 1; p->tail_cnt = frame->tail_cnt + 1; } else { p->frame_cnt = frame->frame_cnt; p->tail_cnt = frame->tail_cnt; p->loopf = LOOP_EVAL; } p->newip = newip; lastpbp = pbp; pendt = ch = 0; frame = nxf; nxf = calloc(1, sizeof *nxf); return(ip = newip); } void sfree(struct s *p) { int i; if (p->nargs > 0) { free(p->argt); free(p->argsp); } free(p->numtab); free(p->nhash); if (p->contab) { for (i = 0; i < p->NM; i++) if (p->contab[i].mx > 0) ffree((filep)p->contab[i].mx); free(p->contab); free(p->mhash); } } struct s * macframe(void) { struct s *p; for (p = frame; p != stk && (p->flags & (FLAG_STRING|FLAG_DIVERSION) || p->loopf); p = p->pframe); return(p); } static int _getsn(int *strp, int create) { register int i; if ((i = getach()) == 0) return(0); if (i == '(') return(getrq2()); else if (i == '[' && xflag > 1) return(getls(']', strp, create)); else return(i); } int getsn(int create) { return _getsn(0, create); } int setstr(void) { struct contab *contp; register int i, k; int space = 0; tchar c; lgf++; if ((i = _getsn(&space, 0)) == 0 || (contp = findmn(i)) == NULL || !contp->mx) { if (space) { do { if (cbits(c = getch()) == ']') break; } while (!nlflg); if (nlflg) nodelim(']'); } nosuch(i); lgf--; return(0); } else { if (space) _collect(']'); else nxf->nargs = 0; strflg++; lgf--; contp->flags |= FLAG_USED; k = pushi((filep)contp->mx, i, contp->flags); frame->contp = contp; return(k); } } void collect(void) { _collect(0); } static void _collect(int termc) { register tchar i = 0; int at = 0, asp = 0; int nt = 0, nsp = 0, nsp0; int quote, right; struct s *savnxf; copyf++; nxf->nargs = 0; nxf->argt = NULL; nxf->argsp = NULL; savnxf = nxf; nxf = calloc(1, sizeof *nxf); if (skip(0)) goto rtn; strflg = 0; while (!skip(0)) { if (nt >= at) savnxf->argt = realloc(savnxf->argt, (at += 10) * sizeof *savnxf->argt); savnxf->argt[nt] = nsp0 = nsp; /* CK: Bugfix: \} counts \n(.$ */ quote = right = 0; if (cbits(i = getch()) == '"') quote++; else ch = i; while (1) { i = getch(); if (termc && !quote && i == termc) { if (nsp >= asp) savnxf->argsp = realloc(savnxf->argsp, ++asp * sizeof *savnxf->argsp); nt++; savnxf->argsp[nsp++] = 0; goto rtn; } if (nlflg || (!quote && cbits(i) == ' ')) break; if ( quote && (cbits(i) == '"') && (cbits(i = getch()) != '"')) { ch = i; break; } if (nsp >= asp) savnxf->argsp = realloc(savnxf->argsp, (asp += 200) * sizeof *savnxf->argsp); if (cbits(i) == RIGHT) /* CK: Bugfix: \} counts \n(.$ */ right = 1; else savnxf->argsp[nsp++] = i; } if (nsp >= asp) savnxf->argsp = realloc(savnxf->argsp, ++asp * sizeof *savnxf->argsp); if (!right || nsp != nsp0) { /* CK: Bugfix: \} counts \n(.$ */ nt++; savnxf->argsp[nsp++] = 0; } } rtn: if (termc && i != termc) nodelim(termc); free(nxf); nxf = savnxf; nxf->nargs = nt; copyf--; } void seta(void) { register int c, i; char q[] = { 0, 0 }; struct s *s; for (s = frame; s != stk; s = s->pframe) { if (s->loopf) continue; if (gflag && s->contp && s->contp->flags & FLAG_STRING && s->nargs == 0) continue; break; } switch (c = cbits(getch())) { case '@': q[0] = '"'; /*FALLTHRU*/ case '*': if (xflag == 0) goto dfl; for (i = s->nargs; i >= 1; i--) { if (q[0]) cpushback(q); pushback(&s->argsp[s->argt[i - 1]]); if (q[0]) cpushback(q); if (i > 1) cpushback(" "); } break; case '(': if (xflag == 0) goto dfl; c = cbits(getch()); i = 10 * (c - '0'); c = cbits(getch()); i += c - '0'; goto assign; case '[': if (xflag == 0) goto dfl; i = 0; while ((c = cbits(getch())) != ']' && c != '\n' && c != 0) i = 10 * i + (c - '0'); goto assign; default: dfl: i = c - '0'; assign: if (i > 0 && i <= s->nargs) pushback(&s->argsp[s->argt[i - 1]]); else if (i == 0) cpushback(macname(s->mname)); } } static void caseshift(void) { int i, j; struct s *s; for (s = frame; s->loopf && s != stk; s = s->pframe); if (skip(0)) i = 1; else { noscale++; i = hatoi(); noscale--; if (nonumb) return; } if (i > 0 && i <= s->nargs) { s->nargs -= i; for (j = 1; j <= s->nargs; j++) s->argt[j - 1] = s->argt[j + i - 1]; } } void casebox(void) { casedi(1); } void caseboxa(void) { caseda(1); } void caseda(int box) { app++; casedi(box); } void casedi(int box) { register int i, j; register int *k; int nlink; lgf++; if (skip(0) || (i = getrq(1)) == 0) { if (dip != d) wbt((tchar)0); if (dilev > 0) { #ifdef DEBUG if (debug & DB_MAC) fprintf(stderr, "ending diversion %s\n", macname(dip->curd)); #endif /* DEBUG */ numtab[DN].val = dip->dnl; numtab[DL].val = dip->maxl; prwatchn(&numtab[DN]); prwatchn(&numtab[DL]); if (dip->boxenv) { relsev(&env); env = *dip->boxenv; free(dip->boxenv); } prwatch(dip->soff, dip->curd, 1); dip = &d[--dilev]; offset = dip->op; } else if (warn & WARN_DI) errprint(".di outside active diversion"); goto rtn; } #ifdef DEBUG if (debug & DB_MAC) fprintf(stderr, "starting diversion %s\n", macname(i)); #endif /* DEBUG */ if (++dilev == NDI) { struct d *nd; const int inc = 5; if ((nd = realloc(d, (NDI+inc) * sizeof *d)) == NULL) { --dilev; errprint("Diversions nested too deep"); edone(02); } d = nd; memset(&d[NDI], 0, inc * sizeof *d); NDI += inc; } if (dip != d) wbt((tchar)0); diflg++; dip = &d[dilev]; if ((dip->op = finds(i, 1, 1)) == 0) { dip = &d[--dilev]; goto rtn; } dip->curd = i; if (newmn && oldmn != NULL && (nlink = oldmn->nlink) > 0) { munhash(newmn); j = oldmn->rq; } else { j = i; nlink = 0; } clrmn(oldmn); if (newmn) { newmn->rq = j; newmn->nlink = nlink; newmn->flags &= ~FLAG_STRING; newmn->flags |= FLAG_DIVERSION; if (i != j) maddhash(newmn); prwatch(newmn, i, 0); } dip->soff = newmn; k = &dip->dnl; dip->flss = 0; for (j = 0; j < 10; j++) k[j] = 0; /*not op and curd*/ memset(dip->mlist, 0, sizeof dip->mlist); memset(dip->nlist, 0, sizeof dip->nlist); if (box) { dip->boxenv = malloc(sizeof *dip->boxenv); *dip->boxenv = env; evc(&env, &env); } else dip->boxenv = 0; rtn: app = 0; diflg = 0; } void casedt(void) { lgf++; dip->dimac = dip->ditrap = dip->ditf = 0; skip(0); dip->ditrap = vnumb((int *)0); if (nonumb) return; skip(0); dip->dimac = getrq(1); } void caseals(void) { struct contab *contp; int i, j, _t; int flags = 0; if (skip(1)) return; i = getrq(1); if (skip(1)) return; j = getrq(1); if ((contp = findmn(j)) == NULL) { nosuch(j); return; } if (contp->nlink == 0) { munhash(contp); _t = makerq(NULL); contp->rq = _t; maddhash(contp); if (contp->flags & FLAG_LOCAL) dl++; if (finds(j, 0, 0) != 0 && newmn) { newmn->als = _t; newmn->rq = j; maddhash(newmn); contp->nlink = 1; } } else _t = j; if (contp->flags & FLAG_LOCAL) dl++; if (finds(i, 0, !dl) != 0) { if (oldmn != NULL && newmn != NULL) flags = oldmn->flags | newmn->flags; flags &= FLAG_WATCH|FLAG_STRING|FLAG_DIVERSION; clrmn(oldmn); if (newmn) { if (newmn->rq) munhash(newmn); newmn->als = _t; newmn->rq = i; newmn->flags |= flags; maddhash(newmn); contp = findmn(j); contp->nlink++; if (flags & FLAG_WATCH) errprint("%s: creating alias %s to %s%s %s", macname(lastrq), contp->flags & FLAG_LOCAL ? "local " : "", contp->flags & FLAG_STRING ? "string" : contp->flags & FLAG_DIVERSION ? "diversion" : "macro", macname(i), macname(j)); } } } void casewatch(int unwatch) { struct contab *contp; int j; lgf++; if (skip(1)) return; do { if (!(j = getrq(1))) break; if ((contp = findmn(j)) == NULL) { if (finds(j, 0, 0) == 0 || newmn == NULL) continue; if (newmn->rq) munhash(newmn); newmn->rq = j; maddhash(newmn); contp = newmn; } if (unwatch) contp->flags &= ~FLAG_WATCH; else contp->flags |= FLAG_WATCH; } while (!skip(0)); } void caseunwatch(void) { casewatch(1); } static int watchlength = 30; static void casewatchlength(void) { int i; if (!skip(1)) { noscale++; i = hatoi(); noscale--; if (!nonumb) watchlength = i; if (watchlength < 0) watchlength = 0; } } void prwatch(struct contab *contp, int rq, int prc) { const char prtab[] = { 'a',000,000,000,000,000,000,000, 'b','t','n',000,000,000,000,000, '{','}','&',000,'%','c','e',' ', '!',000,000,000,000,000,000,'~', 000 }; char *buf = NULL; const char *local; filep savip; tchar c; int j, k; if (contp == NULL) return; if (rq == 0) rq = contp->rq; local = contp->flags & FLAG_LOCAL ? "local " : ""; if (contp->flags & FLAG_WATCH) { if (watchlength <= 10 || !prc) { errprint("%s: %s%s %s redefined", macname(lastrq), local, contp->flags & FLAG_STRING ? "string" : contp->flags & FLAG_DIVERSION ? "diversion" : "macro", macname(rq)); return; } savip = ip; ip = (filep)contp->mx; app++; j = 0; buf = malloc(watchlength); while ((c = rbf()) != 0) { while (isxfunc(c, CHAR)) c = charout[sbits(c)].ch; if (iscopy(c) && (k = wctomb(&buf[j], cbits(c))) > 0) j += k; else if (ismot(c)) buf[j++] = '?'; else if ((k = cbits(c)) < 0177) { if (isprint(k)) buf[j++] = k; else if (istrans(c)) { buf[j++] = '\\'; buf[j++] = ')'; } else if (k < ' ' && prtab[k]) { buf[j++] = '\\'; buf[j++] = prtab[k]; } else if (k < ' ') { buf[j++] = '^'; buf[j++] = k + 0100; } else buf[j++] = '?'; } else if (k == ACUTE) buf[j++] = '\''; else if (k == GRAVE) buf[j++] = '`'; else if (j == UNDERLINE) buf[j++] = '_'; else if (j == MINUS) buf[j++] = '-'; else buf[j++] = '?'; if (j >= watchlength - 5 - mb_cur_max) { buf[j++] = '.'; buf[j++] = '.'; buf[j++] = '.'; break; } } buf[j] = 0; ip = savip; app--; errprint("%s: %s%s %s redefined to \"%s\"", macname(lastrq), local, contp->flags & FLAG_STRING ? "string" : contp->flags & FLAG_DIVERSION ? "diversion" : "macro", macname(rq), buf); free(buf); } } void casetl(void) { register int j; int w[3]; tchar *buf = NULL; int bufsz = 0; register tchar *tp; tchar i, delim, nexti; int oev; dip->nls = 0; skip(1); if (ismot(delim = getch())) { ch = delim; delim = '\''; } else delim = cbits(delim); noschr = 0; argdelim = delim; bufsz = LNSIZE; buf = malloc(bufsz * sizeof *buf); tp = buf; numtab[HP].val = 0; w[0] = w[1] = w[2] = 0; j = 0; nexti = getch(); while (cbits(i = nexti) != '\n') { if (cbits(i) == cbits(delim)) { if (j < 3) w[j] = numtab[HP].val; numtab[HP].val = 0; j++; *tp++ = 0; nexti = getch(); } else { if (cbits(i) == pagech) { setn1(numtab[PN].val, findr('%')->fmt, sfmask(i)); nexti = getch(); continue; } numtab[HP].val += width(i); oev = ev; nexti = getch(); if (ev == oev) numtab[HP].val += kernadjust(i, nexti); if (tp >= &buf[bufsz-10]) { tchar *k; bufsz += 100; k = realloc(buf, bufsz * sizeof *buf); tp = (tchar *) ((char *)tp + ((char *)k - (char *)buf)); buf = k; } *tp++ = i; } } argdelim = 0; if (j<3) w[j] = numtab[HP].val; *tp++ = 0; *tp++ = 0; *tp++ = 0; tp = buf; #ifdef NROFF horiz(po); #endif while ((i = *tp++)) pchar(i); if (w[1] || w[2]) { #ifdef NROFF if (gemu) horiz(j = quant((lt + HOR - w[1]) / 2 - w[0], HOR)); else #endif horiz(j = quant((lt - w[1]) / 2 - w[0], HOR)); } while ((i = *tp++)) pchar(i); if (w[2]) { horiz(lt - w[0] - w[1] - w[2] - j); while ((i = *tp++)) pchar(i); } newline(0); if (dip != d) { if (dip->dnl > dip->hnl) dip->hnl = dip->dnl; } else { if (numtab[NL].val > dip->hnl) dip->hnl = numtab[NL].val; } free(buf); } void casepc(void) { pagech = chget(IMP); } void casechop(void) { int i; struct contab *contp; filep savip; if (dip != d) wbfl(); lgf++; skip(1); if ((i = getrq(0)) == 0) return; if ((contp = findmn(i)) == NULL || !contp->mx) { nosuch(i); return; } savip = ip; ip = (filep)contp->mx; app = 1; while (rbf() != 0); app = 0; if (ip > (filep)contp->mx) { offset = ip - 1; wbt(0); } ip = savip; offset = dip->op; prwatch(contp, i, 1); } void casesubstring(void) { struct contab *contp; int i, j, k, sz = 0, st; int n1, n2 = -1, nlink; tchar *tp = NULL, c; filep savip; if (dip != d) wbfl(); lgf++; skip(1); if ((i = getrq(0)) == 0) return; if ((contp = findmn(i)) == NULL || !contp->mx) { nosuch(i); return; } if (skip(1)) return; noscale++; n1 = hatoi(); if (skip(0) == 0) n2 = hatoi(); noscale--; savip = ip; ip = (filep)contp->mx; k = 0; app = 1; while ((c = rbf()) != 0) { if (k >= sz) { sz += 512; tp = realloc(tp, sz * sizeof *tp); } tp[k++] = c; } app = 0; ip = savip; if ((offset = finds(i, 1, 0)) != 0) { st = 0; if (n1 < 0) n1 = k + n1; if (n2 < 0) n2 = k + n2; if (n1 >= 0 || n2 >= 0) { if (n2 < n1) { j = n1; n1 = n2; n2 = j; } for (j = 0; j <= k; j++) { if (st == 0) { if (j >= n1) st = 1; } if (st == 1) { if (tp) wbf(tp[j]); if (j >= n2) break; } } } wbt(0); if (oldmn != NULL && (nlink = oldmn->nlink) > 0) k = oldmn->rq; else { k = i; nlink = 0; } clrmn(oldmn); if (newmn) { if (newmn->rq) munhash(newmn); newmn->rq = k; newmn->nlink = nlink; maddhash(newmn); prwatch(newmn, i, 1); } } free(tp); offset = dip->op; ip = savip; } void caselength(void) { tchar c; int i, j; struct numtab *numtp; lgf++; skip(1); if ((i = getrq(1)) == 0) return; j = 0; lgf--; copyf++; if (skip(1) == 0) { if (cbits(c = getch()) != '"' || ismot(c)) ch = c; while(cbits(getch()) != '\n') j++; } copyf--; numtp = findr(i); numtp->val = j; prwatchn(numtp); } void caseindex(void) { int i, j, n, N; struct contab *contp; - int *sp = NULL, as = 0, ns = 0, *np; + size_t *sp = NULL; + int as = 0, ns = 0, *np; tchar c; filep savip; struct numtab *numtp; lgf++; skip(1); if ((N = getrq(1)) == 0) return; skip(1); if ((i = getrq(1)) == 0) return; if ((contp = findmn(i)) == NULL || !contp->mx) { nosuch(i); return; } copyf++; if (!skip(0)) { if (cbits(c = getch()) != '"' || ismot(c)) ch = c; while ((c = getch()) != 0 && !ismot(c) && (i = cbits(c)) != '\n') { if (ns >= as) sp = realloc(sp, (as += 10) * sizeof *sp); sp[ns++] = i; } np = malloc((ns + 1) * sizeof *np); i = 0; j = -1; for (;;) { np[i++] = j++; if (i >= ns) break; while (j >= 0 && sp[i] != sp[j]) j = np[j]; } savip = ip; ip = (filep)contp->mx; app = 1; j = 0; n = 0; while ((c = rbf()) != 0 && j < ns) { while (j >= 0 && cbits(c) != sp[j]) j = np[j]; j++; n++; } n = j == ns ? n - ns : -1; app = 0; ip = savip; free(sp); free(np); } else n = -1; copyf--; numtp = findr(N); numtp->val = n; prwatchn(numtp); } static void caseasciify(void) { caseunformat(1); } static void caseunformat(int flag) { struct contab *contp; int i, j, k, nlink; int ns = 0, as = 0; tchar *tp = NULL, c; filep savip; int noout = 0; if (dip != d) wbfl(); lgf++; skip(1); if ((i = getrq(0)) == 0) return; if ((contp = findmn(i)) == NULL || !contp->mx) { nosuch(i); return; } savip = ip; ip = (filep)contp->mx; ns = 0; app = 1; while ((c = rbf()) != 0) { if (ns >= as) { as += 512; tp = realloc(tp, as * sizeof *tp); } tp[ns++] = c; } app = 0; ip = savip; if ((offset = finds(i, 1, 0)) != 0) { for (j = 0; j < ns; j++) { if (!ismot(c) && cbits(c) == '\n') noout = 0; else if (j+1 < ns && isxfunc(tp[j+1], HYPHED)) noout = 1; c = tp[j]; while (flag & 1 && isxfunc(c, CHAR)) c = charout[sbits(c)].ch; if (isadjspc(c)) { if (cbits(c) == WORDSP) setcbits(c, ' '); c &= ~ADJBIT; } else if (c == WORDSP) { j++; continue; } else if (c == FLSS) { j++; continue; } else if (cbits(c) == XFUNC) { switch (fbits(c)) { case FLDMARK: if ((c = sbits(c)) == 0) continue; break; case LETSP: case NLETSP: case LETSH: case NLETSH: case INDENT: continue; } } else if (isadjmot(c)) continue; else if (cbits(c) == PRESC) { if (!noout) { wbf(eschar); wbf('e'); } continue; } if (flag & 1 && !ismot(c) && cbits(c) != SLANT) { #ifndef NROFF int m = cbits(c); int f = fbits(c); int k; if (islig(c) && lgrevtab && lgrevtab[f] && lgrevtab[f][m]) { for (k = 0; lgrevtab[f][m][k]; k++) if (!noout) wbf(lgrevtab[f][m][k]); continue; } else #endif c = cbits(c); } if (flag & 1 && !ismot(c) && (k = trintab[c]) != 0) c = k; if (!noout) wbf(c); } wbt(0); if (oldmn != NULL && (nlink = oldmn->nlink) > 0) k = oldmn->rq; else { k = i; nlink = 0; } clrmn(oldmn); if (newmn) { if (newmn->rq) munhash(newmn); newmn->rq = k; newmn->nlink = nlink; maddhash(newmn); prwatch(newmn, i, 1); } } free(tp); offset = dip->op; } /* * Tables for names with more than two characters. Any number in * contab.rq or numtab.rq that is greater or equal to MAXRQ2 refers * to a long name. */ #define MAXRQ2 0200000 static struct map { struct map *link; int n; } *map[128]; -static char **had; +static const char **had; static int hadn; static int alcd; #define maphash(cp) (_pjw(cp) & 0177) static unsigned _pjw(const char *cp) { unsigned h = 0, g; cp--; while (*++cp) { h = (h << 4 & 0xffffffff) + (*cp&0377); if ((g = h & 0xf0000000) != 0) { h = h ^ g >> 24; h = h ^ g; } } return h; } static int mapget(const char *cp) { int h = maphash(cp); struct map *mp; for (mp = map[h]; mp; mp = mp->link) if (strcmp(had[mp->n], cp) == 0) return mp->n; return hadn; } static void mapadd(const char *cp, int n) { int h = maphash(cp); struct map *mp; mp = calloc(1, sizeof *mp); mp->n = n; mp->link = map[h]; map[h] = mp; } void casepm(void) { struct contab *contp; register int i, k; int xx, cnt, tcnt, kk, tot; filep j; kk = cnt = tcnt = 0; tot = !skip(0); for (i = 0; i < NM; i++) { if ((xx = contab[i].rq) == 0 || contab[i].mx == 0) { if (contab[i].als && (contp = findmx(xx)) != NULL) { k = contp - contab; if (contab[k].rq == 0 || contab[k].mx == 0) continue; } else continue; } tcnt++; if (contab[i].als == 0 && (j = (filep) contab[i].mx) != 0) { k = 1; - while ((j = blist[blisti(j)]) != (unsigned) ~0) { + while ((j = blist[blisti(j)]) != (int) ~0) { k++; } cnt++; } else k = 0; kk += k; if (!tot && contab[i].nlink == 0) fprintf(stderr, "%s %d\n", macname(xx), k); } fprintf(stderr, "pm: total %d, macros %d, space %d\n", tcnt, cnt, kk); } void stackdump (void) /* dumps stack of macros in process */ { struct s *p; if (frame != stk) { for (p = frame; p != stk; p = p->pframe) if (p->mname != LOOP) fprintf(stderr, "%s ", macname(p->mname)); fprintf(stderr, "\n"); } } static char laststr[NC+1]; const char * macname(int rq) { static char buf[4][3]; static int i; if (rq < 0) { return laststr; } else if (rq < MAXRQ2) { i &= 3; buf[i][0] = rq&0177; buf[i][1] = (rq>>BYTE)&0177; buf[i][2] = 0; return buf[i++]; } else if (rq - MAXRQ2 < hadn) return had[rq - MAXRQ2]; else return "???"; } const char nmctab[] = { 000,000,000,000,000,000,000,000, 000,000,000,000,000,000,000,000, 001,002,003,000,004,005,000,006, 000,000,000,000,000,000,000,000, 000 }; static tchar mgetach(void) { tchar i; size_t j; lgf++; i = getch(); while (isxfunc(i, CHAR)) i = charout[sbits(i)].ch; j = cbits(i); if (ismot(i) || j == ' ' || j == '\n' || j >= 0200 || (j < sizeof nmctab && nmctab[j])) { if (!ismot(i) && j >= 0200) illseq(j, NULL, -3); ch = i; j = 0; } lgf--; return j & 0177; } /* * To handle requests with more than two characters, an additional * table is maintained. On places where more than two characters are * allowed, the characters collected are passed in "sofar", and "flags" * specifies whether the request is a new one. The routine returns an * integer which is above the regular PAIR() values. */ int maybemore(int sofar, int flags) { char c, buf[NC+1], pb[] = { '\n', 0 }; int n, _raw = raw, _init = init, _app = app; size_t i = 2; if (xflag < 2) return sofar; if (xflag == 2) raw = 1; else app = 0; buf[0] = sofar&BYTEMASK; buf[1] = (sofar>>BYTE)&BYTEMASK; do { c = xflag < 3 ? getch0() : mgetach(); if (i+1 >= sizeof buf) { buf[i] = 0; goto retn; } buf[i++] = c; } while (c && c != ' ' && c != '\t' && c != '\n'); buf[i-1] = 0; buf[i] = 0; if (i == 3) goto retn; if ((n = mapget(buf)) >= hadn) { if ((flags & 1) == 0) { n_strcpy(laststr, buf, sizeof(laststr)); retn: buf[i-1] = c; if (xflag < 3) cpushback(&buf[2]); raw = _raw; init = _init; app = _app; if (flags & 2) { if (i > 3 && xflag >= 3) sofar = -2; } else if (i > 3 && xflag >= 3) { buf[i-1] = 0; if (warn & WARN_MAC) errprint("%s: no such request", buf); sofar = 0; } else if (warn & WARN_SPACE && i > 3 && _findmn(sofar, 0, 0) != NULL) { buf[i-1] = 0; errprint("%s: missing space", macname(sofar)); } return sofar; } if (n >= alcd) had = realloc(had, (alcd += 20) * sizeof *had); had[n] = strdup(buf); hadn = n+1; mapadd(buf, n); } pb[0] = c; if (xflag < 3) cpushback(pb); raw = _raw; init = _init; app = _app; return MAXRQ2 + n; } static int getls(int termc, int *strp, int create) { char c, buf[NC+1]; int j = -1, n = -1; size_t i = 0; do { c = xflag < 3 ? getach() : mgetach(); if (i >= sizeof buf) return -1; buf[i++] = c; } while (c && c != termc); if (strp) *strp = 0; if (c != termc) { if (strp && !nlflg) *strp = 1; else nodelim(termc); } buf[--i] = 0; if (i == 0 || (c != termc && (!strp || nlflg))) j = 0; else if (i <= 2) { j = PAIR(buf[0], buf[1]); } else { if ((n = mapget(buf)) >= hadn) { if (create) { if (hadn++ >= alcd) had = realloc(had, (alcd += 20) * sizeof *had); had[n] = strdup(buf); hadn = n + 1; mapadd(buf, n); } else { n = -1; n_strcpy(laststr, buf, sizeof(laststr)); } } } return n >= 0 ? MAXRQ2 + n : j; } int makerq(const char *name) { static int t; char _name[20]; int n; if (name == NULL) { roff_sprintf(_name, sizeof(_name), "\13%d", ++t); name = _name; } if (name[0] == 0 || name[1] == 0 || name[2] == 0) return PAIR(name[0], name[1]); if ((n = mapget(name)) < hadn) return MAXRQ2 + n; if (hadn++ >= alcd) had = realloc(had, (alcd += 20) * sizeof *had); had[n] = strdup(name); hadn = n + 1; mapadd(name, n); return MAXRQ2 + n; } static void addcon(int _t, const char *rs, void(*f)(int)) { int n = hadn; if (hadn++ >= alcd) had = realloc(had, (alcd += 20) * sizeof *had); had[n] = rs; contab[_t].rq = MAXRQ2 + n; contab[_t].f = f; mapadd(rs, n); } Index: vendor/heirloom-doctools/dist/troff/n5.c =================================================================== --- vendor/heirloom-doctools/dist/troff/n5.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/n5.c (revision 310550) @@ -1,2535 +1,2535 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* from OpenSolaris "n5.c 1.10 05/06/08 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)n5.c 1.130 (gritter) 10/23/09 */ /* * Changes Copyright (c) 2014, 2015 Carsten Kunze */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved * * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. */ #include #include #include #include #include #include #include #if defined (EUC) #include #include #endif /* EUC */ #include #include #include "tdef.h" #include "ext.h" #ifdef NROFF #include "tw.h" #endif #include "pt.h" /* * troff5.c * * misc processing requests */ void casead(void) { register int i; ad = 1; /*leave admod alone*/ if (skip(0)) return; pa = 0; loop: switch (i = cbits(getch())) { case 'r': /*right adj, left ragged*/ admod = 2; break; case 'l': /*left adj, right ragged*/ admod = ad = 0; /*same as casena*/ break; case 'c': /*centered adj*/ admod = 1; break; case 'b': case 'n': admod = 0; break; case '0': case '2': case '4': ad = 0; case '1': case '3': case '5': admod = (i - '0') / 2; break; case 'p': case '7': if (xflag) { pa = 1; admod = 0; goto loop; } } } void casena(void) { ad = 0; } void casefi(void) { tbreak(); fi++; pendnf = 0; } void casenf(void) { tbreak(); fi = 0; } void casepadj(void) { int n; if (skip(0)) padj = 1; else { n = hatoi(); if (!nonumb) padj = n; } } void casers(void) { dip->nls = 0; } void casens(void) { dip->nls++; } void casespreadwarn(void) { if (skip(0)) spreadwarn = !spreadwarn; else { dfact = EM; spreadlimit = inumb(&spreadlimit); spreadwarn = 1; } } int chget(int c) { tchar i = 0; charf++; if (skip(0) || ismot(i = getch()) || cbits(i) == ' ' || cbits(i) == '\n') { ch = i; return(c); } else return(cbits(i)); } void casecc(void) { cc = chget('.'); } void casec2(void) { c2 = chget('\''); } void casehc(void) { ohc = chget(OHC); } void casetc(void) { tabc = chget(0); } void caselc(void) { dotc = chget(0); } void casehy(void) { register int i; hyf = 1; if (skip(0)) return; noscale++; i = hatoi(); noscale = 0; if (nonumb) return; hyf = max(i, 0); } void casenh(void) { hyf = 0; } void casehlm(void) { int i; if (!skip(0)) { noscale++; i = hatoi(); noscale = 0; if (!nonumb) hlm = i; } else hlm = -1; } void casehcode(void) { tchar c, _d; int k; lgf++; if (skip(1)) return; do { c = getch(); if (skip(1)) break; _d = getch(); if (c && _d && !ismot(c) && !ismot(_d)) { if ((k = cbits(c)) >= nhcode) { hcode = realloc(hcode, (k+1) * sizeof *hcode); memset(&hcode[nhcode], 0, (k+1-nhcode) * sizeof *hcode); nhcode = k+1; } hcode[k] = cbits(_d); } } while (!skip(0)); } void caseshc(void) { shc = skip(0) ? 0 : getch(); } void casehylen(void) { int n; if (skip(0)) hylen = 5; else { n = hatoi(); if (!nonumb) hylen = n; } } void casehypp(void) { float _t; if (skip(0)) hypp = hypp2 = hypp3 = 0; else { _t = atop(); if (!nonumb) hypp = _t; if (skip(0)) hypp2 = hypp3 = 0; else { _t = atop(); if (!nonumb) hypp2 = _t; if (skip(0)) hypp3 = 0; else { _t = atop(); if (!nonumb) hypp3 = _t; } } } } static void chkin(int indent, int linelength, const char *note) { if (indent > linelength - INCH / 10) { if (warn & WARN_RANGE) errprint("excess of %sindent", note); } } void casepshape(void) { int i, l; int lastin = in, lastll = ll; pshapes = 0; if (skip(0)) { pshapes = 0; return; } do { i = max(hnumb(&lastin), 0); if (nonumb) break; if (skip(0)) l = ll; else { l = max(hnumb(&lastll), INCH / 10); if (nonumb) break; } if (pshapes >= pgsize) growpgsize(); chkin(i, l, ""); pgin[pshapes] = i; pgll[pshapes] = l; pshapes++; lastin = i; lastll = l; } while (!skip(0)); } void caselpfx(void) { int n; tchar c; if (skip(0)) { free(lpfx); lpfx = NULL; nlpfx = 0; } else { for (n = 0; ; n++) { if (n+1 >= nlpfx) { nlpfx += 10; lpfx = realloc(lpfx, nlpfx * sizeof *lpfx); } c = getch(); if (nlflg) break; if (n == 0 && cbits(c) == '"') continue; lpfx[n] = c; } lpfx[n] = 0; } } int max(int aa, int bb) { if (aa > bb) return (aa); else return (bb); } int min(int aa, int bb) { if (aa < bb) return (aa); else return (bb); } static void cerj(int dorj) { register int i; noscale++; skip(0); i = max(hatoi(), 0); if (nonumb) i = 1; tbreak(); if (dorj) { rj = i; ce = 0; } else { ce = i; rj = 0; } noscale = 0; } void casece(void) { cerj(0); } void caserj(void) { if (xflag) cerj(1); } static void _brnl(int p) { int n; noscale++; if (skip(0)) n = INT_MAX; else { n = hatoi(); if (nonumb || n < 0) n = p ? brpnl : brpnl; } noscale--; tbreak(); if (p) { brpnl = n; brnl = 0; } else { brnl = n; brpnl = 0; } } void casebrnl(void) { _brnl(0); } void casebrpnl(void) { _brnl(1); } void casein(void) { register int i; if ((pa || padj) && pglines == 0 && pgchars) tbreak(); if (skip(0)) i = in1; else i = max(hnumb(&in), 0); tbreak(); in1 = in; in = i; chkin(in, ll, ""); if (!nc && !pgwords) { un = in; setnel(); } else if (pgwords) { pgflags[pgwords] |= PG_NEWIN; pgwdin[pgwords] = in; } } void casell(void) { register int i; if (skip(0)) i = ll1; else i = max(hnumb(&ll), INCH / 10); ll1 = ll; ll = i; chkin(in, ll, ""); setnel(); if (pgwords) { pgflags[pgwords] |= PG_NEWLL; pgwdll[pgwords] = ll; } } void caselt(void) { register int i; if (skip(0)) i = lt1; else i = max(hnumb(<), 0); lt1 = lt; lt = i; } void caseti(void) { register int i; if (skip(1)) return; if ((pa || padj) && pglines == 0 && pgchars) tbreak(); i = max(hnumb(&in), 0); tbreak(); un1 = i; chkin(i, ll, "temporary "); setnel(); } void casels(void) { register int i; noscale++; if (skip(0)) i = ls1; else i = max(inumb(&ls), 1); ls1 = ls; ls = i; noscale = 0; } void casepo(void) { register int i; if (skip(0)) i = po1; else i = max(hnumb(&po), 0); po1 = po; po = i; #ifndef NROFF if (!ascii) esc += po - po1; #endif } void casepl(void) { register int i; skip(0); if ((i = vnumb(&pl)) == 0) pl = defaultpl ? defaultpl : 11 * INCH; /*11in*/ else pl = i; if (numtab[NL].val > pl) { numtab[NL].val = pl; prwatchn(&numtab[NL]); } } static void chkt(struct d *dp, int n) { if (n <= 0 && dp != d) if (warn & WARN_RANGE) errprint("trap at %d not effective in diversion", n); } static void _casewh(struct d *dp) { register int i, j, k; lgf++; skip(1); i = vnumb((int *)0); if (nonumb) return; skip(0); j = getrq(1); if ((k = findn(dp, i)) != NTRAP) { dp->mlist[k] = j; return; } for (k = 0; k < NTRAP; k++) if (dp->mlist[k] == 0) break; if (k == NTRAP) { flusho(); errprint("cannot plant trap."); return; } dp->mlist[k] = j; dp->nlist[k] = i; chkt(dp, i); } void casewh(void) { _casewh(d); } void casedwh(void) { _casewh(dip); } static void _casech(struct d *dp) { register int i, j, k; lgf++; skip(1); if (!(j = getrq(0))) return; else { for (k = 0; k < NTRAP; k++) if (dp->mlist[k] == j) break; } if (k == NTRAP) return; skip(0); i = vnumb((int *)0); if (nonumb) dp->mlist[k] = 0; dp->nlist[k] = i; chkt(dp, i); } void casech(void) { _casech(d); } void casedch(void) { _casech(dip); } void casevpt(void) { if (skip(1)) return; vpt = hatoi() != 0; } tchar setolt(void) { storerq(getsn(1)); return mkxfunc(OLT, 0); } int findn(struct d *dp, int i) { register int k; for (k = 0; k < NTRAP; k++) if ((dp->nlist[k] == i) && (dp->mlist[k] != 0)) break; return(k); } void casepn(void) { register int i; skip(1); noscale++; i = max(inumb(&numtab[PN].val), 0); prwatchn(&numtab[PN]); noscale = 0; if (!nonumb) { npn = i; npnflg++; } } void casebp(void) { register int i; register struct s *savframe; if (dip != d) return; savframe = frame; if (skip(0)) i = -1; else { if ((i = inumb(&numtab[PN].val)) < 0) i = 0; if (nonumb) i = -1; } tbreak(); if (i >= 0) { npn = i; npnflg++; } else if (dip->nls && donef < 1) return; eject(savframe); } static void tmtmcwr(int ab, int tmc, int wr, int ep, int tmm) { const char tmtab[] = { 'a',000,000,000,000,000,000,000, 000,000,000,000,000,000,000,000, '{','}','&',000,'%','c','e',' ', '!',000,000,000,000,000,000,'~', 000 }; struct contab *cp; register int i, j; tchar c; char tmbuf[NTM]; filep savip = ip; int discard = 0; lgf++; if (tmm) { if (skip(1) || (i = getrq(0)) == 0) return; if ((cp = findmn(i)) == NULL || !cp->mx) { nosuch(i); return; } savip = ip; ip = (filep)cp->mx; app++; copyf++; } else { copyf++; if (skip(0) && ab) errprint("User Abort"); } loop: for (i = 0; i < NTM - 5 - mb_cur_max; ) { if (tmm) { if ((c = rbf()) == 0) { ip = savip; tmm = 0; app--; break; } } else c = getch(); if (discard) { discard--; continue; } if (c == '\n') { tmbuf[i++] = '\n'; break; } c: j = cbits(c); if (iscopy(c)) { int n; if ((n = wctomb(&tmbuf[i], j)) > 0) { i += n; continue; } } if (xflag == 0) { tmbuf[i++] = c; continue; } if (ismot(c)) continue; tmbuf[i++] = '\\'; if (c == (OHC|BLBIT)) j = ':'; else if (istrans(c)) j = ')'; - else if (j >= 0 && j < sizeof tmtab && tmtab[j]) + else if (j >= 0 && j < (int)sizeof tmtab && tmtab[j]) j = tmtab[j]; else if (j == ACUTE) j = '\''; else if (j == GRAVE) j = '`'; else if (j == UNDERLINE) j = '_'; else if (j == MINUS) j = '-'; else { i--; if (c == WORDSP) j = ' '; else if (j == WORDSP) continue; else if (j == FLSS) { discard++; continue; } } if (j == XFUNC) switch (fbits(c)) { case CHAR: c = charout[sbits(c)].ch; goto c; default: continue; } tmbuf[i++] = j; } if (i == NTM - 2) tmbuf[i++] = '\n'; if (tmc) i--; tmbuf[i] = 0; if (ab) /* truncate output */ obufp = obuf; /* should be a function in n2.c */ if (ep) { flusho(); errprint("%s", tmbuf); } else if (wr < 0) { flusho(); fprintf(stderr, "%s", tmbuf); } else if (i) write(wr, tmbuf, i); if (tmm) goto loop; copyf--; lgf--; } void casetm(int ab) { tmtmcwr(ab, 0, -1, 0, 0); } void casetmc(void) { tmtmcwr(0, 1, -1, 0, 0); } void caseerrprint(void) { tmtmcwr(0, 1, -1, 1, 0); } static struct stream { char *name; int fd; } *streams; static int nstreams; static void open1(int flags) { int ns = nstreams; lgf++; if (skip(1) || !getname() || skip(1)) return; streams = realloc(streams, sizeof *streams * ++nstreams); streams[ns].name = malloc(NS); n_strcpy(streams[ns].name, nextf, NS); getname(); if ((streams[ns].fd = open(nextf, flags, 0666)) < 0) { errprint("can't open file %s", nextf); done(02); } } void caseopen(void) { open1(O_WRONLY|O_CREAT|O_TRUNC); } void caseopena(void) { open1(O_WRONLY|O_CREAT|O_APPEND); } static int getstream(const char *name) { int i; for (i = 0; i < nstreams; i++) if (strcmp(streams[i].name, name) == 0) return i; errprint("no such stream %s", name); return -1; } static void write1(int writec, int writem) { int i; lgf++; if (skip(1) || !getname()) return; if ((i = getstream(nextf)) < 0) return; tmtmcwr(0, writec, streams[i].fd, 0, writem); } void casewrite(void) { write1(0, 0); } void casewritec(void) { write1(1, 0); } void casewritem(void) { write1(0, 1); } void caseclose(void) { int i; lgf++; if (skip(1) || !getname()) return; if ((i = getstream(nextf)) < 0) return; free(streams[i].name); memmove(&streams[i], &streams[i+1], (nstreams-i-1) * sizeof *streams); nstreams--; } void casesp(int a) { register int i, j, savlss; tbreak(); if (dip->nls || trap) return; i = findt1(); if (!a) { skip(0); j = vnumb((int *)0); if (nonumb) j = lss; } else j = a; if (j == 0) return; if (i < j) j = i; savlss = lss; if (dip != d) i = dip->dnl; else i = numtab[NL].val; if ((i + j) < 0) j = -i; lss = j; newline(0); lss = savlss; } void casebrp(void) { if (nc || pgchars) { spread = 2; flushi(); if (pgchars) tbreak(); else { pendt++; text(); } } else tbreak(); } void caseblm(void) { if (!skip(0)) blmac = getrq(1); else blmac = 0; } void caselsm(void) { if (!skip(0)) lsmac = getrq(1); else lsmac = 0; } void casert(void) { register int a, *p; skip(0); if (dip != d) p = &dip->dnl; else p = &numtab[NL].val; a = vnumb(p); if (nonumb) a = dip->mkline; if ((a < 0) || (a >= *p)) return; nb++; casesp(a - *p); } void caseem(void) { lgf++; skip(1); em = getrq(1); } void casefl(void) { tbreak(); flusho(); } static struct evnames { int number; char *name; } *evnames; static struct env *evp; static int *evlist; static int evi; static int evlsz; static int Nev = NEV; static struct env * findev(int *number, char *name) { int i; if (*number < 0) return &evp[-1 - (*number)]; else if (name) { for (i = 0; i < Nev-NEV; i++) if (evnames[i].name != NULL && strcmp(evnames[i].name, name) == 0) { *number = -1 - i; return &evp[i]; } *number = -1 - i; return NULL; } else if (*number >= NEV) { for (i = 0; i < Nev-NEV; i++) if (evnames[i].name == NULL && evnames[i].number == *number) return &evp[i]; *number = -1 - i; return NULL; } else { extern tchar *corebuf; return &((struct env *)corebuf)[*number]; } } static int getev(int *nxevp, char **namep) { char *name = NULL; int nxev = 0; int c; int i = 0, sz = 0, valid = 1; *namep = NULL; *nxevp = 0; if (skip(0)) return 0; c = cbits(ch); if (xflag == 0 || isdigit(c) || c == '(') { noscale++; nxev = hatoi(); noscale = 0; if (nonumb) { flushi(); return 0; } } else { do { c = rgetach(); if (i >= sz) name = realloc(name, (sz += 8) * sizeof *name); name[i++] = c; } while (c); if (*name == 0) { free(name); name = NULL; valid = 0; } } flushi(); *namep = name; *nxevp = nxev; return valid; } void caseev(void) { char *name; int nxev; struct env *np, *op; if (getev(&nxev, &name) == 0) { if (evi == 0) return; nxev = evlist[--evi]; goto e1; } if (xflag == 0 && ((nxev >= NEV) || (nxev < 0) || (evi >= EVLSZ))) goto cannot; if (evi >= evlsz) { evlsz = evi + 1; if ((evlist = realloc(evlist, evlsz * sizeof *evlist)) == NULL) goto cannot; } if ((name && findev(&nxev, name) == NULL) || nxev >= Nev) { if ((evp = realloc(evp, (Nev-NEV+1) * sizeof *evp)) == NULL || (evnames = realloc(evnames, (Nev-NEV+1) * sizeof *evnames)) == NULL) goto cannot; evnames[Nev-NEV].number = nxev; evnames[Nev-NEV].name = name; evp[Nev-NEV] = initenv; Nev++; } if (name == NULL && nxev < 0) { flusho(); cannot: errprint("cannot do ev."); if (error) done2(040); else edone(040); return; } evlist[evi++] = ev; e1: if (ev == nxev) return; if ((np = findev(&nxev, name)) == NULL || (op = findev(&ev, NULL)) == NULL) goto cannot; *op = env; env = *np; ev = nxev; if (evname == NULL) { if (name) evname = name; else { size_t l = 20; evname = malloc(l); roff_sprintf(evname, l, "%d", ev); } } } void caseevc(void) { char *name; int nxev; struct env *ep; if (getev(&nxev, &name) == 0 || (ep = findev(&nxev, name)) == NULL) return; relsev(&env); evc(&env, ep); } void evc(struct env *dp, struct env *sp) { if (dp != sp) { char *name; name = dp->_evname; memcpy(dp, sp, sizeof *dp); dp->_evname = name; } if (sp->_hcode) { dp->_hcode = malloc(dp->_nhcode * sizeof *dp->_hcode); memcpy(dp->_hcode, sp->_hcode, dp->_nhcode * sizeof *dp->_hcode); } if (sp->_lpfx) { dp->_lpfx = malloc(dp->_nlpfx * sizeof *dp->_lpfx); memcpy(dp->_lpfx, sp->_lpfx, dp->_nlpfx * sizeof *dp->_lpfx); } dp->_pendnf = 0; dp->_pendw = 0; dp->_pendt = 0; dp->_wch = 0; dp->_wne = 0; dp->_wsp = 0; dp->_wdstart = 0; dp->_wdend = 0; dp->_lnsize = 0; dp->_line = NULL; dp->_linep = NULL; dp->_wdsize = 0; dp->_word = 0; dp->_wdpenal = 0; dp->_wordp = 0; dp->_spflg = 0; dp->_seflg = 0; dp->_ce = 0; dp->_rj = 0; dp->_pgsize = 0; dp->_pgcsize = 0; dp->_pgssize = 0; dp->_pglines = 0; dp->_pgwords = 0; dp->_pgchars = 0; dp->_pgspacs = 0; dp->_para = NULL; dp->_parsp = NULL; dp->_pgwordp = NULL; dp->_pgspacp = NULL; dp->_pgwordw = NULL; dp->_pghyphw = NULL; dp->_pgadspc = NULL; dp->_pglsphc = NULL; dp->_pgopt = NULL; dp->_pgspacw = NULL; dp->_pglgsc = NULL; dp->_pglgec = NULL; dp->_pglgsw = NULL; dp->_pglgew = NULL; dp->_pglgsh = NULL; dp->_pglgeh = NULL; dp->_pgin = NULL; dp->_pgll = NULL; dp->_pgwdin = NULL; dp->_pgwdll = NULL; dp->_pgflags = NULL; dp->_pglno = NULL; dp->_pgpenal = NULL; dp->_inlevp = NULL; if (dp->_brnl < INT_MAX) dp->_brnl = 0; if (dp->_brpnl < INT_MAX) dp->_brpnl = 0; dp->_nn = 0; dp->_ndf = 0; dp->_nms = 0; dp->_ni = 0; dp->_ul = 0; dp->_cu = 0; dp->_it = 0; dp->_itc = 0; dp->_itmac = 0; dp->_nc = 0; dp->_un = 0; dp->_un1 = -1; dp->_nwd = 0; dp->_hyoff = 0; dp->_nb = 0; dp->_spread = 0; dp->_lnmod = 0; dp->_hlc = 0; dp->_cht = 0; dp->_cdp = 0; dp->_maxcht = 0; dp->_maxcdp = 0; setnel(); } void evcline(struct env *dp, struct env *sp) { if (dp == sp) return; #ifndef NROFF dp->_lspnc = sp->_lspnc; dp->_lsplow = sp->_lsplow; dp->_lsphigh = sp->_lsphigh; dp->_lspcur = sp->_lspcur; dp->_lsplast = sp->_lsplast; dp->_lshwid = sp->_lshwid; dp->_lshlow = sp->_lshlow; dp->_lshhigh = sp->_lshhigh; dp->_lshcur = sp->_lshcur; #endif dp->_fldcnt = sp->_fldcnt; dp->_hyoff = sp->_hyoff; dp->_hlc = sp->_hlc; dp->_nel = sp->_nel; dp->_adflg = sp->_adflg; dp->_adspc = sp->_adspc; dp->_wne = sp->_wne; dp->_wsp = sp->_wsp; dp->_ne = sp->_ne; dp->_nc = sp->_nc; dp->_nwd = sp->_nwd; dp->_un = sp->_un; dp->_wch = sp->_wch; dp->_rhang = sp->_rhang; dp->_cht = sp->_cht; dp->_cdp = sp->_cdp; dp->_maxcht = sp->_maxcht; dp->_maxcdp = sp->_maxcdp; if (icf == 0) dp->_ic = sp->_ic; memcpy(dp->_hyptr, sp->_hyptr, NHYP * sizeof *sp->_hyptr); dp->_line = malloc((dp->_lnsize = sp->_lnsize) * sizeof *dp->_line); memcpy(dp->_line, sp->_line, sp->_lnsize * sizeof *sp->_line); dp->_word = malloc((dp->_wdsize = sp->_wdsize) * sizeof *dp->_word); memcpy(dp->_word, sp->_word, sp->_wdsize * sizeof *sp->_word); dp->_wdpenal = malloc((dp->_wdsize = sp->_wdsize) * sizeof *dp->_wdpenal); memcpy(dp->_wdpenal, sp->_wdpenal, sp->_wdsize * sizeof *sp->_wdpenal); dp->_linep = sp->_linep + (dp->_line - sp->_line); dp->_wordp = sp->_wordp + (dp->_word - sp->_word); dp->_wdend = sp->_wdend + (dp->_word - sp->_word); dp->_wdstart = sp->_wdstart + (dp->_word - sp->_word); dp->_para = malloc((dp->_pgcsize = sp->_pgcsize) * sizeof *dp->_para); memcpy(dp->_para, sp->_para, dp->_pgcsize * sizeof *sp->_para); dp->_parsp = malloc((dp->_pgssize = sp->_pgssize) * sizeof *dp->_parsp); memcpy(dp->_parsp, sp->_parsp, dp->_pgssize * sizeof *sp->_parsp); dp->_pgsize = sp->_pgsize; dp->_pgwordp = malloc(dp->_pgsize * sizeof *dp->_pgwordp); memcpy(dp->_pgwordp, sp->_pgwordp, dp->_pgsize * sizeof *dp->_pgwordp); dp->_pgwordw = malloc(dp->_pgsize * sizeof *dp->_pgwordw); memcpy(dp->_pgwordw, sp->_pgwordw, dp->_pgsize * sizeof *dp->_pgwordw); dp->_pghyphw = malloc(dp->_pgsize * sizeof *dp->_pghyphw); memcpy(dp->_pghyphw, sp->_pghyphw, dp->_pgsize * sizeof *dp->_pghyphw); dp->_pgadspc = malloc(dp->_pgsize * sizeof *dp->_pgadspc); memcpy(dp->_pgadspc, sp->_pgadspc, dp->_pgsize * sizeof *dp->_pgadspc); dp->_pglsphc = malloc(dp->_pgsize * sizeof *dp->_pglsphc); memcpy(dp->_pglsphc, sp->_pglsphc, dp->_pgsize * sizeof *dp->_pglsphc); dp->_pgopt = malloc(dp->_pgsize * sizeof *dp->_pgopt); memcpy(dp->_pgopt, sp->_pgopt, dp->_pgsize * sizeof *dp->_pgopt); dp->_pgspacw = malloc(dp->_pgsize * sizeof *dp->_pgspacw); memcpy(dp->_pgspacw, sp->_pgspacw, dp->_pgsize * sizeof *dp->_pgspacw); dp->_pgspacp = malloc(dp->_pgsize * sizeof *dp->_pgspacp); memcpy(dp->_pgspacp, sp->_pgspacp, dp->_pgsize * sizeof *dp->_pgspacp); dp->_pglgsc = malloc(dp->_pgsize * sizeof *dp->_pglgsc); memcpy(dp->_pglgsc, sp->_pglgsc, dp->_pgsize * sizeof *dp->_pglgsc); dp->_pglgec = malloc(dp->_pgsize * sizeof *dp->_pglgec); memcpy(dp->_pglgec, sp->_pglgec, dp->_pgsize * sizeof *dp->_pglgec); dp->_pglgsw = malloc(dp->_pgsize * sizeof *dp->_pglgsw); memcpy(dp->_pglgsw, sp->_pglgsw, dp->_pgsize * sizeof *dp->_pglgsw); dp->_pglgew = malloc(dp->_pgsize * sizeof *dp->_pglgew); memcpy(dp->_pglgew, sp->_pglgew, dp->_pgsize * sizeof *dp->_pglgew); dp->_pglgsh = malloc(dp->_pgsize * sizeof *dp->_pglgsh); memcpy(dp->_pglgsh, sp->_pglgsh, dp->_pgsize * sizeof *dp->_pglgsh); dp->_pglgeh = malloc(dp->_pgsize * sizeof *dp->_pglgeh); memcpy(dp->_pglgeh, sp->_pglgeh, dp->_pgsize * sizeof *dp->_pglgeh); dp->_pgin = malloc(dp->_pgsize * sizeof *dp->_pgin); memcpy(dp->_pgin, sp->_pgin, dp->_pgsize * sizeof *dp->_pgin); dp->_pgll = malloc(dp->_pgsize * sizeof *dp->_pgll); memcpy(dp->_pgll, sp->_pgll, dp->_pgsize * sizeof *dp->_pgll); dp->_pgwdin = malloc(dp->_pgsize * sizeof *dp->_pgwdin); memcpy(dp->_pgwdin, sp->_pgwdin, dp->_pgsize * sizeof *dp->_pgwdin); dp->_pgwdll = malloc(dp->_pgsize * sizeof *dp->_pgwdll); memcpy(dp->_pgwdll, sp->_pgwdll, dp->_pgsize * sizeof *dp->_pgwdll); dp->_pgflags = malloc(dp->_pgsize * sizeof *dp->_pgflags); memcpy(dp->_pgflags, sp->_pgflags, dp->_pgsize * sizeof *dp->_pgflags); dp->_pglno = malloc(dp->_pgsize * sizeof *dp->_pglno); memcpy(dp->_pglno, sp->_pglno, dp->_pgsize * sizeof *dp->_pglno); dp->_pgpenal = malloc(dp->_pgsize * sizeof *dp->_pgpenal); memcpy(dp->_pgpenal, sp->_pgpenal, dp->_pgsize * sizeof *dp->_pgpenal); dp->_inlevp = malloc(dp->_ainlev * sizeof *dp->_inlevp); memcpy(dp->_inlevp, sp->_inlevp, dp->_ninlev * sizeof *dp->_inlevp); dp->_pgwords = sp->_pgwords; dp->_pgchars = sp->_pgchars; dp->_pgspacs = sp->_pgspacs; dp->_pglines = sp->_pglines; } void relsev(struct env *ep) { free(ep->_hcode); ep->_hcode = NULL; ep->_nhcode = 0; free(ep->_line); ep->_line = NULL; ep->_lnsize = 0; free(ep->_word); ep->_word = NULL; free(ep->_wdpenal); ep->_wdpenal = NULL; ep->_wdsize = 0; free(ep->_para); ep->_para = NULL; ep->_pgcsize = 0; free(ep->_pgwordp); ep->_pgwordp = NULL; free(ep->_pgwordw); ep->_pgwordw = NULL; free(ep->_pghyphw); ep->_pghyphw = NULL; free(ep->_pgadspc); ep->_pgadspc = NULL; free(ep->_pglsphc); ep->_pglsphc = NULL; free(ep->_pgopt); ep->_pgopt = NULL; free(ep->_pgspacw); ep->_pgspacw = NULL; free(ep->_pgspacp); ep->_pgspacp = NULL; free(ep->_pglgsc); ep->_pglgsc = NULL; free(ep->_pglgec); ep->_pglgec = NULL; free(ep->_pglgsw); ep->_pglgsw = NULL; free(ep->_pglgew); ep->_pglgew = NULL; free(ep->_pglgsh); ep->_pglgsh = NULL; free(ep->_pglgeh); ep->_pglgeh = NULL; free(ep->_pgin); ep->_pgin = NULL; free(ep->_pgll); ep->_pgll = NULL; free(ep->_pgwdin); ep->_pgwdin = NULL; free(ep->_pgwdll); ep->_pgwdll = NULL; free(ep->_pgflags); ep->_pgflags = NULL; free(ep->_pglno); ep->_pglno = NULL; free(ep->_pgpenal); ep->_pgpenal = NULL; ep->_pgsize = 0; free(ep->_inlevp); ep->_inlevp = NULL; ep->_ninlev = 0; ep->_ainlev = 0; } void caseel(void) { caseif(2); } void caseie(void) { caseif(1); } int tryglf; void caseif(int x) { extern int falsef; register int notflag, true; tchar i, j; enum warn w = warn; int flt = 0; static int el; if (x == 3) goto i2; if (x == 2) { notflag = 0; true = el; el = 0; goto i1; } true = 0; skip(1); if ((cbits(i = getch())) == '!') { notflag = 1; if (xflag == 0) /*EMPTY*/; else if ((cbits(i = getch())) == 'f') flt = 1; else ch = i; } else if (xflag && cbits(i) == 'f') { flt = 1; notflag = 0; } else { notflag = 0; ch = i; } if (flt) i = atof0() > 0; else i = (int)atoi0(); if (!nonumb) { if (i > 0) true++; goto i1; } i = getch(); switch (cbits(i)) { case 'e': if (!(numtab[PN].val & 01)) true++; break; case 'o': if (numtab[PN].val & 01) true++; break; #ifdef NROFF case 'n': true++; case 't': #endif #ifndef NROFF case 't': true++; case 'n': #endif break; case 'c': if (xflag == 0) goto dfl; warn &= ~WARN_CHAR; tryglf++; if (!skip(1)) { j = getch(); true = !ismot(j) && cbits(j) && cbits(j) != ' '; } tryglf--; warn = w; break; case 'r': case 'd': if (xflag == 0) goto dfl; warn &= ~(WARN_MAC|WARN_SPACE|WARN_REG); if (!skip(1)) { j = getrq(2); true = (cbits(i) == 'r' ? usedr(j) != NULL : findmn(j) != NULL); } warn = w; break; case 'F': if (xflag == 0) goto dfl; if (!skip(1)) { j = getrq(3); true = findft(j, 0) != -1; } break; case 'v': /* break; */ case ' ': break; default: dfl: true = cmpstr(i); } i1: true ^= notflag; if (x == 1) { el = !true; } if (true) { if (frame->loopf & LOOP_EVAL) { if (nonumb) goto i3; frame->loopf &= ~LOOP_EVAL; frame->loopf |= LOOP_NEXT; } i2: noschr = 0; bol = 1; while ((cbits(i = getch())) == ' ') ; bol = 0; if (cbits(i) == LEFT) goto i2; ch = i; nflush++; } else { i3: if (frame->loopf & LOOP_EVAL) frame->loopf = LOOP_FREE; copyf++; falsef++; eatblk(0); copyf--; falsef--; } } void casenop(void) { caseif(3); } void casechomp(void) { chomp = 1; caseif(3); } void casereturn(void) { flushi(); nflush++; while (frame->loopf) { frame->loopf = LOOP_FREE; popi(); } popi(); } void casewhile(void) { tchar c; int k, level; filep newip; if (dip != d) wbfl(); if ((nextb = alloc()) == 0) { errprint("out of space"); edone(04); return; } newip = offset = nextb; wbf(mkxfunc(CC, 0)); wbf(XFUNC); /* caseif */ wbf(' '); copyf++, clonef++; level = 0; do { nlflg = 0; k = cbits(c = getch()); switch (k) { case LEFT: level++; break; case RIGHT: level--; break; } wbf(c); } while (!nlflg || level > 0); if (level < 0 && warn & WARN_DELIM) errprint("%d excess delimiter(s)", -level); wbt(0); copyf--, clonef--; pushi(newip, LOOP, 0); offset = dip->op; } void casebreak(void) { casecontinue(1); } void casecontinue(int _break) { int i, j; struct s *s; noscale++; if (skip(0) || (i = hatoi()) <= 0 || nonumb) i = 1; noscale--; j = 0; for (s = frame; s != stk; s = s->pframe) if (s->loopf && ++j >= i) break; if (j != i) { if (i == 1) { if (warn & WARN_RANGE) errprint("%s outside loop", macname(lastrq)); return; } if (warn & WARN_RANGE) errprint("%s: breaking out of %d current loop " "levels but %d requested", macname(lastrq), j, i); _break = 1; i = j; } flushi(); nflush++; while (i > 1 || (_break && i > 0)) { if (frame->loopf) { frame->loopf = LOOP_FREE; i--; } popi(); } if (i == 1) { while (frame->loopf == 0) popi(); popi(); } } void eatblk(int inblk) { register int cnt, i; tchar ii; cnt = 0; do { if (ch) { i = cbits(ii = ch); ch = 0; } else i = cbits(ii = getch0()); if (i == ESC) cnt++; else { if (cnt == 1) switch (i) { case '{': i = LEFT; break; case '}': i = RIGHT; break; case '\n': i = 'x'; break; } cnt = 0; } if (i == LEFT) eatblk(1); } while ((!inblk && (i != '\n')) || (inblk && (i != RIGHT))); if (i == '\n') { nlflg++; tailflg = istail(ii); } } int cmpstr(tchar c) { register int j, delim; register tchar i; register int val; int savapts, savapts1, savfont, savfont1, savpts, savpts1; tchar string[1280]; register tchar *sp; if (ismot(c)) return(0); argdelim = delim = cbits(c); savapts = apts; savapts1 = apts1; savfont = font; savfont1 = font1; savpts = pts; savpts1 = pts1; sp = string; while ((j = cbits(i = getch()))!=delim && j!='\n' && sp<&string[1280-1]) *sp++ = i; if (j != delim) nodelim(delim); if (sp >= string + 1280) { errprint("too-long string compare."); edone(0100); } if (nlflg) { val = sp==string; goto rtn; } *sp++ = 0; apts = savapts; apts1 = savapts1; font = savfont; font1 = savfont1; pts = savpts; pts1 = savpts1; mchbits(); val = 1; sp = string; while ((j = cbits(i = getch())) != delim && j != '\n') { if (*sp != i) { eat(delim); val = 0; goto rtn; } sp++; } if (j != delim) nodelim(delim); if (*sp) val = 0; rtn: apts = savapts; apts1 = savapts1; font = savfont; font1 = savfont1; pts = savpts; pts1 = savpts1; mchbits(); argdelim = 0; return(val); } void caserd(void) { lgf++; skip(0); getname(); if (!iflg) { if (quiet) { #ifdef NROFF echo_off(); flusho(); #endif /* NROFF */ fprintf(stderr, "\007"); /*bell*/ } else { if (nextf[0]) { fprintf(stderr, "%s:", nextf); } else { fprintf(stderr, "\007"); /*bell*/ } } } collect(); tty++; pushi(-1, PAIR('r','d'), 0); } int rdtty(void) { char onechar; #if defined (EUC) int i, n; loop: #endif /* EUC */ onechar = 0; if (read(0, &onechar, 1) == 1) { if (onechar == '\n') tty++; else tty = 1; #if !defined (EUC) if (tty != 3) return(onechar); #else /* EUC */ if (tty != 3) { if (!multi_locale) return(onechar); i = onechar & 0377; *mbbuf1p++ = i; *mbbuf1p = 0; if ((*mbbuf1&~(wchar_t)0177) == 0) { twc = 0; mbbuf1p = mbbuf1; } else if ((n = mbtowc(&twc, mbbuf1, mb_cur_max)) <= 0) { if (mbbuf1p >= mbbuf1 + mb_cur_max) { illseq(-1, mbbuf1, mbbuf1p-mbbuf1); twc = 0; mbbuf1p = mbbuf1; *mbbuf1p = 0; i &= 0177; } else { goto loop; } } else { i = twc | COPYBIT; twc = 0; mbbuf1p = mbbuf1; } return(i); } #endif /* EUC */ } popi(); tty = 0; #ifdef NROFF if (quiet) echo_on(); #endif /* NROFF */ return(0); } void caseec(void) { eschar = chget('\\'); } void caseeo(void) { eschar = 0; } void caseecs(void) { ecs = eschar; } void caseecr(void) { eschar = ecs; } void caseta(void) { int T[NTAB]; register int i, j, n = 0; tabtab[0] = nonumb = 0; Tflg = 1; for (i = 0; ((i < (NTAB - 1)) && !nonumb); i++) { if (skip(0)) break; tabtab[i] = max(hnumb(&tabtab[max(i-1,0)]), 0) & TABMASK; if (nonumb && cbits(ch) == 'T') { ch = 0; nonumb = 0; Tflg = 0; goto T; } if (!nonumb) switch (cbits(ch)) { case 'C': tabtab[i] |= CTAB; break; case 'R': tabtab[i] |= RTAB; break; default: /*includes L*/ break; } nonumb = ch = 0; } Tflg = 0; tabtab[i] = 0; return; T: for (j = 0; j < NTAB - 1 && !nonumb; j++) { if (skip(0)) break; T[j] = hatoi() & TABMASK; if (!nonumb) switch (cbits(ch)) { case 'C': T[j] |= CTAB; break; case 'R': T[j] |= RTAB; break; default: break; } nonumb = ch = 0; } T[j] = 0; while (i < NTAB - 1) { if (T[j] == 0) { j = 0; n = (i ? tabtab[i-1] : 0) & TABMASK; } tabtab[i++] = (n + (T[j] & TABMASK)) | (T[j] & ~TABMASK); j++; } tabtab[i] = 0; } void casene(void) { register int i, j; skip(0); i = vnumb((int *)0); if (nonumb) i = lss; if (i > (j = findt1())) { i = lss; lss = j; dip->nls = 0; newline(0); lss = i; } } void casetr(int flag) { register int i, j; tchar k; lgf++; tryglf++; skip(1); if (!ch && cbits(getch()) == '\n') goto r; while ((i = cbits(k=getch())) != '\n') { if (ismot(k)) goto r; if (ismot(k = getch())) goto r; if ((j = cbits(k)) == '\n') j = ' '; trtab[i] = j; if (flag & 1) trintab[j] = i; else trintab[j] = 0; if (flag & 2) trnttab[i] = i; else trnttab[i] = j; } r: tryglf--; } void casetrin(void) { casetr(1); } void casetrnt(void) { casetr(2); } void casecu(void) { cu++; caseul(); } void caseul(void) { register int i; noscale++; if (skip(0)) i = 1; else i = hatoi(); if (ul && (i == 0)) { font = sfont; ul = cu = 0; } if (i) { if (!ul) { sfont = font; font = ulfont; } ul = i; } noscale = 0; mchbits(); } void caseuf(void) { register int i, j; extern int findft(int, int); if (skip(0) || !(i = getrq(2)) || i == 'S' || (j = findft(i, 1)) == -1) ulfont = ULFONT; /*default underline position*/ else ulfont = j; #ifdef NROFF if (ulfont == FT) ulfont = ULFONT; #endif } void caseit(int cflag) { register int i; lgf++; it = itc = itmac = 0; noscale++; skip(0); i = hatoi(); skip(0); if (!nonumb && (itmac = getrq(1))) { it = i; itc = cflag; } noscale = 0; } void caseitc(void) { caseit(1); } void casemc(void) { register int i; if (icf > 1) ic = 0; icf = 0; if (skip(0)) return; ic = getch(); icf = 1; skip(0); i = max(hnumb((int *)0), 0); if (!nonumb) ics = i; } static void -propchar(int *tp) +propchar(size_t *tp) { - int c, *tpp; + size_t c, *tpp; tchar i; if (skip(0)) { *tp = IMP; return; } tpp = tp; do { while (!ismot(c = cbits(i = getch())) && c != ' ' && c != '\n') if (tpp < &tp[NSENT]) *tpp++ = c; } while (!skip(0)); } void casesentchar(void) { propchar(sentch); } void casetranschar(void) { propchar(transch); } void casebreakchar(void) { propchar(breakch); } void casenhychar(void) { propchar(nhych); } void caseconnectchar(void) { propchar(connectch); } void casemk(void) { register int i, j; struct numtab *np; if (dip != d) j = dip->dnl; else j = numtab[NL].val; if (skip(0)) { dip->mkline = j; return; } if ((i = getrq(1)) == 0) return; np = findr(i); np->val = j; prwatchn(np); } void casesv(void) { register int i; skip(0); if ((i = vnumb((int *)0)) < 0) return; if (nonumb) i = 1; sv += i; caseos(); } void caseos(void) { register int savlss; if (sv <= findt1()) { savlss = lss; lss = sv; newline(0); lss = savlss; sv = 0; } } void casenm(void) { register int i; lnmod = nn = 0; if (skip(0)) return; lnmod++; noscale++; i = inumb(&numtab[LN].val); if (!nonumb) numtab[LN].val = max(i, 0); prwatchn(&numtab[LN]); getnm(&ndf, 1); getnm(&nms, 0); getnm(&ni, 0); noscale = 0; nmbits = chbits; } void getnm(int *p, int min) { register int i; eat(' '); if (skip(0)) return; i = atoi0(); if (nonumb) return; *p = max(i, min); } void casenn(void) { noscale++; skip(0); nn = max(hatoi(), 1); noscale = 0; } void caseab(void) { casetm(1); done3(0); } #ifdef NROFF /* * The following routines are concerned with setting terminal options. * The manner of doing this differs between research/Berkeley systems * and UNIX System V systems (i.e. DOCUMENTER'S WORKBENCH) * The distinction is controlled by the #define'd variable USG, * which must be set by System V users. */ #ifdef USG #include #define ECHO_USG (ECHO | ECHOE | ECHOK | ECHONL) static struct termios ttys; #else #include struct sgttyb ttys[2]; #endif /* USG */ static int ttysave[2] = {-1, -1}; void save_tty(void) /*save any tty settings that may be changed*/ { #ifdef USG if (tcgetattr(0, &ttys) >= 0) ttysave[0] = ttys.c_lflag; #else if (gtty(0, &ttys[0]) >= 0) ttysave[0] = ttys[0].sg_flags; if (gtty(1, &ttys[1]) >= 0) ttysave[1] = ttys[1].sg_flags; #endif /* USG */ } void restore_tty (void) /*restore tty settings from beginning*/ { if (ttysave[0] != -1) { #ifdef USG ttys.c_lflag = ttysave[0]; tcsetattr(0, TCSADRAIN, &ttys); #else ttys[0].sg_flags = ttysave[0]; stty(0, &ttys[0]); } if (ttysave[1] != -1) { ttys[1].sg_flags = ttysave[1]; stty(1, &ttys[1]); #endif /* USG */ } } void set_tty (void) /*this replaces the use of bset and breset*/ { #ifndef USG /*for research/BSD only, reset CRMOD*/ if (ttysave[1] == -1) save_tty(); if (ttysave[1] != -1) { ttys[1].sg_flags &= ~CRMOD; stty(1, &ttys[1]); } #endif /* USG */ } void echo_off (void) /*turn off ECHO for .rd in "-q" mode*/ { if (ttysave[0] == -1) return; #ifdef USG ttys.c_lflag &= ~ECHO_USG; tcsetattr(0, TCSADRAIN, &ttys); #else ttys[0].sg_flags &= ~ECHO; stty(0, &ttys[0]); #endif /* USG */ } void echo_on (void) /*restore ECHO after .rd in "-q" mode*/ { if (ttysave[0] == -1) return; #ifdef USG ttys.c_lflag |= ECHO_USG; tcsetattr(0, TCSADRAIN, &ttys); #else ttys[0].sg_flags |= ECHO; stty(0, &ttys[0]); #endif /* USG */ } #endif /* NROFF */ Index: vendor/heirloom-doctools/dist/troff/n7.c =================================================================== --- vendor/heirloom-doctools/dist/troff/n7.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/n7.c (revision 310550) @@ -1,2342 +1,2342 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* from OpenSolaris "n7.c 1.10 05/06/08 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)n7.c 1.181 (gritter) 6/19/11 * * Portions Copyright (c) 2014, 2015 Carsten Kunze */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved * * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. */ #include #include #include #include "tdef.h" #ifdef NROFF #include "tw.h" #include "draw.h" #endif #include "pt.h" #ifdef NROFF #define GETCH gettch tchar gettch(void); #endif #ifndef NROFF #define GETCH getch #endif /* * troff7.c * * text */ #include #include #include #include "ext.h" #if defined (EUC) && defined (NROFF) && defined (ZWDELIMS) wchar_t cwc, owc, wceoll; #endif /* EUC && NROFF && ZWDELIMS */ static int brflg; #undef iswascii #define iswascii(c) (((c) & ~(wchar_t)0177) == 0) static int _findt(struct d *, int, int); static tchar adjbit(tchar); static void sethtdp(void); static void leftend(tchar, int, int); static void parword(void); static void parfmt(void); #ifndef NROFF #define nroff 0 extern int lastrst; extern int lastrsb; static void setlhang(tchar); static void setrhang(void); static void letshrink(void); static int letgrow(void); static int lspcomp(int); #else /* NROFF */ #define nroff 1 #define lastrst 0 #define lastrsb 0 #define setlhang(a) #define setrhang() #define getlsp(c) 0 #define storelsp(a, b) #define getlsh(c, w) 0 #define storelsh(a, b) #define letshrink() #define letgrow() 0 #define lspcomp(a) 0 #endif /* NROFF */ void tbreak(void) { register int pad, k; register tchar *i, j, c; register int resol = 0; int _minflg; restart: trap = 0; if (nb) return; if (dip == d && numtab[NL].val == -1) { newline(1); return; } if (!nc && !pgchars) { setnel(); if (!wch) return; if (pendw) getword(1); movword(); } else if (pendw && !brflg) { getword(1); movword(); } else if (!brflg && adflg & 1) { adflg |= 2; text(); return; } if ((pa || padj) && pglines == 0 && pgchars) { parfmt(); goto restart; } if (minspsz && !brflg && ad && !admod) ne += adspc; *linep = dip->nls = 0; #ifdef NROFF if (dip == d) horiz(po); #endif if (lnmod) donum(); lastl = ne; if (brflg != 1) { totout = 0; hlc = 0; } else if (ad) { if ((lastl = ll - un + rhang + lsplast) < ne) lastl = ne; } if (admod && ad && (brflg != 2)) { lastl = ne; adsp = adrem = 0; if (admod == 1) un += quant(nel / 2, HOR); else if (admod == 2) un += nel; } _minflg = minspsz && admod == 0 && ad && brflg == 1 && adflg & 4; totout++; brflg = 0; if (lastl + un > dip->maxl) dip->maxl = lastl + un; horiz(un); if (un != 0) pchar(mkxfunc(INDENT, un)); #ifdef NROFF if (adrem % t.Adj) resol = t.Hor; else resol = t.Adj; #else resol = HOR; #endif adrem = (adrem / resol) * resol; for (i = line; nc > 0; ) { if ((c = cbits(j = *i++)) == ' ' || c == STRETCH) { if ((xflag && !fi && dilev) || iszbit(j) || isadjspc(j)) goto std; pad = 0; if (i > &line[1]) pad += kernadjust(i[-2], i[-1]); do { if (xflag) pchar(adjbit(j)); minflg = _minflg; pad += width(j); nc--; } while ((c = cbits(j = *i++)) == ' ' || c == STRETCH); pad += kernadjust(i[-2], i[-1]); i--; pad += adsp; --nwd; if (adrem) { if (adrem < 0) { pad -= resol; adrem += resol; } else if ((totout & 01) || adrem / resol >= nwd) { pad += resol; adrem -= resol; } } pchar((tchar) WORDSP); horiz(pad); } else { std: if (!ismot(j) && isxfunc(j, FLDMARK)) fldcnt--; else if (fldcnt == 0 && nc && !ismot(j) && !iszbit(j)) { if (lspcur && (cbits(j) > ' ' || isxfunc(j, CHAR))) { for (c = j; isxfunc(c, CHAR); c = charout[sbits(c)].ch); k = (int)sbits(c) / 2 * lspcur / LAFACT; if (k >= 0) c = mkxfunc(LETSP, k); else c = mkxfunc(NLETSP, -k); pchar(c); } if (lshcur && cbits(j) > ' ') { k = lshcur; if (k >= 0) c = mkxfunc(LETSH, k); else c = mkxfunc(NLETSH, -k); pchar(c); } } pchar(j); nc--; } } if (hlc) pchar(mkxfunc(HYPHED, 0)); if (ic) { if ((k = ll - un - lastl + ics) > 0) horiz(k); pchar(ic); } if (icf) icf++; else ic = 0; ne = nwd = 0; un = in; setnel(); newline(0); if (dip != d) { if (dip->dnl > dip->hnl) dip->hnl = dip->dnl; } else { if (numtab[NL].val > dip->hnl) dip->hnl = numtab[NL].val; } for (k = ls - 1; k > 0 && !trap; k--) newline(0); spread = 0; spbits = 0; } void donum(void) { register int i, nw; nrbits = nmbits; nw = width('1' | nrbits); if (nn) { nn--; goto d1; } if (numtab[LN].val % ndf) { numtab[LN].val++; d1: un += nw * (3 + nms + ni); return; } i = 0; if (numtab[LN].val < 100) i++; if (numtab[LN].val < 10) i++; horiz(nw * (ni + i)); nform = 0; fnumb(numtab[LN].val, pchar); un += nw * nms; numtab[LN].val++; } void text(void) { register tchar i, c, lasti = 0; int k = 0; static int spcnt; int recadj = 0; if (adflg & 2) { adflg &= ~3; recadj = 1; goto adj; } adflg = 0; nflush++; numtab[HP].val = 0; if ((dip == d) && (numtab[NL].val == -1)) { newline(1); goto r; } setnel(); if (ce || rj || !fi) { nofill(); goto r; } if (pendw) goto t4; if (pendt) { if (spcnt) goto t2; else goto t3; } pendt++; if (spcnt) goto t2; while ((c = cbits(i = GETCH())) == ' ' || c == STRETCH) { if (iszbit(i)) break; if (isadjspc(i)) continue; spcnt++; widthp = xflag ? width(i) : sps; sethtdp(); numtab[HP].val += widthp; lasti = i; } if (lasti) { k = kernadjust(lasti, i); numtab[HP].val += k; widthp += k; } if (nlflg) { t1: nflush = pendt = ch = spcnt = 0; callsp(); goto r; } ch = i; if (spcnt) { t2: lsn = spcnt; glss = spcnt * sps + k; if (lsmac) { spcnt = 0; control(lsmac, 0); goto rtn; } else { tbreak(); if (nc || wch) goto rtn; un += glss; spcnt = 0; setnel(); if (trap) goto rtn; if (nlflg) goto t1; } } t3: if (spread && !brpnl) goto t5; if (pendw || !wch) t4: if (getword(0)) { if (!pendw) { if (brnl || (brpnl && spread)) goto tb; if (brpnl) goto t5; } goto t6; } if (!movword()) goto t3; t5: if (nlflg) pendt = 0; adj: adsp = adrem = 0; if (ad) { setrhang(); if (admod == 0 && lspcur == 0 && lshcur == 0 && nel < 0 && lspnc) letshrink(); jst: if (nwd == 1) adsp = nel; else adsp = nel / (nwd - 1); adsp = (adsp / HOR) * HOR; if (admod == 0 && lspcur == 0 && lshcur == 0 && adsp > letsps - sps) if (letgrow()) goto jst; adrem = nel - adsp*(nwd-1); if (admod == 0 && nwd == 1 && warn & WARN_BREAK) errprint("can't break line"); else if (admod == 0 && spreadwarn && adsp >= spreadlimit) errprint("spreadlimit exceeded, %gm", (double)adsp/EM); } brflg = 1; tb: tbreak(); spread = 0; if (!trap && !recadj && !brnl && !brpnl) goto t3; if (brnl > 0 && brnl < INT_MAX) brnl--; if (brpnl > 0 && brpnl < INT_MAX) brpnl--; if (!nlflg) goto rtn; t6: pendt = 0; ckul(); rtn: nflush = 0; r: if (chomp) { chomp = 0; chompend = 1; } } void nofill(void) { - register int j; + size_t j; register tchar i, nexti; int k, oev; if (chompend) { chompend = 0; } else if (!pendnf && !chomp) { over = 0; tbreak(); if (trap) goto rtn; if (nlflg) { ch = nflush = 0; callsp(); return; } adsp = adrem = 0; nwd = 10000; } nexti = GETCH(); leftend(nexti, !ce && !rj && !pendnf, !isdi(nexti)); while ((j = (cbits(i = nexti))) != '\n') { if (stopch && issame(i, stopch)) break; if (j == ohc) { nexti = GETCH(); continue; } if (j == CONT) { pendnf++; nflush = 0; flushi(); ckul(); return; } j = width(i); widthp = j; sethtdp(); numtab[HP].val += j; storeline(i, j); oev = ev; nexti = GETCH(); if (ev == oev) { k = kernadjust(i, nexti); ne += k; nel -= k; numtab[HP].val += k; } } if (chomp) { return; } if (ce) { ce--; if ((i = quant(nel / 2, HOR)) > 0) un += i; } if (rj) { rj--; setrhang(); if (nel > 0) un += nel; } if (!nc) storeline((tchar)FILLER, 0); brflg = 2; tbreak(); ckul(); rtn: pendnf = nflush = 0; } void callsp(void) { register int i; if (flss) i = flss; else i = lss; flss = 0; if (blmac && (fi || (frame->flags & FLAG_DIVERSION) == 0)) control(blmac, 0); else casesp(i); } void ckul(void) { if (ul && (--ul == 0)) { cu = 0; font = sfont; mchbits(); } if (it && !pglines && (!itc || (!pendw && !pendnf)) && (--it == 0) && itmac) control(itmac, 0); } int storeline(register tchar c, int w) { #ifdef NROFF if (ismot(c)) { if (isvmot(c)) { if (isnmot(c)) lvmot -= c & BMBITS; else lvmot += c & BMBITS; } } else if (ndraw && !(cbits(c) & ~0xffff)) { storechar(c, numtab[NL].val+lvmot, po + in + ne); } #endif if (linep == NULL || linep >= line + lnsize - 4) { tchar *k; if (over) return 0; lnsize += lnsize ? 100 : LNSIZE; if ((k = realloc(line, lnsize * sizeof *line)) == NULL) { flusho(); errprint("Line overflow."); over++; c = LEFTHAND; w = -1; goto s1; } linep = (tchar *)((char *)linep + ((char *)k - (char *)line)); line = k; } s1: if (w == -1) { minflg = minspsz && ad && !admod; w = width(c); } ne += w; nel -= w; *linep++ = c; nc++; return 1; } #ifndef NROFF static int getlsp(tchar c) { int s; if (!ad || admod || ismot(c)) return 0; if (iszbit(c) || (cbits(c) <= ' ' && !isxfunc(c, CHAR))) return 0; while (isxfunc(c, CHAR)) c = charout[sbits(c)].ch; s = sbits(c) / 2; return s; } static void storelsp(tchar c, int neg) { int s; if (isxfunc(c, FLDMARK)) { lsplow = lsphigh = lspnc = 0; fldcnt += neg ? -1 : 1; return; } if ((s = getlsp(c)) != 0) { if (neg) s = -s; lsplow += s * lspmin / LAFACT; lsphigh += s * lspmax / LAFACT; lspnc += neg ? -1 : 1; } } static int getlsh(tchar c, int w) { if (!ad || admod || ismot(c)) return 0; if (iszbit(c) || cbits(c) <= ' ') return 0; return w; } static void storelsh(tchar c, int w) { int s; if (isxfunc(c, FLDMARK)) { lshlow = lshhigh = lshwid = 0; return; } if ((s = getlsh(c, w)) != 0) { lshwid += s; lshlow = lshwid * lshmin / LAFACT; lshhigh = lshwid * lshmax / LAFACT; } } #endif /* !NROFF */ void newline(int a) { register int i, j, nlss = 0, nl; int opn; #ifdef NROFF if (lvmot) { tchar c; c = MOT | VMOT | (lvmot < 0 ? -lvmot : lvmot | NMOT); pchar1(c); lvmot = 0; } #endif if (a) goto nl1; if (dip != d) { j = lss; pchar1((tchar)FLSS); if (flss) lss = flss; i = nlss = lss + dip->blss; dip->dnl += i; pchar1((tchar)i); pchar1((tchar)'\n'); lss = j; dip->blss = flss = 0; if (dip->alss) { pchar1((tchar)FLSS); pchar1((tchar)dip->alss); pchar1((tchar)'\n'); dip->dnl += dip->alss; nlss += dip->alss; dip->alss = 0; } if (vpt > 0 && dip->ditrap && !dip->ditf && dip->dnl >= dip->ditrap && dip->dimac) if (control(dip->dimac, 0)) { trap++; dip->ditf++; } goto nlt; } j = lss; if (flss) lss = flss; nlss = dip->alss + dip->blss + lss; numtab[NL].val += nlss; #ifndef NROFF if (ascii) { dip->alss = dip->blss = 0; } #endif pchar1((tchar)'\n'); flss = 0; lss = j; if (vpt == 0 || numtab[NL].val < pl) goto nl2; nl1: ejf = dip->hnl = numtab[NL].val = 0; ejl = frame->tail_cnt; if (donef || (ndone && pgchars && !pglines)) { if ((!nc && !wch && !pglines) || ndone) done1(0); ndone++; donef = 0; if (frame == stk) nflush++; } opn = numtab[PN].val; numtab[PN].val++; if (npnflg) { numtab[PN].val = npn; npn = npnflg = 0; } prwatchn(&numtab[PN]); nlpn: if (numtab[PN].val == pfrom) { print++; pfrom = -1; } else if (opn == pto) { print = 0; opn = -1; chkpn(); goto nlpn; } if (print) newpage(numtab[PN].val); /* supposedly in a clean state so can pause */ if (stop && print) { dpn++; if (dpn >= stop) { dpn = 0; dostop(); } } nl2: trap = 0; nlt: if (dip != d) nl = dip->dnl; else nl = numtab[NL].val; if (vpt <= 0) /*EMPTY*/; else if (nl == 0) { if ((j = findn(dip, 0)) != NTRAP) trap |= control(dip->mlist[j], 0); } else if ((i = _findt(dip, nl - nlss, 0)) <= nlss) { if ((j = findn1(dip, nl - nlss + i)) == NTRAP) { flusho(); errprint("Trap botch."); done2(-5); } trap |= control(dip->mlist[j], 0); } if (nolt && dip == d) { for (i = nolt - 1; i >= 0; i--) trap |= control(olt[i], 0); nolt = 0; free(olt); olt = NULL; } } int findn1(struct d *dp, int a) { register int i, j; for (i = 0; i < NTRAP; i++) { if (dp->mlist[i]) { if ((j = dp->nlist[i]) < 0 && dp == d) j += pl; if (j == a) break; } } return(i); } void chkpn(void) { pto = *(pnp++); pfrom = pto>=0 ? pto : -pto; if (pto == -32767) { flusho(); done1(0); } if (pto < 0) { pto = -pto; print++; pfrom = 0; } } int findt(struct d *dp, int a) { return _findt(dp, a, 1); } static int _findt(struct d *dp, int a, int maydi) { register int i, j, k; k = INT_MAX; if (dip != d && maydi) { if (dip->dimac && (i = dip->ditrap - a) > 0) k = i; } for (i = 0; i < NTRAP; i++) { if (dp->mlist[i]) { if ((j = dp->nlist[i]) < 0 && dp == d) j += pl; if ((j -= a) <= 0) continue; if (j < k) k = j; } } if (dp == d) { i = pl - a; if (k > i) k = i; } return(k); } int findt1(void) { register int i; if (dip != d) i = dip->dnl; else i = numtab[NL].val; return(findt(dip, i)); } void eject(struct s *a) { register int savlss; #ifdef NROFF if (ndraw) npic(0); #endif if (dip != d) return; if (vpt == 0) { if (donef == 0) { errprint("page not ejected because traps are disabled"); return; } errprint("page forcefully ejected although traps are disabled"); vpt = -1; } ejf++; if (a) ejl = a->tail_cnt; else ejl = frame->tail_cnt; if (trap) return; e1: savlss = lss; lss = findt(d, numtab[NL].val); newline(0); lss = savlss; if (numtab[NL].val && !trap) goto e1; } static int maybreak(tchar c, int dv) { - int i, k = cbits(c); + size_t i, k = cbits(c); if (c & BLBIT) return 1; if (iszbit(c)) return 0; switch (breakch[0]) { case IMP: return 0; case 0: - return (!gemu || dv) && (k == '-' || k == EMDASH); + return (!gemu || dv) && (k == '-' || k == (size_t)EMDASH); default: for (i = 0; breakch[i] && i < NSENT; i++) if (breakch[i] == k) return 1; return 0; } } static int nhychar(tchar c) { - int i, k = cbits(c); + size_t i, k = cbits(c); switch (nhych[0]) { case IMP: return 0; case 0: if (hyext) return 0; - return k == '-' || k == EMDASH; + return k == '-' || k == (size_t)EMDASH; default: for (i = 0; nhych[i] && i < NSENT; i++) if (nhych[i] == k) return 1; return 0; } } static int ishyp(tchar *wp) { tchar *tp; int yes = 0; tp = (tchar *)((intptr_t)*hyp & ~(intptr_t)03); if (hyoff != 1 && tp == wp && !iszbit(*wp)) { if (!wdstart || (wp > wdstart + 1 && wp < wdend && (!(wdhyf & 04) || wp < wdend - 1) && /* 04 => last 2 */ (!(wdhyf & 010) || wp > wdstart + 2)) || /* 010 => 1st 2 */ (wdhyf & 020 && wp == wdend) || /* 020 = allow last */ (wdhyf & 040 && wp == wdstart + 1)) /* 040 = allow first */ yes = 1; hyp++; } return yes; } int movword(void) { register int w; register tchar i, *wp, c, *lp, *lastlp, lasti = 0; int savwch, hys, stretches = 0, wholewd = 0, mnel, hyphenated = 0; int hc; #ifndef NROFF tchar lgs = 0, lge = 0, optlgs = 0, optlge = 0; int *ip, s, lgw = 0, optlgw = 0, lgr = 0, optlgr = 0; tchar *optlinep = NULL, *optwp = NULL; int optnc = 0, optnel = 0, optne = 0, optadspc = 0, optwne = 0, optwch = 0, optwholewd = 0, optlsplow = 0, optlsphigh = 0, optlspnc = 0, optfldcnt = 0, optlshwid = 0, optlshlow = 0, optlshhigh = 0; #else /* NROFF */ #define lgw 0 #define optlinep 0 #endif /* NROFF */ if (pa || padj) { parword(); return(0); } over = 0; wp = wordp; if (!nwd) { while ((c = cbits(i = *wp++)) == ' ') { if (iszbit(i)) break; wch--; wne -= xflag ? width(i) : sps; if (xflag && linep > line) storeline(adjbit(i), 0); } wp--; if (wp > wordp) wne -= kernadjust(wp[-1], wp[0]); leftend(*wp, admod != 1 && admod != 2, 1); } if (wdhyf == -1) wdhyf = hyf; wsp = 0; if (wne > nel - adspc && !hyoff && wdhyf && (hlm < 0 || hlc < hlm) && (!nwd || nel + lsplow + lshlow - adspc > 3 * (minsps && ad && !admod ? minsps : sps)) && (!(wdhyf & 02) || (findt1() > lss))) hyphen(wp); savwch = wch; hyp = hyptr; nhyp = 0; while (*hyp && *hyp <= wp) hyp++; while (wch) { if (ishyp(wp)) { i = IMP; setsbits(i, (intptr_t)(hyp[-1]) & 03); if (storeline(i, 0)) nhyp++; } i = *wp++; minflg = minspsz && ad && !admod; w = width(i); storelsh(i, rawwidth); adspc += minspc; w += kernadjust(i, *wp); wne -= w; wch--; if (cbits(i) == STRETCH && cbits(lasti) != STRETCH) stretches++; lasti = i; storeline(i, w); if (letsps) storelsp(i, 0); } *linep = *wp; lastlp = linep; mnel = ad && !admod ? (sps - minsps) * nwd : 0; if (nel >= 0 || (nel + lsplow + lshlow >= 0 && lspnc - (nwd ? nwd : 1) > 0)) { if ((nel >= 0 && nwd && nel - adspc < 0 && nel / nwd < sps) || (nel < 0 && nel + lsplow + lshlow >= 0)) { wholewd = 1; goto m0; } nwd += stretches + 1; if (nel - adspc < 0 && nwd > 1) adflg |= 5; w = kernadjust(lasti, ' ' | (spbits?spbits:sfmask(lasti))); ne += w; nel -= w; return(0); /* line didn't fill up */ } m0: hc = shc ? shc : HYPHEN; #ifndef NROFF xbits((tchar)hc, 1); #endif hys = width((tchar)hc); if (wholewd) goto m1a; m1: if (!nhyp) { if (!nwd) goto m3; if (wch == savwch) { if (optlinep) goto m2; goto m4; } } if ((*--linep & ~SMASK) != IMP) goto m5; #ifndef NROFF i = *(linep + 1); if ((s = sbits(*linep)) != 0 && (ip = lgrevtab[fbits(i)][cbits(i)]) != NULL) { lgs = strlg(fbits(i), ip, s) | sfmask(i) | AUTOLIG; for (w = 0; ip[s+w]; w++); lge = strlg(fbits(i), &ip[s], w) | sfmask(i) | AUTOLIG; lgw = width(lgs); lgr = rawwidth; if (linep - 1 >= wordp) { lgw += kernadjust(i, *(linep - 1)); lgw -= kernadjust(*(linep + 1), *(linep - 1)); } } else { lgs = 0; lge = 0; lgw = 0; } #endif /* !NROFF */ if (!(--nhyp)) if (!nwd) goto m2; if (nel + lsplow + lshlow < hys + lgw) { nc--; goto m1; } if (nel >= mnel + hys + lgw) goto m2; wholewd = 0; m1a: #ifndef NROFF if ((minspsz && ad && !admod && wch < savwch && nwd && nel / nwd > 0 && nel < mnel) || (nel + lsplow + lshlow >= (wholewd ? 0 : hys + lgw) && nel < (wholewd ? 0 : hys + lgw))) { optlgs = lgs, optlge = lge, optlgw = lgw, optlgr = lgr; optlinep = linep, optwp = wp, optnc = nc, optnel = nel, optne = ne, optadspc = adspc, optwne = wne, optwch = wch; optlsplow = lsplow, optlsphigh = lsphigh, optlspnc = lspnc; optfldcnt = fldcnt; optlshwid = lshwid, optlshlow = lshlow, optlshhigh = lshhigh; optwholewd = wholewd; nc -= !wholewd; goto m1; } else if (wholewd) { wholewd = 0; goto m1; } #endif m2: #ifndef NROFF if (optlinep && 3*abs(optnel - mnel) < 5*abs(nel - mnel)) { lgs = optlgs, lge = optlge, lgw = optlgw, lgr = optlgr; linep = optlinep, wp = optwp, nc = optnc, nel = optnel, ne = optne, adspc = optadspc, wne = optwne, wch = optwch; lsplow = optlsplow, lsphigh = optlsphigh, lspnc = optlspnc; fldcnt = optfldcnt; lshwid = optlshwid, lshlow = optlshlow, lshhigh = optlshhigh; if ((wholewd = optwholewd)) goto m3; } else if (optlinep && wch == savwch && !nhyp) goto m4; if (lgs != 0) { *wp = lge; storeline(lgs, lgw); storelsh(lgs, lgr); } #endif /* !NROFF */ if (!maybreak(*(linep - 1), 1)) { *linep = sfmask(*(linep - 1)) | hc; w = -kernadjust(*(linep - 1), *(linep + 1)); w += kernadjust(*(linep - 1), *linep); w += width(*linep); storelsh(*linep, rawwidth); w += kernadjust(*linep, ' ' | sfmask(*linep)); nel -= w; ne += w; if (letsps) storelsp(*linep, 0); linep++; hyphenated++; } m3: nwd++; m4: if (letsps && linep > line) storelsp(linep[-1], 1); adflg &= ~1; adflg |= 4; wordp = wp; if (hyphenated) hlc++; else hlc = 0; return(1); /* line filled up */ m5: nc--; minflg = minspsz && ad && !admod; w = width(*linep); storelsh(*linep, -rawwidth); adspc -= minspc; for (lp = &linep[1]; lp < lastlp && cbits(*lp) == IMP; lp++); w += kernadjust(*linep, *lp ? *lp : ' ' | sfmask(*linep)); ne -= w; nel += w; wne += w; wch++; wp--; if (letsps) storelsp(*linep, 1); goto m1; } void horiz(int i) { vflag = 0; if (i) pchar(makem(i)); } void setnel(void) { if (!nc) { linep = line; if (un1 >= 0 && (!pgwords || pglines)) { un = un1; un1 = -1; } nel = ll - un; rhang = ne = adsp = adrem = adspc = 0; #ifndef NROFF lsplow = lsphigh = lspcur = lsplast = lspnc = fldcnt = 0; lshwid = lshhigh = lshlow = lshcur = 0; #endif /* !NROFF */ cht = cdp = 0; } } int getword(int x) { - register int j, k = 0, w; + size_t j, k = 0, w; register tchar i = 0, *wp, nexti, gotspc = 0, _t; int noword, n, inword = 0; int lastsp = ' '; static int dv; #if defined (EUC) && defined (NROFF) && defined (ZWDELIMS) wchar_t *wddelim; char mbbuf3[MB_LEN_MAX + 1]; char *mbbuf3p; int wbf; tchar m; #endif /* EUC && NROFF && ZWDELIMS */ dv = 0; noword = 0; if (x) if (pendw) { *pendw = 0; goto rtn; } if ((wordp = pendw)) goto g1; hyp = hyptr; wordp = word; over = wne = wch = 0; hyoff = 0; wdhyf = -1; memset(wdpenal, 0, wdsize * sizeof *wdpenal); n = 0; while (1) { /* picks up 1st char of word */ j = cbits(i = GETCH()); #if defined (EUC) && defined (NROFF) && defined (ZWDELIMS) if (multi_locale) collectmb(i); #endif /* EUC && NROFF && ZWDELIMS */ if (j == '\n') { wne = wch = 0; noword = 1; goto rtn; } if (j == ohc) { hyoff = 1; /* 1 => don't hyphenate */ continue; } if ((j == ' ' || (padj && j == STRETCH)) && !iszbit(i)) { lastsp = j; n++; if (isadjspc(i)) w = 0; else if (xflag && seflg && sesspsz == 0) { i |= ZBIT; w = 0; } else if (xflag && seflg && sesspsz && n == 1) { if (spbits) { i = lastsp | SENTSP | spbits; w = width(i); } else w = ses; } else if (spbits && xflag) { i = lastsp | spbits; w = width(i); } else w = sps; cht = cdp = 0; storeword(i, w); numtab[HP].val += w; if (!isadjspc(j)) { widthp = w; gotspc = i; spbits = sfmask(i); } continue; } if (gotspc) { k = kernadjust(gotspc, i); numtab[HP].val += k; wne += k; widthp += k; } break; } seflg = 0; #if defined (EUC) && defined (NROFF) && defined (ZWDELIMS) if (!multi_locale) goto a0; if (wddlm && iswprint(wceoll) && iswprint(cwc) && (!iswascii(wceoll) || !iswascii(cwc)) && !iswspace(wceoll) && !iswspace(cwc)) { wddelim = (*wddlm)(wceoll, cwc, 1); wceoll = 0; if (*wddelim != ' ') { if (!*wddelim) { storeword(((*wdbdg)(wceoll, cwc, 1) < 3) ? ZWDELIM(1) : ZWDELIM(2), 0); } else { while (*wddelim) { if ((n = wctomb(mbbuf3, *wddelim++)) > 0) { m = setuc0(wddelim[-1]); storeword(m, -1); } else { storeword(' ' | chbits, sps); break; } } } spflg = 0; goto g0; } } a0: #endif /* EUC && NROFF && ZWDELIMS */ if (spbits && xflag) { _t = lastsp | spbits; w = width(_t); } else { _t = lastsp | chbits; w = sps; } cdp = cht = 0; if (chompend) { chompend = 0; } else { storeword(_t, w + k); } if (spflg) { if (xflag == 0 || ses != 0) storeword(_t | SENTSP, ses); spflg = 0; } if (!nwd) wsp = wne; g0: if (ninlev) wdhyf = hyf; if (j == CONT) { pendw = wordp; nflush = 0; flushi(); return(1); } if (hyoff != 1) { if (j == ohc) { if (!inword && xflag) { hyoff = 1; goto g1; } hyoff = 2; *hyp++ = wordp; if (hyp > (hyptr + NHYP - 1)) hyp = hyptr + NHYP - 1; if (isblbit(i) && wordp > word) wordp[-1] |= BLBIT; goto g1; } if (maybreak(j, dv)) { if (wordp > word + 1) { int _i; if (!xflag) hyoff = 2; if (gemu && hyp > hyptr && wordp > word && hyp[-1] == wordp && ( (_i = cbits(wordp[-1])) == '-' || _i == EMDASH)) hyp--; *hyp++ = wordp + 1; if (hyp > (hyptr + NHYP - 1)) hyp = hyptr + NHYP - 1; } } else { int _i = cbits(j); dv = alph(j) || (_i >= '0' && _i <= '9'); } if (xflag && nhychar(j)) hyoff = 2; } j = width(i); numtab[HP].val += j; storeword(i, j); if (1) { int oev = ev; nexti = GETCH(); if (ev == oev) { if (cbits(nexti) == '\n') _t = ' ' | chbits; else _t = nexti; k = kernadjust(i, _t); wne += k; widthp += k; numtab[HP].val += k; } } else g1: nexti = GETCH(); j = cbits(i = nexti); if (gemu && (j == FILLER || j == UNPAD)) inword = 0; else if (!ismot(i) && j != ohc) inword = 1; #if defined (EUC) && defined (NROFF) && defined (ZWDELIMS) if (multi_locale) collectmb(i); #endif /* EUC && NROFF && ZWDELIMS */ { - static int sentchar[] = + static size_t sentchar[] = { '.', '?', '!', ':', 0 }; /* sentence terminators */ - int *sp, *tp; - static int transchar[] = + size_t *sp, *tp; + static size_t transchar[] = { '"', '\'', ')', ']', '*', 0, 0 }; transchar[5] = DAGGER; if ((j != '\n' && j != ' ' && (!padj || j != STRETCH)) || ismot(i) || iszbit(i) || isadjspc(i)) #if defined (EUC) && defined (NROFF) && defined (ZWDELIMS) if (!multi_locale) #endif /* EUC && NROFF && ZWDELIMS */ goto g0; #if defined (EUC) && defined (NROFF) && defined (ZWDELIMS) else { if (!wdbdg || (iswascii(cwc) && iswascii(owc))) goto g0; if ((wbf = (*wdbdg)(owc, cwc, 1)) < 5) { storeword((wbf < 3) ? ZWDELIM(1) : ZWDELIM(2), 0); *wordp = 0; goto rtn; } else goto g0; } #endif /* EUC && NROFF && ZWDELIMS */ if (j == STRETCH && padj) storeword(mkxfunc(PENALTY, INFPENALTY), 0); wp = wordp-1; /* handle extra space at end of sentence */ sp = *sentch ? sentch : sentchar; tp = *transch ? transch : transchar; while (sp[0] != IMP && wp >= word) { j = cbits(*wp--); if (istrans(wp[1])) goto cont; for (k = 0; tp[0] != IMP && tp[k] && k < NSENT; k++) if (j == tp[k]) goto cont; for (k = 0; sp[k] && k < NSENT; k++) if (j == sp[k]) { if (nlflg) spflg++; else seflg++; break; } break; cont:; } } #if defined (EUC) && defined (NROFF) && defined (ZWDELIMS) wceoll = owc; #endif /* EUC && NROFF && ZWDELIMS */ *wordp = 0; numtab[HP].val += xflag ? width(i) : sps; rtn: if (i & SFMASK) spbits = sfmask(i); else if (i == '\n') spbits = chbits; for (wp = word; *wp; wp++) { j = cbits(*wp); if ((j == ' ' || j == STRETCH) && !iszbit(j) && !isadjspc(j)) continue; if (!ischar(j) || (!isdigit(j) && j != '-')) break; } if (*wp == 0) /* all numbers, so don't hyphenate */ hyoff = 1; wdstart = 0; wordp = word; pendw = 0; *hyp++ = 0; setnel(); return(noword); } void storeword(register tchar c, register int w) { if (wordp == NULL || wordp >= &word[wdsize - 3]) { tchar *k, **h; ptrdiff_t j; int *pp, owdsize; if (over) return; owdsize = wdsize; wdsize += wdsize ? 100 : WDSIZE; if ((k = realloc(word, wdsize * sizeof *word)) == NULL || (pp = realloc(wdpenal, wdsize * sizeof *wdpenal)) == NULL) { flusho(); errprint("Word overflow."); over++; c = LEFTHAND; w = -1; wdsize = owdsize; goto s1; } j = (char *)k - (char *)word; wordp = (tchar *)((char *)wordp + j); for (h = hyptr; h < hyp; h++) if (*h) *h = (tchar *)((char *)*h + j); word = k; wdpenal = pp; memset(&wdpenal[owdsize], 0, (wdsize - owdsize) * sizeof *wdpenal); } s1: if (isxfunc(c, PENALTY)) { wdpenal[max(0, wordp - word - 1)] = sbits(c) | 0x80000000; return; } if (isxfunc(c, DPENAL)) { if ((wdpenal[max(0, wordp - word - 1)]&0x80000000) == 0) wdpenal[max(0, wordp - word - 1)] = sbits(c); return; } if (w == -1) w = width(c); widthp = w; sethtdp(); wne += w; *wordp++ = c; wch++; if (dpenal) wdpenal[max(0, wordp - word - 1)] = dpenal; } #ifdef NROFF tchar gettch(void) { extern int c_isalnum; tchar i; int j; i = getch(); j = cbits(i); if (ismot(i) || fbits(i) != ulfont) return(i); if (cu) { if (trtab[j] == ' ') { setcbits(i, '_'); setfbits(i, FT); /* default */ } return(i); } /* should test here for characters that ought to be underlined */ /* in the old nroff, that was the 200 bit on the width! */ /* for now, just do letters, digits and certain special chars */ if (j <= 127) { if (!isalnum(j)) setfbits(i, FT); } else { if (j < c_isalnum) setfbits(i, FT); } return(i); } #endif #if defined (EUC) && defined (NROFF) && defined (ZWDELIMS) int collectmb(tchar i) { owc = cwc; cwc = tr2un(cbits(i), fbits(i)); return(0); } #endif /* EUC && NROFF && ZWDELIMS */ static tchar adjbit(tchar c) { if (cbits(c) == ' ') setcbits(c, WORDSP); return(c | ADJBIT); } static void sethtdp(void) { if ((cht = lastrst) > maxcht) maxcht = cht; if ((cdp = -lastrsb) > maxcdp) maxcdp = cdp; } static void leftend(tchar c __unused, int hang, int dolpfx) { int k, w; if (dolpfx && lpfx) { if (hang) setlhang(lpfx[0]); for (k = 0; lpfx[k]; k++) { w = width(lpfx[k]); w += k ? kernadjust(lpfx[k-1], lpfx[k]) : 0; storeline(lpfx[k], w); } if (k) { w = kernadjust(lpfx[k-1], c); nel -= w; ne += w; } } else if (hang) setlhang(c); } #ifndef NROFF static void setlhang(tchar c) { int k; if (lhangtab != NULL && !ismot(c) && cbits(c) != SLANT && cbits(c) != XFUNC && lhangtab[fbits(c)] != NULL && (k = lhangtab[fbits(c)][cbits(c)]) != 0) { width(c); /* set xpts */ k = (k * u2pts(xpts) + (Unitwidth / 2)) / Unitwidth; nel -= k; storeline(makem(k), 0); } } static void setrhang(void) { int j, k; tchar c; if (nc > 0) { c = 0; for (j = nc - 1; j >= 0; j--) if ((c = line[j]) != IMP) break; width(c); j = lasttrack; j += kernadjust(c, ' ' | sfmask(c)); if (admod != 1 && rhangtab != NULL && !ismot(c) && rhangtab[xfont] != NULL && (k = rhangtab[xfont][cbits(c)]) != 0) { rhang = (k * u2pts(xpts) + (Unitwidth / 2)) / Unitwidth; j += rhang; } ne -= j; nel += j; } } static void letshrink(void) { int diff, nsp, lshdiff; nsp = nwd == 1 ? nwd : nwd - 1; diff = nel; if (lspnc && lsplow) diff += nel * nsp / lspnc; if (lshwid) { if (lshlow < -diff / 2) lshcur = -lshmin; else if (lsplow < -diff / 2) lshcur = (double)(diff - lsplow) / lshwid * LAFACT; else lshcur = (double)diff / 2 / lshwid * LAFACT; lshdiff = (double)lshcur / LAFACT * lshwid; nel -= lshdiff; ne += lshdiff; } else lshdiff = 0; diff -= lshdiff; if (lsplow) lspcur = lspmin * diff / lsplow; else lspcur = 0; ne += lspcomp(lshdiff); } static int letgrow(void) { int diff, n, nsp, lshdiff; nsp = nwd == 1 ? nwd : nwd - 1; if ((lspnc - nsp <= 0 || lsphigh <= 0) && lshhigh <= 0) return 0; n = (letsps - (minsps && ad && !admod ? minsps : sps)) * nsp; diff = nel; if (lspnc && lsphigh) diff += nel * nsp / lspnc - n; if (lshwid) { if (lshhigh < diff / 2) lshcur = lshmax; else if (lsphigh < diff / 2) lshcur = (double)(diff - lsphigh) / lshwid * LAFACT; else lshcur = (double)diff / 2 / lshwid * LAFACT; lshdiff = (double)lshcur / LAFACT * lshwid; nel -= lshdiff; ne += lshdiff; } else lshdiff = 0; diff -= lshdiff; if (diff > lsphigh) diff = lsphigh; if (lsphigh) lspcur = lspmax * diff / lsphigh; else lspcur = 0; return lspcomp(lshdiff); } static int lspcomp(int idiff) { int diff = 0, i; tchar c; diff = 0; for (i = 0; i < nc; i++) if (!ismot(c = line[i])) { if (isxfunc(c, FLDMARK)) diff = lsplast = 0; else if (cbits(c) > ' ' || isxfunc(c, CHAR)) { while (isxfunc(c, CHAR)) c = charout[sbits(c)].ch; lsplast = (int)sbits(c) / 2 * lspcur / LAFACT; diff += lsplast; } } diff -= lsplast; nel -= diff; ne += lsplast; return idiff + diff; } #endif /* !NROFF */ /* * A dynamic programming approach to line breaking over * a paragraph as introduced by D. E. Knuth & M. F. Plass, * "Breaking paragraphs into lines", Software - Practice * and Experience, Vol. 11, Issue 12 (1981), pp. 1119-1184. */ static double penalty(int k, int s, int h, int h2, int h3) { double _t, _d; _t = nel - k; _t = _t >= 0 ? _t * 5 / 3 : -_t; if (ad && !admod) { _d = s; if (k - s && (letsps || lshmin || lshmax)) _d += (double)(k - s) / 100; if (_d) _t /= _d; } else _t /= nel / 10; if (h && hypp) _t += hypp; if (h2 && hypp2) _t += hypp2; if (h3 && hypp3) _t += hypp3; _t = _t * _t * _t; if (_t > MAXPENALTY) _t = MAXPENALTY; return _t; } static void parcomp(int start) { double *cost, *_cost; long double _t; int *prevbreak, *hypc, *_hypc, *brcnt, *_brcnt; int i, j, k, m, h, v, s; _cost = malloc((pgsize + 1) * sizeof *_cost); cost = &_cost[1]; _hypc = calloc(pgsize + 1, sizeof *_hypc); hypc = &_hypc[1]; _brcnt = calloc(pgsize + 1, sizeof *_brcnt); brcnt = &_brcnt[1]; prevbreak = calloc(pgsize, sizeof *prevbreak); for (i = -1; i < start; i++) cost[i] = 0; for (i = start; i < pgwords; i++) cost[i] = HUGE_VAL; for (i = start; i < pgwords; i++) { if (pshapes) { j = brcnt[i-1]; if (j < pshapes) nel = pgll[j] - pgin[j]; else nel = pgll[pshapes-1] - pgin[pshapes-1]; } else if (un != in) { nel = ll; nel -= i > start ? in : un; } k = pgwordw[i] + pglgsw[i]; m = pglsphc[i] + pglgsh[i]; s = 0; for (j = i; j < pgwords; j++) { if (j > i) { k += pgspacw[j] + pgwordw[j]; m += pgadspc[j] + pglsphc[j]; s += pgspacw[j]; } v = k + pghyphw[j] + pglgew[j]; if (v - m - pglgeh[j] <= nel) { if (!spread && j == pgwords - 1 && pgpenal[j] == 0) _t = 0; else _t = penalty(v, s, pghyphw[j], pghyphw[j] && hypc[i-1], pghyphw[j] && j >= pglastw); _t += pgpenal[j]; _t += cost[i-1]; /*fprintf(stderr, "%c%c%c%c to %c%c%c%c " "t=%g cost[%d]=%g " "brcnt=%d oldbrcnt=%d\n", (char)para[pgwordp[i]], (char)para[pgwordp[i]+1], (char)para[pgwordp[i]+2], (char)para[pgwordp[i]+3], (char)para[pgwordp[j+1]-4], (char)para[pgwordp[j+1]-3], (char)para[pgwordp[j+1]-2], (char)para[pgwordp[j+1]-1], t, j, cost[j], 1 + brcnt[i-1], brcnt[j] );*/ if ((double)_t <= cost[j]) { if (pghyphw[j]) h = hypc[i-1] + 1; else h = 0; /* * This is not completely * correct: It might be * preferable to disallow * an earlier hyphenation * point. But it seems * good enough. */ if (hlm < 0 || h <= hlm) { hypc[j] = h; cost[j] = _t; prevbreak[j] = i; brcnt[j] = 1 + brcnt[i-1]; } } } else { if (j == i) { _t = 1 + cost[i-1]; cost[j] = _t; prevbreak[j] = i; brcnt[j] = 1 + brcnt[i-1]; } break; } } } /*for (i = 0; i < pgwords; i++) fprintf(stderr, "cost[%d] = %g %c%c%c%c to %c%c%c%c\n", i, cost[i], (char)para[pgwordp[prevbreak[i]]], (char)para[pgwordp[prevbreak[i]]+1], (char)para[pgwordp[prevbreak[i]]+2], (char)para[pgwordp[prevbreak[i]]+3], (char)para[pgwordp[i]], (char)para[pgwordp[i]+1], (char)para[pgwordp[i]+2], (char)para[pgwordp[i]+3] );*/ pglines = 0; memset(&pgopt[pglnout], 0, (pgsize - pglnout) * sizeof *pgopt); i = j = pgwords - 1; do { pglines++; j = prevbreak[j]; pgopt[i--] = j--; } while (j >= start && i >= pglnout); memmove(&pgopt[pglnout+1], &pgopt[i+2], pglines * sizeof *pgopt); pgopt[pglnout] = start; free(_cost); free(_hypc); free(_brcnt); free(prevbreak); } void growpgsize(void) { pgsize += 20; pgwordp = realloc(pgwordp, pgsize * sizeof *pgwordp); pgwordw = realloc(pgwordw, pgsize * sizeof *pgwordw); pghyphw = realloc(pghyphw, pgsize * sizeof *pghyphw); pgadspc = realloc(pgadspc, pgsize * sizeof *pgadspc); pglsphc = realloc(pglsphc, pgsize * sizeof *pglsphc); pgopt = realloc(pgopt, pgsize * sizeof *pgopt); pgspacp = realloc(pgspacp, pgsize * sizeof *pgspacp); pgspacw = realloc(pgspacw, pgsize * sizeof *pgspacw); pglgsc = realloc(pglgsc, pgsize * sizeof *pglgsc); pglgec = realloc(pglgec, pgsize * sizeof *pglgec); pglgsw = realloc(pglgsw, pgsize * sizeof *pglgsw); pglgew = realloc(pglgew, pgsize * sizeof *pglgew); pglgsh = realloc(pglgsh, pgsize * sizeof *pglgsh); pglgeh = realloc(pglgeh, pgsize * sizeof *pglgeh); pgin = realloc(pgin, pgsize * sizeof *pgin); pgll = realloc(pgll, pgsize * sizeof *pgll); pgwdin = realloc(pgwdin, pgsize * sizeof *pgwdin); pgwdll = realloc(pgwdll, pgsize * sizeof *pgwdll); pgflags = realloc(pgflags, pgsize * sizeof *pgflags); pglno = realloc(pglno, pgsize * sizeof *pglno); pgpenal = realloc(pgpenal, pgsize * sizeof *pgpenal); if (pgwordp == NULL || pgwordw == NULL || pghyphw == NULL || pgopt == NULL || pgspacw == NULL || pgadspc == NULL || pglsphc == NULL || pglgsc == NULL || pglgec == NULL || pglgsw == NULL || pglgew == NULL || pglgsh == NULL || pglgeh == NULL || pgin == NULL || pgll == NULL || pgwdin == NULL || pgwdll == NULL || pgflags == NULL || pglno == NULL || pgpenal == NULL || pgwdin == NULL || pgwdin == NULL) { errprint("out of memory justifying paragraphs"); done(02); } } static void parlgzero(int i) { pglgsc[i] = 0; pglgec[i] = 0; pglgsw[i] = 0; pglgew[i] = 0; pglgsh[i] = 0; pglgeh[i] = 0; } static float makepgpenal(int p) { p &= ~0x80000000; p -= INFPENALTY0 + 1; if (p >= INFPENALTY0) return INFPENALTY; else if (p <= -INFPENALTY0) return -INFPENALTY; else return p * PENALSCALE; } static void parword(void) { int a, c, w, hc; tchar i, *wp; if (pgwords + 1 >= pgsize) growpgsize(); hc = shc ? shc : HYPHEN; pglastw = pgwords; wp = wordp; a = w = 0; pglno[pgwords] = numtab[CD].val; pgspacp[pgwords] = pgspacs; pgpenal[pgwords] = 0; pgwdin[pgwords] = in; pgwdll[pgwords] = ll; if (pgwords == 0) pgflags[pgwords] = 0; un1 = -1; while ((c = cbits(i = *wp++)) == ' ' || c == STRETCH) { if (iszbit(i)) break; wch--; minflg = minspsz && ad && !admod; w += width(i); a += minspc; w += kernadjust(wp[-1], wp[0]); if (pgspacs >= pgssize) { pgssize += 60; parsp = realloc(parsp, pgssize * sizeof *parsp); if (parsp == NULL) { errprint("no memory for spaces in paragraph"); done(02); } } parsp[pgspacs++] = i; if (c == STRETCH) pgpenal[pgwords] = INFPENALTY; else if (wdpenal[wp-word-1]) pgpenal[pgwords] = makepgpenal(wdpenal[wp-word-1]); } if (wch == 0) return; pgspacp[pgwords+1] = pgspacs; if (--wp > wordp && pgchars > 0) w += kernadjust(para[pgchars-1], wordp[0]); wne -= w; pgspacw[pgwords] = pgwords ? w + a : 0; pghyphw[pgwords] = 0; pgadspc[pgwords] = pgwords ? a : 0; pglsphc[pgwords] = 0; pgwordw[pgwords] = 0; pgwordp[pgwords] = pgchars; pgne += pgspacw[pgwords]; parlgzero(pgwords); parlgzero(pgwords+1); if (wdhyf == -1) wdhyf = hyf; if (!hyoff && wdhyf && hlm) hyphen(wp); hyp = hyptr; nhyp = 0; while (*hyp && *hyp <= wp) hyp++; while (wch) { if (ishyp(wp) && !maybreak(wp[-1], 1)) { i = sfmask(wp[-1]) | hc; w = width(i); w += kernadjust(wp[-1], i); pghyphw[pgwords] = w; #ifndef NROFF { int *ip; intptr_t n; tchar e, s; n = (intptr_t)hyp[-1] & 03; ip = n ? lgrevtab[fbits(*wp)][cbits(*wp)] : NULL; if (n != 0 && ip != NULL) { pglgec[pgwords] = e = strlg(fbits(*wp), ip, n) | sfmask(*wp) | AUTOLIG; for (w = 0; ip[n+w]; w++); pglgsc[pgwords+1] = s = strlg(fbits(*wp), &ip[n], w) | sfmask(*wp) | AUTOLIG; pglgew[pgwords] = width(e); pglgeh[pgwords] = getlsh(e, rawwidth) * lshmin / LAFACT; pglgew[pgwords] += kernadjust(wp[-1], e); pghyphw[pgwords] += kernadjust(e, i); pghyphw[pgwords] -= kernadjust(wp[-1], i); pglgsw[pgwords+1] = width(s); pglgsh[pgwords+1] = getlsh(s, rawwidth) * lshmin / LAFACT; pglgsw[pgwords+1] -= width(*wp); pglgsh[pgwords+1] -= getlsh(*wp, rawwidth) * lshmin / LAFACT; pglgsw[pgwords+1] += kernadjust(s, wp[1]); pglgsw[pgwords+1] -= kernadjust(wp[0], wp[1]); } } #endif /* !NROFF */ } if (pghyphw[pgwords] || (wp > word && maybreak(wp[-1], 1))) { if (pghyphw[pgwords]) pghyphw[pgwords] -= kernadjust(wp[-1], wp[0]); pgne += pgwordw[pgwords]; pgwordp[++pgwords] = pgchars; if (pgwords + 1 >= pgsize) growpgsize(); pglno[pgwords] = numtab[CD].val; pgspacp[pgwords] = pgspacs; pgspacp[pgwords+1] = pgspacs; pgspacw[pgwords] = 0; pgwordw[pgwords] = 0; pghyphw[pgwords] = 0; pgadspc[pgwords] = 0; pglsphc[pgwords] = 0; pgpenal[pgwords] = 0; pgwdin[pgwords] = in; pgwdll[pgwords] = ll; pgflags[pgwords] = 0; parlgzero(pgwords+1); } i = *wp++; w = width(i); pglsphc[pgwords] += getlsh(i, rawwidth) * lshmin / LAFACT; w += kernadjust(i, *wp); wne -= w; wch--; pgwordw[pgwords] += w; if (letsps) pglsphc[pgwords] += getlsp(i) * lspmin / LAFACT; if (pgchars + 1 >= pgcsize) { pgcsize += 600; para = realloc(para, pgcsize * sizeof *para); if (para == NULL) { errprint("no memory for characters " "in paragraph"); done(02); } } para[pgchars++] = i; if (wdpenal[wp-word-1]) pgpenal[pgwords] = makepgpenal(wdpenal[wp-word-1]); } pgne += pgwordw[pgwords]; pgwordp[++pgwords] = pgchars; pgspacw[pgwords] = 0; pgwordw[pgwords] = 0; pghyphw[pgwords] = 0; pgadspc[pgwords] = 0; pglsphc[pgwords] = 0; pgpenal[pgwords] = 0; pgwdin[pgwords] = in; pgwdll[pgwords] = ll; pgflags[pgwords] = 0; parlgzero(pgwords); if (spread) tbreak(); } static void pbreak(int sprd, int lastf, struct s *s) { int j; if (sprd) adflg |= 5; if (pshapes) { j = pglnout < pshapes ? pglnout : pshapes - 1; un = pgin[j]; } nlflg = 1; tbreak(); pglnout++; if (trap) { extern jmp_buf sjbuf; jmp_buf savsjbuf; if (setjmp(*s->jmp) == 0) { nlflg = 1; memcpy(&savsjbuf, &sjbuf, sizeof sjbuf); if (donep && lastf) donef = -1; mainloop(); } memcpy(&sjbuf, &savsjbuf, sizeof sjbuf); } } static void parpr(struct s *s) { int i, j, k = 0, nw = 0, w, stretches, _spread = spread, hc; int savll, savin, savcd, lastin, lastll, curin, curll; tchar c, e, lastc, lgs; savll = ll; savin = in; curin = 0; lastin = 0; curll = -1; lastll = 0; savcd = numtab[CD].val; hc = shc ? shc : HYPHEN; nw = 0; for (i = 0; i < pgwords; i++) { lgs = 0; numtab[CD].val = pglno[i]; if (i == 0 || pgflags[i] & PG_NEWIN) lastin = pgwdin[i]; if (i == 0 || pgflags[i] & PG_NEWLL) lastll = pgwdll[i]; if (k == 0 || pgopt[k] == i) { if (k++ > 0) { if (pghyphw[i-1]) { #ifndef NROFF if ((e = pglgec[i-1]) != 0) { w = width(e); storelsh(e, rawwidth); w += kernadjust(para[pgwordp[i]-1], e); storeline(e, w); if (letsps) storelsp(e, 0); lgs = pglgsc[i]; } else #endif e = para[pgwordp[i]-1]; c = sfmask(e) | hc; w = width(c); storelsh(c, rawwidth); w += kernadjust(e, c); storeline(c, w); if (letsps) storelsp(c, 0); } pbreak(1, i >= pgwords, s); if (i >= pgwords) break; } if (pshapes) { if (k == 1) parcomp(0); j = k-1 < pshapes ? k-1 : pshapes - 1; ll = pgll[j]; un = pgin[j]; nel = ll - un; } else if (k > 1 && (in != curin || ll != curll)) { savin = curin = lastin = in; savll = curll = lastll = ll; un = in; nel = ll - un; parcomp(i); } else if (lastin != curin || lastll != curll) { savin = in = curin = lastin; savll = ll = curll = lastll; if (k > 1) un = in; nel = ll - un; parcomp(i); } nel = ll - un; nw = nwd = 1; leftend(para[pgwordp[i]], admod != 1 && admod != 2, 1); } else { for (j = pgspacp[i]; j < pgspacp[i+1]; j++) { c = parsp[j]; minflg = minspsz && ad && !admod; w = width(c); adspc += minspc; if (j == pgspacp[i] && i > 0) w += kernadjust(para[pgwordp[i]-1], c); if (j == pgspacp[i+1]-1) w += kernadjust(c, para[pgwordp[i]]); storeline(c, w); spbits = sfmask(c); } nwd += pgspacp[i] != pgspacp[i+1]; } stretches = 0; lastc = 0; for (j = pgwordp[i]; j < pgwordp[i+1]; j++) { c = lgs ? lgs : para[j]; lgs = 0; w = width(c); storelsh(c, rawwidth); if (j == pgwordp[i] && i > 0 && nw > 1 && pgspacp[i] == pgspacp[i+1]) w += kernadjust(para[j-1], c); if (j < pgwordp[i+1]-1) w += kernadjust(c, para[j+1]); storeline(c, w); if (cbits(c) == STRETCH && cbits(lastc) != STRETCH) stretches++; lastc = c; if (letsps) storelsp(c, 0); } nwd += stretches; nw++; } pbreak((nel - adspc < 0 && nwd > 1) || _spread, 1, s); if (pgflags[pgwords] & PG_NEWIN) savin = pgwdin[pgwords]; if (pgflags[pgwords] & PG_NEWLL) savll = pgwdll[pgwords]; pgwords = pgchars = pgspacs = pglines = pgne = pglastw = 0; ll = savll; in = un = savin; numtab[CD].val = savcd; } static void parfmt(void) { int _nlflg = nlflg; int _spread = spread; struct s *s; if (pgchars == 0) return; setnel(); pglnout = 0; s = frame; nxf->jmp = malloc(sizeof *nxf->jmp); pushi(-2, 0, FLAG_PARAGRAPH); parpr(frame); while (frame != s) ch = popi(); nlflg = _nlflg; if (_spread == 1 && pshapes > pglnout) { memmove(&pgin[0], &pgin[pglnout], (pshapes - pglnout) * sizeof *pgin); memmove(&pgll[0], &pgll[pglnout], (pshapes - pglnout) * sizeof *pgll); pshapes -= pglnout; } else pshapes = 0; } Index: vendor/heirloom-doctools/dist/troff/n8.c =================================================================== --- vendor/heirloom-doctools/dist/troff/n8.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/n8.c (revision 310550) @@ -1,648 +1,648 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* from OpenSolaris "n8.c 1.8 05/06/08 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)n8.c 1.44 (gritter) 9/26/10 */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved * * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. */ #include #include #ifdef EUC #include #endif #include #include #include #include "tdef.h" #include "ext.h" #include "pt.h" #include "libhnj/hyphen.h" #define HY_BIT 0200 /* generic stuff in here only works for ascii */ #define HY_BIT2 0x80000000 /* * troff8.c * * hyphenation */ static int *hbuf; static int NHEX; static int *nexth; static tchar *hyend; #define THRESH 160 /*digram goodness threshold*/ static int thresh = THRESH; static void hyphenhnj(void); static int * growhbuf(int **pp) { int *nhbuf; int inc = 4; ptrdiff_t j; if ((nhbuf = realloc(hbuf, (NHEX+inc) * sizeof *hbuf)) == NULL) return NULL; NHEX += inc; j = (char *)nhbuf - (char *)hbuf; nexth = (int *)((char *)nexth + j); if (pp) *pp = (int *)((char *)*pp + j); return hbuf = nhbuf; } void hyphen(tchar *wp) { register int j; register tchar *i; tchar *_wdstart, *_wdend; i = wp; while (punct(*i++)) ; if (!alph(*--i)) return; wdstart = i++; while (hyext ? *i++ : alph(*i++)) ; hyend = wdend = --i - 1; while (punct(*i++)) ; if (*--i) return; if (!(wdhyf & 060) && (wdend - wdstart - (hylen - 1)) < 0) return; hyp = hyptr; *hyp = 0; hyoff = 2; if (dicthnj) { i = _wdstart = wdstart; _wdend = wdend; do { - if (cbits(*i) == '-' || cbits(*i) == EMDASH || + if (cbits(*i) == '-' || cbits(*i) == (size_t)EMDASH || i == _wdend) { while (wdstart <= i && (punct(*wdstart) || (cbits(*wdstart) >= '0' && cbits(*wdstart) <= '9'))) wdstart++; for (wdend = wdstart; wdend <= i; wdend++) { if (!alph(*wdend) || (cbits(*wdend) >= '0' && cbits(*wdend) <= '9')) break; } hyend = --wdend; if ((wdhyf & 060 || wdstart + 3 <= wdend) && !exword()) hyphenhnj(); wdstart = &i[1]; if (i < _wdend) { *hyp++ = &i[1]; if (hyp > (hyptr + NHYP - 1)) hyp = hyptr + NHYP - 1; } } } while (i++ <= _wdend); wdstart = _wdstart; wdend = _wdend; } else if (!exword() && !suffix()) digram(); *hyp++ = 0; if (*hyptr) for (j = 1; j; ) { j = 0; for (hyp = hyptr + 1; *hyp != 0; hyp++) { if (*(hyp - 1) > *hyp) { j++; i = *hyp; *hyp = *(hyp - 1); *(hyp - 1) = i; } } } } int punct(tchar i) { if (!cbits(i) || alph(i)) return(0); else return(1); } int alph(tchar j) { int i; int f; int h; while (isxfunc(j, CHAR)) j = charout[sbits(j)].ch; i = cbits(j); f = fbits(j); if (!ismot(j) && i < nhcode && (h = hcode[i]) != 0) { if (h & ~0177) h = tr2un(h, f); #ifdef EUC return hyext ? iswalnum(h) : iswalpha(h); } else #else /* !EUC */ i = h; } #endif /* !EUC */ #ifdef EUC if (!ismot(j) && i & ~0177) { int u; #ifndef NROFF if (islig(j) && hyext && lgrevtab && lgrevtab[f] && lgrevtab[f][i]) return 1; #endif /* !NROFF */ u = tr2un(i, f); if (u == 0x017F) /* longs */ u = 's'; return hyext ? iswalnum(u) : iswalpha(u); } else #endif /* EUC */ if ((!ismot(j) && i >= 'a' && i <= 'z') || (i >= 'A' && i <= 'Z') || (hyext && i >= '0' && i <= '9')) return(1); else return(0); } void caseht(void) { thresh = THRESH; if (skip(0)) return; noscale++; thresh = hatoi(); noscale = 0; } void casehw(void) { register int i, k; int *j; tchar t; int cnt = 0; lgf++; if (nexth == NULL) growhbuf(NULL); k = 0; while (!skip(!cnt++)) { if ((j = nexth) >= (hbuf + NHEX - 2) && growhbuf(&j) == NULL) goto full; for (; ; ) { if (ismot(t = getch())) continue; i = cbits(t); if (i == ' ' || i == '\n') { *j++ = 0; nexth = j; *j = 0; if (i == ' ') break; else return; } if (i == '-') { k = HY_BIT2; continue; } *j++ = maplow(t) | k; k = 0; if (j >= (hbuf + NHEX - 2) && growhbuf(&j) == NULL) goto full; } } return; full: errprint("exception word list full."); *nexth = 0; } int exword(void) { register tchar *w; register int *e; int *save; e = hbuf; while (1) { save = e; if (e == NULL || *e == 0) return(0); w = wdstart; while (*e && w <= hyend) { #ifndef NROFF int i, m, f; m = cbits(*w); f = fbits(*w); if (islig(*w) && lgrevtab && lgrevtab[f] && lgrevtab[f][m]) { for (i = 0; lgrevtab[f][m][i]; i++) { if ((*e&~HY_BIT2) == maplow(lgrevtab[f][m][i])) { e++; } else goto end; } w++; } else #endif { if ((*e&~HY_BIT2) == maplow(*w)) { e++; w++; } else goto end; } } end: if (!*e) { if (w-1 == hyend || (w == wdend && maplow(*w) == 's')) { w = wdstart; for (e = save; *e; e++) { #ifndef NROFF int i, m, f; m = cbits(*w); f = fbits(*w); if (islig(*w) && lgrevtab && lgrevtab[f] && lgrevtab[f][m]) { for (i = 0; lgrevtab[f][m][i]; i++) { if (*e++ & HY_BIT2) { *hyp = (void *) ((intptr_t)w | i); hyp++; } } e--; } else #endif { if (*e & HY_BIT2) *hyp++ = w; } w++; if (hyp > (hyptr + NHYP - 1)) hyp = hyptr + NHYP - 1; } return(1); } else { e++; continue; } } else while (*e++) ; } } int suffix(void) { register tchar *w; register const char *s, *s0; tchar i; extern const char *suftab[]; again: i = cbits(*hyend); if (i >= 128 || !alph(*hyend)) return(0); if (i < 'a') i -= 'A' - 'a'; if ((s0 = suftab[i-'a']) == 0) return(0); for (; ; ) { if ((i = *s0 & 017) == 0) return(0); s = s0 + i - 1; w = hyend - 1; while (s > s0 && w >= wdstart && (*s & 0177) == maplow(*w)) { s--; w--; } if (s == s0) break; s0 += i; } s = s0 + i - 1; w = hyend; if (*s0 & HY_BIT) goto mark; while (s > s0) { w--; if (*s-- & HY_BIT) { mark: hyend = w - 1; if (*s0 & 0100) continue; if (!chkvow(w)) return(0); *hyp++ = w; } } if (*s0 & 040) return(0); if (exword()) return(1); goto again; } int maplow(tchar t) { int h, i, f; while (isxfunc(t, CHAR)) t = charout[sbits(t)].ch; i = cbits(t); f = fbits(t); if (!ismot(t) && i < nhcode && (h = hcode[i]) != 0) { if (h & ~0177) h = tr2un(h, f); h = tr2un(h, f); return(h); } else #ifdef EUC if (!ismot(t) && i & ~0177) { i = tr2un(i, f); if (i == 0x017F) /* longs */ i = 's'; if (iswupper(i)) i = towlower(i); } else #endif /* EUC */ if (ischar(i) && isupper(i)) i = tolower(i); return(i); } int vowel(tchar i) { switch (maplow(i)) { case 'a': case 'e': case 'i': case 'o': case 'u': case 'y': return(1); default: return(0); } } tchar * chkvow(tchar *w) { while (--w >= wdstart) if (vowel(*w)) return(w); return(0); } void digram(void) { register tchar *w; register int val; tchar * nhyend, *maxw = 0; int maxval; extern const char bxh[26][13], bxxh[26][13], xxh[26][13], xhx[26][13], hxx[26][13]; for (w = wdstart; w <= wdend; w++) if (cbits(*w) & ~0177) return; again: if (!(w = chkvow(hyend + 1))) return; hyend = w; if (!(w = chkvow(hyend))) return; nhyend = w; maxval = 0; w--; while ((++w < hyend) && (w < (wdend - 1))) { val = 1; if (w == wdstart) val *= dilook('a', *w, bxh); else if (w == wdstart + 1) val *= dilook(*(w-1), *w, bxxh); else val *= dilook(*(w-1), *w, xxh); val *= dilook(*w, *(w+1), xhx); val *= dilook(*(w+1), *(w+2), hxx); if (val > maxval) { maxval = val; maxw = w + 1; } } hyend = nhyend; if (maxval > thresh) *hyp++ = maxw; goto again; } int dilook(tchar a, tchar b, const char t[26][13]) { register int i, j; i = t[maplow(a)-'a'][(j = maplow(b)-'a')/2]; if (!(j & 01)) i >>= 4; return(i & 017); } void casehylang(void) { int c, i = 0, sz = 0; char *path = NULL; size_t l; dicthnj = NULL; free(hylang); hylang = NULL; hyext = 0; skip(0); do { c = getach(); if (i >= sz) hylang = realloc(hylang, (sz += 8) * sizeof *hylang); hylang[i++] = c; } while (c); if (i == 1) { free(hylang); hylang = NULL; return; } if (strchr(hylang, '/') == NULL) { l = strlen(hylang) + strlen(HYPDIR) + 12; path = malloc(l); snprintf(path, l, "%s/hyph_%s.dic", HYPDIR, hylang); } else { path = strdup(hylang); } if ((dicthnj = hnj_hyphen_load(path)) == NULL) { errprint("Can't load %s", path); free(hylang); hylang = NULL; free(path); return; } free(path); hyext = 1; } static int addc(int m, char **cp, tchar **wp, int **wpp, int distance) { tchar t; t = m ? m | sfmask(**wp) : **wp; m = maplow(t); if (m > 0 && m <= 0x7f) { *(*cp)++ = m; *(*wpp)++ = distance; } else if (m >= 0x80 && m <= 0x7ff) { *(*cp)++ = (m >> 6 & 037) | 0300; *(*wpp)++ = distance; *(*cp)++ = (m & 077) | 0200; *(*wpp)++ = -1000; } else if (m >= 0x800 && m <= 0xffff) { *(*cp)++ = (m >> 12 & 017) | 0340; *(*wpp)++ = distance; *(*cp)++ = (m >> 6 & 077) | 0200; *(*wpp)++ = -1000; *(*cp)++ = (m & 077) | 0200; *(*wpp)++ = -1000; } else return 0; return 1; } static void hyphenhnj(void) { tchar *wp; char *cb, *cp, *hb; int *wpos, *wpp; int i, j, k; i = 12 * (wdend - wdstart) + 1; cb = malloc(i * sizeof *cb); hb = malloc(i * sizeof *hb); wpos = malloc(i * sizeof *wpos); cp = cb; wpp = wpos; for (wp = wdstart; wp <= wdend; wp++) { #ifndef NROFF int m = cbits(*wp); int f = fbits(*wp); if (islig(*wp) && lgrevtab && lgrevtab[f] && lgrevtab[f][m]) { for (i = 0; lgrevtab[f][m][i]; i++) { if (addc(lgrevtab[f][m][i], &cp, &wp, &wpp, i ? -i : wp-wdstart) == 0) goto retn; } } else #endif { if (addc(0, &cp, &wp, &wpp, wp - wdstart) == 0) goto retn; } } *cp = '\0'; j = cp - cb; while (wpp <= &wpos[j]) *wpp++ = -1000; hnj_hyphen_hyphenate(dicthnj, cb, j, hb); k = 0; for (i = 0; i < j; i++) { if (wpos[i+1] >= 0) k = wpos[i+1]; if ((hb[i] - '0') & 1 && wpos[i+1] >= -3) { if (wpos[i+1] >= 0) *hyp = &wdstart[wpos[i+1]]; else { *hyp = &wdstart[k]; *hyp = (void *)((intptr_t)*hyp | -wpos[i+1]); } if (++hyp > (hyptr + NHYP - 1)) hyp = hyptr + NHYP - 1; } } retn: free(cb); free(hb); free(wpos); } Index: vendor/heirloom-doctools/dist/troff/n9.c =================================================================== --- vendor/heirloom-doctools/dist/troff/n9.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/n9.c (revision 310550) @@ -1,1351 +1,1351 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 1989 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* from OpenSolaris "n9.c 1.11 05/06/08 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)n9.c 1.78 (gritter) 10/23/09 */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved * * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. */ #include #include #include #include #include #include #include #ifdef EUC #include #include #include #endif /* EUC */ #include "tdef.h" #ifdef NROFF #include "tw.h" #endif #include "pt.h" #include "ext.h" #ifdef EUC #define ISO646 "646" int multi_locale; int (*wdbdg)(wchar_t, wchar_t, int); wchar_t *(*wddlm)(wchar_t, wchar_t, int); int csi_width[4] = { 1, 1, 2, 3, }; #endif /* EUC */ /* * troff9.c * * misc functions */ tchar setz(void) { tchar i; if (!ismot(i = getch()) && cbits(i) != ohc) i |= ZBIT; return(i); } static int connectchar(tchar i) { - int *cp, c; + size_t *cp, c; c = cbits(i); if (*connectch) { for (cp = connectch; *cp; cp++) if (c == *cp) return 1; return 0; } - return c == RULE || c == UNDERLINE || c == ROOTEN; + return c == (size_t)RULE || c == (size_t)UNDERLINE || c == (size_t)ROOTEN; } void setline(void) { register tchar *i; tchar c, delim; int length; int w, cnt, rem, temp; tchar linebuf[NC]; if (ismot(c = getch())) return; delim = c; vflag = 0; dfact = EM; length = quant(hatoi(), HOR); dfact = 1; if (!length) { eat(delim); return; } s0: if (c = getch(), issame(c, delim)) { ch = c; c = RULE | chbits; } else if (cbits(c) == FILLER) goto s0; w = width(c); i = linebuf; if (length < 0) { *i++ = makem(length); length = -length; } if (!(cnt = length / w)) { *i++ = makem(-(temp = ((w - length) / 2))); *i++ = c; *i++ = makem(-(w - length - temp)); goto s1; } if ((rem = length % w)) { if (connectchar(c)) *i++ = c | ZBIT; *i++ = makem(rem); } if (cnt) { *i++ = RPT; *i++ = cnt; *i++ = c; } s1: *i++ = 0; eat(delim); pushback(linebuf); } tchar eat(tchar c) { register tchar i; while (i = getch(), !issame(i, c) && (cbits(i) != '\n')) ; if (cbits(c) != ' ' && !issame(i, c)) nodelim(c); return(i); } void setov(void) { register int j = 0, k; tchar i, delim, o[NOV]; int w[NOV]; if (ismot(i = getch())) return; delim = i; for (k = 0; (k < NOV) && (j = cbits(i = getch()), !issame(i, delim)) && (j != '\n'); k++) { o[k] = i; w[k] = width(i); } if (!issame(j, delim)) nodelim(delim); o[k] = w[k] = 0; if (o[0]) for (j = 1; j; ) { j = 0; for (k = 1; o[k] ; k++) { if (w[k-1] < w[k]) { j++; i = w[k]; w[k] = w[k-1]; w[k-1] = i; i = o[k]; o[k] = o[k-1]; o[k-1] = i; } } } else return; pbbuf[pbp++] = makem(w[0] / 2); for (k = 0; o[k]; k++) ; while (k>0) { k--; if (pbp >= pbsize-4) if (growpbbuf() == NULL) { errprint("no space for .ov"); done(2); } pbbuf[pbp++] = makem(-((w[k] + w[k+1]) / 2)); pbbuf[pbp++] = o[k]; } } void setbra(void) { register int k; tchar i, *j, dwn, delim; int cnt; tchar brabuf[NC]; if (ismot(i = getch())) return; delim = i; j = brabuf + 1; cnt = 0; #ifdef NROFF dwn = sabsmot(2 * t.Halfline) | MOT | VMOT; #endif #ifndef NROFF dwn = sabsmot((int)EM) | MOT | VMOT; #endif while ((k = cbits(i = getch()), !issame(delim, i)) && (k != '\n') && (j <= (brabuf + NC - 4))) { *j++ = i | ZBIT; *j++ = dwn; cnt++; } if (!issame(i, delim)) nodelim(delim); if (--cnt < 0) return; else if (!cnt) { ch = *(j - 2); return; } *j = 0; #ifdef NROFF *--j = *brabuf = sabsmot(cnt * t.Halfline) | MOT | NMOT | VMOT; #endif #ifndef NROFF *--j = *brabuf = sabsmot((cnt * (int)EM) / 2) | MOT | NMOT | VMOT; #endif *--j &= ~ZBIT; pushback(brabuf); } void setvline(void) { register int i; tchar c, _d, delim, rem, ver, neg; int cnt, v; tchar vlbuf[NC]; register tchar *vlp; if (ismot(c = getch())) return; delim = c; dfact = lss; vflag++; i = quant(hatoi(), VERT); dfact = 1; if (!i) { eat(delim); vflag = 0; return; } if (c = getch(), issame(c, delim)) { c = BOXRULE | chbits; /*default box rule*/ } else { _d = getch(); if (!issame(_d, delim)) nodelim(delim); } c |= ZBIT; neg = 0; if (i < 0) { i = -i; neg = NMOT; } #ifdef NROFF v = 2 * t.Halfline; #endif #ifndef NROFF v = EM; #endif cnt = i / v; rem = makem(i % v) | neg; ver = makem(v) | neg; vlp = vlbuf; if (!neg) *vlp++ = ver; if (absmot(rem) != 0) { *vlp++ = c; *vlp++ = rem; } while ((vlp < (vlbuf + NC - 3)) && cnt--) { *vlp++ = c; *vlp++ = ver; } *(vlp - 2) &= ~ZBIT; if (!neg) vlp--; *vlp++ = 0; pushback(vlbuf); vflag = 0; } #define NPAIR (NC/2-6) /* max pairs in spline, etc. */ void setdraw (void) /* generate internal cookies for a drawing function */ { int i, dx[NPAIR], dy[NPAIR], type; tchar c, delim; #ifndef NROFF int hpos, vpos; int j, k; tchar drawbuf[NC]; #else extern int tlp, utf8; char drawbuf[NC]; #endif /* NROFF */ /* input is \D'f dx dy dx dy ... c' (or at least it had better be) */ /* this does drawing function f with character c and the */ /* specified dx,dy pairs interpreted as appropriate */ /* pairs are deltas from last point, except for radii */ /* l dx dy: line from here by dx,dy */ /* c x: circle of diameter x, left side here */ /* e x y: ellipse of diameters x,y, left side here */ /* a dx1 dy1 dx2 dy2: ccw arc: ctr at dx1,dy1, then end at dx2,dy2 from there */ /* ~ dx1 dy1 dx2 dy2...: spline to dx1,dy1 to dx2,dy2 ... */ /* f dx dy ...: f is any other char: like spline */ if (ismot(c = getch())) return; delim = c; type = cbits(getch()); for (i = 0; i < NPAIR ; i++) { c = getch(); if (issame(c, delim)) break; /* ought to pick up optional drawing character */ if (cbits(c) != ' ') ch = c; vflag = 0; dfact = type == DRAWTHICKNESS ? 1 : EM; dx[i] = quant(hatoi(), HOR); if (dx[i] > MAXMOT) dx[i] = MAXMOT; else if (dx[i] < -MAXMOT) dx[i] = -MAXMOT; if (c = getch(), issame(c, delim)) { /* spacer */ dy[i++] = 0; break; } vflag = 1; dfact = lss; dy[i] = quant(hatoi(), VERT); if (type == DRAWTHICKNESS) dy[i] = 0; else if (dy[i] > MAXMOT) dy[i] = MAXMOT; else if (dy[i] < -MAXMOT) dy[i] = -MAXMOT; } dfact = 1; vflag = 0; #ifndef NROFF drawbuf[0] = DRAWFCN | chbits | ZBIT; drawbuf[1] = type | chbits | ZBIT; drawbuf[2] = '.' | chbits | ZBIT; /* use default drawing character */ hpos = vpos = 0; for (k = 0, j = 3; k < i; k++) { drawbuf[j++] = MOT | ((dx[k] >= 0) ? sabsmot(dx[k]) : (NMOT | sabsmot(-dx[k]))); drawbuf[j++] = MOT | VMOT | ((dy[k] >= 0) ? sabsmot(dy[k]) : (NMOT | sabsmot(-dy[k]))); hpos += dx[k]; vpos += dy[k]; } if (type == DRAWELLIPSE || type == DRAWELLIPSEFI) { drawbuf[5] = drawbuf[4] | NMOT; /* so the net vertical is zero */ j = 6; } if (gflag && (type == DRAWPOLYGON || type == DRAWPOLYGONFI) && (hpos || vpos)) { drawbuf[j++] = MOT | ((hpos < 0) ? sabsmot(-hpos) : (NMOT | sabsmot(hpos))); drawbuf[j++] = MOT | VMOT | ((vpos < 0) ? sabsmot(-vpos) : (NMOT | sabsmot(vpos))); } drawbuf[j++] = DRAWFCN | chbits | ZBIT; /* marks end for ptout */ drawbuf[j] = 0; pushback(drawbuf); #else switch (type) { case 'l': if (dx[0] && !dy[0]) { if (dx[0] < 0) { snprintf(drawbuf, sizeof(drawbuf), "\\h'%du'", dx[0]); cpushback(drawbuf); } snprintf(drawbuf, sizeof(drawbuf), "\\l'%du%s'", dx[0], tlp ? "\\&-" : utf8 ? "\\U'2500'" : ""); cpushback(drawbuf); } else if (dy[0] && !dx[0]) { snprintf(drawbuf, sizeof(drawbuf), "\\L'%du%s'", dy[0], tlp ? "|" : utf8 ? "\\U'2502'" : ""); cpushback(drawbuf); } } #endif } void casefc(void) { register int i; tchar j; gchtab[fc] &= ~FCBIT; fc = IMP; padc = ' '; if (skip(0) || ismot(j = getch()) || (i = cbits(j)) == '\n') return; fc = i; gchtab[fc] |= FCBIT; if (skip(0) || ismot(ch) || (ch = cbits(ch)) == fc) return; padc = ch; } tchar setfield(int x) { register tchar ii, jj, *fp; register int i, j, k; int length, ws, npad, temp; unsigned int type; tchar **pp, *padptr[NPP]; tchar fbuf[FBUFSZ]; int savfc, savtc, savlc; tchar rchar = 0, nexti = 0; int savepos; int oev; prdblesc = 1; if (x == tabch) rchar = tabc | chbits; else if (x == ldrch) rchar = dotc | chbits; if (chartab[trtab[cbits(rchar)]] != 0) rchar = setchar(rchar); temp = npad = ws = 0; savfc = fc; savtc = tabch; savlc = ldrch; tabch = ldrch = fc = IMP; savepos = numtab[HP].val; gchtab[tabch] &= ~TABBIT; gchtab[ldrch] &= ~LDRBIT; gchtab[fc] &= ~FCBIT; gchtab[IMP] |= TABBIT|LDRBIT|FCBIT; for (j = 0; ; j++) { if ((tabtab[j] & TABMASK) == 0) { if (x == savfc) errprint("zero field width."); jj = 0; goto rtn; } if ((length = ((tabtab[j] & TABMASK) - numtab[HP].val)) > 0 ) break; } type = tabtab[j] & (~TABMASK); fp = fbuf; pp = padptr; if (x == savfc) { *fp++ = mkxfunc(FLDMARK, 0); nexti = getch(); while (1) { j = cbits(ii = nexti); jj = width(ii); oev = ev; if (j != savfc && j != '\n' && pp < (padptr + NPP - 1) && fp < (fbuf + FBUFSZ - 3)) nexti = getch(); else nexti = 0; if (ev == oev) jj += kernadjust(ii, nexti); widthp = jj; numtab[HP].val += jj; if (j == padc) { npad++; *pp++ = fp; if (pp > (padptr + NPP - 1)) break; goto s1; } else if (j == savfc) break; else if (j == '\n') { temp = j; nlflg = 0; break; } ws += jj; s1: *fp++ = ii; if (fp > (fbuf + FBUFSZ - 3)) break; } if (!npad) { npad++; *pp++ = fp; *fp++ = 0; } *fp++ = temp; *fp++ = 0; temp = i = (j = length - ws) / npad; i = (i / HOR) * HOR; if ((j -= i * npad) < 0) j = -j; ii = makem(i); if (temp < 0) ii |= NMOT; for (; npad > 0; npad--) { *(*--pp) = ii; if (j) { j -= HOR; (*(*pp)) += HOR; } } pushback(fbuf); jj = 0; } else if (type == 0) { /*plain tab or leader*/ if (pbp >= pbsize-4) growpbbuf(); pbbuf[pbp++] = mkxfunc(FLDMARK, 0); if ((j = width(rchar)) > 0) { int nchar; k = kernadjust(rchar, rchar); if (length < j) nchar = 0; else { nchar = 1; length -= j; nchar += length / (k+j); length %= k+j; } pbbuf[pbp++] = FILLER; while (nchar-->0) { if (pbp >= pbsize-5) if (growpbbuf() == NULL) break; numtab[HP].val += j; widthp = j; if (nchar > 0) { numtab[HP].val += k; widthp += k; } pbbuf[pbp++] = rchar; } pbbuf[pbp++] = FILLER; } if (length) jj = sabsmot(length) | MOT; else jj = 0; } else { /*center tab*/ /*right tab*/ *fp++ = mkxfunc(FLDMARK, 0); nexti = getch(); while (((j = cbits(ii = nexti)) != savtc) && (j != '\n') && (j != savlc)) { jj = width(ii); oev = ev; if (fp < (fbuf + FBUFSZ - 3)) { nexti = getch(); if (ev == oev) jj += kernadjust(ii, nexti); } ws += jj; numtab[HP].val += jj; widthp = jj; *fp++ = ii; if (fp > (fbuf + FBUFSZ - 3)) break; } *fp++ = ii; *fp++ = 0; if (type == RTAB) length -= ws; else length -= ws / 2; /*CTAB*/ pushback(fbuf); if ((j = width(rchar)) != 0 && length > 0) { int nchar; k = kernadjust(rchar, rchar); if (length < j) nchar = 0; else { nchar = 1; length -= j; nchar += length / (k+j); length %= k+j; } if (pbp >= pbsize-3) growpbbuf(); pbbuf[pbp++] = FILLER; while (nchar-- > 0) { if (pbp >= pbsize-3) if (growpbbuf() == NULL) break; pbbuf[pbp++] = rchar; } } length = (length / HOR) * HOR; jj = makem(length); nlflg = 0; } rtn: gchtab[fc] &= ~FCBIT; gchtab[tabch] &= ~TABBIT; gchtab[ldrch] &= ~LDRBIT; fc = savfc; tabch = savtc; ldrch = savlc; gchtab[fc] |= FCBIT; gchtab[tabch] = TABBIT; gchtab[ldrch] |= LDRBIT; numtab[HP].val = savepos; if (pbp < pbsize-3 || growpbbuf()) pbbuf[pbp++] = mkxfunc(FLDMARK, x); prdblesc = 0; return(jj | ADJBIT); } static int readpenalty(int *valp) { int n, _t; _t = dpenal ? dpenal - INFPENALTY0 - 1 : 0; noscale++; n = inumb(&_t); noscale--; if (nonumb) return 0; if (n > INFPENALTY0) n = INFPENALTY0; else if (n < -INFPENALTY0) n = -INFPENALTY0; n += INFPENALTY0 + 1; *valp = n; return 1; } static int getpenalty(int *valp) { tchar c, delim; if (ismot(delim = getch())) return 0; if (readpenalty(valp) == 0) return 0; c = getch(); if (!issame(c, delim)) { nodelim(delim); return 0; } return 1; } tchar setpenalty(void) { int n; if (getpenalty(&n)) return mkxfunc(PENALTY, n); return 0; } tchar setdpenal(void) { if (getpenalty(&dpenal)) return mkxfunc(DPENAL, dpenal); return 0; } tchar mkxfunc(int f, int s) { tchar _t = XFUNC; setfbits(_t, f); setsbits(_t, s); return _t; } void pushinlev(void) { if (ninlev >= ainlev) { ainlev += 4; inlevp = realloc(inlevp, ainlev * sizeof *inlevp); } inlevp[ninlev]._apts = apts; inlevp[ninlev]._apts1 = apts1; inlevp[ninlev]._pts = pts; inlevp[ninlev]._pts1 = pts1; inlevp[ninlev]._font = font; inlevp[ninlev]._font1 = font1; inlevp[ninlev]._cc = cc; inlevp[ninlev]._c2 = c2; inlevp[ninlev]._ohc = ohc; inlevp[ninlev]._hyf = hyf; inlevp[ninlev]._tabc = tabc; inlevp[ninlev]._dotc = dotc; inlevp[ninlev]._dpenal = dpenal; ninlev++; } tchar popinlev(void) { tchar c = 0; if (--ninlev < 0) { ninlev = 0; return c; } if (dpenal != inlevp[ninlev]._dpenal) c = mkxfunc(DPENAL, inlevp[ninlev]._dpenal); apts = inlevp[ninlev]._apts; apts1 = inlevp[ninlev]._apts1; pts = inlevp[ninlev]._pts; pts1 = inlevp[ninlev]._pts1; font = inlevp[ninlev]._font; font1 = inlevp[ninlev]._font1; cc = inlevp[ninlev]._cc; c2 = inlevp[ninlev]._c2; ohc = inlevp[ninlev]._ohc; hyf = inlevp[ninlev]._hyf; tabc = inlevp[ninlev]._tabc; dotc = inlevp[ninlev]._dotc; dpenal = inlevp[ninlev]._dpenal; mchbits(); if (ninlev == 0) { free(inlevp); inlevp = NULL; ainlev = 0; } return c; } #ifdef EUC /* locale specific initialization */ wchar_t *wddelim(wchar_t, wchar_t, int); int wdbindf(wchar_t, wchar_t, int); void localize(void) { char *codeset; codeset = nl_langinfo(CODESET); if (mb_cur_max > 1) multi_locale = 1; else { if (*codeset == '\0' || (strcmp(codeset, ISO646) == 0)) { /* * if codeset is an empty string * assumes this is C locale (7-bit) locale. * This happens in 2.5, 2.5.1, and 2.6 system * Or, if codeset is "646" * this is 7-bit locale. */ multi_locale = 0; } else { /* 8-bit locale */ multi_locale = 1; } } wdbdg = wdbindf; wddlm = wddelim; } #ifndef __sun int wdbindf(wchar_t wc1 __unused, wchar_t wc2 __unused, int type __unused) { return 6; } wchar_t * wddelim(wchar_t wc1 __unused, wchar_t wc2 __unused, int type __unused) { return L" "; } #endif /* !__sun */ #endif /* EUC */ void caselc_ctype(void) { #ifdef EUC char c, *buf = NULL; int i = 0, sz = 0; skip(1); do { c = getach()&0377; if (i >= sz) buf = realloc(buf, (sz += 8) * sizeof *buf); buf[i++] = c; } while (c && c != ' ' && c != '\n'); buf[i-1] = 0; setlocale(LC_CTYPE, buf); mb_cur_max = MB_CUR_MAX; localize(); #ifndef NROFF ptlocale(buf); #endif free(buf); #endif } #ifndef NROFF struct fg { char buf[512]; char *bp; char *ep; int fd; int eof; }; static int psskip(struct fg *fp, size_t n) { size_t i; if (fp->eof) return -1; if (fp->bp < fp->ep) { i = fp->ep - fp->bp; if (i > n) { fp->bp += n; return 0; } fp->bp = fp->buf; n -= i; } if (lseek(fp->fd, n, SEEK_CUR) == (off_t)-1) return -1; return 0; } static int psgetline(struct fg *fp, char **linebp, size_t *linesize) { - int i, n = 0; - int nl = 0; + size_t n = 0; + int i, nl = 0; if (fp->bp == NULL) fp->bp = fp->buf; for (;;) { if (fp->eof == 0 && fp->bp == fp->buf) { if ((i = read(fp->fd, fp->buf, sizeof fp->buf)) <= 0) fp->eof = 1; fp->ep = &fp->buf[i]; } for (;;) { if (*linesize < n + 2) *linebp = realloc(*linebp, *linesize += 128); if (fp->bp >= fp->ep) break; if (*fp->bp == '\n' || nl) { nl = 2; break; } if (*fp->bp == '\r') nl = 1; (*linebp)[n++] = *fp->bp++; } if (fp->bp < fp->ep && *fp->bp == '\n') { (*linebp)[n++] = *fp->bp++; break; } if (nl == 2 || fp->eof) break; fp->bp = fp->buf; } (*linebp)[n] = 0; return n; } static char * getcom(const char *cp, const char *tp) { int n; n = strlen(tp); if (strncmp(cp, tp, n)) return NULL; if (cp[n] == ' ' || cp[n] == '\t' || cp[n] == '\r' || cp[n] == '\n' || cp[n] == 0) return (char *)&cp[n]; return NULL; } static void getpsbb(const char *name, double bb[4]) { struct fg *fp; char *buf = NULL; char *cp; size_t size = 0; int fd, n, k; int lineno = 0; int found = 0; int atend = 0; int state = 0; int indoc = 0; if ((fd = open(name, O_RDONLY)) < 0) { errprint("can't open %s", name); return; } fp = calloc(1, sizeof *fp); fp->fd = fd; for (;;) { n = psgetline(fp, &buf, &size); if (++lineno == 1 && (n == 0 || strncmp(buf, "%!PS-", 5))) { errprint("%s is not a DSC-conforming " "PostScript document", name); break; } if (n > 0 && state != 1 && (cp = getcom(buf, "%%BoundingBox:")) != NULL) { while (*cp == ' ' || *cp == '\t') cp++; if (strncmp(cp, "(atend)", 7) == 0) { atend++; continue; } bb[0] = strtod(cp, &cp); if (*cp) bb[1] = strtod(cp, &cp); if (*cp) bb[2] = strtod(cp, &cp); if (*cp) { bb[3] = strtod(cp, &cp); found = 1; } else errprint("missing arguments to " "%%%%BoundingBox: in %s, line %d\n", name, lineno); continue; } if (n > 0 && state != 1 && (cp = getcom(buf, "%%HiResBoundingBox:")) != NULL) { while (*cp == ' ' || *cp == '\t') cp++; if (strncmp(cp, "(atend)", 7) == 0) { atend++; continue; } bb[0] = strtod(cp, &cp); if (*cp) bb[1] = strtod(cp, &cp); if (*cp) bb[2] = strtod(cp, &cp); if (*cp) { bb[3] = strtod(cp, &cp); break; } else { errprint("missing arguments to " "%%%%HiResBoundingBox: in %s, " "line %d\n", name, lineno); continue; } } if (n == 0 || (state == 0 && (getcom(buf, "%%EndComments") != NULL || buf[0] != '%' || buf[1] == ' ' || buf[1] == '\t' || buf[1] == '\r' || buf[1] == '\n'))) { eof: if (found == 0 && (atend == 0 || n == 0)) errprint("%s lacks a %%%%BoundingBox: DSC " "comment", name); if (atend == 0 || n == 0) break; state = 1; continue; } if (indoc == 0 && getcom(buf, "%%EOF") != NULL) { n = 0; goto eof; } if (state == 1 && indoc == 0 && getcom(buf, "%%Trailer") != NULL) { state = 2; continue; } if (state == 1 && getcom(buf, "%%BeginDocument:") != NULL) { indoc++; continue; } if (state == 1 && indoc > 0 && getcom(buf, "%%EndDocument") != NULL) { indoc--; continue; } if (state == 1 && (cp = getcom(buf, "%%BeginBinary:")) != NULL) { if ((k = strtol(cp, &cp, 10)) > 0) psskip(fp, k); continue; } if (state == 1 && (cp = getcom(buf, "%%BeginData:")) != NULL) { if ((k = strtol(cp, &cp, 10)) > 0) { while (*cp == ' ' || *cp == '\t') cp++; while (*cp && *cp != ' ' && *cp != '\t') cp++; while (*cp == ' ' || *cp == '\t') cp++; if (strncmp(cp, "Bytes", 5) == 0) psskip(fp, k); else if (strncmp(cp, "Lines", 5) == 0) { while (k--) { n = psgetline(fp, &buf, &size); if (n == 0) goto eof; } } } continue; } } free(fp); free(buf); close(fd); } #endif /* !NROFF */ void casepsbb(void) { #ifndef NROFF char *buf = NULL; int c; int n = 0, sz = 0; double bb[4] = { 0, 0, 0, 0 }; lgf++; skip(1); do { c = getach(); if (n >= sz) buf = realloc(buf, (sz += 14) * sizeof *buf); buf[n++] = c; } while (c); getpsbb(buf, bb); free(buf); setnrf("llx", bb[0], 0); setnrf("lly", bb[1], 0); setnrf("urx", bb[2], 0); setnrf("ury", bb[3], 0); #endif /* !NROFF */ } static const struct { enum warn n; const char *s; } warnnames[] = { { WARN_NONE, "none" }, { WARN_CHAR, "char" }, { WARN_NUMBER, "number" }, { WARN_BREAK, "break" }, { WARN_DELIM, "delim" }, { WARN_EL, "el" }, { WARN_SCALE, "scale" }, { WARN_RANGE, "range" }, { WARN_SYNTAX, "syntax" }, { WARN_DI, "di" }, { WARN_MAC, "mac" }, { WARN_REG, "reg" }, { WARN_RIGHT_BRACE, "right-brace" }, { WARN_MISSING, "missing" }, { WARN_INPUT, "input" }, { WARN_ESCAPE, "escape" }, { WARN_SPACE, "space" }, { WARN_FONT, "font" }, { WARN_ALL, "all" }, { WARN_W, "w" }, { 0, NULL } }; static int warn1(void) { char name[NC]; int n, sign; size_t i; tchar c; switch (cbits(c = getch())) { case '-': c = getch(); sign = -1; break; case '+': c = getch(); sign = 1; break; default: sign = 0; break; case 0: return 1; } ch = c; n = atoi0(); if ((i = cbits(ch)) != 0 && i != ' ' && i != '\n') { if (c != ch) { while (getach()); errprint("illegal number, char %c", i); return 1; } for (i = 0; i < sizeof name - 2; i++) { if ((c = getach()) == 0) break; name[i] = c; } name[i] = 0; for (i = 0; warnnames[i].s; i++) if (strcmp(name, warnnames[i].s) == 0) { n = warnnames[i].n; break; } if (warnnames[i].s == NULL) { errprint("unknown warning category %s", name); return 1; } } switch (sign) { case 1: warn |= n; break; case -1: warn &= ~n; break; default: warn = n; } return 0; } void casewarn(void) { if (skip(0)) warn = WARN_W; else while (!warn1() && !skip(0)); } void nosuch(int rq) { if (rq && rq != RIGHT && rq != PAIR(RIGHT, RIGHT) && warn & WARN_MAC) errprint("%s: no such request", macname(rq)); } void missing(void) { if (warn & WARN_MISSING) { if (lastrq) errprint("%s: missing argument", macname(lastrq)); else errprint("missing argument"); } } void nodelim(int delim) { if (warn & WARN_DELIM) errprint("%c delimiter missing", (int)delim); } void illseq(int wc, const char *mb, int n) { if ((warn & WARN_INPUT) == 0) return; if (n == -3) errprint("non-ASCII input byte 0x%x terminates name", wc); else if (n == 0) { if (wc & ~0177) errprint("ignoring '%U' in input", wc); else errprint("ignoring '\\%o' in input", wc); } else errprint("illegal byte sequence at '\\%o' in input", *mb&0377); } void storerq(int i) { tchar tp[2]; tp[0] = mkxfunc(RQ, i); tp[1] = 0; pushback(tp); } int fetchrq(tchar *tp) { if (ismot(tp[0]) || !isxfunc(tp[0], RQ)) return 0; return sbits(tp[0]); } void morechars(int n) { int i, nnc; if (n <= NCHARS) return; for (nnc = 1024; nnc <= n; nnc <<= 1); widcache = realloc(widcache, nnc * sizeof *widcache); memset(&widcache[NCHARS], 0, (nnc-NCHARS) * sizeof *widcache); trtab = realloc(trtab, nnc * sizeof *trtab); trnttab = realloc(trnttab, nnc * sizeof *trnttab); for (i = NCHARS; i < nnc; i++) trnttab[i] = trtab[i] = i; trintab = realloc(trintab, nnc * sizeof *trintab); memset(&trintab[NCHARS], 0, (nnc-NCHARS) * sizeof *trintab); gchtab = realloc(gchtab, nnc * sizeof *gchtab); memset(&gchtab[NCHARS], 0, (nnc-NCHARS) * sizeof *gchtab); chartab = realloc(chartab, nnc * sizeof *chartab); memset(&chartab[NCHARS], 0, (nnc-NCHARS) * sizeof *chartab); #ifndef NROFF fchartab = realloc(fchartab, nnc * sizeof *fchartab); memset(&fchartab[NCHARS], 0, (nnc-NCHARS) * sizeof *fchartab); for (i = 0; i <= nfonts; i++) { extern short **fitab; if (fitab != NULL && fitab[i] != NULL) { fitab[i] = realloc(fitab[i], nnc * sizeof **fitab); memset(&fitab[i][NCHARS], 0, (nnc-NCHARS) * sizeof **fitab); } if (lhangtab != NULL && lhangtab[i] != NULL) { lhangtab[i] = realloc(lhangtab[i], nnc * sizeof **lhangtab); memset(&lhangtab[i][NCHARS], 0, (nnc-NCHARS) * sizeof **lhangtab); } if (lhangtab != NULL && rhangtab[i] != NULL) { rhangtab[i] = realloc(rhangtab[i], nnc * sizeof **rhangtab); memset(&rhangtab[i][NCHARS], 0, (nnc-NCHARS) * sizeof **rhangtab); } if (kernafter != NULL && kernafter[i] != NULL) { kernafter[i] = realloc(kernafter[i], nnc * sizeof **kernafter); memset(&kernafter[i][NCHARS], 0, (nnc-NCHARS) * sizeof **kernafter); } if (kernbefore != NULL && kernbefore[i] != NULL) { kernbefore[i] = realloc(kernbefore[i], nnc * sizeof **kernbefore); memset(&kernbefore[i][NCHARS], 0, (nnc-NCHARS) * sizeof **kernbefore); } if (ftrtab != NULL && ftrtab[i] != NULL) { int j; ftrtab[i] = realloc(ftrtab[i], nnc * sizeof **ftrtab); for (j = NCHARS; j < nnc; j++) ftrtab[i][j] = j; } if (lgtab != NULL && lgtab[i] != NULL) { lgtab[i] = realloc(lgtab[i], nnc * sizeof **lgtab); memset(&lgtab[i][NCHARS], 0, (nnc-NCHARS) * sizeof **lgtab); } if (lgrevtab != NULL && lgrevtab[i] != NULL) { lgrevtab[i] = realloc(lgrevtab[i], nnc * sizeof **lgrevtab); memset(&lgrevtab[i][NCHARS], 0, (nnc-NCHARS) * sizeof **lgrevtab); } } #endif /* !NROFF */ NCHARS = nnc; } Index: vendor/heirloom-doctools/dist/troff/ni.c =================================================================== --- vendor/heirloom-doctools/dist/troff/ni.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/ni.c (revision 310550) @@ -1,352 +1,354 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2002 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* from OpenSolaris "ni.c 1.11 05/06/08 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)ni.c 1.47 (gritter) 12/17/06 */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved * * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. */ +#include + #include "tdef.h" #include "ext.h" /* You may want to change these names */ #ifdef NROFF char *termtab = TABDIR "/tab."; /* term type added in ptinit() */ char *fontfile = ""; /* not used */ char devname[20] = "37"; #else char *termtab = FNTDIR; /* rest added in ptinit() */ char *fontfile = FNTDIR; /* rest added in casefp() */ char devname[20] = "ps"; /* default typesetter */ int html; #endif char obuf[OBUFSZ]; /* characters collected here for typesetter output */ char *obufp = obuf; int NN; struct numtab *numtab; const struct numtab initnumtab[] = { - { PAIR('%', 0) }, - { PAIR('n', 'l') }, - { PAIR('y', 'r') }, - { PAIR('h', 'p') }, - { PAIR('c', 't') }, - { PAIR('d', 'n') }, - { PAIR('m', 'o') }, - { PAIR('d', 'y') }, - { PAIR('d', 'w') }, - { PAIR('l', 'n') }, - { PAIR('d', 'l') }, - { PAIR('s', 't') }, - { PAIR('s', 'b') }, - { PAIR('c', '.') }, - { PAIR('$', '$') }, - { 0 } + { PAIR('%', 0), 0, 0, 0, NULL, 0, 0, 0, 0, 0 }, + { PAIR('n', 'l'), 0, 0, 0, NULL, 0, 0, 0, 0, 0 }, + { PAIR('y', 'r'), 0, 0, 0, NULL, 0, 0, 0, 0, 0 }, + { PAIR('h', 'p'), 0, 0, 0, NULL, 0, 0, 0, 0, 0 }, + { PAIR('c', 't'), 0, 0, 0, NULL, 0, 0, 0, 0, 0 }, + { PAIR('d', 'n'), 0, 0, 0, NULL, 0, 0, 0, 0, 0 }, + { PAIR('m', 'o'), 0, 0, 0, NULL, 0, 0, 0, 0, 0 }, + { PAIR('d', 'y'), 0, 0, 0, NULL, 0, 0, 0, 0, 0 }, + { PAIR('d', 'w'), 0, 0, 0, NULL, 0, 0, 0, 0, 0 }, + { PAIR('l', 'n'), 0, 0, 0, NULL, 0, 0, 0, 0, 0 }, + { PAIR('d', 'l'), 0, 0, 0, NULL, 0, 0, 0, 0, 0 }, + { PAIR('s', 't'), 0, 0, 0, NULL, 0, 0, 0, 0, 0 }, + { PAIR('s', 'b'), 0, 0, 0, NULL, 0, 0, 0, 0, 0 }, + { PAIR('c', '.'), 0, 0, 0, NULL, 0, 0, 0, 0, 0 }, + { PAIR('$', '$'), 0, 0, 0, NULL, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, NULL, 0, 0, 0, 0, 0 } }; int pto = 10000; int pfrom = 1; int print = 1; char *nextf; int NS; char **mfiles; int nmfi = 0; int NMF; #ifndef NROFF -int oldbits = -1; +unsigned int oldbits = (unsigned int)-1; #endif int init = 1; int fc = IMP; /* field character */ -int eschar = '\\'; +unsigned int eschar = '\\'; int ecs = '\\'; #ifdef NROFF int pl = 11*INCH; int po = PO; #else int pl; int po; #endif int dfact = 1; int dfactd = 1; int res = 1; int smnt = 0; /* beginning of special fonts */ int ascii = ASCII; int ptid = PTID; int lg = LG; int pnlist[NPN] = { -1 }; int vpt = 1; int *pnp = pnlist; int npn = 1; int npnflg = 1; int dpn = -1; int totout = 1; int ulfont = ULFONT; int tabch = TAB; int ldrch = LEADER; extern void caseft(void), caseps(void), casevs(void), casefp(void), casess(void), casecs(void), casebd(void), caselg(void); enum warn warn = WARN_FONT; int NM; struct contab *contab; -#define C(a,b) {a, 0, (void(*)(int))b, 0} +#define C(a,b) {a, 0, (void(*)(int))b, 0, 0, 0, 0} const struct contab initcontab[] = { C(PAIR('d', 's'), caseds), C(PAIR('a', 's'), caseas), C(PAIR('s', 'p'), casesp), C(PAIR('f', 't'), caseft), C(PAIR('p', 's'), caseps), C(PAIR('v', 's'), casevs), C(PAIR('n', 'r'), casenr), C(PAIR('i', 'f'), caseif), C(PAIR('i', 'e'), caseie), C(PAIR('e', 'l'), caseel), C(PAIR('p', 'o'), casepo), C(PAIR('t', 'l'), casetl), C(PAIR('t', 'm'), casetm), C(PAIR('b', 'p'), casebp), C(PAIR('c', 'h'), casech), C(PAIR('p', 'n'), casepn), C(PAIR('b', 'r'), tbreak), C(PAIR('t', 'i'), caseti), C(PAIR('n', 'e'), casene), C(PAIR('n', 'f'), casenf), C(PAIR('c', 'e'), casece), C(PAIR('r', 'j'), caserj), C(PAIR('f', 'i'), casefi), C(PAIR('i', 'n'), casein), C(PAIR('l', 'l'), casell), C(PAIR('n', 's'), casens), C(PAIR('m', 'k'), casemk), C(PAIR('r', 't'), casert), C(PAIR('a', 'm'), caseam), C(PAIR('d', 'e'), casede), C(PAIR('d', 'i'), casedi), C(PAIR('d', 'a'), caseda), C(PAIR('w', 'h'), casewh), C(PAIR('d', 't'), casedt), C(PAIR('i', 't'), caseit), C(PAIR('r', 'm'), caserm), C(PAIR('r', 'r'), caserr), C(PAIR('r', 'n'), casern), C(PAIR('a', 'd'), casead), C(PAIR('r', 's'), casers), C(PAIR('n', 'a'), casena), C(PAIR('p', 'l'), casepl), C(PAIR('t', 'a'), caseta), C(PAIR('t', 'r'), casetr), C(PAIR('u', 'l'), caseul), C(PAIR('c', 'u'), casecu), C(PAIR('l', 't'), caselt), C(PAIR('n', 'x'), casenx), C(PAIR('s', 'o'), caseso), C(PAIR('i', 'g'), caseig), C(PAIR('t', 'c'), casetc), C(PAIR('f', 'c'), casefc), C(PAIR('e', 'c'), caseec), C(PAIR('e', 'o'), caseeo), C(PAIR('l', 'c'), caselc), C(PAIR('e', 'v'), caseev), C(PAIR('r', 'd'), caserd), C(PAIR('a', 'b'), caseab), C(PAIR('f', 'l'), casefl), C(PAIR('e', 'x'), done), C(PAIR('s', 's'), casess), C(PAIR('f', 'p'), casefp), C(PAIR('c', 's'), casecs), C(PAIR('b', 'd'), casebd), C(PAIR('l', 'g'), caselg), C(PAIR('h', 'c'), casehc), C(PAIR('h', 'y'), casehy), C(PAIR('n', 'h'), casenh), C(PAIR('n', 'm'), casenm), C(PAIR('n', 'n'), casenn), C(PAIR('s', 'v'), casesv), C(PAIR('o', 's'), caseos), C(PAIR('l', 's'), casels), C(PAIR('c', 'c'), casecc), C(PAIR('c', '2'), casec2), C(PAIR('e', 'm'), caseem), C(PAIR('a', 'f'), caseaf), C(PAIR('h', 'w'), casehw), C(PAIR('m', 'c'), casemc), C(PAIR('p', 'm'), casepm), C(PAIR('p', 'i'), casepi), C(PAIR('u', 'f'), caseuf), C(PAIR('p', 'c'), casepc), C(PAIR('h', 't'), caseht), C(PAIR('c', 'f'), casecf), C(PAIR('s', 'y'), casesy), C(PAIR('l', 'f'), caself), C(PAIR('d', 'b'), casedb), /* C(PAIR('!', 0), casesy), */ /* synonym for .sy */ C(PAIR(XFUNC, 0), caseif), /* while loop execution */ C(PAIR('c', 'p'), casecp), C(0, 0) }; tchar *oline; /* * troff environment block */ struct env env = { /* int ics */ 0, /* int sps */ 0, /* int ses */ 0, /* int spacesz */ 0, /* int sesspsz */ 0, #ifndef NROFF /* int minsps */ 0, /* int minspsz */ 0, /* int letspsz */ 0, /* int letsps */ 0, /* int lspmin */ 0, /* int lspmax */ 0, /* int lspnc */ 0, /* int lsplow */ 0, /* int lsphigh */ 0, /* int lspcur */ 0, /* int lsplast */ 0, /* int lshmin */ 0, /* int lshmax */ 0, /* int lshwid */ 0, /* int lshlow */ 0, /* int lshhigh */ 0, /* int lshcur */ 0, #endif /* !NROFF */ /* int fldcnt */ 0, /* int lss */ 0, /* int lss1 */ 0, /* int ll */ 0, /* int ll1 */ 0, /* int lt */ 0, /* int lt1 */ 0, /* tchar i */ 0, /* insertion character */ /* int icf */ 0, /* tchar chbits */ 0, /* size+font bits for current character */ /* tchar spbits */ 0, /* tchar nmbits */ 0, /* int apts */ PS, /* actual point size -- as requested by user */ /* int apts1 */ PS, /* need not match an existent size */ /* int pts */ PS, /* hence, this is the size that really exists */ /* int pts1 */ PS, /* int font */ FT, /* int font1 */ FT, /* int ls */ 1, /* int ls1 */ 1, /* int ad */ 1, /* int nms */ 1, /* int ndf */ 1, /* int fi */ 1, /* int cc */ '.', /* int c2 */ '\'', /* int ohc */ OHC, /* int tdelim */ IMP, /* int hyf */ 1, /* int hyoff */ 0, /* int hlm */ -1, /* int hlc */ 0, /* int hylen */ 5, /* float hypp */ 0, /* float hypp2 */ 0, /* float hypp3 */ 0, /* int un1 */ -1, /* int tabc */ 0, /* int dotc */ '.', /* int adsp */ 0, /* int adrem */ 0, /* int lastl */ 0, /* int nel */ 0, /* int admod */ 0, /* int adflg */ 0, /* int adspc */ 0, /* int pa */ 0, /* tchar *wordp */ 0, /* int spflg */ 0, /* probably to indicate space after punctuation needed */ /* int seflg */ 0, /* tchar *linep */ 0, /* tchar *wdend */ 0, /* tchar *wdstart */ 0, /* int wne */ 0, /* int wsp */ 0, /* int ne */ 0, /* int nc */ 0, /* int nb */ 0, /* int lnmod */ 0, /* int nwd */ 0, /* int nn */ 0, /* int ni */ 0, /* int ul */ 0, /* int cu */ 0, /* int ce */ 0, /* int rj */ 0, /* int brnl */ 0, /* int brpnl */ 0, /* int in */ 0, /* int in1 */ 0, /* int un */ 0, /* int wch */ 0, /* int rhang */ 0, /* int pendt */ 0, /* tchar *pendw */ (tchar *)0, /* int pendnf */ 0, /* int spread */ 0, /* int dpenal */ 0, /* int it */ 0, /* int itc */ 0, /* int itmac */ 0, /* int lnsize */ 0, /* int wdsize */ 0, }; Index: vendor/heirloom-doctools/dist/troff/nii.c =================================================================== --- vendor/heirloom-doctools/dist/troff/nii.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/nii.c (revision 310550) @@ -1,196 +1,198 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 1989 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* from OpenSolaris "nii.c 1.7 05/06/08 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)nii.c 1.48 (gritter) 3/5/07 */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved * * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. */ +#include + #include "tdef.h" #ifdef NROFF #include "tw.h" #endif #include "pt.h" #include "ext.h" struct s *frame, *stk; int ejl; struct s *nxf; pid_t pipeflg = -1; int hflg; /* used in nroff only */ int eqflg; /* used in nroff only */ #ifndef NROFF int xpts; int ppts; int pfont; int mpts; int mfont; int cs; int ccs; int bd; char *fchartab; #else long lvmot; #endif int stdi; int nofeed; int quiet; int stop; char ibuf[IBUFSZ]; char xbuf[IBUFSZ]; char *ibufp; char *xbufp; char *eibuf; char *xeibuf; tchar *pbbuf; /* pushback buffer for arguments, \n, etc. */ int pbsize; /* number of members allocated for pbbuf */ int pbp; /* next free slot in pbbuf */ int lastpbp; /* pbp in previous stack frame */ int nx; int mflg; tchar ch = 0; int ttyod; int iflg; int rargc; char **argp; int *trtab; int *trintab; int *trnttab; int lgf; int copyf; filep ip; int nlflg; int donef; int nflush; int nfo; int ifile; int padc; int raw; int ifl[NSO]; int ifi; int flss; int nonumb; int trap; int tflg; int ejf; int gflag; int dilev; filep offset; int em; int ds; filep woff; int app; int ndone; int lead; int ralss; filep nextb; tchar nrbits; int nform; int macerr; filep apptr; int diflg; filep roff; int wbfi; int vflag; int noscale; int po1; int ev; int tty; int sfont = FT; /* appears to be "standard" font; used by .ul */ int sv; int esc; int widthp; int xflag = 1; int xfont; int setwdf; int over; int nhyp; tchar **hyp; tchar *olinep; int dotT; int no_out; struct widcache *widcache; struct d *d; struct d *dip; int mb_cur_max; struct env initenv; int lastkern; int lasttrack; int defaultpl; int NCHARS; int NDI; int spreadwarn; int spreadlimit; int lastrq; long realpage; int tryglf; char *gchtab; int tailflg; int minflg; int minspc; int blmac; int lsmac; int glss; int lsn; int rawwidth; int *olt; int nolt; int clonef; size_t olinesz; tchar **chartab; struct charout *charout; int charoutsz; int charf; int fmtchar; int Tflg; int dl; int padj; int defcf; int donep; int gemu; int argdelim; int chomp; int chompend; Index: vendor/heirloom-doctools/dist/troff/nroff.d/nroff.1 =================================================================== --- vendor/heirloom-doctools/dist/troff/nroff.d/nroff.1 (revision 310549) +++ vendor/heirloom-doctools/dist/troff/nroff.d/nroff.1 (nonexistent) @@ -1,271 +0,0 @@ -.\" -.\" Sccsid @(#)nroff.1b 1.13 (gritter) 9/4/06 -.\" Derived from troff(1), Unix 7th edition: -.\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" Redistributions of source code and documentation must retain the -.\" above copyright notice, this list of conditions and the following -.\" disclaimer. -.\" 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. -.\" All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed or owned by Caldera -.\" International, Inc. -.\" Neither the name of Caldera International, Inc. nor the names of -.\" other contributors may be used to endorse or promote products -.\" derived from this software without specific prior written permission. -.\" -.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA -.\" INTERNATIONAL, INC. 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 CALDERA INTERNATIONAL, INC. 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. -.TH NROFF 1 "9/4/06" "Heirloom Documentation Tools" "BSD System Compatibility" -.SH NAME -nroff \- format documents for display or line-printer -.SH SYNOPSIS -.HP -.ad l -.nh -\fBnroff\fR -[\fB\-ehiqzV\fR] -[\fB\-d\fIaS\fR] -[\fB\-d\fIa\fB=\fIS\fR] -[\fB\-F\fIfontdir\fR] -[\fB\-m\fIname\fR] -[\fB\-n\fIN\fR] -[\fB\-o\fIlist\fR] -[\fB\-r\fIaN\fR] -[\fB\-r\fIa\fB=\fIN\fR] -[\fB\-s\fIN\fR] -[\fB\-T\fIname\fR] -[\fB\-u\fIN\fR] -[\fB\-x\fIN\fR] -.br -.hy 1 -.ad b -.SH DESCRIPTION -.I nroff -formats text in the named -.I files -for typewriter-like devices. -Its capabilities are described in the -.I Nroff/Troff user's manual. -.PP -If no -.I file -argument is present, the standard input is read. -An argument consisting of a single minus -.RB ( \- ) -is taken to be -a file name corresponding to the standard input. -The options, which may appear in any order so long as they appear -before the files, are: -.TP 10n -.BI \-o list -Print only pages whose page numbers appear in -the comma-separated -.I list -of numbers and ranges. -A range -.IB N \- M -means pages -.I N -through -.IR M ; -an initial -.I \-N -means -from the beginning to page -.IR N ; -and a final -.IR N \- -means -from -.I N -to the end. -.TP -.BI \-n N -Number first generated page -.IR N . -.TP -.BI \-s N -Stop every -.I N -pages. -.I Nroff -will halt prior to every -.I N -pages (default -.IR N =1) -to allow paper loading or -changing, and will resume upon receipt of a newline. -.TP -.BI \-m name -Prepend the macro file -.BI /usr/ucblib/doctools/tmac/tmac. name -to the input -.IR files . -.TP -.BI \-r aN -Set register -.I a -(one-character) to -.IR N . -.TP -.BI \-r a = N -Set register -.I a -(may be more than one character) to -.IR N . -.TP -.BI \-d aN -Define string -.I a -(one-character) to -.IR S . -.TP -.BI \-d a = N -Define string -.I a -(may be more than one character) to -.IR S . -.TP -.B \-i -Read standard input after the input files are exhausted. -.TP -.B \-q -Invoke the simultaneous input-output mode of the -.B rd -request. -.TP -.B \-z -Check syntax only; -do not generate any output -except for error messages. -.TP -.BI \-F fontdir -Use the directory -.I fontdir -to locate font files. -.TP -.B \-u N -Set the emboldening amount, -i.e. the number of times a character is printed -to simulate bold output, -to -.IR N . -.TP -.BI \-T name -Prepare output for specified terminal. -Known -.I names -are -.B 37 -for the (default) -Teletype Corporation Model 37 terminal, -.B lp -for any line printer or terminal without half-line capability, -.B tn300 -for the GE TermiNet\ 300, -.B 300S -for the \s-1DASI\s+1-300S, -.B 300 -for the \s-1DASI\s+1-300, -and -.B 450 -for the \s-1DASI\s+1-450 -(Diablo Hyterm). -A special -.IR name , -.BR locale , -is also supported. -It generates UTF-8 output if permitted by -the current locale, -and has the same effect as -.I lp -otherwise. -.TP -.B \-e -Produce equally-spaced words in adjusted -lines, using full terminal resolution. -.TP -.B \-h -Use output tabs during horizontal spacing -to speed output and reduce output character count. -Tab settings are assumed to be every -8 nominal character widths. -.TP -.BI \-x N -Enable extensions to previous versions of -.I nroff -at level -.IR N . -Level 0 disables any extensions; -level 1 enables all extensions -except for long requests and request arguments; -level 2 enables these in addition -but executes short requests which are prefixes of undefined long requests; -level 3 ignores undefined long requests. -.TP -.B \-V -Print nroff version. -.SH "ENVIRONMENT VARIABLES" -.TP -.BR LANG ", " LC_ALL -See -.IR locale (7). -.TP -.B LC_CTYPE -Determines the mapping -of bytes to characters, -and the choice of output characters with the -.I \-Tlocale -option. -.TP -.B TYPESETTER -Specifies a device name as with the -.I \-T -option. -.TP -.B TROFFMACS -Specifies the location to search for macro files with the -.I \-m -option. -This string forms a prefix to which the macro package name -is immediately appended. -Thus to make `\-mname' work with a file `/path/to/tmac.name', -use `TROFFMACS=/path/to/tmac.' -.SH FILES -.ta \w'/usr/ucblib/doctools/tmac/* 'u -/tmp/ta* temporary file -.br -/usr/ucblib/doctools/tmac/* standard macro files -.br -/usr/ucblib/doctools/nterm/* terminal driving tables -.\".br -.\"/usr/ucblib/doctools/font/* font width tables for -.\".I troff -.SH "SEE ALSO" -J. F. Ossanna, -.I Nroff/Troff user's manual -.br -B. W. Kernighan, -.I -A TROFF Tutorial -.br -eqn(1), tbl(1) -.br -col(1) Property changes on: vendor/heirloom-doctools/dist/troff/nroff.d/nroff.1 ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/nroff.d/Makefile.mk =================================================================== --- vendor/heirloom-doctools/dist/troff/nroff.d/Makefile.mk (revision 310549) +++ vendor/heirloom-doctools/dist/troff/nroff.d/Makefile.mk (revision 310550) @@ -1,49 +1,54 @@ VPATH=.. LIBHNJ = ../libhnj BST = ../../stuff/bst OBJ = n10.o n6.o hytab.o n1.o n2.o n3.o n4.o n5.o \ n7.o n8.o n9.o ni.o nii.o suftab.o \ version.o draw.o $(BST)/bst.o FLAGS = -DNROFF -DUSG $(EUC) -I. -I.. -I../../include -DMACDIR='"$(MACDIR)"' \ -DFNTDIR='"$(FNTDIR)"' -DTABDIR='"$(TABDIR)"' -DHYPDIR='"$(HYPDIR)"' \ -DSHELL='"$(SHELL)"' -DRELEASE='"$(RELEASE)"' $(DEFINES) \ -I$(BST) .c.o: $(CC) $(_CFLAGS) $(FLAGS) -c $< -all: nroff +all: nroff nroff.1 nroff: $(OBJ) $(LIBHNJ)/libhnj.a $(CC) $(_CFLAGS) $(_LDFLAGS) $(OBJ) -L$(LIBHNJ) -lhnj $(LIBS) -o nroff install: $(INSTALL) -c nroff $(ROOT)$(BINDIR)/nroff $(STRIP) $(ROOT)$(BINDIR)/nroff $(INSTALL) -c -m 644 nroff.1 $(ROOT)$(MANDIR)/man1/nroff.1 clean: - rm -f $(OBJ) nroff core log *~ + rm -f $(OBJ) nroff core log *~ nroff.1 mrproper: clean + +nroff.1: nroff.1.in + sed -e 's"/usr/ucblib/doctools/tmac/"$(ROOT)$(MACDIR)/"' \ + -e 's"/usr/ucblib/doctools/nterm/"$(ROOT)$(TABDIR)/"' \ + nroff.1.in > $@ draw.o: ../tdef.h ../ext.h n10.o: n10.c ../tdef.h ../ext.h tw.h pt.h n6.o: n6.c ../tdef.h tw.h pt.h ../ext.h hytab.o: ../hytab.c malloc.o: ../malloc.c ../mallint.h n1.o: ../n1.c ../tdef.h ../ext.h ./pt.h tw.h n2.o: ../n2.c ../tdef.h ./pt.h ../ext.h tw.h n3.o: ../n3.c ../tdef.h ./pt.h ../ext.h tw.h n4.o: ../n4.c ../tdef.h ./pt.h ../ext.h tw.h n5.o: ../n5.c ../tdef.h ./pt.h ../ext.h tw.h n7.o: ../n7.c ../tdef.h ./pt.h ../ext.h tw.h n8.o: ../n8.c ../tdef.h ../ext.h ./pt.h n9.o: ../n9.c ../tdef.h ./pt.h ../ext.h tw.h ni.o: ../ni.c ../tdef.h ./pt.h ./ext.h nii.o: ../nii.c ../tdef.h ./pt.h ../ext.h tw.h suftab.o: ../suftab.c version.o: ../version.c Index: vendor/heirloom-doctools/dist/troff/nroff.d/n6.c =================================================================== --- vendor/heirloom-doctools/dist/troff/nroff.d/n6.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/nroff.d/n6.c (revision 310550) @@ -1,707 +1,707 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* from OpenSolaris "n6.c 1.12 05/06/08 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)n6.c 1.51 (gritter) 6/19/11 */ /* * Changes Copyright (c) 2014 Carsten Kunze */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved * * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. */ #include #include //#ifdef EUC #include #include #include //#endif #include #include "tdef.h" #include "tw.h" #include "pt.h" #include "ext.h" /* * n6.c -- width functions, sizes and fonts */ int initbdtab[NFONT+1] ={ 0, 0, 0, 3, 3, 0, }; static int sbold = 0; int initfontlab[NFONT+1] = { 0, 'R', 'I', 'B', PAIR('B','I'), 'S', 0 }; extern int nchtab; int width(register tchar j) { register int i, k; if (isadjspc(j)) return(0); if (j & (ZBIT|MOT)) { if (iszbit(j)) return(0); if (isvmot(j)) return(0); k = absmot(j); if (isnmot(j)) k = -k; return(k); } i = cbits(j); if (isxfunc(j, CHAR)) return(charout[sbits(j)].width); if (i < ' ') { if (i == '\b') return(-widthp); if (i == PRESC) i = eschar; else if (iscontrol(i)) return(0); } - if (i==ohc) + if ((size_t)i==ohc) return(0); #ifdef EUC if (multi_locale && i >= nchtab + _SPECCHAR_ST) { i = tr2un(i, fbits(j)); if ((i = wcwidth(i)) < 0) i = 0; k = t.Char * csi_width[i]; widthp = k; return(k); } #endif /* EUC */ i = trtab[i]; if (i < 32) return(0); k = t.width[i] * t.Char; widthp = k; return(k); } tchar setch(int delim) { register int j; char temp[40]; register char *s; s = temp; if (delim == 'C') { do { j = getach(); if (s < &temp[sizeof temp - 1]) *s++ = j; } while (j != 0 && (s == &temp[1] || j != temp[0])); if (s - temp == 3) return temp[1]; else if (s - temp == 4) { temp[0] = temp[1]; temp[1] = temp[2]; s = &temp[2]; } else { *s = 0; if (j != temp[0]) nodelim(temp[0]); else if (warn & WARN_CHAR) { errprint("missing glyph \\C%s", temp); } return 0; } } else if (delim == '[' && (j = getach()) != ']') { *s++ = j; while ((j = getach()) != ']' && j != 0) if (s < &temp[sizeof temp - 1]) *s++ = j; if (s - temp == 1) return temp[0]; else if (s - temp != 2) { *s = '\0'; if (j != ']') nodelim(']'); else { size_t l = strlen(temp); if (gemu) { if (l == 5 && *temp == 'u' && isxdigit((unsigned)temp[1]) && isxdigit((unsigned)temp[2]) && isxdigit((unsigned)temp[3]) && isxdigit((unsigned)temp[4])) { int n; n = strtol(temp + 1, NULL, 16); if (n) return setuc0(n); } else if ((l == 6 || (l == 7 && isdigit((unsigned)temp[6]))) && isdigit((unsigned)temp[5]) && isdigit((unsigned)temp[4]) && !strncmp(temp, "char", 4)) { int i = atoi(temp + 4); if (i <= 255) return i + nchtab + _SPECCHAR_ST; } } if ((j = findch(temp)) > 0) return j | chbits; else if (warn & WARN_CHAR) errprint("missing glyph \\[%s]", temp); return 0; } } } else { if ((*s++ = getach()) == 0 || (*s++ = getach()) == 0) return(0); } *s = '\0'; if ((j = findch(temp)) > 0) return j | chbits; else { if (warn & WARN_CHAR) errprint("missing glyph \\%c%s", delim, temp); return 0; } } tchar setabs (void) /* set absolute char from \C'...' */ { /* for now, a no-op */ int n; getch(); n = 0; n = inumb(&n); getch(); if (nonumb || n + nchtab + _SPECCHAR_ST >= NCHARS) return 0; return n + nchtab + _SPECCHAR_ST; } int tr2un(tchar c, int f __unused) { int k; k = cbits(c); if (k >= nchtab + _SPECCHAR_ST) return k - nchtab - _SPECCHAR_ST; if (k & ~0177) return 0; return k; } int findft(register int i, int required) { register int k; if ((k = i - '0') >= 0 && k <= nfonts && k < smnt) return(k); for (k = 0; fontlab[k] != i; k++) if (k > nfonts) { if (required && warn & WARN_FONT) errprint("%s: no such font", macname(i)); return(-1); } return(k); } void caseps(void) { } void mchbits(void) { chbits = 0; setfbits(chbits, font); ses = sps = width(' ' | chbits); } void setps(void) { tchar c; register int i, j, k; noschr++; i = cbits(c = getch()); if (noschr) noschr--; if (ismot(c) && xflag) return; if (ischar(i) && isdigit(i)) { /* \sd or \sdd */ i -= '0'; if (i == 0) /* \s0 */ ; else if (i <= 3 && ischar(j = cbits(ch = getch())) && isdigit(j)) { /* \sdd */ ch = 0; } } else if (i == '(') { /* \s(dd */ getch(); getch(); } else if (i == '+' || i == '-') { /* \s+, \s- */ j = cbits(c = getch()); if (ischar(j) && isdigit(j)) { /* \s+d, \s-d */ ; } else if (j == '(') { /* \s+(dd, \s-(dd */ getch(); getch(); } else if (xflag) { /* \s+[dd], */ k = j == '[' ? ']' : j; /* \s-'dd' */ setcbits(c, k); hatoi(); if (nonumb) return; if (!issame(getch(), c)) nodelim(k); } } else if (xflag) { /* \s'+dd', \s[dd] */ if (i == '[') { i = ']'; setcbits(c, i); } j = inumb(&apts); if (nonumb) return; if (!issame(getch(), c)) nodelim(i); } } tchar setht (void) /* set character height from \H'...' */ { getch(); inumb(&apts); getch(); return(0); } tchar setslant (void) /* set slant from \S'...' */ { int n; getch(); n = 0; n = inumb(&n); getch(); return(0); } void caseft(void) { skip(0); setfont(1); } void setfont(int a) { register int i, j; if (a) i = getrq(3); else i = getsn(0); if (!i || i == 'P') { j = font1; goto s0; } if (/* i == 'S' || */ i == '0') return; if ((j = findft(i, 0)) == -1) { if (xflag) { font1 = font; } return; } s0: font1 = font; font = j; mchbits(); } void setwd(void) { register int base, wid; register tchar i; tchar delim; int emsz, k; int savhp, savapts, savapts1, savfont, savfont1, savpts, savpts1; int savlgf; base = numtab[ST].val = wid = numtab[CT].val = 0; if (ismot(i = getch())) return; delim = i; savhp = numtab[HP].val; numtab[HP].val = 0; savapts = apts; savapts1 = apts1; savfont = font; savfont1 = font1; savpts = pts; savpts1 = pts1; savlgf = lgf; lgf = 0; setwdf++; while (i = getch(), !issame(i, delim) && !nlflg) { k = width(i); wid += k; numtab[HP].val += k; if (!ismot(i)) { emsz = (INCH * pts + 36) / 72; } else if (isvmot(i)) { k = absmot(i); if (isnmot(i)) k = -k; base -= k; emsz = 0; } else continue; if (base < numtab[SB].val) numtab[SB].val = base; if ((k = base + emsz) > numtab[ST].val) numtab[ST].val = k; } if (!issame(i, delim)) nodelim(delim); setn1(wid, 0, (tchar) 0); setnr("rst", 0, 0); setnr("rsb", 0, 0); numtab[HP].val = savhp; apts = savapts; apts1 = savapts1; font = savfont; font1 = savfont1; pts = savpts; pts1 = savpts1; lgf = savlgf; mchbits(); setwdf = 0; } tchar vmot(void) { dfact = lss; vflag++; return(mot()); } tchar hmot(void) { dfact = EM; return(mot()); } tchar mot(void) { register int j, n; register tchar i; tchar c, delim; j = HOR; noschr++; delim = getch(); /*eat delim*/ if (noschr) noschr--; if ((n = hatoi())) { if (vflag) j = VERT; i = makem(quant(n, j)); } else i = 0; noschr++; c = getch(); if (noschr) noschr--; if (!issame(c, delim)) nodelim(delim); vflag = 0; dfact = 1; return(i); } tchar sethl(int k) { register int j; tchar i; j = t.Halfline; if (k == 'u') j = -j; else if (k == 'r') j = -2 * j; vflag++; i = makem(j); vflag = 0; return(i); } tchar makem(int i) { register tchar j; if ((j = i) < 0) j = -j; j = sabsmot(j) | MOT; if (i < 0) j |= NMOT; if (vflag) j |= VMOT; return(j); } tchar getlg(tchar i) { return(i); } void caselg(void) { } void caseflig(void) { } void casefp(void) { register int i, j; skip(1); if ((i = cbits(getch()) - '0') < 0 || i > nfonts) return; if (skip(1) || !(j = getrq(3))) return; fontlab[i] = j; } void casefps(void) { skip(1); getname(); casefp(); } void casecs(void) { } void casebd(void) { register int i, j = 0, k; k = 0; bd0: if (skip(1) || !(i = getrq(0)) || (j = findft(i, 1)) == -1) { if (k) goto bd1; else return; } if (j == smnt) { k = smnt; goto bd0; } if (k) { sbold = j; j = k; } bd1: skip(0); noscale++; bdtab[j] = hatoi(); noscale = 0; } void casevs(void) { register int i; skip(0); vflag++; dfact = INCH; /*default scaling is points!*/ dfactd = 72; res = VERT; i = inumb(&lss); if (nonumb) i = lss1; if (xflag && i < 0) { if (warn & WARN_RANGE) errprint("negative vertical spacing ignored"); i = lss1; } if (i < VERT) i = VERT; /* was VERT */ lss1 = lss; lss = i; } void casess(void) { } tchar xlss(void) { /* stores \x'...' into * two successive tchars. * the first contains HX, the second the value, * encoded as a vertical motion. * decoding is done in n2.c by pchar(). */ int i; getch(); dfact = lss; i = quant(hatoi(), VERT); dfact = 1; getch(); if (i >= 0) pbbuf[pbp++] = MOT | VMOT | sabsmot(i); else pbbuf[pbp++] = MOT | VMOT | NMOT | sabsmot(-i); return(HX); } tchar setuc0(int n) { if (n & ~0177) { #ifdef EUC int k; k = (n + nchtab + _SPECCHAR_ST) | chbits; if (k >= NCHARS) morechars(k); return k; #else return 0; #endif } else return n | chbits; } static void discard(void) { int c, delim; if ((delim = getach()) != 0) do { if ((c = getach()) == 0) { if (cbits(ch) == ' ') ch = 0; else break; } } while (c != delim); } tchar setanchor(void) { discard(); return 0; } tchar setlink(void) { if ((linkin = !linkin)) discard(); return 0; } tchar setulink(void) { if ((linkin = !linkin)) discard(); return 0; } void casedummy(void){;} Index: vendor/heirloom-doctools/dist/troff/nroff.d/nroff.1.in =================================================================== --- vendor/heirloom-doctools/dist/troff/nroff.d/nroff.1.in (nonexistent) +++ vendor/heirloom-doctools/dist/troff/nroff.d/nroff.1.in (revision 310550) @@ -0,0 +1,271 @@ +.\" +.\" Sccsid @(#)nroff.1b 1.13 (gritter) 9/4/06 +.\" Derived from troff(1), Unix 7th edition: +.\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" Redistributions of source code and documentation must retain the +.\" above copyright notice, this list of conditions and the following +.\" disclaimer. +.\" 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. +.\" All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" Neither the name of Caldera International, Inc. nor the names of +.\" other contributors may be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. 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 CALDERA INTERNATIONAL, INC. 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. +.TH NROFF 1 "9/4/06" "Heirloom Documentation Tools" "BSD System Compatibility" +.SH NAME +nroff \- format documents for display or line-printer +.SH SYNOPSIS +.HP +.ad l +.nh +\fBnroff\fR +[\fB\-ehiqzV\fR] +[\fB\-d\fIaS\fR] +[\fB\-d\fIa\fB=\fIS\fR] +[\fB\-F\fIfontdir\fR] +[\fB\-m\fIname\fR] +[\fB\-n\fIN\fR] +[\fB\-o\fIlist\fR] +[\fB\-r\fIaN\fR] +[\fB\-r\fIa\fB=\fIN\fR] +[\fB\-s\fIN\fR] +[\fB\-T\fIname\fR] +[\fB\-u\fIN\fR] +[\fB\-x\fIN\fR] +.br +.hy 1 +.ad b +.SH DESCRIPTION +.I nroff +formats text in the named +.I files +for typewriter-like devices. +Its capabilities are described in the +.I Nroff/Troff user's manual. +.PP +If no +.I file +argument is present, the standard input is read. +An argument consisting of a single minus +.RB ( \- ) +is taken to be +a file name corresponding to the standard input. +The options, which may appear in any order so long as they appear +before the files, are: +.TP 10n +.BI \-o list +Print only pages whose page numbers appear in +the comma-separated +.I list +of numbers and ranges. +A range +.IB N \- M +means pages +.I N +through +.IR M ; +an initial +.I \-N +means +from the beginning to page +.IR N ; +and a final +.IR N \- +means +from +.I N +to the end. +.TP +.BI \-n N +Number first generated page +.IR N . +.TP +.BI \-s N +Stop every +.I N +pages. +.I Nroff +will halt prior to every +.I N +pages (default +.IR N =1) +to allow paper loading or +changing, and will resume upon receipt of a newline. +.TP +.BI \-m name +Prepend the macro file +.BI /usr/ucblib/doctools/tmac/tmac. name +to the input +.IR files . +.TP +.BI \-r aN +Set register +.I a +(one-character) to +.IR N . +.TP +.BI \-r a = N +Set register +.I a +(may be more than one character) to +.IR N . +.TP +.BI \-d aN +Define string +.I a +(one-character) to +.IR S . +.TP +.BI \-d a = N +Define string +.I a +(may be more than one character) to +.IR S . +.TP +.B \-i +Read standard input after the input files are exhausted. +.TP +.B \-q +Invoke the simultaneous input-output mode of the +.B rd +request. +.TP +.B \-z +Check syntax only; +do not generate any output +except for error messages. +.TP +.BI \-F fontdir +Use the directory +.I fontdir +to locate font files. +.TP +.B \-u N +Set the emboldening amount, +i.e. the number of times a character is printed +to simulate bold output, +to +.IR N . +.TP +.BI \-T name +Prepare output for specified terminal. +Known +.I names +are +.B 37 +for the (default) +Teletype Corporation Model 37 terminal, +.B lp +for any line printer or terminal without half-line capability, +.B tn300 +for the GE TermiNet\ 300, +.B 300S +for the \s-1DASI\s+1-300S, +.B 300 +for the \s-1DASI\s+1-300, +and +.B 450 +for the \s-1DASI\s+1-450 +(Diablo Hyterm). +A special +.IR name , +.BR locale , +is also supported. +It generates UTF-8 output if permitted by +the current locale, +and has the same effect as +.I lp +otherwise. +.TP +.B \-e +Produce equally-spaced words in adjusted +lines, using full terminal resolution. +.TP +.B \-h +Use output tabs during horizontal spacing +to speed output and reduce output character count. +Tab settings are assumed to be every +8 nominal character widths. +.TP +.BI \-x N +Enable extensions to previous versions of +.I nroff +at level +.IR N . +Level 0 disables any extensions; +level 1 enables all extensions +except for long requests and request arguments; +level 2 enables these in addition +but executes short requests which are prefixes of undefined long requests; +level 3 ignores undefined long requests. +.TP +.B \-V +Print nroff version. +.SH "ENVIRONMENT VARIABLES" +.TP +.BR LANG ", " LC_ALL +See +.IR locale (7). +.TP +.B LC_CTYPE +Determines the mapping +of bytes to characters, +and the choice of output characters with the +.I \-Tlocale +option. +.TP +.B TYPESETTER +Specifies a device name as with the +.I \-T +option. +.TP +.B TROFFMACS +Specifies the location to search for macro files with the +.I \-m +option. +This string forms a prefix to which the macro package name +is immediately appended. +Thus to make `\-mname' work with a file `/path/to/tmac.name', +use `TROFFMACS=/path/to/tmac.' +.SH FILES +.ta \w'/usr/ucblib/doctools/tmac/* 'u +/tmp/ta* temporary file +.br +/usr/ucblib/doctools/tmac/* standard macro files +.br +/usr/ucblib/doctools/nterm/* terminal driving tables +.\".br +.\"/usr/ucblib/doctools/font/* font width tables for +.\".I troff +.SH "SEE ALSO" +J. F. Ossanna, +.I Nroff/Troff user's manual +.br +B. W. Kernighan, +.I +A TROFF Tutorial +.br +eqn(1), tbl(1) +.br +col(1) Property changes on: vendor/heirloom-doctools/dist/troff/nroff.d/nroff.1.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/nroff.d/pt.h =================================================================== --- vendor/heirloom-doctools/dist/troff/nroff.d/pt.h (revision 310549) +++ vendor/heirloom-doctools/dist/troff/nroff.d/pt.h (revision 310550) @@ -1,85 +1,86 @@ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)pt.h 1.43 (gritter) 8/19/08 */ /* n10.c */ extern void ptinit(void); extern char *skipstr(char *); extern char *getstr(char *, char *); extern char *getint(char *, int *); extern void specnames(void); extern int findch(register const char *); extern void twdone(void); extern void ptout1(void); +void ptout(tchar); extern char *plot(char *); extern void move(void); extern void ptlead(void); extern void dostop(void); extern void newpage(int); extern void pttrailer(void); /* n6.c */ extern int width(register tchar); extern tchar setch(int); extern tchar setabs(void); extern int tr2un(tchar, int); extern int findft(register int, int); extern void caseps(void); extern void mchbits(void); extern void setps(void); extern tchar setht(void); extern tchar setslant(void); extern void caseft(void); extern void setfont(int); extern void setwd(void); extern tchar vmot(void); extern tchar hmot(void); extern tchar mot(void); extern tchar sethl(int); extern tchar makem(int); extern tchar getlg(tchar); extern void caselg(void); extern void caseflig(void); extern void casefp(void); extern void casefps(void); extern void casecs(void); extern void casebd(void); extern void casevs(void); extern void casess(void); extern tchar xlss(void); extern tchar setuc0(int); extern tchar setanchor(void); extern tchar setlink(void); extern tchar setulink(void); extern void casedummy(void); #define casetrack casedummy #define casefallback casedummy #define casehidechar casedummy #define casefzoom casedummy #define casekern casedummy #define casepapersize casedummy #define casemediasize casedummy #define caselhang casedummy #define caserhang casedummy #define casekernpair casedummy #define casekernbefore casedummy #define casekernafter casedummy #define caseftr casedummy #define casefeature casedummy #define casetrimat casedummy #define casebleedat casedummy #define casecropat casedummy #define casefspacewidth casedummy #define casespacewidth casedummy #define casefdeferlig casedummy #define casefkern casedummy #define caseminss casedummy #define caseletadj casedummy #define kernadjust(a, b) 0 #define u2pts(i) (i) #define getascender() 0 #define getdescender() 0 #define getfzoom() 0 Index: vendor/heirloom-doctools/dist/troff/tdef.h =================================================================== --- vendor/heirloom-doctools/dist/troff/tdef.h (revision 310549) +++ vendor/heirloom-doctools/dist/troff/tdef.h (revision 310550) @@ -1,960 +1,960 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* from OpenSolaris "tdef.h 1.11 05/06/08 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)tdef.h 1.165 (gritter) 10/23/09 * * Portions Copyright (c) 2014 Carsten Kunze */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved * * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. */ #include "global.h" /* starting values for typesetting parameters: */ #define PS 10 /* default point size */ #define FT 1 /* default font position */ #define ULFONT 2 /* default underline font */ #define BDFONT 3 /* default emboldening font */ #define BIFONT 4 /* default bold italic font */ #define LL (unsigned) 65*INCH/10 /* line length; 39picas=6.5in */ #define VS ((12*INCH)/72) /* initial vert space */ #ifdef NROFF # define EM t.Em # define HOR t.Adj # define VERT t.Vert # define INCH 240 /* increments per inch */ # define SPS INCH/10 /* space size */ # define SS INCH/10 /* " */ # define SES SPS /* sentence space size */ # define SSS SS /* " */ # define TRAILER 0 # define PO 0 /* page offset */ # define ASCII 1 # define PTID 1 # define LG 0 # define DTAB 0 /* set at 8 Ems at init time */ # define ICS 2*SPS #endif #ifndef NROFF /* TROFF */ /* Inch is set by ptinit() when troff started. */ /* all derived values set then too */ # define INCH Inch /* troff resolution -- number of goobies/inch */ # define POINT (INCH/72) /* goobies per point (1/72 inch) */ # define HOR Hor /* horizontal resolution in goobies */ # define VERT Vert /* vertical resolution in goobies */ # define SPS (EM/3) /* space size */ # define SES SPS /* sentence space size */ # define SS 12 /* space size in 36ths of an em */ # define SSS SS /* sentence space size in 36ths of an em */ # define PO (INCH) /* page offset 1 inch */ /* # define EM (POINT * pts) */ #define EM (((long) INCH * u2pts(pts) + 36) / 72) /* don't lose significance */ #define EMPTS(pts) (((long) INCH * u2pts(pts) + 36) / 72) # define ASCII 0 # define PTID 1 # define LG 1 # define DTAB (INCH/2) # define ICS 3*SPS #endif /* These "characters" are used to encode various internal functions * Some make use of the fact that most ascii characters between * 0 and 040 don't have any graphic or other function. * The few that do have a purpose (e.g., \n, \b, \t, ... * are avoided by the ad hoc choices here. * See ifilt[] in n1.c for others -- 1, 2, 3, 5, 6, 7, 010, 011, 012 */ #define LEADER 001 #define IMP 004 /* impossible char; glues things together */ #define TAB 011 #define RPT 014 /* next character is to be repeated many times */ #define CHARHT 015 /* size field sets character height */ #define SLANT 016 /* size field sets amount of slant */ #define DRAWFCN 017 /* next several chars describe arb drawing fcn */ /* line: 'l' dx dy char */ /* circle: 'c' r */ /* ellipse: 'e' rx ry */ /* arc: 'a' dx dy r */ /* wiggly line '~' x y x y ... */ #define DRAWLINE 'l' #define DRAWCIRCLE 'c' /* circle */ #define DRAWCIRCLEFI 'C' /* filled circle */ #define DRAWELLIPSE 'e' #define DRAWELLIPSEFI 'E' /* filled ellipse */ #define DRAWARC 'a' /* arbitrary arc */ #define DRAWSPLINE '~' /* quadratic B spline */ #define DRAWTHICKNESS 't' /* line thickness */ #define DRAWPOLYGON 'p' /* polygon */ #define DRAWPOLYGONFI 'P' /* filled polygon */ #define LEFT 020 /* \{ */ #define RIGHT 021 /* \} */ #define FILLER 022 /* \& and similar purposes */ #define XON 023 /* \X'...' starts here */ #define OHC 024 /* optional hyphenation character \% */ #define CONT 025 /* \c character */ #define PRESC 026 /* printable escape */ #define UNPAD 027 /* unpaddable blank */ #define STRETCH 037 /* stretchable but unbreakable blank */ #define XPAR 030 /* transparent mode indicator */ #define FLSS 031 #define WORDSP 032 /* paddable word space */ #define ESC 033 #define XOFF 034 /* \X'...' ends here */ #define iscontrol(n) (n==035 || n==036) /* used to test the next two */ #define HX 035 /* next character is value of \x'...' */ #define FONTPOS 036 /* position of font \f(XX encoded in top */ #define XFUNC 013 /* extended function codes, type in fbits: */ #define ANCHOR 0001 /* anchor definition */ #define LINKON 0002 /* link start */ #define LINKOFF 0003 /* link end */ #define LETSP 0004 /* positive letter spacing */ #define NLETSP 0005 /* negative letter spacing */ #define FLDMARK 0006 /* field marker */ #define LETSH 0007 /* expanded letter shapes */ #define NLETSH 0010 /* condensed letter shapes */ #define HYPHED 0011 /* previous character is an automatic hyphen */ #define OLT 0012 /* output line trap */ #define YON 0013 /* indirect copy through */ #define CC 0014 /* unchangeable control character */ #define RQ 0015 /* request number */ #define CHAR 0022 /* formatted result of a .char execution */ #define INDENT 0023 /* current indent (informational only, no move) */ #define PENALTY 0024 /* line breaking penalty */ #define DPENAL 0025 /* default line breaking penalty change */ #define ULINKON 0026 /* ulink start */ #define ULINKOFF 0027 /* ulink end */ #define isxfunc(c, x) (cbits(c) == XFUNC && fbits(c) == (x)) #define LAFACT 1000 /* letter adjustment float-to-int conversion factor */ #define HYPHEN c_hyphen #define EMDASH c_emdash /* \(em */ #define RULE c_rule /* \(ru */ #define MINUS c_minus /* minus sign on current font */ #define LIG_FI c_fi /* \(ff */ #define LIG_FL c_fl /* \(fl */ #define LIG_FF c_ff /* \(ff */ #define LIG_FFI c_ffi /* \(Fi */ #define LIG_FFL c_ffl /* \(Fl */ #define ACUTE c_acute /* acute accent \(aa */ #define GRAVE c_grave /* grave accent \(ga */ #define UNDERLINE c_under /* \(ul */ #define ROOTEN c_rooten /* root en \(rn */ #define BOXRULE c_boxrule /* box rule \(br */ #define LEFTHAND c_lefthand /* left hand for word overflow */ #define DAGGER c_dagger /* dagger for footnotes */ /* array sizes, and similar limits: */ #define NFONT 10 /* maximum number of fonts (including specials, !afm) */ #define EXTRAFONT 500 /* extra space for swapping a font */ extern int NN; /* number registers */ #define NNAMES 15 /* predefined reg names */ extern int NS; /* name buffer */ #define NTM 4096 /* tm buffer */ #define NEV 3 /* environments */ #define EVLSZ 10 /* size of ev stack */ #define DSIZE 512 /* disk sector size in chars */ extern int NM; /* requests + macros */ #define NHYP 40 /* max hyphens per word */ #define NTAB 40 /* tab stops */ #define NSO 5 /* "so" depth */ extern int NMF; /* size of space for -m flags */ #define WDSIZE 540 /* default word buffer size */ #define LNSIZE 680 /* default line buffer size */ extern int NDI; /* number of diversions */ extern int NCHARS; /* maximum size of troff character set */ #define NTRTAB NCHARS /* number of items in trtab[] */ #define NWIDCACHE NCHARS /* number of items in widcache */ #define NTRAP 20 /* number of traps */ #define NPN 20 /* numbers in "-o" */ #define FBUFSZ 512 /* field buf size words */ #define OBUFSZ 4096 /* bytes */ #define IBUFSZ 4096L /* bytes */ #define NC 1024 /* cbuf size words */ #define NOV 10 /* number of overstrike chars */ #define NPP 10 /* pads per field */ #define NSENT 40 /* number of sentence end characters */ /* Internal character representation: Internally, every character is carried around as a 64 bit cookie, called a "tchar" (typedef int64_t). Bits are numbered 63..0 from left to right. If bit 21 is 1, the character is motion, with if bit 22 it's vertical motion if bit 23 it's negative motion If bit 21 is 0, the character is a real character. if bit 63 zero motion bits 62..40 size bits 39..32 font */ /* in the following, "LL" should really be a tchar, but ... */ #define MOT (01LL<<21) /* motion character indicator */ #define VMOT (01LL<<22) /* vert motion bit */ #define NMOT (01LL<<23) /* negative motion indicator*/ #define BMBITS 0x001FFFFFLL /* basic absolute motion bits */ #define XMBITS 0x03000000LL /* extended absolute motion bits */ #define XMSHIFT 3 /* extended absolute motion shift */ #define MAXMOT 0x007FFFFFLL /* bad way to write this!!! */ #define ismot(n) ((n) & MOT) #define isvmot(n) ((n) & VMOT) /* must have tested MOT previously */ #define isnmot(n) ((n) & NMOT) /* ditto */ #define absmot(n) (unsigned long)((BMBITS&(n)) | ((n)&XMBITS)>>XMSHIFT) #define sabsmot(n) (!xflag || (n) <= MAXMOT ? ((n)&BMBITS) | ((n)&~BMBITS)<> 40) & 037777777) #define fbits(n) (((n) >> 32) & 0377) #define sfbits(n) (unsigned)(037777777777UL & (((n) & SFMASK) >> 32)) #define cbits(n) (unsigned)(0x003FFFFFLL & (n)) /* isolate bottom 22 bits */ #define setsbits(n,s) n = (n & ~SMASK) | (tchar)(s) << 40 #define setfbits(n,f) n = (n & ~FMASK) | (tchar)(f) << 32 #define setsfbits(n,sf) n = (n & ~SFMASK) | (tchar)(sf) << 32 #define setcbits(n,c) n = ((n & ~0x001FFFFFLL) | (c)) /* set character bits */ #define BYTEMASK 0377 #define BYTE 8 #define ischar(n) (((n) & ~BYTEMASK) == 0) #if defined (NROFF) && defined (EUC) && defined (ZWDELIMS) #define ZWDELIM1 ZBIT | FIRSTOFMB | ' ' /* non-ASCII word delimiter 1 */ #define ZWDELIM2 ZBIT | MIDDLEOFMB | ' ' /* non-ASCII word delimiter 2 */ #define ZWDELIM(c) ((c) == 0) ? ' ' : ((c) == 1) ? ZWDELIM1 : ZWDELIM2 #endif /* NROFF && EUC && ZWDELIMS */ #define ZONE 5 /* 5 hrs for EST */ #define TABMASK 0x3FFFFFFF #define RTAB (unsigned) 0x80000000 #define CTAB 0x40000000 #define TABBIT 02 /* bits in gchtab */ #define LDRBIT 04 #define FCBIT 010 #define LGBIT 020 #define CHBIT 040 #define INFPENALTY0 (1e6) #define INFPENALTY (1e9) #define MAXPENALTY (1e6) #define PENALSCALE (1.0/50) #define PAIR(A,B) (A|(B<= &obuf[OBUFSZ]) flusho(); else #else #define oput(c) if ((*obufp++ = cbits(c) & BYTEMASK), obufp >= &obuf[OBUFSZ]) flusho(); else #endif /* EUC */ #ifdef NROFF #define ftrans(f, c) (c) #else #define ftrans(f, c) (f >= 0 && f <= nfonts ? ftrtab[f][ftrtab[f][c]] : (c)) #endif #define hex2nibble(x) ((x)>='0' && (x)<='9' ? (x)-'0' : \ (x)>='A' && (x)<='F' ? (x)-'A'+10 : \ (x)-'a'+10 ) /* * "temp file" parameters. macros and strings * are stored in an array of linked blocks, * which may be in memory and an array called * corebuf[]. * The numerology is delicate if filep is 16 bits: #define BLK 128 #define NBLIST 512 * i.e., the product is 16 bits long. * If filep is a long then NBLIST * can be a lot bigger. Of course that makes * the file or core image a lot bigger too, * and means you don't detect missing diversion * terminations as quickly... . * It also means that you may have trouble running * on non-swapping systems, since the core image * will be over 1Mb. * Note: As of 8/14/05, NBLIST has gone, and corebuf is * grown dynamically as needed. * filep must be a signed integer since the value -1 * is special (it indicates that input is read from tty). * filep must be an int for LP64 platforms since it is * casted to unsigned at some places (or changed there) * BLK must be a power of 2 */ typedef int filep; #define BLK 128 /* alloc block in tchars */ /* Other things are stored in the temp file or corebuf: * a single block for .rd input, at offset RD_OFFSET * NEV copies of the environment block, at offset ENV_OFFSET * The existing implementation assumes very strongly that * these are respectively NBLIST*BLK and 0. */ #define RD_OFFSET (NBLIST * BLK) #define ENV_OFFSET 0 #define ENV_BLK ((NEV * sizeof(env) / sizeof(tchar) + BLK-1) / BLK) /* rounded up to even BLK */ #include #include typedef int64_t tchar; extern int Inch, Hor, Vert, Unitwidth; /* BSD systems have a function devname(); avoid a collision */ #define devname troff_devname /* these characters are used as various signals or values * in miscellaneous places. * values are set in specnames in t10.c */ extern int c_hyphen; extern int c_emdash; extern int c_rule; extern int c_minus; extern int c_fi; extern int c_fl; extern int c_ff; extern int c_ffi; extern int c_ffl; extern int c_acute; extern int c_grave; extern int c_under; extern int c_rooten; extern int c_boxrule; extern int c_lefthand; extern int c_dagger; extern int c_isalnum; struct lgtab { struct lgtab *next; struct lgtab *link; int from; int to; }; #ifdef DEBUG extern int debug; /*debug flag*/ #define DB_MAC 01 /*print out macro calls*/ #define DB_ALLC 02 /*print out message from alloc()*/ #define DB_GETC 04 /*print out message from getch()*/ #define DB_LOOP 010 /*print out message before "Eileen's loop" fix*/ #define DB_ABRT 020 /*abort on errprint()*/ #endif /* DEBUG */ extern enum warn { WARN_NONE = 0, WARN_CHAR = 1, WARN_NUMBER = 2, WARN_BREAK = 4, WARN_DELIM = 8, WARN_EL = 16, WARN_SCALE = 32, WARN_RANGE = 64, WARN_SYNTAX = 128, WARN_DI = 256, WARN_MAC = 512, WARN_REG = 1024, WARN_RIGHT_BRACE= 4096, WARN_MISSING = 8192, WARN_INPUT = 16384, WARN_ESCAPE = 32768, WARN_SPACE = 65536, WARN_FONT = 131072, WARN_ALL = 2147481855, /* all except di, mac, reg */ WARN_W = 2147483647 } warn; enum flags { FLAG_WATCH = 01, FLAG_STRING = 02, FLAG_USED = 04, FLAG_DIVERSION = 010, FLAG_LOCAL = 020, FLAG_PARAGRAPH = 040 }; enum { PG_NONE = 00, PG_NEWIN = 01, PG_NEWLL = 02 }; struct d { /* diversion */ filep op; int dnl; int dimac; int ditrap; int ditf; int alss; int blss; int nls; int mkline; int maxl; int hnl; int curd; int flss; struct contab *soff; int mlist[NTRAP]; int nlist[NTRAP]; struct env *boxenv; }; struct charout { /* formatted result of .char */ filep op; int width; int height; int depth; tchar ch; }; struct s { /* stack frame */ int nargs; struct s *pframe; filep pip; filep newip; int *argt; tchar *argsp; int ppendt; tchar pch; int lastpbp; int mname; int frame_cnt; int tail_cnt; struct contab *contp; struct numtab *numtab; struct numtab **nhash; struct contab *contab; struct contab **mhash; int NN; int NM; enum { LOOP_FREE = 01, LOOP_NEXT = 02, LOOP_EVAL = 04 } loopf; enum flags flags; jmp_buf *jmp; }; extern struct contab { unsigned int rq; struct contab *link; void (*f)(int); unsigned mx; unsigned int als; int nlink; enum flags flags; } *contab; extern const struct contab initcontab[]; extern struct numtab { int r; /* name */ short fmt; int inc; int val; struct numtab *link; int aln; int nlink; float fval; float finc; enum flags flags; } *numtab; extern const struct numtab initnumtab[]; #define PN 0 #define NL 1 #define YR 2 #define HP 3 #define CT 4 #define DN 5 #define MO 6 #define DY 7 #define DW 8 #define LN 9 #define DL 10 #define ST 11 #define SB 12 #define CD 13 #define PID 14 struct acc { long long n; double f; }; /* inline environment */ struct inlev { int _apts; int _apts1; int _pts; int _pts1; int _font; int _font1; int _cc; int _c2; int _ohc; int _hyf; int _tabc; int _dotc; int _dpenal; }; /* the infamous environment block */ #define ics env._ics #define sps env._sps #define ses env._ses #define spacesz env._spacesz #define sesspsz env._sesspsz #ifndef NROFF #define minsps env._minsps #define minspsz env._minspsz #define letspsz env._letspsz #define letsps env._letsps #define lspmin env._lspmin #define lspmax env._lspmax #define lspnc env._lspnc #define lsplow env._lsplow #define lsphigh env._lsphigh #define lspcur env._lspcur #define lsplast env._lsplast #define lshmin env._lshmin #define lshmax env._lshmax #define lshwid env._lshwid #define lshlow env._lshlow #define lshhigh env._lshhigh #define lshcur env._lshcur #else /* NROFF */ #define minsps 0 #define minspsz 0 #define letspsz 0 #define letsps 0 #define lspmin 0 #define lspmax 0 #define lspnc 0 #define lsplow 0 #define lsphigh 0 #define lspcur 0 #define lsplast 0 #define lshmin 0 #define lshmax 0 #define lshwid 0 #define lshlow 0 #define lshhigh 0 #define lshcur 0 #endif /* NROFF */ #define fldcnt env._fldcnt #define lss env._lss #define lss1 env._lss1 #define ll env._ll #define ll1 env._ll1 #define lt env._lt #define lt1 env._lt1 #define ic env._ic #define icf env._icf #define chbits env._chbits #define spbits env._spbits #define nmbits env._nmbits #define apts env._apts #define apts1 env._apts1 #define pts env._pts #define pts1 env._pts1 #define font env._font #define font1 env._font1 #define ls env._ls #define ls1 env._ls1 #define ad env._ad #define nms env._nms #define ndf env._ndf #define fi env._fi #define cc env._cc #define c2 env._c2 #define ohc env._ohc #define tdelim env._tdelim #define hyf env._hyf #define hyoff env._hyoff #define hlm env._hlm #define hlc env._hlc #define hylen env._hylen #define hypp env._hypp #define hypp2 env._hypp2 #define hypp3 env._hypp3 #define un1 env._un1 #define tabc env._tabc #define dotc env._dotc #define adsp env._adsp #define adrem env._adrem #define lastl env._lastl #define nel env._nel #define admod env._admod #define adflg env._adflg #define adspc env._adspc #define pa env._pa #define wordp env._wordp #define spflg env._spflg #define seflg env._seflg #define linep env._linep #define wdend env._wdend #define wdstart env._wdstart #define wne env._wne #define wsp env._wsp #define ne env._ne #define nc env._nc #define nb env._nb #define lnmod env._lnmod #define nwd env._nwd #define nn env._nn #define ni env._ni #define ul env._ul #define cu env._cu #define ce env._ce #define rj env._rj #define brnl env._brnl #define brpnl env._brpnl #define in env._in #define in1 env._in1 #define un env._un #define wch env._wch #define rhang env._rhang #define pendt env._pendt #define pendw env._pendw #define pendnf env._pendnf #define spread env._spread #define dpenal env._dpenal #define it env._it #define itc env._itc #define itmac env._itmac #define lnsize env._lnsize #define wdsize env._wdsize #define pgsize env._pgsize #define pgcsize env._pgcsize #define pgssize env._pgssize #define pgchars env._pgchars #define pgspacs env._pgspacs #define pgwords env._pgwords #define pglines env._pglines #define pglnout env._pglnout #define pshapes env._pshapes #define pgne env._pgne #define pglastw env._pglastw #define linkin env._linkin #define linkout env._linkout #define linkhp env._linkhp #define hylang env._hylang #define dicthnj env._dicthnj #define hyext env._hyext #define hcode env._hcode #define nhcode env._nhcode #define shc env._shc #define lpfx env._lpfx #define nlpfx env._nlpfx #define stopch env._stopch #define cht env._cht #define cdp env._cdp #define maxcht env._maxcht #define maxcdp env._maxcdp #define wdhyf env._wdhyf #define hyptr env._hyptr #define tabtab env._tabtab #define line env._line #define word env._word #define wdpenal env._wdpenal #define sentch env._sentch #define transch env._transch #define breakch env._breakch #define nhych env._nhych #define connectch env._connectch #define para env._para #define parsp env._parsp #define pgwordp env._pgwordp #define pgspacp env._pgspacp #define pgwordw env._pgwordw #define pghyphw env._pghyphw #define pgadspc env._pgadspc #define pglsphc env._pglsphc #define pgopt env._pgopt #define pgspacw env._pgspacw #define pglgsc env._pglgsc #define pglgec env._pglgec #define pglgsw env._pglgsw #define pglgew env._pglgew #define pglgsh env._pglgsh #define pglgeh env._pglgeh #define pgin env._pgin #define pgll env._pgll #define pgwdin env._pgwdin #define pgwdll env._pgwdll #define pgflags env._pgflags #define pglno env._pglno #define pgpenal env._pgpenal #define ninlev env._ninlev #define ainlev env._ainlev #define inlevp env._inlevp #define evname env._evname extern struct env { int _ics; int _sps; int _ses; int _spacesz; int _sesspsz; #ifndef NROFF int _minsps; int _minspsz; int _letspsz; int _letsps; int _lspmin; int _lspmax; int _lspnc; int _lsplow; int _lsphigh; int _lspcur; int _lsplast; int _lshmin; int _lshmax; int _lshwid; int _lshlow; int _lshhigh; int _lshcur; #endif /* !NROFF */ int _fldcnt; int _lss; int _lss1; int _ll; int _ll1; int _lt; int _lt1; tchar _ic; int _icf; tchar _chbits; tchar _spbits; tchar _nmbits; int _apts; int _apts1; int _pts; int _pts1; int _font; int _font1; int _ls; int _ls1; int _ad; int _nms; int _ndf; int _fi; int _cc; int _c2; - int _ohc; + size_t _ohc; int _tdelim; int _hyf; int _hyoff; int _hlm; int _hlc; int _hylen; float _hypp; float _hypp2; float _hypp3; int _un1; int _tabc; int _dotc; int _adsp; int _adrem; int _lastl; int _nel; int _admod; int _adflg; int _adspc; int _pa; tchar *_wordp; int _spflg; int _seflg; tchar *_linep; tchar *_wdend; tchar *_wdstart; int _wne; int _wsp; int _ne; int _nc; int _nb; int _lnmod; int _nwd; int _nn; int _ni; int _ul; int _cu; int _ce; int _rj; int _brnl; int _brpnl; int _in; int _in1; int _un; int _wch; int _rhang; int _pendt; tchar *_pendw; int _pendnf; int _spread; int _dpenal; int _it; int _itc; int _itmac; int _lnsize; int _wdsize; int _pgsize; int _pgcsize; int _pgssize; int _pgchars; int _pgspacs; int _pgwords; int _pglines; int _pglnout; int _pshapes; int _pgne; int _pglastw; int _linkin; int _linkout; int _linkhp; char *_hylang; void *_dicthnj; int _hyext; int *_hcode; int _nhcode; tchar *_lpfx; int _nlpfx; int _shc; tchar _stopch; int _cht; int _cdp; int _maxcht; int _maxcdp; int _wdhyf; tchar *_hyptr[NHYP]; int _tabtab[NTAB]; - int _sentch[NSENT]; - int _transch[NSENT]; - int _breakch[NSENT]; - int _nhych[NSENT]; - int _connectch[NSENT]; + size_t _sentch[NSENT]; + size_t _transch[NSENT]; + size_t _breakch[NSENT]; + size_t _nhych[NSENT]; + size_t _connectch[NSENT]; tchar *_line; tchar *_word; int *_wdpenal; tchar *_para; tchar *_parsp; int *_pgwordp; int *_pgspacp; int *_pgwordw; int *_pghyphw; int *_pgadspc; int *_pglsphc; int *_pgopt; int *_pgspacw; tchar *_pglgsc; tchar *_pglgec; tchar *_pglgsw; tchar *_pglgew; tchar *_pglgsh; tchar *_pglgeh; int *_pgin; int *_pgll; int *_pgwdin; int *_pgwdll; int *_pglno; int *_pgflags; float *_pgpenal; int _ninlev; int _ainlev; struct inlev *_inlevp; char *_evname; } env, initenv; Index: vendor/heirloom-doctools/dist/troff/troff.d/troff.1 =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/troff.1 (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/troff.1 (nonexistent) @@ -1,308 +0,0 @@ -.\" -.\" Sccsid @(#)troff.1b 1.22 (gritter) 9/4/06 -.\" Derived from troff(1), Unix 7th edition: -.\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" Redistributions of source code and documentation must retain the -.\" above copyright notice, this list of conditions and the following -.\" disclaimer. -.\" 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. -.\" All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed or owned by Caldera -.\" International, Inc. -.\" Neither the name of Caldera International, Inc. nor the names of -.\" other contributors may be used to endorse or promote products -.\" derived from this software without specific prior written permission. -.\" -.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA -.\" INTERNATIONAL, INC. 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 CALDERA INTERNATIONAL, INC. 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. -.TH TROFF 1 "9/4/06" "Heirloom Documentation Tools" "BSD System Compatibility" -.SH NAME -troff \- typeset or format documents -.SH SYNOPSIS -.HP -.ad l -.nh -\fBtroff\fR -[\fB\-af\&izV\fR] -[\fB\-d\fIaS\fR] -[\fB\-d\fIa\fB=\fIS\fR] -[\fB\-F\fIfontdir\fR] -[\fB\-m\fIname\fR] -[\fB\-n\fIN\fR] -[\fB\-o\fIlist\fR] -[\fB\-r\fIaN\fR] -[\fB\-r\fIa\fB=\fIN\fR] -[\fB\-s\fIN\fR] -[\fB\-T\fIdevice\fR] -[\fB\-u\fIN\fR] -[\fB\-x\fIN\fR] -.br -.hy 1 -.ad b -.SH DESCRIPTION -.I troff -formats text in the named -.I files -for printing on phototypesetter devices. -Its capabilities are described in the -.I Nroff/Troff user's manual. -.PP -.I troff -generates output in an intermediate ASCII format -which must be passed through a device-dependent post-processor -before it can be printed; -see the description of the -.I \-T -option -and the example -below. -.PP -If no -.I file -argument is present, the standard input is read. -An argument consisting of a single minus -.RB ( \- ) -is taken to be -a file name corresponding to the standard input. -The options, which may appear in any order so long as they appear -before the files, are: -.TP "\w'\f3\-F\f1fontdir 'u" -.BI \-o list -Print only pages whose page numbers appear in -the comma-separated -.I list -of numbers and ranges. -A range -.IB N \- M -means pages -.I N -through -.IR M ; -an initial -.I \-N -means -from the beginning to page -.IR N ; -and a final -.IR N \- -means -from -.I N -to the end. -.TP -.BI \-n N -Number first generated page -.IR N . -.TP -.BI \-s N -Stop every -.I N -pages. -.I Troff -will stop the phototypesetter every -.I N -pages, -produce a trailer to allow changing cassettes, -and resume when the typesetter's start button is pressed. -.TP -.BI \-m name -Prepend the macro file -.BI /usr/ucblib/doctools/tmac/tmac. name -to the input -.IR files . -.TP -.BI \-r aN -Set register -.I a -(one-character) to -.IR N . -.TP -.BI \-r a = N -Set register -.I a -(may be more than one character) to -.IR N . -.TP -.BI \-d aS -Define string -.I a -(one-character) to -.IR S . -.TP -.BI \-d a = S -Define string -.I a -(may be more than one character) to -.IR S . -.TP -.B \-i -Read standard input after the input files are exhausted. -.TP -.B \-z -Check syntax only; -do not generate any output -except for error messages. -.TP -.BI \-F fontdir -Use the directory -.I fontdir -to locate font files. -.TP -.B \-u N -Set the emboldening amount, -i.e. the number of times a character is printed -to simulate bold output, -to -.IR N . -.TP -.BI \-T device -Prepare output for the specified device. -Available -.I devices -are: -.RS -.TP 8n -.PD 0 -.B ps -for PostScript output with 72,000\ dpi -and AFM fonts (default), -with -.I dpost -as post-processor -.TP -.B psmed -for PostScript output with 3,600\ dpi -and AFM fonts, -with -.I dpost -as post-processor -.TP -.B pslow -for PostScript output with 432\ dpi -and AFM fonts, -with -.I dpost -as post-processor -.TP -.B post -for PostScript output with 720\ dpi -and -.I ditroff -fonts, -with -.I dpost -as post-processor -.TP -.B html -for HTML output, -with -.I dhtml -as post-processor -.ig \" aps is not installed any longer -.TP -.B aps -for the Autologic APS-5, -with -.I daps -as post-processor -.. -.PD -.RE -.TP -.B \-f -Refrain from feeding out paper and stopping -phototypesetter at the end of the run. -.TP -.B \-a -Send a printable text-only approximation -of the results to the standard output. -.TP -.BI \-x N -Enable extensions to previous versions of -.I troff -at level -.IR N . -Level 0 disables any extensions; -level 1 enables all extensions -except for long requests and request arguments; -level 2 enables these in addition -but executes short requests which are prefixes of undefined long requests; -level 3 ignores undefined long requests. -.TP -.B \-V -Print troff version. -.SH "ENVIRONMENT VARIABLES" -.TP -.BR LANG ", " LC_ALL -See -.IR locale (7). -.TP -.B LC_CTYPE -Determines the mapping -of bytes to characters. -.TP -.B TYPESETTER -Specifies a device name as with the -.I \-T -option. -.TP -.B TROFFONTS -A colon-separated list of directory names -to search for PostScript fonts -before the device font directory. -.TP -.B TROFFMACS -Specifies the location to search for macro files with the -.I \-m -option. -This string forms a prefix to which the macro package name -is immediately appended. -Thus to make `\-mname' work with a file `/path/to/tmac.name', -use `TROFFMACS=/path/to/tmac.' -.SH FILES -.ta \w'/usr/ucblib/doctools/tmac/* 'u -/tmp/ta* temporary file -.br -/usr/ucblib/doctools/tmac/* standard macro files -.br -/usr/ucblib/doctools/font/* font width tables -.SH EXAMPLES -To generate a PostScript file -from input that contains equations and tables, use -.RS -.nf -.sp -output.ps -.sp -.fi -.RE -The resulting file can then be sent to a printer, -displayed by a previewer, -or passed to further post-processing utilities, -such as a PDF distiller. -.SH "SEE ALSO" -J. F. Ossanna, -.I Nroff/Troff user's manual -.br -B. W. Kernighan, -.I -A TROFF Tutorial -.br -eqn(1), tbl(1) Property changes on: vendor/heirloom-doctools/dist/troff/troff.d/troff.1 ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/troff.d/Makefile.mk =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/Makefile.mk (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/Makefile.mk (revision 310550) @@ -1,66 +1,71 @@ LIBHNJ = ../libhnj BST = ../../stuff/bst VPATH=.. OBJ = t10.o t6.o hytab.o n1.o n2.o n3.o n4.o n5.o \ n7.o n8.o n9.o ni.o nii.o suftab.o makedev.o afm.o otf.o unimap.o \ version.o fontmap.o $(BST)/bst.o FLAGS = -DUSG $(EUC) -I. -I.. -I../../include -DMACDIR='"$(MACDIR)"' \ -DFNTDIR='"$(FNTDIR)"' -DTABDIR='"$(TABDIR)"' -DHYPDIR='"$(HYPDIR)"' \ -DSHELL='"$(SHELL)"' -DRELEASE='"$(RELEASE)"' $(DEFINES) -I$(BST) .c.o: $(CC) $(_CFLAGS) $(FLAGS) -c $< -all: troff ta otfdump +all: troff ta otfdump troff.1 troff: $(OBJ) $(LIBHNJ)/libhnj.a $(CC) $(_CFLAGS) $(_LDFLAGS) $(OBJ) -L$(LIBHNJ) -lhnj $(LIBS) -o troff ta: draw.o ta.o $(CC) $(_CFLAGS) $(_LDFLAGS) draw.o ta.o $(LIBS) -lm -o $@ otfdump: otfdump.o otfdump_vs.o $(CC) $(_CFLAGS) $(_LDFLAGS) otfdump.o otfdump_vs.o $(LIBS) -o $@ install: $(INSTALL) -c troff $(ROOT)$(BINDIR)/troff $(STRIP) $(ROOT)$(BINDIR)/troff $(INSTALL) -c ta $(ROOT)$(BINDIR)/ta $(STRIP) $(ROOT)$(BINDIR)/ta $(INSTALL) -c otfdump $(ROOT)$(BINDIR)/otf_info $(STRIP) $(ROOT)$(BINDIR)/otf_info $(INSTALL) -c -m 644 troff.1 $(ROOT)$(MANDIR)/man1/troff.1 $(INSTALL) -c -m 644 otfdump.1 $(ROOT)$(MANDIR)/man1/otf_info.1 clean: rm -f $(OBJ) draw.o ta.o troff ta otfdump otfdump.o otfdump_vs.o \ - core log *~ + core log *~ troff.1 mrproper: clean + +troff.1: troff.1.in + sed -e 's"/usr/ucblib/doctools/font/"$(ROOT)$(FNTDIR)/"' \ + -e 's"/usr/ucblib/doctools/tmac/"$(ROOT)$(MACDIR)/"' \ + troff.1.in > $@ draw.o: draw.c makedev.o: makedev.c dev.h t10.o: t10.c ../tdef.h ../ext.h dev.h afm.h unimap.h troff.h t6.o: t6.c ../tdef.h dev.h ../ext.h afm.h unimap.h troff.h unimap.o: unimap.h ta.o: ta.c dev.h hytab.o: ../hytab.c malloc.o: ../malloc.c ../mallint.h n1.o: ../n1.c ../tdef.h ../ext.h ./pt.h n2.o: ../n2.c ../tdef.h ./pt.h ../ext.h n3.o: ../n3.c ../tdef.h ./pt.h ../ext.h n4.o: ../n4.c ../tdef.h ./pt.h ../ext.h n5.o: ../n5.c ../tdef.h ./pt.h ../ext.h n7.o: ../n7.c ../tdef.h ./pt.h ../ext.h n8.o: ../n8.c ../tdef.h ../ext.h ./pt.h n9.o: ../n9.c ../tdef.h ./pt.h ../ext.h ni.o: ../ni.c ../tdef.h ./pt.h ../ext.h nii.o: ../nii.c ../tdef.h ./pt.h ../ext.h suftab.o: ../suftab.c version.o: ../version.c otfdump_vs.o: ../version.c afm.o: dev.h afm.h otf.o: dev.h afm.h unimap.h otfdump.o: afm.h afm.c otf.c otfdump.c dev.h fontmap.o: fontmap.h Index: vendor/heirloom-doctools/dist/troff/troff.d/afm.c =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/afm.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/afm.c (revision 310550) @@ -1,1203 +1,1202 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)afm.c 1.65 (gritter) 1/14/10 */ #include #include #include "dev.h" #include "afm.h" #ifndef __unused #define __unused __attribute__((unused)) #endif extern char *chname; extern short *chtab; extern int nchtab; extern void errprint(const char *, ...); #if !defined (DPOST) && !defined (DUMP) static void addkernpair(struct afmtab *, char *_line); #endif /* * This table maps troff special characters to PostScript names. */ static const struct names { const char *trname; const char *psname; } names[] = { { "hy", "hyphen" }, { "ct", "cent" }, { "fi", "fi" }, { "fi", "f_i" }, { "fl", "fl" }, { "fl", "f_l" }, { "ff", "ff" }, { "ff", "f_f" }, { "Fi", "ffi" }, { "Fi", "f_f_i" }, { "Fl", "ffl" }, { "Fl", "f_f_l" }, { "dg", "dagger" }, { "dd", "daggerdbl" }, { "bu", "bullet" }, { "de", "ring" }, { "em", "emdash" }, { "en", "endash" }, { "sc", "section" }, { "``", "quotedblleft" }, { "''", "quotedblright" }, { "12", "onehalf" }, { "14", "onequarter" }, { "34", "threequarters" }, { "aq", "quotesingle" }, { "oq", "quoteleft" }, { "cq", "quoteright" }, { 0, 0 } }; /* * Names for Symbol fonts only. */ static const struct names greeknames[] = { { "*A", "Alpha" }, { "*B", "Beta" }, { "*C", "Xi" }, { "*D", "Delta" }, { "*E", "Epsilon" }, { "*F", "Phi" }, { "*G", "Gamma" }, { "*H", "Theta" }, { "*I", "Iota" }, { "*K", "Kappa" }, { "*L", "Lambda" }, { "*M", "Mu" }, { "*N", "Nu" }, { "*O", "Omicron" }, { "*P", "Pi" }, { "*Q", "Psi" }, { "*R", "Rho" }, { "*S", "Sigma" }, { "*T", "Tau" }, { "*U", "Upsilon" }, { "*W", "Omega" }, { "*X", "Chi" }, { "*Y", "Eta" }, { "*Z", "Zeta" }, { "*a", "alpha" }, { "*b", "beta" }, { "*c", "xi" }, { "*d", "delta" }, { "*e", "epsilon" }, { "*f", "phi" }, { "*g", "gamma" }, { "*h", "theta" }, { "*i", "iota" }, { "*k", "kappa" }, { "*l", "lambda" }, { "*m", "mu" }, { "*n", "nu" }, { "*o", "omicron" }, { "*p", "pi" }, { "*q", "psi" }, { "*r", "rho" }, { "*s", "sigma" }, { "*t", "tau" }, { "*u", "upsilon" }, { "*w", "omega" }, { "*x", "chi" }, { "*y", "eta" }, { "*z", "zeta" }, { 0, 0 } }; static const struct names mathnames[] = { { "!=", "notequal" }, { "**", "asteriskmath" }, { "+-", "plusminus" }, { "->", "arrowright" }, { "<", "less" }, { "<-", "arrowleft" }, { "<=", "lessequal" }, { "==", "equivalence" }, { ">", "greater" }, { ">=", "greaterequal" }, { "O+", "circleplus" }, { "Ox", "circlemultiply" }, { "^", "logicaland" }, { "al", "aleph" }, { "ap", "similar" }, { "bu", "bullet" }, { "ca", "intersection" }, { "co", "copyrightserif" }, { "cu", "union" }, { "da", "arrowdown" }, { "de", "degree" }, { "di", "divide" }, { "eq", "equal" }, { "es", "emptyset" }, { "fa", "universal" }, { "fm", "minute" }, { "gr", "gradient" }, { "ib", "reflexsubset" }, { "if", "infinity" }, { "ip", "reflexsuperset" }, { "is", "integral" }, { "mi", "minus" }, { "mo", "element" }, { "mu", "multiply" }, { "no", "logicalnot" }, { "or", "bar" }, { "or", "logicalor" }, { "pd", "partialdiff" }, { "pl", "plus" }, { "pt", "proportional" }, { "rg", "registerserif" }, { "sb", "propersubset" }, { "sl", "fraction" }, { "sp", "propersuperset" }, { "sr", "radical" }, { "te", "existential" }, { "tm", "trademarkserif" }, { "ts", "sigma1" }, { "ua", "arrowup" }, { "~~", "approxequal" }, { 0, 0 }, }; static const struct names largenames[] = { { "bv", "braceex" }, { "lb", "braceleftbt" }, { "lc", "bracketlefttp" }, { "lf", "bracketleftbt" }, { "lk", "braceleftmid" }, { "lt", "bracelefttp" }, { "rb", "bracerightbt" }, { "rc", "bracketrighttp" }, { "rf", "bracketrightbt" }, { "rk", "bracerightmid" }, { "rn", "radicalex" }, { "rt", "bracerighttp" }, { 0, 0 } }; static const struct names punctnames[] = { { "or", "bar" }, { "\\-","endash" }, { "aa","acute" }, { "ga","grave" }, { "rs","backslash" }, { "dq","quotedbl" }, { 0, 0 } }; /* * These names are only used with the S font. */ static const struct names Snames[] = { { "br", "parenleftex" }, { "ul", "underscore" }, { "vr", "bracketleftex" }, { 0, 0 } }; /* * These names are only used with the S1 font. */ static const struct names S1names[] = { { "ru", "underscore" }, { 0, 0 } }; /* * Figures from charlib. */ #define NCHARLIB 16 static const struct charlib { const char *name; int width; int kern; int code; int symbol; enum { NEEDS_F = 01, NEEDS_I = 02, NEEDS_L = 04 } needs; } charlib[] = { { "bx", 500, 2, 1, 0, 0 }, { "ci", 750, 0, 1, 0, 0 }, { "sq", 500, 2, 1, 0, 0 }, { "ff", 600, 2, 1, 0, 1 }, /* widths of the ligatures */ { "Fi", 840, 2, 1, 0, 3 }, /* are likely wrong, but */ { "Fl", 840, 2, 1, 0, 5 }, /* they are normally not used */ { "~=", 550, 0, 1, 1, 0 }, { "L1", 1100, 1, 2, 1, 0 }, { "LA", 1100, 1, 2, 1, 0 }, { "LV", 1100, 3, 2, 1, 0 }, { "LH", 2100, 1, 2, 1, 0 }, { "Lb", 2100, 1, 2, 1, 0 }, { "lh", 1000, 0, 2, 1, 0 }, { "rh", 1000, 0, 2, 1, 0 }, { "Sl", 500, 2, 1, 1, 0 }, { "ob", 380, 0, 1, 1, 0 }, { 0, 0, 0, 0, 0, 0 } }; /* * The values in this table determine if a character that is found on an * ASCII position in a PostScript font actually is that ASCII character. * If not, the position in fitab remains empty, and the fallback sequence * is used to find it in another font. */ static const struct asciimap { int code; const char *psc; } asciimap[] = { { 0x0020, "space" }, { 0x0021, "exclam" }, { 0x0024, "dollar" }, { 0x0024, "dollaralt" }, /* FournierMT-RegularAlt */ { 0x0025, "percent" }, { 0x0026, "ampersand" }, { 0x0026, "ampersandalt" }, /* AGaramondAlt-Italic */ { 0x0027, "quoteright" }, { 0x0028, "parenleft" }, { 0x0029, "parenright" }, { 0x002A, "asterisk" }, { 0x002B, "plus" }, { 0x002C, "comma" }, { 0x002D, "hyphen" }, { 0x002E, "period" }, { 0x002F, "slash" }, { 0x0030, "zero" }, { 0x0030, "zerooldstyle" }, { 0x0030, "zeroalt" }, /* BulmerMT-RegularAlt */ { 0x0031, "one" }, { 0x0031, "oneoldstyle" }, { 0x0031, "onefitted" }, { 0x0031, "onealtfitted" }, /* BulmerMT-ItalicAlt */ { 0x0032, "two" }, { 0x0032, "twooldstyle" }, { 0x0032, "twoalt" }, /* BulmerMT-RegularAlt */ { 0x0033, "three" }, { 0x0033, "threeoldstyle" }, { 0x0033, "threealt" }, /* BulmerMT-RegularAlt */ { 0x0034, "four" }, { 0x0034, "fouroldstyle" }, { 0x0034, "fouralt" }, /* BulmerMT-RegularAlt */ { 0x0035, "five" }, { 0x0035, "fiveoldstyle" }, { 0x0035, "fivealt" }, /* BulmerMT-RegularAlt */ { 0x0036, "six" }, { 0x0036, "sixoldstyle" }, { 0x0036, "sixalt" }, /* BulmerMT-RegularAlt */ { 0x0037, "seven" }, { 0x0037, "sevenoldstyle" }, { 0x0037, "sevenalt" }, /* BulmerMT-RegularAlt */ { 0x0038, "eight" }, { 0x0038, "eightoldstyle" }, { 0x0038, "eightalt" }, /* BulmerMT-RegularAlt */ { 0x0039, "nine" }, { 0x0039, "nineoldstyle" }, { 0x0039, "ninealt" }, /* BulmerMT-RegularAlt */ { 0x003A, "colon" }, { 0x003B, "semicolon" }, { 0x003D, "equal" }, { 0x003F, "question" }, { 0x0041, "A" }, { 0x0041, "Aswash" }, /* AGaramondAlt-Italic */ { 0x0042, "B" }, { 0x0042, "Bswash" }, /* AGaramondAlt-Italic */ { 0x0043, "C" }, { 0x0043, "Cswash" }, /* AGaramondAlt-Italic */ { 0x0044, "D" }, { 0x0044, "Dswash" }, /* AGaramondAlt-Italic */ { 0x0045, "E" }, { 0x0045, "Eswash" }, /* AGaramondAlt-Italic */ { 0x0046, "F" }, { 0x0046, "Fswash" }, /* AGaramondAlt-Italic */ { 0x0047, "G" }, { 0x0047, "Gswash" }, /* AGaramondAlt-Italic */ { 0x0048, "H" }, { 0x0048, "Hswash" }, /* AGaramondAlt-Italic */ { 0x0049, "I" }, { 0x0049, "Iswash" }, /* AGaramondAlt-Italic */ { 0x004A, "J" }, { 0x004A, "Jalt" }, /* FournierMT-RegularAlt */ { 0x004A, "Jalttwo" }, /* BulmerMT-ItalicAlt */ { 0x004A, "Jswash" }, /* AGaramondAlt-Italic */ { 0x004A, "JTallCapalt" }, /* FournierMT-RegularAlt */ { 0x004B, "K" }, { 0x004B, "Kalt" }, /* BulmerMT-ItalicAlt */ { 0x004B, "Kswash" }, /* AGaramondAlt-Italic */ { 0x004C, "L" }, { 0x004C, "Lswash" }, /* AGaramondAlt-Italic */ { 0x004D, "M" }, { 0x004D, "Mswash" }, /* AGaramondAlt-Italic */ { 0x004E, "N" }, { 0x004E, "Nalt" }, /* BulmerMT-ItalicAlt */ { 0x004E, "Nswash" }, /* AGaramondAlt-Italic */ { 0x004F, "O" }, { 0x004F, "Oalt" }, /* BulmerMT-ItalicAlt */ { 0x004F, "Oswash" }, /* AGaramondAlt-Italic */ { 0x0050, "P" }, { 0x0050, "Pswash" }, /* AGaramondAlt-Italic */ { 0x0051, "Q" }, { 0x0051, "Qalt" }, /* FournierMT-RegularAlt */ { 0x0051, "Qalttitling" }, /* AGaramondAlt-Regular */ { 0x0051, "Qswash" }, /* AGaramondAlt-Italic */ { 0x0051, "QTallCapalt" }, /* FournierMT-RegularAlt */ { 0x0052, "R" }, { 0x0052, "Ralternate" }, /* Bembo-Alt */ { 0x0052, "Rswash" }, /* AGaramondAlt-Italic */ { 0x0053, "S" }, { 0x0053, "Sswash" }, /* AGaramondAlt-Italic */ { 0x0054, "T" }, { 0x0054, "Talt" }, /* BulmerMT-ItalicAlt */ { 0x0054, "Tswash" }, /* AGaramondAlt-Italic */ { 0x0055, "U" }, { 0x0055, "Uswash" }, /* AGaramondAlt-Italic */ { 0x0056, "V" }, { 0x0056, "Vswash" }, /* AGaramondAlt-Italic */ { 0x0057, "W" }, { 0x0057, "Wswash" }, /* AGaramondAlt-Italic */ { 0x0058, "X" }, { 0x0058, "Xswash" }, /* AGaramondAlt-Italic */ { 0x0059, "Y" }, { 0x0059, "Yalt" }, /* BulmerMT-ItalicAlt */ { 0x0059, "Yswash" }, /* AGaramondAlt-Italic */ { 0x005A, "Z" }, { 0x005A, "Zswash" }, /* AGaramondAlt-Italic */ { 0x005B, "bracketleft" }, { 0x005D, "bracketright" }, { 0x005F, "underscore" }, { 0x0060, "quoteleft" }, { 0x0060, "quotealtleft" }, /* BulmerMT-RegularAlt */ { 0x0061, "a" }, { 0x0061, "Asmall" }, { 0x0061, "aswash" }, /* AGaramondAlt-Regular */ { 0x0062, "b" }, { 0x0062, "Bsmall" }, { 0x0063, "c" }, { 0x0063, "Csmall" }, { 0x0064, "d" }, { 0x0064, "Dsmall" }, { 0x0065, "e" }, { 0x0065, "Esmall" }, { 0x0065, "eswash" }, /* AGaramondAlt-Regular */ { 0x0066, "f" }, { 0x0066, "Fsmall" }, { 0x0067, "g" }, { 0x0067, "Gsmall" }, { 0x0068, "h" }, { 0x0068, "Hsmall" }, { 0x0069, "i" }, { 0x0069, "Ismall" }, { 0x006A, "j" }, { 0x006A, "Jsmall" }, { 0x006A, "Jsmallalt" }, /* FournierMT-RegularAlt */ { 0x006B, "k" }, { 0x006B, "Ksmall" }, { 0x006C, "l" }, { 0x006C, "Lsmall" }, { 0x006D, "m" }, { 0x006D, "Msmall" }, { 0x006E, "n" }, { 0x006E, "Nsmall" }, { 0x006E, "nswash" }, /* AGaramondAlt-Regular */ { 0x006F, "o" }, { 0x006F, "Osmall" }, { 0x0070, "p" }, { 0x0070, "Psmall" }, { 0x0071, "q" }, { 0x0071, "Qsmall" }, { 0x0072, "r" }, { 0x0072, "Rsmall" }, { 0x0072, "rswash" }, /* AGaramondAlt-Regular */ { 0x0073, "s" }, { 0x0073, "Ssmall" }, { 0x0074, "t" }, { 0x0074, "Tsmall" }, { 0x0074, "tswash" }, /* AGaramondAlt-Regular */ { 0x0074, "tswashalt" }, /* AGaramondAlt-Regular */ { 0x0075, "u" }, { 0x0075, "Usmall" }, { 0x0076, "v" }, { 0x0076, "Vsmall" }, { 0x0076, "vswash" }, /* AGaramondAlt-Italic */ { 0x0077, "w" }, { 0x0077, "Wsmall" }, { 0x0077, "walt" }, /* FournierMT-RegularAlt */ { 0x0078, "x" }, { 0x0078, "Xsmall" }, { 0x0079, "y" }, { 0x0079, "Ysmall" }, { 0x007A, "z" }, { 0x007A, "Zsmall" }, { 0x007A, "zalt" }, /* FournierMT-ItalicAlt */ { 0x007A, "zswash" }, /* AGaramondAlt-Regular */ { 0x007B, "braceleft" }, { 0x007C, "bar" }, { 0x007D, "braceright" }, { 0, 0 } }; /* * ASCII characters that are always taken from the S (math) font. */ static const struct asciimap mathascii[] = { { 0x002D, "minus" }, { 0x007E, "similar" }, { 0, 0 } }; /* * ASCII characters that are always taken from the S1 (punct) font. */ static const struct asciimap punctascii[] = { { 0x0022, "quotedbl" }, { 0x0023, "numbersign" }, { 0x003C, "less" }, { 0x003E, "greater" }, { 0x0040, "at" }, { 0x005C, "backslash" }, { 0x005E, "circumflex" }, { 0x007E, "tilde" }, { 0, NULL } }; int nextprime(int n) { const int primes[] = { 509, 1021, 2039, 4093, 8191, 16381, 32749, 65521, 131071, 262139, 524287, 1048573, 2097143, 4194301, 8388593, 16777213, 33554393, 67108859, 134217689, 268435399, 536870909, 1073741789, 2147483647 }; int mprime = 7; size_t i; for (i = 0; i < sizeof primes / sizeof *primes; i++) if ((mprime = primes[i]) >= (n < 65536 ? n*4 : n < 262144 ? n*2 : n)) break; if (i == sizeof primes / sizeof *primes) mprime = n; /* not so prime, but better than failure */ return mprime; } unsigned pjw(const char *cp) { unsigned h = 0, g; cp--; while (*++cp) { h = (h << 4 & 0xffffffff) + (*cp&0377); if ((g = h & 0xf0000000) != 0) { h = h ^ g >> 24; h = h ^ g; } } return h; } struct namecache * afmnamelook(struct afmtab *a, const char *name) { struct namecache *np; int h, c, n = 0; h = pjw(name) % a->nameprime; np = &a->namecache[c = h]; while (np->afpos != 0) { if (a->nametab[np->afpos] == 0 || strcmp(a->nametab[np->afpos], name) == 0) break; h = (n + 1) / 2; h *= h; if (n & 1) c -= h; else c += h; n++; while (c >= a->nameprime) c -= a->nameprime; np = &a->namecache[c]; } return np; } static int mapname1(const char *psname, const struct names *np) { int i, j; for (i = 0; np[i].trname; i++) if (strcmp(np[i].psname, psname) == 0) break; if (np[i].trname) for (j = 0; j < nchtab; j++) if (strcmp(np[i].trname, &chname[chtab[j]]) == 0) return j + 128; return 0; } int afmmapname(const char *psname, enum spec s) { int k; if (s & SPEC_S && (k = mapname1(psname, Snames)) > 0) return k; if (s & SPEC_S1 && (k = mapname1(psname, S1names)) > 0) return k; if (s & (SPEC_MATH|SPEC_S) && (k = mapname1(psname, mathnames)) > 0) return k; if (s & (SPEC_GREEK|SPEC_S) && (k = mapname1(psname, greeknames)) > 0) return k; if (s & (SPEC_LARGE|SPEC_S) && (k = mapname1(psname, largenames)) > 0) return k; if (s & (SPEC_PUNCT|SPEC_S1) && (k = mapname1(psname, punctnames)) > 0) return k; return mapname1(psname, names); } /* * After all characters have been read, construct a font-specific * encoding for the rest. Also move the name table to permanent space. */ void afmremap(struct afmtab *a) { int i, j = 128 - 32 + nchtab; char *space, *tp; struct namecache *np; for (i = 1; i < a->nchars; i++) { if (a->codetab[i] == NOCODE && a->nametab[i] != NULL) { #if defined (DPOST) || defined (DUMP) while (a->fitab[j] != 0) j++; #else /* TROFF */ extern int ps2cc(const char *); j = ps2cc(a->nametab[i]) + 128 - 32 + nchtab; #endif /* TROFF */ a->fitab[j] = i; np = afmnamelook(a, a->nametab[i]); np->afpos = i; np->fival[0] = j; if (np->gid != 0 && a->gid2tr) a->gid2tr[np->gid].ch1 = j + 32 + nchtab + 128; if (strcmp(a->nametab[i], "space") == 0) { np->fival[1] = 0; if (np->gid != 0 && a->gid2tr) a->gid2tr[np->gid].ch2 = 32; } } } space = malloc(a->nspace); for (i = 0; i < a->nchars; i++) { if (a->nametab[i]) { tp = a->nametab[i]; a->nametab[i] = space; while ((*space++ = *tp++)); } } } #ifndef DUMP static int asciiequiv(int code __unused, const char *psc, enum spec s) { int i; if (psc != NULL) { for (i = 0; asciimap[i].psc; i++) if (strcmp(asciimap[i].psc, psc) == 0) return asciimap[i].code; if (s & (SPEC_MATH|SPEC_S)) { for (i = 0; mathascii[i].psc; i++) if (strcmp(mathascii[i].psc, psc) == 0) return mathascii[i].code; } if (s & (SPEC_PUNCT|SPEC_S1)) { for (i = 0; punctascii[i].psc; i++) if (strcmp(punctascii[i].psc, psc) == 0) return punctascii[i].code; } } return 0; } static char * thisword(char *text, const char *wrd) { while (*text == *wrd) text++, wrd++; if (*wrd != 0) return 0; if (*text == 0 || *text == ' ' || *text == '\t' || *text == '\n' || *text == '\r') { while (*text != 0 && (*text == ' ' || *text == '\t')) text++; return text; } return NULL; } #endif /* !DUMP */ int unitconv(int i) { if (unitsPerEm * 72 != dev.unitwidth * dev.res) i = i * dev.unitwidth * dev.res / 72 / unitsPerEm; return i; } #ifndef DUMP void afmaddchar(struct afmtab *a, int C, int tp, int cl, int WX, int B[4], char *N, enum spec s, int gid) { struct namecache *np = NULL; if (N != NULL) { np = afmnamelook(a, N); np->afpos = a->nchars; np->gid = gid; if (a->isFixedPitch && strcmp(N, "space") == 0) a->fontab[0] = _unitconv(WX); } a->fontab[a->nchars] = _unitconv(WX); if (B) { a->bbtab[a->nchars] = malloc(4 * sizeof **a->bbtab); a->bbtab[a->nchars][0] = _unitconv(B[0]); a->bbtab[a->nchars][1] = _unitconv(B[1]); a->bbtab[a->nchars][2] = _unitconv(B[2]); a->bbtab[a->nchars][3] = _unitconv(B[3]); /* * Crude heuristics mainly based on observations with the existing * fonts for -Tpost and on tests with eqn. */ if (B[1] <= -10) a->kerntab[a->nchars] |= 1; if (B[3] > (a->xheight + a->capheight) / 2) a->kerntab[a->nchars] |= 2; } /* * Only map a character directly if it maps to an ASCII * equivalent or to a troff special character. */ C = asciiequiv(C, N, s); if (cl) a->codetab[a->nchars] = cl; else if (tp) a->codetab[a->nchars] = tp; else if (C > 32 && C < 127 && a->fitab[C - 32] == 0) a->codetab[a->nchars] = C; else a->codetab[a->nchars] = NOCODE; if (C > 32 && C < 127 && a->fitab[C - 32] == 0) { a->fitab[C - 32] = a->nchars; if (gid && a->gid2tr) a->gid2tr[gid].ch1 = C; if (np) np->fival[0] = C - 32; } else if (C == 32 && np) np->fival[0] = 0; if (tp) { a->fitab[tp - 32] = a->nchars; if (gid && a->gid2tr) a->gid2tr[gid].ch2 = tp; if (np) np->fival[1] = tp - 32; } a->nametab[a->nchars] = N; a->nchars++; } /* * Add charlib figues. */ static void addcharlib(struct afmtab *a, int symbol) { int i, j; int B[4] = { 0, 0, 0, 0 }; for (j = 0; j < nchtab; j++) for (i = 0; charlib[i].name; i++) { if (charlib[i].symbol && !symbol) continue; if (charlib[i].needs & NEEDS_F && a->fitab['f'-32] == 0) continue; if (charlib[i].needs & NEEDS_I && a->fitab['i'-32] == 0) continue; if (charlib[i].needs & NEEDS_L && a->fitab['l'-32] == 0) continue; if (strcmp(charlib[i].name, &chname[chtab[j]]) == 0) { B[1] = charlib[i].kern & 1 ? -11 : 0; B[3] = charlib[i].kern & 2 ? a->capheight + 1 : 0; afmaddchar(a, NOCODE, j+128, charlib[i].code, charlib[i].width * unitsPerEm / 1024, B, NULL, SPEC_NONE, 0); } } } static void addmetrics(struct afmtab *a, char *_line, enum spec s) { char *lp = _line, c, *xp; int C = NOCODE, WX = 0, tp; char *N = NULL; int B[4] = { -1, -1, -1, -1 }; while (*lp && *lp != '\n' && *lp != '\r') { switch (*lp) { case 'C': C = strtol(&lp[1], NULL, 10); break; case 'W': if (lp[1] == 'X') WX = strtol(&lp[2], NULL, 10); break; case 'N': for (N = &lp[1]; *N == ' ' || *N == '\t'; N++); for (lp = N; *lp && *lp != '\n' && *lp != '\r' && *lp != ' ' && *lp != '\t' && *lp != ';'; lp++); c = *lp; *lp++ = 0; a->nspace += lp - N; if (c == ';') continue; break; case 'B': xp = &lp[1]; B[0] = strtol(xp, &xp, 10); B[1] = strtol(xp, &xp, 10); B[2] = strtol(xp, &xp, 10); B[3] = strtol(xp, &xp, 10); break; case 'L': if (C == 'f') { xp = &lp[1]; while (*xp == ' ' || *xp == '\t') xp++; switch (*xp) { case 'i': a->Font.ligfont |= LFI; break; case 'l': a->Font.ligfont |= LFL; break; } } break; default: lp++; } while (*lp && *lp != '\n' && *lp != '\r' && *lp != ';') lp++; if (*lp == ';') { while (*lp && *lp != '\n' && *lp != '\r' && (*lp == ' ' || *lp == '\t' || *lp == ';')) lp++; } } if (N == NULL) return; tp = afmmapname(N, s); afmaddchar(a, C, tp, 0, WX, B, N, s, 0); } void afmalloc(struct afmtab *a, int n) { int i; #if defined (DPOST) || defined (DUMP) a->fichars = n+NCHARLIB+1 + 128 - 32 + nchtab; #else /* TROFF */ extern int psmaxcode; a->fichars = n+NCHARLIB+1 + 128 - 32 + nchtab + psmaxcode+1; #endif /* TROFF */ a->fitab = calloc(a->fichars, sizeof *a->fitab); a->fontab = malloc((n+NCHARLIB+1)*sizeof *a->fontab); a->fontab[0] = dev.res * dev.unitwidth / 72 / 3; a->bbtab = calloc(n+NCHARLIB+1, sizeof *a->bbtab); a->kerntab = calloc(n+NCHARLIB+1, sizeof *a->kerntab); a->codetab = malloc((n+NCHARLIB+1)*sizeof *a->codetab); a->codetab[0] = 0; for (i = 1; i < n+NCHARLIB+1; i++) a->codetab[i] = NOCODE; a->nametab = malloc((n+NCHARLIB+1)*sizeof *a->nametab); a->nametab[0] = 0; a->nchars = 1; addcharlib(a, (a->base[0]=='S' && a->base[1]==0) || a->spec&SPEC_S); a->nameprime = nextprime(n+NCHARLIB+1); a->namecache = calloc(a->nameprime, sizeof *a->namecache); for (i = 0; i < a->nameprime; i++) { a->namecache[i].fival[0] = NOCODE; a->namecache[i].fival[1] = NOCODE; } } int afmget(struct afmtab *a, char *contents, size_t size) { enum { NONE, FONTMETRICS, CHARMETRICS, KERNDATA, KERNPAIRS } state = NONE; char *cp, *th, *tp; int n = 0; enum spec s; - size_t l; if ((cp = strrchr(a->file, '/')) == NULL) cp = a->file; else cp++; a->base = strdup(cp); if ((cp = strrchr(a->base, '.')) != NULL) *cp = '\0'; if (dev.allpunct) a->spec |= SPEC_PUNCT; if (a->base[0]=='S' && a->base[1]==0) a->spec |= SPEC_S; if (a->base[0]=='S' && a->base[1]=='1' && a->base[2]==0) a->spec |= SPEC_S1; s = a->spec; a->xheight = 500; a->capheight = 700; unitsPerEm = 1000; if (memcmp(contents, "OTTO", 4) == 0 || memcmp(contents, "\0\1\0\0", 4) == 0 || memcmp(contents, "true", 4) == 0) return otfget(a, contents, size); a->lineno = 1; for (cp = contents; cp < &contents[size]; a->lineno++, cp++) { while (*cp == ' ' || *cp == '\t' || *cp == '\r') cp++; if (*cp == '\n') continue; if (thisword(cp, "Comment")) /*EMPTY*/; else if (state == NONE && thisword(cp, "StartFontMetrics")) state = FONTMETRICS; else if (state == FONTMETRICS && thisword(cp, "EndFontMetrics")) state = NONE; else if (state == FONTMETRICS && (th = thisword(cp, "FontName")) != NULL) { for (tp = th; *tp && *tp != ' ' && *tp != '\t' && *tp != '\n' && *tp != '\r'; tp++); a->fontname = malloc(tp - th + 1); memcpy(a->fontname, th, tp - th); a->fontname[tp - th] = 0; } else if (state == FONTMETRICS && (th = thisword(cp, "IsFixedPitch")) != NULL) { a->isFixedPitch = strncmp(th, "true", 4) == 0; } else if (state == FONTMETRICS && (th = thisword(cp, "XHeight")) != NULL) { a->xheight = strtol(th, NULL, 10); } else if (state == FONTMETRICS && (th = thisword(cp, "CapHeight")) != NULL) { a->capheight = strtol(th, NULL, 10); } else if (state == FONTMETRICS && (th = thisword(cp, "Ascender")) != NULL) { a->ascender = strtol(th, NULL, 10); } else if (state == FONTMETRICS && (th = thisword(cp, "Descender")) != NULL) { a->descender = strtol(th, NULL, 10); } else if (state == FONTMETRICS && (th = thisword(cp, "StartCharMetrics")) != 0) { n = strtol(th, NULL, 10); state = CHARMETRICS; afmalloc(a, n); } else if (state == CHARMETRICS && thisword(cp, "EndCharMetrics")) { state = FONTMETRICS; afmremap(a); } else if (state == CHARMETRICS && n-- > 0) { addmetrics(a, cp, s); #ifndef DPOST } else if (state == FONTMETRICS && thisword(cp, "StartKernData") != 0) { state = KERNDATA; } else if (state == KERNDATA && (th = thisword(cp, "StartKernPairs")) != 0) { n = strtol(th, NULL, 10); state = KERNPAIRS; } else if (state == KERNPAIRS && thisword(cp, "EndKernPairs")) { state = KERNDATA; } else if (state == KERNPAIRS && n-- > 0) { addkernpair(a, cp); } else if (state == KERNDATA && thisword(cp, "EndKernData")) { state = FONTMETRICS; #endif /* !DPOST */ } while (cp < &contents[size] && *cp != '\n') cp++; } if (a->fontname == NULL) { errprint("Missing \"FontName\" in %s", a->path); return -1; } a->Font.nwfont = a->nchars > 255 ? 255 : a->nchars; return 0; } /* * This is for legacy font support. It exists at this place because both * troff and dpost need it in combination with AFM support. */ void makefont(int nf, const char *devfontab, const char *devkerntab, const char *devcodetab, const char *devfitab, int nw) { int i; free(fontab[nf]); free(kerntab[nf]); free(codetab[nf]); free(fitab[nf]); fontab[nf] = calloc(nw, sizeof *fontab); kerntab[nf] = calloc(nw, sizeof *kerntab); codetab[nf] = calloc(nw, sizeof *codetab); fitab[nf] = calloc(NCHARS ? NCHARS : 128 - 32 + nchtab, sizeof *fitab); if (devfontab) for (i = 0; i < nw; i++) fontab[nf][i] = devfontab[i]&0377; if (devkerntab) for (i = 0; i < nw; i++) kerntab[nf][i] = devkerntab[i]&0377; if (devcodetab) for (i = 0; i < nw; i++) codetab[nf][i] = devcodetab[i]&0377; if (devfitab) for (i = 0; i < 128 - 32 + nchtab; i++) fitab[nf][i] = devfitab[i]&0377; fontbase[nf]->spacewidth = fontab[nf][0]; fontbase[nf]->cspacewidth = -1; } #ifndef DPOST /* * For short to medium-sized documents, the run time is dominated by * the time required to read kerning pairs for fonts with many pairs. * Kerning pairs are thus simply dumped in the order they occur at * this point. Later when a kerning pair is actually looked up, the * structures accessed are sorted (eliding duplicates), leading to * better performance with large documents. */ void afmaddkernpair(struct afmtab *a, int ch1, int ch2, int k) { struct kernpairs *kp; if (k == 0) return; if (a->kernpairs == NULL) a->kernpairs = calloc(a->fichars, sizeof *a->kernpairs); kp = &a->kernpairs[ch1]; while (kp->cnt == NKERNPAIRS) { if (kp->next == NULL) kp->next = calloc(1, sizeof *kp->next); kp = kp->next; } kp->ch2[kp->cnt] = ch2; kp->k[kp->cnt] = k; kp->cnt++; } static void addkernpair(struct afmtab *a, char *_line) { struct namecache *np1, *np2; char *lp = _line, c, *cp; int n, i, j; if (lp[0] == 'K' && lp[1] == 'P') { lp += 2; if (*lp == 'X') lp++; while ((*lp && *lp == ' ') || *lp == '\t') lp++; cp = lp; while (*lp && *lp != '\n' && *lp != '\r' && *lp != ' ' && *lp != '\t') lp++; if ((c = *lp) == 0) return; *lp = 0; np1 = afmnamelook(a, cp); *lp = c; while ((*lp && *lp == ' ') || *lp == '\t') lp++; cp = lp; while (*lp && *lp != '\n' && *lp != '\r' && *lp != ' ' && *lp != '\t') lp++; if ((c = *lp) == 0) return; *lp = 0; np2 = afmnamelook(a, cp); *lp = c; n = _unitconv(strtol(&lp[1], NULL, 10)); for (i = 0; i < 2; i++) if (np1->fival[i] != NOCODE) for (j = 0; j < 2; j++) if (np2->fival[j] != NOCODE) afmaddkernpair(a, np1->fival[i], np2->fival[j], n); } } static void sortkernpairs(struct kernpairs *kp) { int i, j, s, t; do { s = 0; for (i = 0; i < kp->cnt-1; i++) if (kp->ch2[i] > kp->ch2[i+1]) { t = kp->ch2[i]; kp->ch2[i] = kp->ch2[i+1]; kp->ch2[i+1] = t; t = kp->k[i]; kp->k[i] = kp->k[i+1]; kp->k[i+1] = t; s = 1; } } while (s); for (j = 0; j < kp->cnt-1; j++) if (kp->ch2[j] == kp->ch2[j+1]) { for (i = j+1; i < kp->cnt-1; i++) { kp->ch2[i] = kp->ch2[i+1]; kp->k[i] = kp->k[i+1]; } kp->cnt--; j--; } kp->sorted = 1; } int afmgetkern(struct afmtab *a, int ch1, int ch2) { struct kernpairs *kp; int l, m, r; if (a->kernpairs) { kp = &a->kernpairs[ch1]; do { if (kp->sorted == 0) sortkernpairs(kp); r = kp->cnt - 1; if (ch2 >= kp->ch2[0] && r >= 0 && ch2 <= kp->ch2[r]) { l = 0; do { m = (l+r) / 2; if (ch2 < kp->ch2[m]) r = m-1; else l = m+1; } while (ch2 != kp->ch2[m] && l <= r); if (kp->ch2[m] == ch2) return kp->k[m]; } } while ((kp = kp->next) != NULL); } return 0; } #endif /* !DPOST */ char * afmencodepath(const char *cp) { const char hex[] = "0123456789ABCDEF"; char *enc, *ep; ep = enc = malloc(3 * strlen(cp) + 1); while (*cp) { if (*cp&0200 || *cp <= 040 || *cp == 0177) { *ep++ = '%'; *ep++ = hex[(*cp&0360) >> 4]; *ep++ = hex[*cp++&017]; } else *ep++ = *cp++; } *ep = 0; return enc; } static int unhex(int c) { if (c >= 'A' && c <= 'F') return c - 'A'; if (c >= 'a' && c <= 'f') return c - 'a'; return c - '0'; } static int xdigit(int c) { return (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f') || (c >= '0' && c <= '9'); } char * afmdecodepath(const char *cp) { char *dec, *dp; dec = dp = malloc(strlen(cp) + 1); while (*cp) { if (cp[0] == '%' && xdigit(cp[1]&0377) && xdigit(cp[2]&0377)) { *dp++ = unhex(cp[1]) << 4 | unhex(cp[2]); cp += 3; } else *dp++ = *cp++; } *dp = 0; return dec; } #endif /* !DUMP */ Index: vendor/heirloom-doctools/dist/troff/troff.d/afm.h =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/afm.h (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/afm.h (revision 310550) @@ -1,149 +1,149 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)afm.h 1.35 (gritter) 10/5/06 */ #ifndef TROFF_AFM_H #define TROFF_AFM_H enum spec { SPEC_NONE = 00000, SPEC_MATH = 00001, SPEC_GREEK = 00002, SPEC_PUNCT = 00004, SPEC_LARGE = 00010, SPEC_S1 = 01000, SPEC_S = 02000 }; #define NOCODE ((unsigned short)-1) #define NKERNPAIRS 45 struct kernpairs { struct kernpairs *next; int sorted; int cnt; unsigned short ch2[NKERNPAIRS]; short k[NKERNPAIRS]; }; struct namecache { unsigned short afpos; unsigned short fival[2]; unsigned short gid; }; struct charpair { unsigned short ch1; unsigned short ch2; }; struct feature { char *name; struct charpair *pairs; int npairs; }; extern struct afmtab { struct Font Font; char *encpath; char *path; char *file; char *base; char *fontname; char *supply; int *fontab; short **bbtab; char *kerntab; unsigned short *codetab; unsigned short *fitab; char **nametab; int *unitab; int nunitab; void *unimap; int *encmap; struct namecache *namecache; int nameprime; struct kernpairs *kernpairs; struct charpair *gid2tr; int nspace; struct feature **features; int rq; int lineno; int nchars; int fichars; int capheight; int xheight; int isFixedPitch; int ascender; int descender; enum spec spec; enum { TYPE_AFM, TYPE_OTF, TYPE_TTF } type; } **afmtab; extern int nafm; extern unsigned short **fitab; extern int **fontab; extern char **kerntab; extern unsigned short **codetab; extern struct Font **fontbase; extern int NCHARS; extern unsigned short unitsPerEm; extern int afmget(struct afmtab *, char *, size_t); extern int otfget(struct afmtab *, char *, size_t); extern struct namecache *afmnamelook(struct afmtab *, const char *); extern int afmgetkern(struct afmtab *, int, int); extern void makefont(int, const char *, const char *, const char *, const char *, int); extern int unitconv(int); extern void afmalloc(struct afmtab *, int); extern void afmremap(struct afmtab *); extern int afmmapname(const char *, enum spec); extern void afmaddchar(struct afmtab *, int, int, int, int, int[], char *, enum spec, int); extern void afmaddkernpair(struct afmtab *, int, int, int); extern int nextprime(int n); extern unsigned pjw(const char *); extern char *afmencodepath(const char *); extern char *afmdecodepath(const char *); -#ifdef DPOST #include +int fprintenc(FILE *, const char *); +#ifdef DPOST extern int otfcff(const char *, char *, size_t, size_t *, size_t *); extern int otft42(char *, char *, char *, size_t, FILE *); -extern int fprintenc(FILE *, const char *); #endif extern struct dev dev; #define _unitconv(i) (unitsPerEm * 72 == dev.res ? (i) : unitconv(i)) #endif /* !TROFF_AFM_H */ Index: vendor/heirloom-doctools/dist/troff/troff.d/dhtml/dhtml.l =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/dhtml/dhtml.l (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/dhtml/dhtml.l (revision 310550) @@ -1,87 +1,89 @@ %{ /* * Copyright (c) 2015, Carsten Kunze * 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #include #include "dhtml.h" #include "tr_out.h" #include "char.h" #include "main.h" static int i0; %} +%option nounput +%option noinput %x X FONT_NUM FONT_NAM T X_X LINK ULINK ANCHOR WS [ ] NWS [^ \n] %% f{NWS}*{WS}+ { BEGIN FONT_NUM; } T{NWS}*{WS}+ { BEGIN T; } X{NWS}*{WS}+ { BEGIN X_X; } [^fTX].* { BEGIN 0; } [0-9]+{WS}+ { i0 = atoi(yytext); BEGIN FONT_NAM; } {NWS}+ { out_x_f(i0, yytext); BEGIN 0; } {NWS}+ { out_x_T(yytext); BEGIN 0; } Link{WS}+ { BEGIN LINK; } ULink{WS}+ { BEGIN ULINK; } U?Link{WS}*\n { out_end_link(); BEGIN 0; } Anchor{WS}+ { BEGIN ANCHOR; } LC_TYPE.* { BEGIN 0; } [^AL].* { BEGIN 0; } .+ { out_begin_link(yytext); BEGIN 0; } .+ { out_begin_ulink(yytext); BEGIN 0; } .+ { out_anchor(yytext); BEGIN 0; } c. { char_c(yytext[1]); } [0-9][0-9]. { char_c(yytext[2]); } C{NWS}+ { char_C(yytext+1); } w { out_w(); } H-?[0-9]+ { ; } h-?[0-9]+ { out_h(atoi(yytext+1)); } V-?[0-9]+ { out_V(atoi(yytext+1)); } v-?[0-9]+ { fprintf(stderr, "Ignore v %s\n", yytext+1); } f[0-9]+ { out_f(atoi(yytext+1)); } N[0-9]+ { char_N(atoi(yytext+1)); } n[0-9]+{WS}+[0-9]+ { out_n(atoi(yytext+1)); } s[0-9]+ { out_s(atoi(yytext+1)); } p[0-9]+ { ; } x{WS}+ { BEGIN X; } D.+ { ; } \n { ; } . { fprintf(stderr, "Ignore '%c'\n", *yytext); } %% int yywrap(void) { return 1; } void run_lex(void) { yylex(); } Index: vendor/heirloom-doctools/dist/troff/troff.d/dhtml/lib.c =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/dhtml/lib.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/dhtml/lib.c (revision 310550) @@ -1,148 +1,149 @@ /* * Copyright (c) 2015, Carsten Kunze * 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #include #include #include #include #include #include #include "main.h" #include "bst.h" +#include "lib.h" void * /* pointer to \0 terminated file contents */ file2ram(char *p, /* path to file */ ssize_t *l) { /* pointer to buffer size variable */ int f; struct stat s; char *b = NULL; if ((f = open(p, O_RDONLY)) == -1) { fprintf(stderr, "%s: open(%s) failed: ", progname, p); perror(NULL); goto r; } if (fstat(f, &s) == -1) { fprintf(stderr, "%s: fstat(%s) failed: ", progname, p); perror(NULL); goto c; } if (!(b = malloc(s.st_size + 1))) goto c; if ((*l = read(f, b, s.st_size)) == -1) { free(b); fprintf(stderr, "%s: read(%s) failed: ", progname, p); perror(NULL); goto c; } b[*l] = 0; c: close(f); r: return b; } ssize_t lineskip(char **b, ssize_t n) { char *p = *b; int i = 0; int c; while (1) { for (; n && (!(c = *p) || c == ' ' || c == '\t' || c == '\n'); n--, p++) { if (c == '\n') i = 0; else i++; } if (!n || !i || c != '#') goto r; for (; n && (c = *p) && c != '\n'; n--, p++); } r: *b = p; return n; } char * /* pointer to word */ get_word(char **b, /* begin of buffer, then end of buffer */ ssize_t *l, /* buffer length */ size_t *s, /* word length (if not NULL) */ int *t) { /* type (if not NULL) */ char *w = NULL; char *p = *b; ssize_t n = *l; int c; size_t i = 0; int f = 0; for (; n && (!(c = *p) || c == ' ' || c == '\t' || c == '\n'); n--, p++); if (!n) goto r; w = p; for (; n && (c = *p) && c != ' ' && c != '\t' && c != '\n'; i++, n--, p++) { if (c >= '0' && c <= '9') f |= 1; else f |= 2; } if (!n) goto r; *p = 0; r: *b = p; *l = n; if (s) *s = i; if (t) *t = f; return w; } char * /* pointer to line */ get_line(char **b, /* begin of buffer, then end of buffer */ ssize_t *l, /* buffer length */ size_t *s) { /* line length (if not NULL) */ char *w = NULL; char *p = *b; ssize_t n = *l; int c; size_t i = 0; for (; n && (!(c = *p) || c == ' ' || c == '\t'); n--, p++); if (!n) goto r; w = p; for (; n && (c = *p) && c != '\n'; i++, n--, p++); if (!n) goto r; *p = 0; r: *b = p; *l = n; if (s) *s = i; return w; } int bst_scmp(union bst_val a, union bst_val b) { return strcmp(a.p, b.p); } int bst_icmp(union bst_val a, union bst_val b) { return a.i < b.i ? -1 : a.i > b.i ? 1 : 0 ; } Index: vendor/heirloom-doctools/dist/troff/troff.d/dpost.d/dpost.1 =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/dpost.d/dpost.1 (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/dpost.d/dpost.1 (nonexistent) @@ -1,258 +0,0 @@ -.\" -.\" CDDL HEADER START -.\" -.\" The contents of this file are subject to the terms of the -.\" Common Development and Distribution License (the "License"). -.\" You may not use this file except in compliance with the License. -.\" -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -.\" or http://www.opensolaris.org/os/licensing. -.\" See the License for the specific language governing permissions -.\" and limitations under the License. -.\" -.\" When distributing Covered Code, include this CDDL HEADER in each -.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE. -.\" If applicable, add the following below this CDDL HEADER, with the -.\" fields enclosed by brackets "[]" replaced with your own identifying -.\" information: Portions Copyright [yyyy] [name of copyright owner] -.\" -.\" CDDL HEADER END -.\" Copyright 1989 AT&T Copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved. -.\" -.\" Portions Copyright (c) 2007 Gunnar Ritter, Freiburg i. Br., Germany -.\" -.\" Sccsid @(#)dpost.1 1.11 (gritter) 2/7/07 -.\" -.\" from OpenSolaris dpost 1 "9 Sep 1996" "SunOS 5.11" "User Commands" -.TH DPOST 1 "2/7/07" "Heirloom Documentation Tools" "User Commands" -.SH NAME -dpost \- troff postprocessor for PostScript printers -.SH SYNOPSIS -.HP -.ad l -.nh -\fBdpost\fR -[\fB\-c\fR\ \fInum\fR] -[\fB\-e\fR\ \fInum\fR] -[\fB\-m\fR\ \fInum\fR] -[\fB\-n\fR\ \fInum\fR] -[\fB\-o\fR\ \fIlist\fR] -[\fB\-p\fR\ \fImode\fR] -[\fB\-w\fR\ \fInum\fR] -[\fB\-x\fR\ \fInum\fR] -[\fB\-y\fR\ \fInum\fR] -[\fB\-F\fR\ \fIdir\fR] -[\fB\-H\fR\ \fIdir\fR] -[\fB\-L\fR\ \fIfile\fR] -[\fB\-M\fR\ \fImarks\fR] -[\fB\-O\fR] -[\fB\-T\fR \fIname\fR] -[\fIfile\fR] .\|.\|. -.br -.ad b -.hy 1 -.SH DESCRIPTION -\fIdpost\fR translates \fIfiles\fR created by -\fItroff\fR(1) -into PostScript and writes the results on the standard output. -If no -\fIfiles\fR are specified, or if \- is one of the input \fIfiles\fR, -the standard input -is read. -The following options are accepted: -.TP 15 -\fB\-c\fR\fI num\fR -Print \fInum\fR copies of each page. -By default -only one copy is printed. -.TP -\fB\-e\fR\fI num\fR -Sets the text encoding level to \fInum\fR. -The recognized choices are -digits between 0 and 5. -\fB0\fR uses the PostScript \fBashow\fR operator, and produces -output essentially identical to previous versions of \fIdpost\fR. -\fB1\fR also uses \fBashow\fR but integrates motion commands -with text commands. -\fB2\fR uses the PostScript \fBawidthshow\fR operator, -computing space widths in PostScript. -\fB3\fR also uses \fBawidthshow\fR -but computes space widths in \fIdpost\fR. -\fB4\fR uses \fBashow\fR, storing position as differences. -\fB5\fR emits the same commands as 4 -but in a binary PostScript Level 2 representation. -The default is 3 with the \fBps\fR device. -.TP -\fB\-m\fR\fI num\fR -Magnify each logical page by the factor \fInum\fR. -Pages are scaled -uniformly about the origin, -which is located near the upper left corner of each page. -The default -magnification is \fB1.0\fR. -.TP -\fB\-n\fR\fI num\fR -Print \fInum\fR logical pages on each piece of paper, where \fInum\fR -can be any positive integer. -By default, \fInum\fR is set to \fB1\fR. -.TP -\fB\-o\fR\fI list\fR -Print those pages for which numbers are given in the comma-separated -\fIlist\fR. -The list -contains single numbers \fIN\fR and ranges \fIN1\fR\fB\(mi\fR\fIN2.\fR -A missing \fIN1\fR means the lowest -numbered page, a missing \fIN2\fR means the highest. -The page range is -an expression of logical pages rather than physical sheets of paper. -For example, if you are printing two logical -pages to a sheet, and you specified a range of \fB4\fR, then two sheets -of paper would print, containing four page layouts. -If you specified a -page range of \fB3-4\fR, when requesting -two logical pages to a sheet; then \fIonly\fR page 3 and page 4 layouts -would print, and they would appear on one physical sheet of paper. -.TP -\fB\-p\fR\fI mode\fR -Print \fIfiles\fR in either \fBportrait\fR or \fBlandscape\fR \fImode\fR. -Only -the first character of \fImode\fR is significant. -The default -\fImode\fR is portrait. -.TP -\fB\-w\fR\fI num\fR -Set the line width used to implement \fItroff\fR graphics commands to -\fInum\fR -points, where a point is approximately 1/72 of an inch. -By default, -\fInum\fR is set to \fB0.3\fR points. -.TP -\fB\-x\fR\fI num\fR -Translate the origin \fInum\fR inches along the positive x axis. -The -default coordinate system -has the origin fixed near the upper left corner of the page, with -positive x to the right and positive y down the page. -Positive -\fInum\fR moves everything right. -The default offset -is \fB0\fR inches. -.TP -\fB\-y\fR\fI num\fR -Translate the origin \fInum\fR inches along the positive y axis. -Positive \fInum\fR moves text up the page. -The default offset is -\fB0\fR. -.TP -\fB\-F\fR\fI dir\fR -Use \fIdir\fR as the font directory. -The default \fIdir\fR is -\fB/usr/ucblib/doctools/font\fR, and \fIdpost\fR reads binary font files from -directory \fB/usr/ucblib/doctools/font/devps\fR. -.TP -\fB\-H\fR\fI dir\fR -Use \fIdir\fR as the host resident font directory. -Files in this -directory should be complete -PostScript font descriptions, and must be assigned a name that -corresponds to the appropriate two-character \fItroff\fR font name. -Each font file is copied to the output file only when needed -and at most once during each job. -There is no default directory. -.TP -\fB\-L\fR\fI file\fR -Use \fIfile\fR as the PostScript prologue which, by default, is -\fB/usr/lib/lp/postscript/dpost.ps\fR. -.TP -\fB\-M \fImarks\fR -Print marks (in combination with the \fB\%trimat\fR \fItroff\fR request). -Valid types of \fImarks\fR are: -\fB\%cutmarks\fR, -\fB\%registrationmarks\fR, -\fB\%startargets\fR, -\fB\%colorbars\fR, -and -\fB\%all\fR. -Mark names can be abbreviated and combined by colons, -e.g. \fB\-Mcut:reg\fR will print cut marks and registration marks. -.TP -\fB\-O\fR -Disables PostScript picture inclusion. -A recommended option when -\fIdpost\fR is run by a spooler in a networked environment. -.TP -\fB\-T\fR\fI name\fR -Use font files for device \fIname\fR as the best description of -available PostScript fonts. -By default, \fIname\fR is set to \fBps\fR and \fIdpost\fR reads -files from \fB/usr/ucblib/doctools/font/devps\fR. -.PP -The \fIfiles\fR should be prepared by \fItroff\fR. -The default font -files in \fB/usr/ucblib/doctools/font/devps\fR produce the best output. -They assume a resolution of 72000 dpi, and can be used to format files by -adding the \fB\-Tps\fR option to the \fItroff\fR call. -.PP -\fIdpost\fR makes no assumptions about resolutions. -The first -\fBx\ res\fR command sets the resolution used to translate the input -\fIfiles\fR, the \fBDESC\fR file, usually -\fB/usr/ucblib/doctools/font/devps/DESC\fR, -defines the resolution used in -the binary font files, and the PostScript prologue is responsible for -setting up an appropriate -user coordinate system. -.SH EXAMPLES -.HP -\fBpic \fR\fBfile\fR\fB | tbl | eqn | troff \fR\fB\-mm\fR\fB -\fR\fB\-Tps\fR\fB | dpost\fR -.SH FILES -/usr/ucblib/doctools/font/devps/* -.br -/usr/ucblib/doctools/font/devpost/charlib/* -.br -/usr/ucblib/doctools/font/devpost/postscript/dpost.ps -.br -/usr/ucblib/doctools/font/devpost/postscript/color.ps -.br -/usr/ucblib/doctools/font/devpost/postscript/cutmarks.ps -.br -/usr/ucblib/doctools/font/devpost/postscript/draw.ps -.br -/usr/ucblib/doctools/font/devpost/postscript/forms.ps -.br -/usr/ucblib/doctools/font/devpost/postscript/ps.requests -.br -/usr/ucblib/doctools/tmac/pictures -.br -/usr/ucblib/doctools/tmac/color -.SH SEE ALSO -troff(1) -.SH DIAGNOSTICS -The following exit values are returned: -.TP 10 -\fB\fB0\fR\fR -Successful completion. -.TP -\fBnon-zero\fR -An error occurred. -.SH NOTES -Although \fIdpost\fR can handle files formatted for any device, -emulation is expensive and can easily double the print time and the -size of the output file. -No attempt has been made to -implement the character sets or fonts available on all devices -supported by \fItroff\fR. -Missing characters will be replaced by white -space, and unrecognized fonts will usually default to one -of the Times fonts (that is, \fBR\fR, \fBI\fR, \fBB\fR, or \fBBI\fR). -.PP -An \fBx res\fR command must precede the first \fBx init\fR command, -and all the input \fIfiles\fR should have been prepared for the same -output device. -.PP -Use of the \fB\-T\fR option is not encouraged. -Its only purpose is to -enable the use of other PostScript font and device description files, -that perhaps use different resolutions, character -sets, or fonts. Property changes on: vendor/heirloom-doctools/dist/troff/troff.d/dpost.d/dpost.1 ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/troff.d/dpost.d/Makefile.mk =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/dpost.d/Makefile.mk (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/dpost.d/Makefile.mk (revision 310550) @@ -1,42 +1,48 @@ BST = ../../../stuff/bst OBJ = dpost.o draw.o color.o pictures.o ps_include.o afm.o \ makedev.o glob.o misc.o request.o version.o \ asciitype.o otf.o ../fontmap.o $(BST)/bst.o FLAGS = -I. -I.. -DFNTDIR='"$(FNTDIR)"' -DPSTDIR='"$(PSTDIR)"' $(EUC) \ $(DEFINES) -I../../../include -I.. -I$(BST) .c.o: $(CC) $(_CFLAGS) $(FLAGS) -c $< -all: dpost +all: dpost dpost.1 dpost: $(OBJ) $(CC) $(_CFLAGS) $(_LDFLAGS) $(OBJ) $(LIBS) -o dpost install: $(INSTALL) -c dpost $(ROOT)$(BINDIR)/dpost $(STRIP) $(ROOT)$(BINDIR)/dpost mkdir -p $(ROOT)$(MANDIR)/man1 $(INSTALL) -c -m 644 dpost.1 $(ROOT)$(MANDIR)/man1/dpost.1 clean: - rm -f $(OBJ) dpost core log *~ + rm -f $(OBJ) dpost core log *~ dpost.1 mrproper: clean + +dpost.1: dpost.1.in + sed -e 's"/usr/ucblib/doctools/font/devpost/postscript/"$(ROOT)$(PSTDIR)/"' \ + -e 's"/usr/ucblib/doctools/font"$(ROOT)$(FNTDIR)"' \ + -e 's"/usr/lib/lp/postscript/"$(ROOT)$(PSTDIR)/"' \ + -e 's"/usr/ucblib/doctools/tmac/"$(ROOT)$(MACDIR)/"' dpost.1.in > $@ color.o: color.c gen.h ext.h dpost.o: dpost.c comments.h gen.h path.h ext.h ../dev.h dpost.h ../afm.h \ asciitype.h draw.o: draw.c gen.h ext.h glob.o: glob.c gen.h misc.o: misc.c gen.h ext.h path.h asciitype.h pictures.o: pictures.c comments.h gen.h path.h ps_include.o: ps_include.c ext.h gen.h asciitype.h path.h request.o: request.c gen.h request.h path.h afm.o: afm.c ../dev.h ../afm.h ../afm.c otf.o: otf.c ../dev.h ../afm.h ../otf.c makedev.o: makedev.c ../dev.h ../makedev.c asciitype.o: asciitype.h version.o: version.c ../../version.c Index: vendor/heirloom-doctools/dist/troff/troff.d/dpost.d/dpost.1.in =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/dpost.d/dpost.1.in (nonexistent) +++ vendor/heirloom-doctools/dist/troff/troff.d/dpost.d/dpost.1.in (revision 310550) @@ -0,0 +1,258 @@ +.\" +.\" CDDL HEADER START +.\" +.\" The contents of this file are subject to the terms of the +.\" Common Development and Distribution License (the "License"). +.\" You may not use this file except in compliance with the License. +.\" +.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +.\" or http://www.opensolaris.org/os/licensing. +.\" See the License for the specific language governing permissions +.\" and limitations under the License. +.\" +.\" When distributing Covered Code, include this CDDL HEADER in each +.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE. +.\" If applicable, add the following below this CDDL HEADER, with the +.\" fields enclosed by brackets "[]" replaced with your own identifying +.\" information: Portions Copyright [yyyy] [name of copyright owner] +.\" +.\" CDDL HEADER END +.\" Copyright 1989 AT&T Copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved. +.\" +.\" Portions Copyright (c) 2007 Gunnar Ritter, Freiburg i. Br., Germany +.\" +.\" Sccsid @(#)dpost.1 1.11 (gritter) 2/7/07 +.\" +.\" from OpenSolaris dpost 1 "9 Sep 1996" "SunOS 5.11" "User Commands" +.TH DPOST 1 "2/7/07" "Heirloom Documentation Tools" "User Commands" +.SH NAME +dpost \- troff postprocessor for PostScript printers +.SH SYNOPSIS +.HP +.ad l +.nh +\fBdpost\fR +[\fB\-c\fR\ \fInum\fR] +[\fB\-e\fR\ \fInum\fR] +[\fB\-m\fR\ \fInum\fR] +[\fB\-n\fR\ \fInum\fR] +[\fB\-o\fR\ \fIlist\fR] +[\fB\-p\fR\ \fImode\fR] +[\fB\-w\fR\ \fInum\fR] +[\fB\-x\fR\ \fInum\fR] +[\fB\-y\fR\ \fInum\fR] +[\fB\-F\fR\ \fIdir\fR] +[\fB\-H\fR\ \fIdir\fR] +[\fB\-L\fR\ \fIfile\fR] +[\fB\-M\fR\ \fImarks\fR] +[\fB\-O\fR] +[\fB\-T\fR \fIname\fR] +[\fIfile\fR] .\|.\|. +.br +.ad b +.hy 1 +.SH DESCRIPTION +\fIdpost\fR translates \fIfiles\fR created by +\fItroff\fR(1) +into PostScript and writes the results on the standard output. +If no +\fIfiles\fR are specified, or if \- is one of the input \fIfiles\fR, +the standard input +is read. +The following options are accepted: +.TP 15 +\fB\-c\fR\fI num\fR +Print \fInum\fR copies of each page. +By default +only one copy is printed. +.TP +\fB\-e\fR\fI num\fR +Sets the text encoding level to \fInum\fR. +The recognized choices are +digits between 0 and 5. +\fB0\fR uses the PostScript \fBashow\fR operator, and produces +output essentially identical to previous versions of \fIdpost\fR. +\fB1\fR also uses \fBashow\fR but integrates motion commands +with text commands. +\fB2\fR uses the PostScript \fBawidthshow\fR operator, +computing space widths in PostScript. +\fB3\fR also uses \fBawidthshow\fR +but computes space widths in \fIdpost\fR. +\fB4\fR uses \fBashow\fR, storing position as differences. +\fB5\fR emits the same commands as 4 +but in a binary PostScript Level 2 representation. +The default is 3 with the \fBps\fR device. +.TP +\fB\-m\fR\fI num\fR +Magnify each logical page by the factor \fInum\fR. +Pages are scaled +uniformly about the origin, +which is located near the upper left corner of each page. +The default +magnification is \fB1.0\fR. +.TP +\fB\-n\fR\fI num\fR +Print \fInum\fR logical pages on each piece of paper, where \fInum\fR +can be any positive integer. +By default, \fInum\fR is set to \fB1\fR. +.TP +\fB\-o\fR\fI list\fR +Print those pages for which numbers are given in the comma-separated +\fIlist\fR. +The list +contains single numbers \fIN\fR and ranges \fIN1\fR\fB\(mi\fR\fIN2.\fR +A missing \fIN1\fR means the lowest +numbered page, a missing \fIN2\fR means the highest. +The page range is +an expression of logical pages rather than physical sheets of paper. +For example, if you are printing two logical +pages to a sheet, and you specified a range of \fB4\fR, then two sheets +of paper would print, containing four page layouts. +If you specified a +page range of \fB3-4\fR, when requesting +two logical pages to a sheet; then \fIonly\fR page 3 and page 4 layouts +would print, and they would appear on one physical sheet of paper. +.TP +\fB\-p\fR\fI mode\fR +Print \fIfiles\fR in either \fBportrait\fR or \fBlandscape\fR \fImode\fR. +Only +the first character of \fImode\fR is significant. +The default +\fImode\fR is portrait. +.TP +\fB\-w\fR\fI num\fR +Set the line width used to implement \fItroff\fR graphics commands to +\fInum\fR +points, where a point is approximately 1/72 of an inch. +By default, +\fInum\fR is set to \fB0.3\fR points. +.TP +\fB\-x\fR\fI num\fR +Translate the origin \fInum\fR inches along the positive x axis. +The +default coordinate system +has the origin fixed near the upper left corner of the page, with +positive x to the right and positive y down the page. +Positive +\fInum\fR moves everything right. +The default offset +is \fB0\fR inches. +.TP +\fB\-y\fR\fI num\fR +Translate the origin \fInum\fR inches along the positive y axis. +Positive \fInum\fR moves text up the page. +The default offset is +\fB0\fR. +.TP +\fB\-F\fR\fI dir\fR +Use \fIdir\fR as the font directory. +The default \fIdir\fR is +\fB/usr/ucblib/doctools/font\fR, and \fIdpost\fR reads binary font files from +directory \fB/usr/ucblib/doctools/font/devps\fR. +.TP +\fB\-H\fR\fI dir\fR +Use \fIdir\fR as the host resident font directory. +Files in this +directory should be complete +PostScript font descriptions, and must be assigned a name that +corresponds to the appropriate two-character \fItroff\fR font name. +Each font file is copied to the output file only when needed +and at most once during each job. +There is no default directory. +.TP +\fB\-L\fR\fI file\fR +Use \fIfile\fR as the PostScript prologue which, by default, is +\fB/usr/lib/lp/postscript/dpost.ps\fR. +.TP +\fB\-M \fImarks\fR +Print marks (in combination with the \fB\%trimat\fR \fItroff\fR request). +Valid types of \fImarks\fR are: +\fB\%cutmarks\fR, +\fB\%registrationmarks\fR, +\fB\%startargets\fR, +\fB\%colorbars\fR, +and +\fB\%all\fR. +Mark names can be abbreviated and combined by colons, +e.g. \fB\-Mcut:reg\fR will print cut marks and registration marks. +.TP +\fB\-O\fR +Disables PostScript picture inclusion. +A recommended option when +\fIdpost\fR is run by a spooler in a networked environment. +.TP +\fB\-T\fR\fI name\fR +Use font files for device \fIname\fR as the best description of +available PostScript fonts. +By default, \fIname\fR is set to \fBps\fR and \fIdpost\fR reads +files from \fB/usr/ucblib/doctools/font/devps\fR. +.PP +The \fIfiles\fR should be prepared by \fItroff\fR. +The default font +files in \fB/usr/ucblib/doctools/font/devps\fR produce the best output. +They assume a resolution of 72000 dpi, and can be used to format files by +adding the \fB\-Tps\fR option to the \fItroff\fR call. +.PP +\fIdpost\fR makes no assumptions about resolutions. +The first +\fBx\ res\fR command sets the resolution used to translate the input +\fIfiles\fR, the \fBDESC\fR file, usually +\fB/usr/ucblib/doctools/font/devps/DESC\fR, +defines the resolution used in +the binary font files, and the PostScript prologue is responsible for +setting up an appropriate +user coordinate system. +.SH EXAMPLES +.HP +\fBpic \fR\fBfile\fR\fB | tbl | eqn | troff \fR\fB\-mm\fR\fB +\fR\fB\-Tps\fR\fB | dpost\fR +.SH FILES +/usr/ucblib/doctools/font/devps/* +.br +/usr/ucblib/doctools/font/devpost/charlib/* +.br +/usr/ucblib/doctools/font/devpost/postscript/dpost.ps +.br +/usr/ucblib/doctools/font/devpost/postscript/color.ps +.br +/usr/ucblib/doctools/font/devpost/postscript/cutmarks.ps +.br +/usr/ucblib/doctools/font/devpost/postscript/draw.ps +.br +/usr/ucblib/doctools/font/devpost/postscript/forms.ps +.br +/usr/ucblib/doctools/font/devpost/postscript/ps.requests +.br +/usr/ucblib/doctools/tmac/pictures +.br +/usr/ucblib/doctools/tmac/color +.SH SEE ALSO +troff(1) +.SH DIAGNOSTICS +The following exit values are returned: +.TP 10 +\fB\fB0\fR\fR +Successful completion. +.TP +\fBnon-zero\fR +An error occurred. +.SH NOTES +Although \fIdpost\fR can handle files formatted for any device, +emulation is expensive and can easily double the print time and the +size of the output file. +No attempt has been made to +implement the character sets or fonts available on all devices +supported by \fItroff\fR. +Missing characters will be replaced by white +space, and unrecognized fonts will usually default to one +of the Times fonts (that is, \fBR\fR, \fBI\fR, \fBB\fR, or \fBBI\fR). +.PP +An \fBx res\fR command must precede the first \fBx init\fR command, +and all the input \fIfiles\fR should have been prepared for the same +output device. +.PP +Use of the \fB\-T\fR option is not encouraged. +Its only purpose is to +enable the use of other PostScript font and device description files, +that perhaps use different resolutions, character +sets, or fonts. Property changes on: vendor/heirloom-doctools/dist/troff/troff.d/dpost.d/dpost.1.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/troff.d/dpost.d/dpost.c =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/dpost.d/dpost.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/dpost.d/dpost.c (revision 310550) @@ -1,4814 +1,4814 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 1994 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* from OpenSolaris "dpost.c 1.11 05/06/08 SMI" SVr4.0 1.2 */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)dpost.c 1.176 (gritter) 8/19/08 */ /* * * dpost - troff post-processor for PostScript printers. * * A program that translates output generated by the device independent troff * into PostScript. Much was borrowed from dimpress and dps (formally dlzw), * and even though the code has been changed, credit has to be given to Richard * Flood for his early work on the PostScript driver. * * Among the most interesting new features are color support (see devcntrl() and * file color.c) and code to handle complex paths pieced together using any of the * standard drawing commands (see devcntrl() and file draw.c). Reverse video mode * has also been included as a special case of the color support. Two encoding * schemes based on widthshow are also new additions. The safe one is obtained when * you set encoding to 2 (eg. using the -e2 option). The slightly faster method * is obtained by setting encoding to 3 (eg. using the -e3 option), although it's * not recommended. Rounding errors in character widths can accumulate and become * quite noticeable by the time you get to the right margin. More often than not * you end up getting a ragged right margin. * * The program handles files formatted for any device, although the best and * most efficient output is generated when the font and description files match * PostScript's resident fonts. Device emulation is relatively expensive, and * can produce output files that are more than twice the size of the input files. * In most cases output files will be smaller than input files, perhaps by up to * 40 percent, although the results you get depend on what you're doing and the * text encoding you're using. You'll get the worst results if you're emulating * another device, using special bitmap characters, like the logo, or doing lots * of vertical motion or drawing. * * PostScript fonts don't support all of troff's characters, so some have to * be built by special PostScript procedures. Those routines can be found in * *fontdir/devpost/charlib, and are only used when we try to print a character * that has been assigned a code less than 32. Definitions are only made the * first time each character is used. Subsequent requests to print the character * only generate a call to the PostScript procedure that's been copied to the * output file. For example you'll find a file called sq in directory * *fontdir/devpost/charlib. It defines a PostScript procedure called build_sq * that's called whenever we need to print a square. Special characters that * have been assigned a code of 2 are expected to come in two pieces. The * definition part and bitmap part (or whatever). The definition is only made * once, but the contents of the character's .map file are copied to the output * file each time, immediately after charlib() generates the call to the * PostScript procedure (build_?? ) that builds the character. That's typically * how logos built from bitmaps would be handled. * * Several different methods can be used to encode lines of text. What's done * depends on the value assigned to encoding. Print time should decrease as * encoding increases (up to MAXENCODING). Setting encoding to 0, which should * probably be the default, produces output essentially identical to the original * version of dpost. It's the slowest but most stable method of encoding lines of * text, and won't be bothered by rounding errors in the font width tables that * could become noticeable by the time you get to the end of a line. Other schemes * seem to work, but aren't well tested and are not guaranteed for all possible * jobs. encoding can be changed on the command line using the -e option. Part of * the support for different encoding schemes was to move control of all text * related output to separate routines. It makes dpost work harder, but changing * things is easy. For example adding stuff to support widthshow took less than * an hour. * * I've also added code that handles the DOCUMENTFONTS comment, although it's * only produced for those fonts in directory /usr/lib/font/devpost that have an * associated .name file. The first string in a .name file should be the (long) * PostScript name (eg. Times-Roman in R.name). For now everything else in the * .name file is ignored, although that may also change. You'll find .name files * for all the supported fonts in the devpost source directory, although they may * not be installed in /usr/lib/font/devpost. * * The PostScript prologue is copied from *prologue before any of the input files * are translated. The program expects the following procedures are avaliable: * * setup * * mark ... setup - * * Handles special initialization stuff that depends on how the program * was called. Expects to find a mark followed by key/value pairs on the * stack. The def operator is applied to each pair up to the mark, then * the default state is set up. An 'x res' command must preceed the * 'x init' command! * * pagesetup * * page pagesetup - * * Called at the start of each page, immediately after the page level * save, to do special initialization on a per page basis. Right now the * only argument is the current page number, and actually nothing of any * importance is currently done. * * setdecoding * * num setdecoding - * * Selects the text decoding procedure (ie. what's assigned to PostScript * procedure t) from the decodingdefs array defined in the prologue. num * should be the value assigned to variable encoding (in dpost) and will * remain constant throughout a job, unless special features, like reverse * video printing, are requested. The text encoding scheme can be set on * the command line using the -e option. Print time and the size of the * output file will usually decrease as the value assigned to encoding * increases. * * f * * size font f - * * Selects the size and font to be used for character imaging. Font names * are defined, in *prologue, so they agree with the one or two character * names used by troff. * * m * * x y m - * * Moves to point (x, y). Normally only used when the vertical position * changes. Horizontal positioning between words (or letters) is handled * in procedure t (below). * * t * * mark text t mark * * Processes everything on the stack, up to the mark, as a single line * of text to be printed at a fixed vertical position. What's put out as * text depends on the encoding scheme. Setting encoding to 0 produces * output essentially identical to the original version of dpost. In that * case everything on the stack, up to a mark, is interpreted (from top * down) as an absolute horizontal position and a string to be printed at * that point. For example the stack might look like, * * mark(this)1000(is)1100(an)1200(example)1300 t * * Procedure t would go through the stack, up to the mark, adjusting the * horizontal position before printing each string. In other encoding * schemes, like the one based on widthshow, strings containing several * space separated words would appear on the stack, and each one would be * preceeded by a number that's expected to be added to the width of a * space. For example we might have, * * mark(an example)30(this is)40 2 1000 2000 t * * where (1000, 2000) is where the first string starts and 2 is the repeat * count (ie. number of string and space pairs on the stack). * * w * * string x y w - * * Prints a single word starting at position (x, y). Only used in the more * complicated encoding schemes (eg. the ones based on widthshow). * * done * * Makes sure the last page is printed. Only needed when we're printing * more than one page on each sheet of paper. * * The PostScript procedures that support troff's drawing commands have been moved * out of *prologue and put in a separate file (ie. DRAW as defined in path.h). * The procedures are used by the routines in file draw.c, and are copied to the * prologue. * * Many default values, like the magnification and orientation, are defined in * the prologue, which is where they belong. If they're changed (by options), an * appropriate definition is made after the prologue is added to the output file. * The -P option passes arbitrary PostScript through to the output file. Among * other things it can be used to set (or change) values that can't be accessed by * other options. * * * output language from troff: * all numbers are character strings * * sn size in points * fn font as number from 1-n * cx ascii character x * Cxyz funny char xyz. terminated by white space * Hn go to absolute horizontal position n * Vn go to absolute vertical position n (down is positive) * hn go n units horizontally (relative) * vn ditto vertically * nnc move right nn, then print c (exactly 2 digits!) * (this wart is an optimization that shrinks output file size * about 35% and run-time about 15% while preserving ascii-ness) * Dt ...\n draw operation 't': * Dl x y line from here by x,y * Dc d circle of diameter d with left side here * De x y ellipse of axes x,y with left side here * Da x1 y1 x2 y2 arc counter-clockwise from current point (x, y) to * (x + x1 + x2, y + y1 + y2) * D~ x y x y ... wiggly line by x,y then x,y ... * nb a end of line (information only -- no action needed) * b = space before line, a = after * p new page begins -- set v to 0 * #...\n comment * x ...\n device control functions: * x i init * x T s name of device is s * x r n h v resolution is n/inch * h = min horizontal motion, v = min vert * x p pause (can restart) * x s stop -- done forever * x t generate trailer * x f n s font position n contains font s * x H n set character height to n * x S n set slant to N * * Subcommands like "i" are often spelled out like "init". * * * * To get dpost output conforming to Adobe's structuring conventions (DSC), * all output is accumulated in temporary files first. When the document is * completed, files that contain global data are output first, followed by * regular commands, all surrounded by DSC comments. Speed problems, which * were the reason why this was not done by previous versions of dpost, are * no longer of concern in 2005 since several hundred pages of text are * processed now in less than a second. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "comments.h" /* PostScript file structuring comments */ #include "gen.h" /* general purpose definitions */ #include "path.h" /* for the prologue and a few other files */ #include "ext.h" /* external variable definitions */ #include "dev.h" /* typesetter and font descriptions */ #include "dpost.h" /* a few definitions just used here */ #include "asciitype.h" #include "afm.h" #include "fontmap.h" char *progname; static const char *prologue = DPOST; /* the basic PostScript prologue */ const char *colorfile = COLOR; /* things needed for color support */ const char *drawfile = DRAW; /* and drawing */ static const char *cutmarksfile = CUTMARKS; static const char *formfile = FORMFILE; /* stuff for multiple pages per sheet */ const char *baselinefile = BASELINE; static const char *fontdir = FONTDIR; /* binary device directories found here */ static char *hostfontdir = NULL; /* host resident font directory */ static int formsperpage = 1; /* page images on each piece of paper */ static int copies = 1; /* and this many copies of each sheet */ int picflag = ON; /* enable/disable picture inclusion */ /* * * encoding selects the encoding scheme used to output lines of text. Change it * to something other than 0 at your own risk. The other methods seem to work but * aren't well tested and are not guaranteed. Some special features, like reverse * video, may temporarily change the encoding scheme and reset it to realencoding * when done. * * Encoding 4 is new as of 9/8/05. It stores only the distances between words and * thus saves a bit of output size. It is automatically enabled at high resolutions. * */ int encoding = DFLTENCODING; int realencoding = DFLTENCODING; int maxencoding = MAXENCODING; static int eflag; int LanguageLevel; /* PostScript output language level */ static int Binary; /* PostScript output contains binary data */ /* * * seenfonts[] keeps track of the fonts we've used, based on internal numbers. It * helps manage host resident fonts and the DOCUMENTFONTS comment, but only works * if all fonts have internal numbers less than MAXINTERNAL. *docfonts counts the * number of font names we've recorded in *temp_file. If it's positive routine * done() adds *temp_file to the output file before quitting. * */ static char seenfonts[MAXINTERNAL+1]; static int docfonts = 0; static struct afmtab **afmfonts; static int afmcount = 0; /* * * devname[] is the device troff used when the job was formatted, while *realdev * is combined with *fontdir and used to locate the font and device tables that * that control the translation of the input files into PostScript. *realdev can * be changed using the -T option, but if you do you may end up getting garbage. * The character code field must agree with PostScript's font encoding and font * names must be properly mapped into PostScript font names in the prologue. * */ #define devname troff_devname static char devname[20] = ""; /* job is formatted for this printer */ static const char *realdev = DEVNAME; /* a good description of target printer */ /* * * Standard things that come from binary font and description files for *realdev. * Most are initialized in fontinit() or loadfont(). * */ struct dev dev; /* DESC starts this way */ struct Font **fontbase; /* FONT files begin this way */ static int *pstab; /* list of available sizes */ static int nsizes = 1; /* and the number of sizes in that list */ static int smnt; /* index of first special font */ int nchtab; /* number of special character names */ static int fsize; /* max size of a font files in bytes */ static int unitwidth; /* set to dev.unitwidth */ char *chname; /* special character strings */ short *chtab; /* used to locate character names */ unsigned short **fitab; /* locates char info on each font */ int **fontab; /* character width data for each font */ unsigned short **codetab; /* and codes to get characters printed */ char **kerntab; /* for makefont() */ /* * * Special characters missing from standard PostScript fonts are defined by files * in directory *fontdir/devpost/charlib. Files have the same names as the troff * special character names (for now at least) and each one defines a PostScript * procedure that begins with the prefix build_ and ends with the character's * name. * * For example, the routine used to build character \(12, would be build_12. * downloaded[] points to an array, allocated in fontinit(), that keeps track of * the characters that have already been defined - so we only do it once. * */ static char *downloaded; /* nonzero means it's been downloaded */ /* * * Variables that keep track of troff's requests. All are set from values in the * input files. nfonts is adjusted in t_fp() as new fonts are mounted. * */ int nfonts = 0; /* number of font positions */ int size = 1; /* current size - internal value */ #define FRACTSIZE -23 /* if size == FRACTSIZE then ... */ static float fractsize = 0; /* fractional point size */ static int font = 0; /* font position we're using now */ static int subfont = 0; /* extra encoding vector */ int hpos = 0; /* where troff wants to be - horizontally */ int vpos = 0; /* same but vertically */ static float lastw = 0; /* width of the last input character */ static int track = 0; /* tracking hint from troff */ static int lasttrack = 0; /* previous tracking hint */ static int tracked; /* records need to flush track */ static int lastc = 0; /* and its name (or index) */ int res; /* resolution assumed in input file */ static float widthfac = 1.0; /* for emulation = res/dev.res */ static float horscale = 1.0; /* horizontal font scaling */ static float lasthorscale = 1.0; /* last horizontal font scaling */ static int wordspace = 0; /* w command was last */ /* * * Remember some of the same things, but this time for the printer. lastend is only * used when we're doing reverse video, and is where the last character on the * current line was printed. * */ static int lastsize = -1; /* last internal size we used */ static float lastfractsize = -1; /* last fractional size */ static int lastfont = -1; /* last font we told printer about */ static int lastsubfont = -1; /* last extra encoding vector */ static float lastx = -1; /* printer's current position */ static int lasty = -1; static int savey = -1; int lastend; /* where last character on this line was */ /* * * fontname[] keeps track of the mounted fonts. Filled in (by t_fp()) from data * in the binary font files. * * When font metrics are directly read from AFM files, all characters that * are not ASCII are put into the remaining positions in PostScript encoding * vectors. Their position in these vectors in recorded in afm->encmap, and * characters from troff are translated if necessary. * */ static struct { struct afmtab *afm; /* AFM data, if any */ char *name; /* name of the font loaded here */ int number; /* its internal number */ float fontheight; /* points from x H ... */ int fontslant; /* angle from x S ... */ } fontname[NFONT+1]; /* * * All the special fonts will be mounted after the last legitimate font position. * It helps when we're translating files prepared for devices, like the 202, that * have a different set of special fonts. The set of special fonts needed when * *realdev's tables are used may not get mounted when we're emulating another * device. gotspecial keeps track of whether we've done it yet. seenpage is set * to TRUE after we've seen the first page command in the input file. It controls * what's done in t_font() and is needed because nfonts is no longer set when the * DESC file is read, but rather is updated from "x font" commands in the * input files. gotregular ensures that at least one regular font is mounted. * */ static int gotspecial = FALSE; static int gotregular = FALSE; static int seenpage = FALSE; /* * * The amount of horizontal positioning error we accept controls both the size * of the output file and the appearance of the printed text. It's probably most * important when we're emulating other devices, like the APS-5. The error can be * set using the -S option. It's converted from points to machine units in t_init() * after the resolution is known. rvslop is also set in t_init() and only used to * adjust the width of the box that's drawn around text when we're printing in * reverse video mode. * */ static float pointslop = SLOP; /* horizontal error in points */ static int Sflag; /* unless -S gives explicit slop */ static int slop; /* and machine units */ static int rvslop; /* to extend box in reverse video mode */ /* * * Characters are accumulated and saved in PostScript strings that are eventually * processed by making a single call to procedure t. textcount counts the number * of individual strings collected but not yet processed, and is primarily used to * make sure PostScript's stack doesn't get too big. When textcount is positive * we've started accumulating strings and need to generate a call to PostScript * procedure t to process the text before anything else (like a font change) is * done. * */ static int textcount = 0; /* strings accumulated so far */ static int stringstart = 0; /* where the next one starts */ static int laststrstart = INT_MIN; /* save for optimization */ static int spacecount = 0; /* spaces seen so far on current line */ static int charcount = 0; /* characters on current line */ /* * * Things that can be used by text line encoding schemes that need to read and * remember an entire line before doing any output. The strings that make up the * line can be saved in array strings[] and accessed by fields in line[]. *strptr * points to the next free slot in strings[]. * */ static char strings[STRINGSPACE]; static char *strptr; static Line line[MAXSTACK+3]; /* * * When we're emulating another device we may want to map font name requests that * come in as "x font pos name" commands into some other font name before anything * else is done (ie. calling loadfont()). Font names can collide or we may just * want to a mapping that depends on the device troff used to format the input * files. devfontmap points to a structure that's filled in by getdevmap() if the * mapping file /usr/lib/font/dev*realdev/fontmaps/devname exists. mapdevfont() * then uses that table to translate font name requests into something else before * loadfont() gets called. * * fontmap[] provides a simple minded translation that maps an unrecognized font * name (in loadfont()) into another font name that we know will be available. It * doesn't provide the fine control available with *devfontmap, but should be good * enough for most jobs. Both structures are only needed when emulating another * device using *realdev's font tables. * */ static Devfontmap *devfontmap = NULL; /* device level */ static Fontmap fontmap[] = FONTMAP; /* and general mapping tables - emulation */ /* * * Variables and functions for the pdfmark operator. * */ static char *Author; /* DOCINFO /Author */ static char *Title; /* DOCINFO /Title */ static char *Subject; /* DOCINFO /Subject */ static char *Keywords; /* DOCINFO /Keywords */ static struct Bookmark { char *Title; /* OUT /Title */ char *title; /* unencoded title */ int Count; /* OUT /Count */ int level; /* used to generate count */ int closed; /* the bookmark is closed initially */ } *Bookmarks; static size_t nBookmarks; static double pagelength = 792; /* lenght of page in points */ #define MAXBOOKMARKLEVEL 20 static void orderbookmarks(void); static struct box { int val[4]; int flag; } mediasize, bleedat, trimat, cropat; /* * * For the -M option. * */ static enum { M_NONE = 000, M_CUT = 001, M_STAR = 002, M_REG = 004, M_COL = 010, M_ALL = 077 } Mflag; static void setmarks(char *); /* * * A few variables that are really only used if we're doing accounting. Designed * for our use at Murray Hill and probably won't suit your needs. Changes should * be easy and can be made in routine account(). * */ int printed = 0; /* charge for this many pages */ /* * * Output and accounting file definitions. The PostScript output always goes to * stdout or /dev/null, while the accounting file can be selected using the -A * option. * */ FILE *tf = NULL; /* PostScript output goes here */ FILE *gf = NULL; /* global data goes here */ FILE *rf = NULL; /* resource data goes here */ FILE *sf = NULL; /* supplied resource comments go here */ FILE *nf = NULL; /* needed resource comments go here */ FILE *pf = NULL; /* elements of _custompagesetup */ static int sfcount; /* count of supplied resources */ static int nfcount; /* count of needed resources */ static int ostdout; /* old standard output */ static FILE *fp_acct = NULL; /* accounting stuff written here */ /* * * Very temporary space that can be used to do things like building up pathnames * immediately before opening a file. Contents may not be preserved across calls * to subroutines defined in this file, so it probably should only be used in low * level subroutines like loadfont() or fontinit() and nowhere else. * */ static char temp[4096]; /*****************************************************************************/ static char *linkborderstyle; static char *ulinkborderstyle; static void sethorscale(char *); static void t_papersize(char *); static void t_cutat(const char *, struct box *, char *); static void t_track(char *); static void t_strack(void); static void t_pdfmark(char *); static void t_locale(char *); static void t_anchor(char *); static void t_link(char *); static void t_linkcolor(char *); static void t_linkborder(char *); static void t_ulink(char *); static void t_ulinkcolor(char *); static void t_ulinkborder(char *); static char *t_linkborderstyle(char *); static int mb_cur_max; /*****************************************************************************/ int main(int agc, char *agv[]) { const char template[] = "/var/tmp/dpostXXXXXX"; char *tp; FILE *fp; /* * * A program that translates troff output into PostScript. All the input files * must have been formatted for the same device, which doesn't necessarily have to * be *realdev. If there's more than one input file, each begins on a new page. * */ setlocale(LC_CTYPE, ""); mb_cur_max = MB_CUR_MAX; ostdout = dup(1); if (close(mkstemp(tp = strdup(template))) < 0 || freopen(tp, "r+", stdout) == NULL) { perror(tp); return 2; } unlink(tp); if (close(mkstemp(tp = strdup(template))) < 0 || (gf = fopen(tp, "r+")) == NULL) { perror(tp); return 2; } unlink(tp); if (close(mkstemp(tp = strdup(template))) < 0 || (rf = fopen(tp, "r+")) == NULL) { perror(tp); return 2; } unlink(tp); if (close(mkstemp(tp = strdup(template))) < 0 || (sf = fopen(tp, "r+")) == NULL) { perror(tp); return 2; } unlink(tp); if (close(mkstemp(tp = strdup(template))) < 0 || (nf = fopen(tp, "r+")) == NULL) { perror(tp); return 2; } unlink(tp); if (close(mkstemp(tp = strdup(template))) < 0 || (pf = fopen(tp, "r+")) == NULL) { perror(tp); return 2; } unlink(tp); argc = agc; /* global so everyone can use them */ argv = agv; progname = prog_name = argv[0]; /* just for error messages */ init_signals(); /* sets up interrupt handling */ options(); /* command line options */ arguments(); /* translate all the input files */ done(); /* add trailing comments etc. */ fp = fdopen(ostdout, "w"); header(fp); /* PostScript file structuring comments */ account(); /* job accounting data */ return(x_stat); /* everything probably went OK */ } /* End of main */ /*****************************************************************************/ static int putint(int n, FILE *fp) { char buf[20]; int c = 0, i; /* * * Print an integer in PostScript binary token representation. * */ if (n >= -128 && n <= 127) { buf[c++] = 136; buf[c++] = n; } else if (n >= -32768 && n <= 32767) { buf[c++] = 134; buf[c++] = (n&0xff00) >> 8; buf[c++] = (n&0x00ff); } else { buf[c++] = 132; buf[c++] = (n&0xff000000) >> 24; buf[c++] = (n&0x00ff0000) >> 16; buf[c++] = (n&0x0000ff00) >> 8; buf[c++] = (n&0x000000ff); } for (i = 0; i < c; i++) putc(buf[i]&0377, fp); return c; } static int putstring1(const char *sp, int n, FILE *fp) { /* * * Print a string in PostScript binary token representation. * */ putc(142, fp); putc(n, fp); fwrite(sp, 1, n, fp); return n + 2; } static int putstring(const char *sp, int n, FILE *fp) { int c = 0, m; do { m = n > 250 ? 250 : n; c += putstring1(sp, m, fp); sp += m; n -= m; } while (n > 0); return c; } /*****************************************************************************/ void init_signals(void) { void interrupt(int); /* signal handler */ /* * * Make sure we handle interrupts. * */ if ( signal(SIGINT, interrupt) == SIG_IGN ) { signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); signal(SIGHUP, SIG_IGN); } else { signal(SIGHUP, interrupt); signal(SIGQUIT, interrupt); } /* End else */ signal(SIGTERM, interrupt); } /* End of init_signals */ /*****************************************************************************/ static char * pdfdate(time_t *tp, char *buf, size_t sz) { struct tm *tmptr; int tzdiff, tzdiff_hour, tzdiff_min; tzdiff = *tp - mktime(gmtime(tp)); tzdiff_hour = (int)(tzdiff / 60); tzdiff_min = tzdiff_hour % 60; tzdiff_hour /= 60; tmptr = localtime(tp); if (tmptr->tm_isdst > 0) tzdiff_hour++; snprintf(buf, sz, "(D:%04d%02d%02d%02d%02d%02d%+03d'%02d')", tmptr->tm_year + 1900, tmptr->tm_mon + 1, tmptr->tm_mday, tmptr->tm_hour, tmptr->tm_min, tmptr->tm_sec, tzdiff_hour, tzdiff_min); return buf; } /*****************************************************************************/ static void pdfbox(const char *boxname, struct box *bp, FILE *fp, int perpage) { double llx, lly, urx, ury; if (bp->flag == 0) return; llx = bp->val[0] * 72.0 / res; lly = pagelength - ((bp->val[1] + bp->val[3]) * 72.0 / res); urx = (bp->val[0] + bp->val[2]) * 72.0 / res; ury = pagelength - (bp->val[1] * 72.0 / res); fprintf(gf, "/_%s [%g %g %g %g] def\n", boxname, llx, lly, urx, ury); if (perpage) fprintf(fp, "[ {ThisPage} 1 dict dup /%s _%s put /PUT pdfmark\n", boxname, boxname); else fprintf(gf, "[ /%s _%s /PAGES pdfmark\n", boxname, boxname); } /*****************************************************************************/ void header(FILE *fp) { /* * * Print the DSC header, followed by the data generated so far. This function * is now called after all input has been processed. * */ struct Bookmark *bp; time_t now; int n; double x = 0, y = 0; char buf[4096]; char crdbuf[40]; time(&now); if (mediasize.flag) { x = mediasize.val[2] * 72.0 / res; y = mediasize.val[3] * 72.0 / res; } fprintf(fp, "%s", CONFORMING); fprintf(fp, "%s %s\n", CREATOR, creator); fprintf(fp, "%s %s", CREATIONDATE, ctime(&now)); if (LanguageLevel > 1) fprintf(fp, "%%%%LanguageLevel: %d\n", LanguageLevel); if (Binary) fprintf(fp, "%%%%DocumentData: Binary\n"); if ( temp_file != NULL ) { if ( docfonts > 0 ) { cat(temp_file, fp); putc('\n', fp); } /* End if */ unlink(temp_file); } /* End if */ fprintf(fp, "%s %d\n", PAGES, printed); if (mediasize.flag & 2) fprintf(fp, "%%%%DocumentMedia: x%gy%g %g %g 0 () ()\n", x, y, x, y); fflush(nf); rewind(nf); while ((n = fread(buf, 1, sizeof buf, nf)) > 0) fwrite(buf, 1, n, fp); fflush(sf); rewind(sf); while ((n = fread(buf, 1, sizeof buf, sf)) > 0) fwrite(buf, 1, n, fp); fprintf(fp, "%s", ENDCOMMENTS); fprintf(fp, "%s\n", "%%BeginProlog"); if ( cat(prologue, fp) == FALSE ) error(FATAL, "can't read %s", prologue); fflush(rf); rewind(rf); while ((n = fread(buf, 1, sizeof buf, rf)) > 0) fwrite(buf, 1, n, fp); fprintf(fp, "%s", ENDPROLOG); fprintf(fp, "%s", BEGINSETUP); fprintf(fp, "\ [ /CreationDate %s\n\ /Creator (%s)\n", pdfdate(&now, crdbuf, sizeof crdbuf), creator); if (Author) fprintf(fp, " /Author %s\n", Author); if (Title) fprintf(fp, " /Title %s\n", Title); if (Subject) fprintf(fp, " /Subject %s\n", Subject); if (Keywords) fprintf(fp, " /Keywords %s\n", Keywords); fprintf(fp, "/DOCINFO pdfmark\n"); if (Bookmarks) { orderbookmarks(); for (bp = &Bookmarks[0]; bp < &Bookmarks[nBookmarks]; bp++) { fprintf(fp, "[ /Title %s\n", bp->Title); if (bp->Count) fprintf(fp, " /Count %d\n", bp->closed ? -bp->Count : bp->Count); fprintf(fp, " /Dest /Bookmark$%d\n" "/OUT pdfmark\n", (int)(bp - &Bookmarks[0])); } } fflush(pf); rewind(pf); fprintf(fp, "/_custompagesetup {\n"); pdfbox("TrimBox", &trimat, fp, 1); pdfbox("BleedBox", &bleedat, fp, 1); pdfbox("CropBox", &cropat, fp, 0); while ((n = fread(buf, 1, sizeof buf, pf)) > 0) fwrite(buf, 1, n, fp); fprintf(fp, "} def\n"); fprintf(fp, "/_marks {\n"); if (Mflag & M_CUT) fprintf(fp, "_cutmarks\n"); if (Mflag & M_REG) fprintf(fp, "_regmarks\n"); if (Mflag & M_STAR) fprintf(fp, "_startargets\n"); if (Mflag & M_COL) fprintf(fp, "_colorbars\n"); fprintf(fp, "} def\n"); fflush(gf); rewind(gf); while ((n = fread(buf, 1, sizeof buf, gf)) > 0) fwrite(buf, 1, n, fp); if (mediasize.flag) { fprintf(fp, "/pagebbox [0 0 %g %g] def\n", x, y); fprintf(fp, "userdict /gotpagebbox true put\n"); if (mediasize.flag & 2) fprintf(fp, "/setpagedevice where {pop " "1 dict dup /PageSize [%g %g] put setpagedevice" "} if\n", x, y); } fprintf(fp, "mark\n"); fflush(stdout); rewind(stdout); while ((n = fread(buf, 1, sizeof buf, stdout)) > 0) fwrite(buf, 1, n, fp); fprintf(fp, "%s", ENDOFFILE); } /* End of header */ /*****************************************************************************/ void options(void) { const char optnames[] = "a:c:e:m:n:o:p:tw:x:y:A:C:J:F:H:L:M:OP:R:S:T:DI"; int ch; /* name returned by getopt() */ /* * * Reads and processes the command line options. There are, without a doubt, too * many options! * */ while ( (ch = getopt(argc, argv, optnames)) != EOF ) { switch ( ch ) { case 'a': /* aspect ratio */ fprintf(stdout, "/aspectratio %s def\n", optarg); break; case 'c': /* number of copies */ copies = atoi(optarg); fprintf(stdout, "/#copies %s store\n", optarg); break; case 'e': /* change the encoding scheme */ if ( (encoding = atoi(optarg)) < 0 || encoding > MAXENCODING ) encoding = DFLTENCODING; else eflag = 1; realencoding = encoding; break; case 'm': /* magnification */ fprintf(stdout, "/magnification %s def\n", optarg); break; case 'n': /* forms per page */ formsperpage = atoi(optarg); fprintf(stdout, "%s %s\n", FORMSPERPAGE, optarg); fprintf(stdout, "/formsperpage %s def\n", optarg); break; case 'o': /* output page list */ out_list(optarg); break; case 'p': /* landscape or portrait mode */ if ( *optarg == 'l' ) fprintf(stdout, "/landscape true def\n"); else fprintf(stdout, "/landscape false def\n"); break; case 't': /* just for compatibility */ break; case 'w': /* line width for drawing */ fprintf(stdout, "/linewidth %s def\n", optarg); break; case 'x': /* shift horizontally */ fprintf(stdout, "/xoffset %s def\n", optarg); break; case 'y': /* and vertically on the page */ fprintf(stdout, "/yoffset %s def\n", optarg); break; case 'A': /* force job accounting */ case 'J': if ( (fp_acct = fopen(optarg, "a")) == NULL ) error(FATAL, "can't open accounting file %s", optarg); break; case 'C': /* copy file to straight to output */ if ( cat(optarg, stdout) == FALSE ) error(FATAL, "can't read %s", optarg); break; case 'F': /* font table directory */ fontdir = optarg; break; case 'H': /* host resident font directory */ hostfontdir = optarg; break; case 'L': /* PostScript prologue file */ setpaths(optarg); break; case 'M': /* print cut marks */ setmarks(optarg); break; case 'O': /* turn picture inclusion off */ picflag = OFF; break; case 'P': /* PostScript pass through */ fprintf(stdout, "%s\n", optarg); break; case 'R': /* special global or page level request */ saverequest(optarg); break; case 'S': /* horizontal position error */ if ( (pointslop = atof(optarg)) < 0 ) pointslop = 0; Sflag = 1; break; case 'T': /* target printer */ realdev = optarg; break; case 'D': /* debug flag */ debug = ON; tf = stdout; break; case 'I': /* ignore FATAL errors */ ignore = ON; break; case '?': /* don't know the option */ error(FATAL, ""); break; default: error(FATAL, "missing case for option %c", ch); break; } /* End switch */ } /* End while */ argc -= optind; /* get ready for non-options args */ argv += optind; if (Mflag) { FILE *otf = tf; tf = stdout; doglobal(cutmarksfile); tf = otf; } } /* End of options */ /*****************************************************************************/ void setpaths ( char *name /* string that followed the -L option */ ) { char *path; /* start of the pathname */ /* * * Extends the -L option to permit run time modification of pathnames that were * fixed or didn't exist in previous versions of dpost. For example, the PostScript * drawing procedures have been moved out of *prologue and put in *drawfile. The * new syntax can be either -Lfile or -Lname:file. If the "name:" prefix is omitted * file will be used as the prologue, otherwise name should be one of "prologue", * "font", "draw", "color", or "form" and is used to select the pointer that gets * set to string "file". * */ for ( path = name; *path; path++ ) if ( *path == ':' || *path == ' ' ) { while ( *path == ':' || *path == ' ' ) path++; break; } /* End if */ if ( *path == '\0' ) /* didn't find a "name:" prefix */ path = name; if ( path == name || strncmp(name, "prologue", strlen("prologue")) == 0 ) prologue = path; else if ( strncmp(name, "draw", strlen("draw")) == 0 ) drawfile = path; else if ( strncmp(name, "color", strlen("color")) == 0 ) colorfile = path; else if ( strncmp(name, "form", strlen("form")) == 0 ) formfile = path; else if ( strncmp(name, "baseline", strlen("baseline")) == 0 ) baselinefile = path; else if ( strncmp(name, "cutmarks", strlen("cutmarks")) == 0 ) cutmarksfile = path; } /* End of setpaths */ /*****************************************************************************/ static void setmarks(char *str) { char *sp; int c; do { for (sp = str; *sp && *sp != ':'; sp++); c = *sp; *sp = 0; if (prefix(str, "cutmarks")) Mflag |= M_CUT; else if (prefix(str, "registrationmarks")) Mflag |= M_REG; else if (prefix(str, "startargets")) Mflag |= M_STAR; else if (prefix(str, "colorbars")) Mflag |= M_COL; else if (prefix(str, "all")) Mflag |= M_ALL; else error(FATAL, "unknown mark: -M %s", str); *sp = c; str = &sp[1]; } while (c); } /*****************************************************************************/ void setup(void) { /* * Handles things that must be done after the options are read but before the * input files are processed. Called from t_init() after an "x init" command is * read, because we need the resolution before we can generate the call to the * setup procedure defined in *prologue. Only allowing one call to setup assumes * all the input files have been prepared for the same device. * */ writerequest(0, stdout); /* global requests eg. manual feed */ fprintf(stdout, "/resolution %d def\n", res); fprintf(stdout, "setup\n"); fprintf(stdout, "%d setdecoding\n", encoding); if ( formsperpage > 1 ) { /* followed by stuff for multiple pages */ if ( cat(formfile, stdout) == FALSE ) error(FATAL, "can't read %s", formfile); fprintf(stdout, "%d setupforms\n", formsperpage); } /* End if */ fprintf(stdout, "%s", ENDSETUP); } /* End of setup */ /*****************************************************************************/ void arguments(void) { FILE *fp; /* next input file */ /* * * Makes sure all the non-option command line arguments are processed. If we get * here and there aren't any arguments left, or if '-' is one of the input files * we'll translate stdin. * */ if ( argc < 1 ) conv(stdin); else while ( argc > 0 ) { if ( strcmp(*argv, "-") == 0 ) fp = stdin; else if ( (fp = fopen(*argv, "r")) == NULL ) error(FATAL, "can't open %s", *argv); conv(fp); if ( fp != stdin ) fclose(fp); argc--; argv++; } /* End while */ } /* End of arguments */ /*****************************************************************************/ void done(void) { /* * * Finished with all the input files, so mark the end of the pages with a TRAILER * comment, make sure the last page prints, and add things like the DOCUMENTFONTS * and PAGES comments that can only be determined after all the input files have * been read. * */ fprintf(stdout, "%s", TRAILER); fprintf(stdout, "done\n"); } /* End of done */ /*****************************************************************************/ void account(void) { /* * * Writes an accounting record to *fp_acct provided it's not NULL. Accounting is * requested using the -A or -J options. * */ if ( fp_acct != NULL ) fprintf(fp_acct, " print %d\n copies %d\n", printed, copies); } /* End of account */ /*****************************************************************************/ void conv( register FILE *fp /* next input file */ ) { register int c; /* usually first char in next command */ int m, n, n1, m1; /* when we need to read integers */ char str[4096]; /* for special chars and font numbers */ char b; /* * * Controls the translation of troff's device independent output language into * PostScript. The call to t_page() that prints the last page is made when we * exit the loop, but probably belongs in t_trailer(). * */ redirect(-1); /* only do output after a page command */ lineno = 1; /* line in current file */ while ((c = getc(fp)) != EOF) { switch (c) { case '\n': /* just count this line */ lineno++; break; case ' ': /* when input is text */ case 0: /* occasional noise creeps in */ break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': /* two motion digits plus a character */ hmot((c-'0')*10 + getc(fp)-'0'); put1(getc(fp)); break; case 'c': /* single ascii character */ put1(getc(fp)); break; case 'C': /* special character */ sget(str, sizeof str, fp); put1s(str); break; case 'N': /* character at position n */ fscanf(fp, "%d", &m); endtext(); oput(m); endtext(); break; case 'D': /* drawing functions */ endtext(); getdraw(); if ( size != lastsize || (size == FRACTSIZE && fractsize != lastfractsize) || horscale != lasthorscale) { subfont = 0; t_sf(0); } switch ((c=getc(fp))) { case 'p': /* draw a path */ while (fscanf(fp, "%d %d", &n, &m) == 2) drawline(n, m); lineno++; break; case 'P': /* solid polygon */ fprintf(tf, "newpath %d %d neg moveto\n", hpos, vpos); while (fscanf(fp, "%d %d", &n, &m) == 2) { hpos += n; vpos += m; fprintf(tf, "%d %d neg lineto\n", hpos, vpos); } fprintf(tf, "closepath fill\n"); lineno++; break; case 'l': /* draw a line */ fscanf(fp, "%d %d %c", &n, &m, &b); n1 = b; drawline(n, m); break; case 'c': /* circle */ case 'C': /* filled circle */ fscanf(fp, "%d", &n); drawcirc(n, c); break; case 'e': /* ellipse */ case 'E': /* filled ellipse */ fscanf(fp, "%d %d", &m, &n); drawellip(m, n, c); break; case 'a': /* counter-clockwise arc */ case 'A': /* clockwise arc */ fscanf(fp, "%d %d %d %d", &n, &m, &n1, &m1); drawarc(n, m, n1, m1, c); break; case 'q': /* spline without end points */ drawspline(fp, 1); lineno++; break; case '~': /* wiggly line */ drawspline(fp, 2); lineno++; break; case 't': /* set line width, ignore */ fscanf(fp, "%d %d", &m, &n); hgoto(hpos + m); lineno++; break; case 'F': /* color scheme, ignore */ case 'f': /* filling color, ignore */ fgets(str, sizeof str, fp); lineno++; break; default: error(FATAL, "unknown drawing function %c", c); break; } /* End switch */ break; case 's': /* use this point size */ fscanf(fp, "%d", &n); /* ignore fractional sizes */ if (n != FRACTSIZE) setsize(t_size(n), 0); else { float f; fscanf(fp, "%f", &f); setsize(FRACTSIZE, f); } break; case 'f': /* use font mounted here */ sget(str, sizeof str, fp); setfont(t_font(str)); break; case 'H': /* absolute horizontal motion */ fscanf(fp, "%d", &n); hgoto(n); break; case 'h': /* relative horizontal motion */ fscanf(fp, "%d", &n); hmot(n); break; case 'w': /* word space */ wordspace++; break; case 'V': /* absolute vertical position */ fscanf(fp, "%d", &n); vgoto(n); break; case 'v': /* relative vertical motion */ fscanf(fp, "%d", &n); vmot(n); break; case 'p': /* new page */ fscanf(fp, "%d", &n); t_page(n); break; case 'n': /* end of line */ while ( (c = getc(fp)) != '\n' && c != EOF ) ; t_newline(); lineno++; break; case '#': /* comment */ while ( (c = getc(fp)) != '\n' && c != EOF ) ; lineno++; break; case 'x': /* device control function */ devcntrl(fp); lineno++; break; default: error(FATAL, "unknown input character %o %c", c, c); done(); } /* End switch */ } /* End while */ t_page(-1); /* print the last page */ endtext(); } /* End of conv */ /*****************************************************************************/ void devcntrl( FILE *fp /* current input file */ ) { char str[4096], *buf, str1[4096]; - int c, n, sz; + int c, sz; + size_t n; /* * * Called from conv() to process the rest of a device control function. There's * a whole family of them and they all start with the string "x ", which we've * already read. The "x X ..." commands are an extensible (and device dependent) * family that we use here for things like picture inclusion. Unrecognized device * control commands are ignored. * */ buf = malloc(sz = 4096); sget(str, sizeof str, fp); /* get the control function name */ switch ( str[0] ) { /* only the first character counts */ case 'i': /* initialize */ t_init(); break; case 'T': /* device name */ sget(devname, sizeof devname, fp); getdevmap(); /* * This used to be "strcpy(devname, realdev);" but * it does not work when DESC is a text file because * the fonts are in a different directory. */ if (dev.afmfonts || (devname[0] == 'p' && devname[1] == 's')) realdev = devname; else n_strcpy(devname, realdev, sizeof(devname)); break; case 't': /* trailer */ t_trailer(); break; case 'p': /* pause -- can restart */ t_reset('p'); break; case 's': /* stop */ t_reset('s'); break; case 'r': /* resolution assumed when prepared */ fscanf(fp, "%d", &res); break; case 'f': /* load font in a position */ - fscanf(fp, "%d", &n); + fscanf(fp, "%zd", &n); sget(str, sizeof str, fp); fgets(buf, sz, fp); /* in case there's a filename */ ungetc('\n', fp); /* fgets() goes too far */ str1[0] = '\0'; /* in case there's nothing to come in */ c = 0; sscanf(buf, "%s %d", str1, &c); loadfont(n, mapdevfont(str), str1, 0, c); break; /* these don't belong here... */ case 'H': /* char height */ - fscanf(fp, "%d", &n); - if (n != FRACTSIZE) + fscanf(fp, "%zd", &n); + if (n != (size_t)FRACTSIZE) t_charht(n, 0); else { float f; fscanf(fp, "%f", &f); t_charht(FRACTSIZE, f); } break; case 'S': /* slant */ - fscanf(fp, "%d", &n); + fscanf(fp, "%zd", &n); t_slant(n); break; case 'X': /* copy through - from troff */ do c = getc(fp); while (spacechar(c)); n = 0; if (c != EOF) do { if (n + 1 < sizeof str) str[n++] = c; c = getc(fp); } while (c != EOF && !spacechar(c) && c != ':'); str[n] = 0; if (c != ':') ungetc(c, fp); n = 0; for (;;) { fgets(&buf[n], sz - n, fp); if ((c = getc(fp)) != '+') { ungetc(c, fp); break; } while (buf[n]) n++; if (sz - n < 4096) buf = realloc(buf, sz += 4096); lineno++; } if ( strcmp(str, "PI") == 0 || strcmp(str, "PictureInclusion") == 0 ) picture(buf); else if ( strcmp(str, "InlinePicture") == 0 ) inlinepic(fp, buf); else if ( strcmp(str, "SupplyFont") == 0 ) t_supply(buf); else if ( strcmp(str, "PaperSize") == 0 ) t_papersize(buf); else if ( strcmp(str, "TrimAt") == 0 ) t_cutat("Trim size", &trimat, buf); else if ( strcmp(str, "BleedAt") == 0 ) t_cutat("Bleed size", &bleedat, buf); else if ( strcmp(str, "CropAt") == 0 ) t_cutat("Crop size", &cropat, buf); else if ( strcmp(str, "Track") == 0 ) t_track(buf); else if ( strcmp(str, "PDFMark") == 0 ) t_pdfmark(buf); else if ( strcmp(str, "LC_CTYPE") == 0 ) t_locale(buf); else if ( strcmp(str, "Anchor") == 0 ) t_anchor(buf); else if ( strcmp(str, "Link") == 0 ) t_link(buf); else if ( strcmp(str, "SetLinkColor") == 0 ) t_linkcolor(buf); else if ( strcmp(str, "SetLinkBorder") == 0 ) t_linkborder(buf); else if ( strcmp(str, "SetBorderStyle") == 0 ) linkborderstyle = t_linkborderstyle(buf); else if ( strcmp(str, "SetUBorderStyle") == 0 ) ulinkborderstyle = t_linkborderstyle(buf); else if ( strcmp(str, "ULink") == 0 ) t_ulink(buf); else if ( strcmp(str, "SetULinkColor") == 0 ) t_ulinkcolor(buf); else if ( strcmp(str, "SetULinkBorder") == 0 ) t_ulinkborder(buf); else if ( strcmp(str, "HorScale") == 0 ) sethorscale(buf); else if ( strcmp(str, "BeginPath") == 0 ) beginpath(buf, FALSE); else if ( strcmp(str, "DrawPath") == 0 ) drawpath(buf, FALSE); else if ( strcmp(str, "BeginObject") == 0 ) beginpath(buf, TRUE); else if ( strcmp(str, "EndObject") == 0 ) drawpath(buf, TRUE); else if ( strcmp(str, "NewBaseline") == 0 ) newbaseline(buf); else if ( strcmp(str, "DrawText") == 0 ) drawtext(buf); else if ( strcmp(str, "SetText") == 0 ) settext(buf); else if ( strcmp(str, "SetColor") == 0 ) { newcolor(buf); setcolor(); } else if ( strcmp(str, "Sync") == 0 ) { if (tracked) tracked = -1; subfont = 0; t_sf(1); xymove(hpos, vpos); } else if ( strcmp(str, "PSSetup") == 0 ) { fprintf(gf, "%s", buf); } else if ( strcmp(str, "PS") == 0 || strcmp(str, "PostScript") == 0 ) { endtext(); /* xymove(hpos, vpos); ul90-22006 */ fprintf(tf, "%s", buf); } /* End else */ goto done; } /* End switch */ while ( (c = getc(fp)) != '\n' && c != EOF ) ; done: free(buf); } /* End of devcntrl */ /*****************************************************************************/ void fontinit(void) { char *descp; /* for reading the DESC file */ char *filebase; /* the whole thing goes here */ int i; /* loop index */ /* * * Reads *realdev's DESC file and uses what's there to initialize things like * the list of available point sizes. Old versions of the program used *devname's * DESC file to initialize nfonts, but that meant we needed to have *devname's * binary font files available for emulation. That restriction has been removed * and we now set nfonts using the "x font" commands in the input file, so by the * time we get here all we really need is *realdev. In fact devcntrl() reads the * device name from the "x T ..." command, but almost immediately replaces it with * string *realdev so we end up using *realdev's DESC file. Later on (in * t_font()) we mount all of *realdev's special fonts after the last legitimate * font position, just to be sure device emulation works reasonably well - there's * no guarantee *devname's special fonts match what's needed when *realdev's tables * are used. * */ snprintf(temp, sizeof temp, "%s/dev%s/FONTMAP", fontdir, devname); rdftmap(temp); snprintf(temp, sizeof temp, "%s/dev%s/DESC", fontdir, devname); if ( (descp = readdesc(temp)) == 0 ) error(FATAL, "can't open tables for %s", temp); memcpy(&dev, descp, sizeof dev); nfonts = 0; /* was dev.nfonts - now set in t_fp() */ nsizes = dev.nsizes; nchtab = dev.nchtab; unitwidth = dev.unitwidth; filebase = &descp[sizeof dev]; pstab = (int *) filebase; chtab = (short *)(pstab + nsizes + 1); chname = (char *) (chtab + nchtab); fsize = 3 * 255 + nchtab + 128 - 32 + sizeof(struct Font); fitab = calloc(NFONT+1, sizeof *fitab); fontab = calloc(NFONT+1, sizeof *fontab); codetab = calloc(NFONT+1, sizeof *codetab); kerntab = calloc(NFONT+1, sizeof *kerntab); fontbase = calloc(NFONT+1, sizeof *fontbase); for ( i = 1; i <= NFONT; i++ ) { /* so loadfont() knows nothing's there */ fontbase[i] = NULL; } /* End for */ if ( (downloaded = (char *) calloc(nchtab + 128, sizeof(char))) == NULL ) error(FATAL, "no memory"); } /* End of fontinit */ /*****************************************************************************/ void loadfont ( int n, /* load this font position */ const char *s, /* with the file for this font */ char *s1, /* taken from here - possibly */ int forcespecial, /* this is definitively a special font */ int spec /* map specification */ ) { char *fpout = NULL; /* for reading *s file */ int fin; /* for reading *s.afm file */ int nw; /* number of width table entries */ const char *p; char *path; - size_t l; /* * * Loads font position n with the binary font file for *s provided it's not * already there. If *s1 is NULL or points to the empty string we read files from * directory *fontdir/dev*devname, otherwise directory *s1 is used. If the first * open fails we try to map font *s into one we expect will be available, and then * we try again. * */ if ( n < 0 || n > NFONT ) /* make sure it's a legal position */ error(FATAL, "illegal fp command %d %s", n, s); if ( fontbase[n] != NULL && strcmp(s, fontbase[n]->namefont) == 0 ) return; path = temp; if (s1 && strchr(s1, '/') != NULL) path = afmdecodepath(s1); else if (s1 && strstr(s1, ".afm") != NULL) snprintf(temp, sizeof temp, "%s/dev%s/%s", fontdir, devname, s1); else if (strchr(s, '/') != NULL) { path = afmdecodepath(s); if (spec == 0 && s1) spec = atoi(s1); } else if (strstr(s, ".afm") != NULL) { snprintf(temp, sizeof temp, "%s/dev%s/%s", fontdir, devname, s); if (spec == 0 && s1) spec = atoi(s1); } else snprintf(temp, sizeof temp, "%s/dev%s/%s.afm", fontdir, devname, s); if ( (fin = open(path, O_RDONLY)) >= 0 ) { struct afmtab *a; struct stat st; char *contents; int i; if ((p = strrchr(s, '/')) == NULL) p = s; else p++; if (p[0] == 'S' && (p[1] == '\0' || (digitchar(p[1]&0377) && p[2] == '\0') || p[2] == '.')) forcespecial = 1; for (i = 0; i < afmcount; i++) if (afmfonts[i] && strcmp(afmfonts[i]->path, path) == 0 && afmfonts[i]->spec == spec) { a = afmfonts[i]; close(fin); goto have; } if ((a = calloc(1, sizeof *a)) == NULL || fstat(fin, &st) < 0 || (contents = malloc(st.st_size+1)) == NULL || read(fin, contents, st.st_size) != st.st_size) { free(a); close(fin); goto fail; } close(fin); a->path = strdup(path); if (path != temp) free(path); a->file = s; a->spec = spec; if (afmget(a, contents, st.st_size) < 0) { free(a); free(contents); goto fail; } free(contents); afmfonts = realloc(afmfonts, (afmcount+1) * sizeof *afmfonts); afmfonts[afmcount] = a; snprintf(a->Font.intname, sizeof a->Font.intname, "%d", dev.nfonts + ++afmcount); if (forcespecial) a->Font.specfont = 1; have: fontbase[n] = &a->Font; fontab[n] = a->fontab; codetab[n] = a->codetab; fitab[n] = a->fitab; t_fp(n, a->fontname, fontbase[n]->intname, a); goto done; } if (strchr(s, '/') != NULL) goto fail; if ( s1 == NULL || s1[0] == '\0' ) snprintf(temp, sizeof temp, "%s/dev%s/%s", fontdir, devname, s); else snprintf(temp, sizeof temp, "%s/%s", s1, s); if ( access(temp, R_OK) < 0 ) snprintf(temp, sizeof temp, "%s/dev%s/%s", fontdir, devname, mapfont(s)); if ((fpout = readfont(temp, &dev, 0)) == NULL) fail: error(FATAL, "can't open font table %s", temp); if ( fontbase[n] != NULL ) /* something's already there */ free(fontbase[n]); /* so release the memory first */ fontbase[n] = (struct Font *)fpout; p = (char *) fontbase[n] + sizeof(struct Font); nw = fontbase[n]->nwfont & BMASK; makefont(n, p, NULL, p + 2 * nw, p + 3 * nw, nw); t_fp(n, fontbase[n]->namefont, fontbase[n]->intname, NULL); done: if ( smnt == 0 && (fontbase[n]->specfont == 1 || forcespecial) ) smnt = n; if (fontbase[n]->specfont == 1 || forcespecial) gotregular = TRUE; if ( debug == ON ) fontprint(n); } /* End of loadfont */ /*****************************************************************************/ void loadspecial(void) { char *p; /* for next binary font file */ int nw; /* width entries in next font */ int i; /* loop index */ /* * * Loads all the special fonts after the last legal font position. Mostly used * for device emulation, but we'll do it no matter what. Needed because there's * no consistency in special fonts across different devices, and relying on having * them mounted in the input file doesn't guarantee the whole collection will be * there. The special fonts are determined and mounted using the copy of the * DESC file that's been read into memory. Initially had this stuff at the * end of fontinit(), but we now don't know nfonts until much later. * */ if ( gotregular == FALSE ) loadfont(++nfonts, ((struct Font *)(&chname[dev.lchname]))->namefont, NULL, 0, 0); if ( gotspecial == FALSE ) for ( i = 1, p = chname + dev.lchname; i <= dev.nfonts; i++ ) { nw = *p & BMASK; if ( ((struct Font *) p)->specfont == 1 ) loadfont(++nfonts, ((struct Font *)p)->namefont, NULL, 1, 0); p += 3 * nw + dev.nchtab + 128 - 32 + sizeof(struct Font); } /* End for */ gotregular = TRUE; gotspecial = TRUE; } /* End of loadspecial */ /*****************************************************************************/ static const char *defaultFonts[] = { "R", "I", "B", "BI", "CW", "H", "HB", "HX", "S1", "S", NULL }; void loaddefault(void) { int i; for (i = 0; defaultFonts[i] != NULL ; i++) loadfont(++nfonts, defaultFonts[i], NULL, defaultFonts[i][0] == 'S', 0); } void fontprint ( int i /* font's index in fontbase[] */ ) { int j, n; char *p; /* * * Debugging routine that dumps data about the font mounted in position i. * */ fprintf(tf, "font %d:\n", i); p = (char *) fontbase[i]; n = fontbase[i]->nwfont & BMASK; fprintf(tf, "base=0%lo, nchars=%d, spec=%d, name=%s, widtab=0%lo, fitab=0%lo\n", (long)p, n, fontbase[i]->specfont, fontbase[i]->namefont, (long)fontab[i], (long)fitab[i]); fprintf(tf, "widths:\n"); for ( j = 0; j <= n; j++ ) { fprintf(tf, " %2d", fontab[i][j]); if ( j % 20 == 19 ) putc('\n', tf); } /* End for */ fprintf(tf, "\ncodetab:\n"); for ( j = 0; j <= n; j++ ) { fprintf(tf, " %2d", codetab[i][j]); if ( j % 20 == 19 ) putc('\n', tf); } /* End for */ fprintf(tf, "\nfitab:\n"); for ( j = 0; j <= dev.nchtab + 128-32; j++ ) { fprintf(tf, " %2d", fitab[i][j]); if ( j % 20 == 19 ) putc('\n', tf); } /* End for */ putc('\n', tf); } /* End of fontprint */ /*****************************************************************************/ const char * mapfont ( const char *name /* troff wanted this font */ ) { int i; /* loop index */ /* * * If loadfont() can't find font *name we map it into something else that should * be available and return a pointer to the new name. Used mostly for emulating * devices like the APS-5. * */ name = mapft(name); for ( i = 0; fontmap[i].name != NULL; i++ ) if ( strcmp(name, fontmap[i].name) == 0 ) return(fontmap[i].use); switch ( *++name ) { case 'I': return("I"); case 'B': return("B"); case 'X': return("BI"); default: return("R"); } /* End switch */ } /* End of mapfont */ /*****************************************************************************/ void getdevmap(void) { FILE *fp; /* for reading the device fontmap file */ int i = 0; /* number of mapping pairs we've read */ int c; /* for skipping lines */ /* * * Looks for the device font mapping file *fontdir/dev*realdev/fontmaps/devname. * The file, if it exists, should be an ASCII file containing pairs of one or two * character font names per line. The first name is the font troff will be asking * for and the second is the one we'll use. Comments are lines that begin with * a '#' as the first non-white space character on a line. The devfontmap list * ends with a member that has the empty string in the name field. * */ snprintf(temp, sizeof temp, "%s/dev%s/fontmaps/%s", fontdir, realdev, devname); if ( devfontmap == NULL && (fp = fopen(temp, "r")) != NULL ) { devfontmap = (Devfontmap *) malloc(10 * sizeof(Devfontmap)); while ( sget(temp, sizeof temp, fp) == 1 ) { if ( temp[0] != '#' && strlen(temp) < 3 ) if ( sget(&temp[3], sizeof temp - 3, fp) == 1 && strlen(&temp[3]) < 3 ) { n_strcpy((devfontmap + i)->name, temp, sizeof(devfontmap->name)); n_strcpy((devfontmap + i)->use, &temp[3], sizeof(devfontmap->use)); if ( ++i % 10 == 0 ) devfontmap = (Devfontmap *) realloc(devfontmap, (i + 10) * sizeof(Devfontmap)); } /* End if */ while ( (c = getc(fp)) != '\n' && c != EOF ) ; } /* End while */ (devfontmap + i)->name[0] = '\0'; /* end the list we just read */ fclose(fp); } /* End if */ } /* End of getdevmap */ /*****************************************************************************/ char * mapdevfont(char *str) { int i; /* * * Called immediately before loadfont() after an 'x font' command is recognized. * Takes the font name that troff asked for, looks it up in the devfontmap list, * and returns the mapped name to the caller. No mapping is done if the devfontmap * list is empty or font *str isn't found in the list. * */ if ( devfontmap != NULL ) for ( i = 0; (devfontmap + i)->name[0] != '\0'; i++ ) if ( strcmp((devfontmap + i)->name, str) == 0 ) return((devfontmap + i)->use); return(str); } /* End of mapdevfont */ /*****************************************************************************/ void reset(void) { /* * * Resets the variables that keep track of the printer's current position, font, * and size. Typically used after a restore/save pair (eg. when we finish with a * page) to make sure we force the printer back into sync (in terms of the font * and current point) before text is printed. * */ lastx = -(slop + 1); savey = lasty = -1; lastfont = lastsubfont = lastsize = -1; if (tracked) tracked = -1; } /* End of reset */ /*****************************************************************************/ void resetpos(void) { /* * * Resets the variables that keep track of the printer's current position. Used * when there's a chance we've lost track of the printer's current position or * done something that may have wiped it out, and we want to force dpost to set * the printer's position before printing text or whatever. For example stroke or * fill implicitly do a newpath, and that wipes out the current point, unless the * calls were bracketed by a gsave/grestore pair. * */ lastx = -(slop + 1); savey = lasty = -1; } /* End of resetpos */ /*****************************************************************************/ void t_init(void) { static int initialized = FALSE; /* only do most things once */ /* * * Called from devcntrl() after an "x init" command is read. Things only work if * we've already seen the "x res" command, and much of the stuff, including the * call to setup, should only be done once. Restricting everything to one call of * setup (ie. the one in the prologue) means all the input files must have been * formatted for the same device. * */ endtext(); /* moved - for cat'ed troff files */ if ( initialized == FALSE ) { /* only do this stuff once per job */ fontinit(); gotspecial = FALSE; gotregular = FALSE; widthfac = (float) res /dev.res; if (dev.afmfonts) { if (Sflag == 0) pointslop = 0; } if (eflag == 0) realencoding = encoding = dev.encoding; if (encoding == 5) { LanguageLevel = max(LanguageLevel, 2); Binary++; } slop = pointslop * res / POINTS + .5; rvslop = res * .025; setup(); initialized = TRUE; } /* End if */ hpos = vpos = 0; /* upper left corner */ setsize(t_size(10), 0); /* start somewhere */ reset(); /* force position and font stuff - later */ } /* End of t_init */ /*****************************************************************************/ void needresource(const char *s, ...) { va_list ap; if (nfcount++ == 0) fprintf(nf, "%%%%DocumentNeededResources: "); else fprintf(nf, "%%%%+ "); va_start(ap, s); vfprintf(nf, s, ap); va_end(ap); putc('\n', nf); } static struct supplylist { struct supplylist *next; char *font; char *file; char *type; int done; } *supplylist; void t_supply(char *fnt) /* supply a font */ { struct supplylist *sp; char *np, *file, *type = NULL, c; while (*fnt == ' ' || *fnt == '\t') fnt++; for (np = fnt; *np && *np != ' ' && *np != '\t' && *np != '\n'; np++); if (*np == '\0' || *np == '\n') return; *np = '\0'; file = &np[1]; while (*file == ' ' || *file == '\t') file++; for (np = file; *np && *np != ' ' && *np != '\t' && *np != '\n'; np++); c = *np; *np = '\0'; if (c != '\0' && c != '\n') { type = &np[1]; while (*type == ' ' || *type == '\t') type++; for (np = type; *np && *np != ' ' && *np != '\t' && *np != '\n'; np++); *np = '\0'; } for (sp = supplylist; sp; sp = sp->next) if (strcmp(sp->font, fnt) == 0) return; sp = calloc(1, sizeof *sp); sp->font = strdup(fnt); sp->file = afmdecodepath(file); sp->type = type && *type ? strdup(type) : NULL; sp->next = supplylist; supplylist = sp; } static unsigned long ple32(const char *cp) { return (unsigned long)(cp[0]&0377) + ((unsigned long)(cp[1]&0377) << 8) + ((unsigned long)(cp[2]&0377) << 16) + ((unsigned long)(cp[3]&0377) << 24); } static const char ps_adobe_font_[] = "%!PS-AdobeFont-"; static const char ps_truetypefont[] = "%!PS-TrueTypeFont"; static const char hex[] = "0123456789abcdef"; static void supplypfb(char *fnt, char *path, FILE *fp) { char buf[30]; size_t i, n, length; int c = EOF, type = 0, lastch = EOF; if (fread(buf, 1, 6, fp) != 6) error(FATAL, "no data in %s", path); if ((buf[0]&0377) != 0200 || (type = buf[1]) != 1) error(FATAL, "invalid header in %s", path); length = ple32(&buf[2]); n = 0; while (ps_adobe_font_[n] && --length > 0 && (c = getc(fp)) != EOF) { if (c != ps_adobe_font_[n++]) error(FATAL, "file %s does not start with \"%s\"", path, ps_adobe_font_); } while (--length > 0 && (c = getc(fp)) != EOF && c != '\r' && c != '\n'); if (c != '\n') { if ((c = getc(fp)) != '\n') ungetc(c, fp); else length--; } if (sfcount++ == 0) fprintf(sf, "%%%%DocumentSuppliedResources: font %s\n", fnt); else fprintf(sf, "%%%%+ font %s\n", fnt); fprintf(rf, "%%%%BeginResource: font %s\n", fnt); for (;;) { switch (type) { case 1: while (length > 0 && (c = getc(fp)) != EOF) { length--; switch (c) { case '\r': if ((c = getc(fp)) != '\n') ungetc(c, fp); else length--; putc('\n', rf); lastch = '\n'; break; case 0: continue; default: putc(c, rf); lastch = c; } } if (c == EOF) error(FATAL, "short text data in %s", path); break; case 2: while (length) { n = length > sizeof buf ? sizeof buf : length; if (fread(buf, 1, n, fp) != n) error(FATAL, "short binary data in %s", path); for (i = 0; i < n; i++) { putc(hex[(buf[i]&0360)>>4], rf); putc(hex[buf[i]&017], rf); } putc('\n', rf); lastch = '\n'; length -= n; } break; case 3: if (lastch != '\n') putc('\n', rf); fprintf(rf, "%%%%EndResource\n"); fclose(fp); return; default: error(FATAL, "invalid header type %d in %s", path, type); } if ((n = fread(buf, 1, 6, fp)) != 6 && (buf[1] != 3 || n < 2)) error(FATAL, "missing header in %s", path); if ((buf[0]&0377) != 0200) error(FATAL, "invalid header in %s", path); if ((type = buf[1]) != 3) length = ple32(&buf[2]); } } static void supplyotf(char *fnt, char *path, FILE *fp) { static int cffcount; struct stat st; char *contents; size_t sz, offset, length, i; int fsType; const char StartData[] = " StartData "; if (fstat(fileno(fp), &st) < 0) error(FATAL, "cannot stat %s", path); sz = st.st_size; contents = malloc(sz); if (fread(contents, 1, sz, fp) != sz) error(FATAL, "cannot read %s", path); fclose(fp); if ((fsType = otfcff(path, contents, sz, &offset, &length)) < 0) { free(contents); return; } /* * Adobe Technical Note #5176, "The Compact Font Format * Specification", Version 1.0, 12/4/2003, p. 53 proposes * a weird syntax for CFF DSC comments ("ProcSet" etc.); * Adobe Distiller 7 complains about it with DSC warnings * enabled. What follows is an attempt to fix this. */ if (cffcount++ == 0) { fprintf(rf, "%%%%IncludeResource: procset FontSetInit 0 0\n"); needresource("procset FontSetInit 0 0"); } if (sfcount++ == 0) fprintf(sf, "%%%%DocumentSuppliedResources: font %s\n", fnt); else fprintf(sf, "%%%%+ font %s\n", fnt); fprintf(rf, "%%%%BeginResource: font %s\n", fnt); fprintf(rf, "/FontSetInit /ProcSet findresource begin\n"); if (encoding == 5) { fprintf(rf, "%%%%BeginData: %ld Binary Bytes\n", (long)(length + 13 + strlen(fnt) + 12)); fprintf(rf, "/%s %12ld StartData ", fnt, (long)length); fwrite(&contents[offset], 1, length, rf); fprintf(rf, "\n%%%%EndData\n"); } else { fprintf(rf, "/%s %ld ", fnt, (long)length); fprintf(rf, "currentfile /ASCIIHexDecode filter cvx exec\n"); for (i = 0; StartData[i]; i++) { putc(hex[(StartData[i]&0360)>>4], rf); putc(hex[StartData[i]&017], rf); } putc('\n', rf); for (i = offset; i < offset+length; i++) { putc(hex[(contents[i]&0360)>>4], rf); putc(hex[contents[i]&017], rf); if (i > offset && (i - offset + 1) % 34 == 0) putc('\n', rf); } fprintf(rf, ">\n"); } fprintf(rf, "%%%%EndResource\n"); free(contents); LanguageLevel = max(LanguageLevel, 3); } static void supplyttf(char *fnt, char *path, FILE *fp) { struct stat st; char *contents; size_t sz; if (fstat(fileno(fp), &st) < 0) error(FATAL, "cannot stat %s", path); sz = st.st_size; contents = malloc(sz); if (fread(contents, 1, sz, fp) != sz) error(FATAL, "cannot read %s", path); fclose(fp); if (sfcount++ == 0) fprintf(sf, "%%%%DocumentSuppliedResources: font %s\n", fnt); else fprintf(sf, "%%%%+ font %s\n", fnt); fprintf(rf, "%%%%BeginResource: font %s\n", fnt); otft42(fnt, path, contents, sz, rf); fprintf(rf, "%%%%EndResource\n"); free(contents); LanguageLevel = max(LanguageLevel, 2); } static void supply1(char *fnt, char *file, char *type) { FILE *fp; char linebuf[4096], c; if (strchr(file, '/') == 0) { snprintf(temp, sizeof temp, "%s/dev%s/%s.%s", fontdir, devname, file, type); file = temp; } if ((fp = fopen(file, "r")) == NULL) error(FATAL, "can't open %s", file); if (type == NULL) { c = getc(fp); ungetc(c, fp); type = c == '\200' ? "pfb" : c == 'O' ? "otf" : c == 0 || c == 't' ? "ttf" : "anything"; } if (strcmp(type, "pfb") == 0) { supplypfb(fnt, file, fp); return; } if (strcmp(type, "otf") == 0) { supplyotf(fnt, file, fp); return; } if (strcmp(type, "ttf") == 0) { supplyttf(fnt, file, fp); return; } if (fgets(linebuf, sizeof linebuf, fp) == NULL) error(FATAL, "missing data in %s", file); if (strncmp(linebuf, ps_adobe_font_, strlen(ps_adobe_font_)) && strncmp(linebuf, ps_truetypefont, strlen(ps_truetypefont))) error(FATAL, "file %s does not start with \"%s\" or \"%s\"", file, ps_adobe_font_, ps_truetypefont); if (sfcount++ == 0) fprintf(sf, "%%%%DocumentSuppliedResources: font %s\n", fnt); else fprintf(sf, "%%%%+ font %s\n", fnt); fprintf(rf, "%%%%BeginResource: font %s\n", fnt); while (fgets(linebuf, sizeof linebuf, fp) != NULL) fputs(linebuf, rf); fclose(fp); fprintf(rf, "%%%%EndResource\n"); } static void t_dosupply(const char *fnt) { struct supplylist *sp; for (sp = supplylist; sp; sp = sp->next) if (strcmp(sp->font, fnt) == 0) { if (sp->done == 0) { supply1(sp->font, sp->file, sp->type); sp->done = 1; } return; } needresource("font %s", fnt); } /*****************************************************************************/ static void boxcmp(const char *name, struct box *bp, int a, int b, int c, int d) { if (bp->flag && (a != bp->val[0] || b != bp->val[1] || c != bp->val[2] || d != bp->val[3])) error(NON_FATAL, "%s has changed, using new values", name); } static void t_papersize(char *buf) { int x, y, setmedia = 0; if (sscanf(buf, "%d %d %d", &x, &y, &setmedia) < 2) return; boxcmp("Media size", &mediasize, 0, 0, x, y); mediasize.val[2] = x; mediasize.val[3] = y; mediasize.flag |= 1; if (setmedia) mediasize.flag |= 2; pagelength = y * 72.0 / res; } static void t_cutat(const char *name, struct box *bp, char *buf) { int c[4], i; if (sscanf(buf, "%d %d %d %d", &c[0], &c[1], &c[2], &c[3]) < 4) return; boxcmp(name, bp, c[0], c[1], c[2], c[3]); for (i = 0; i < 4; i++) bp->val[i] = c[i]; bp->flag |= 1; } /*****************************************************************************/ void t_page ( int pg /* troff's current page number */ ) { static int lastpg = 0; /* last one we started - for ENDPAGE */ /* * * Called whenever we've finished the last page and want to get ready for the * next one. Also used at the end of each input file, so we have to be careful * about what's done. The first time through (up to the redirect(pg) call) output * goes to /dev/null because of the redirect(-1) call made in conv(). * * Adobe now recommends that the showpage operator occur after the page level * restore so it can be easily redefined to have side-effects in the printer's VM. * Although it seems reasonable I haven't implemented it, because it makes other * things, like selectively setting manual feed or choosing an alternate paper * tray, clumsy - at least on a per page basis. * */ if ( tf == stdout ) /* count the last page */ printed++; endtext(); /* print the last line? */ fprintf(tf, "_marks\n"); fprintf(tf, "cleartomark\n"); fprintf(tf, "showpage\n"); fprintf(tf, "restore\n"); fprintf(tf, "%s %d %d\n", ENDPAGE, lastpg, printed); redirect(pg); fprintf(tf, "%s %d %d\n", PAGE, pg, printed+1); fprintf(tf, "save\n"); fprintf(tf, "mark\n"); writerequest(printed+1, tf); fprintf(tf, "%d pagesetup\n", printed+1); setcolor(); lastpg = pg; /* for the next ENDPAGE comment */ hpos = vpos = 0; /* get ready for the next page */ reset(); /* force position and font stuff - later */ seenpage = TRUE; } /* End of t_page */ /*****************************************************************************/ void t_newline(void) { /* * * Just finished the last line. All we do is set the horizontal position to 0, * although even that probably isn't necessary. * */ hpos = 0; } /* End of t_newline */ /*****************************************************************************/ int t_size ( int n /* convert this to an internal size */ ) { int i; /* loop index */ /* * * Converts a point size into an internal size that can be used as an index into * pstab[]. The internal size is one plus the index of the least upper bound of * n in pstab[], or nsizes if n is larger than all the listed sizes. * */ if ( n <= pstab[0] ) return(1); else if (n >= pstab[nsizes-1]) return(nsizes); for ( i = 0; n > pstab[i]; i++ ) ; return(i+1); } /* End of t_size */ /*****************************************************************************/ void setsize ( int n, float f /* new internal size */ ) { /* * * Now using internal size n, where pstab[n-1] is the best available approximation * to the size troff asked for. * */ size = n; fractsize = f; lasthorscale = horscale = 1.0; } /* End of setsize */ /*****************************************************************************/ void t_fp ( int n, /* this position */ char *s, /* now has this font mounted */ char *si, /* its internal number */ void *a ) { /* * * Updates nfonts and the array that keeps track of the mounted fonts. Called from * loadfont() after an "x font pos font" command is read, and if pos is larger than * the current value assigned to nfonts we set gotspecial to FALSE to make sure * t_font() loads all the special fonts after the last legitimate font position. * */ fontname[n].name = s; fontname[n].number = atoi(si); fontname[n].afm = a; if ( n == lastfont ) /* force a call to t_sf() */ lastfont = lastsubfont = -1; if ( n > nfonts ) { /* got more positions */ nfonts = n; gotspecial = FALSE; gotregular = FALSE; } /* End if */ } /* End of t_fp */ /*****************************************************************************/ int t_font ( char *s /* use font in this position next */ ) { int n; /* * * Converts the string *s into an integer and checks to make sure it's a legal * font position. Also arranges to mount all the special fonts after the last * legitimate font (by calling loadspecial()), provided it hasn't already been * done. * */ n = atoi(s); if ( seenpage == TRUE ) { if ( n < 0 || n > nfonts ) error(FATAL, "illegal font position %d", n); if ( gotspecial == FALSE || gotregular == FALSE ) loadspecial(); } /* End if */ if (tracked) tracked = -1; track = 0; return(n); } /* End of t_font */ /*****************************************************************************/ static void sethorscale(char *buf) { horscale = atof(buf); } /*****************************************************************************/ static void t_track(char *buf) { int t; /* * Handling of track kerning. troff provides this parameter as a hint * only. dpost can use it in combination with the PostScript "ashow" * operator. When the variable "track" is not zero, the printer is * advised to perform tracking by the given amount. This relieves us * of the need to adjust the character position explicitly after each * character and thus greatly reduces the size of the output. * * Currently this is done in encodings 0, 4, and 5 only. */ if (sscanf(buf, "%d", &t) != 1) t = 0; if (t != lasttrack) { tracked = -1; } else if (t && tracked != -1) tracked = 1; track = t; } static void t_strack(void) { endtext(); fprintf(tf, "%d T\n", track); if (tf == stdout) { tracked = track != 0; lasttrack = track; } } /*****************************************************************************/ void setfont ( int n /* use the font mounted here */ ) { /* * * troff wants to use the font that's been mounted in position n. All we do here * is update the variable that keeps track of the current position. PostScript * font changes are handled in t_sf(), and are only generated right before we're * ready to print or draw something. * */ if ( n < 0 || n > NFONT ) error(FATAL, "illegal font %d", n); if ( fontname[n].name == NULL && fontname[n].number == 0) loaddefault(); if ( fontname[n].name == NULL && fontname[n].number == 0) error(FATAL, "font %d not loaded: check 'dpost' input for 'x font %d XXX' before 'f%d'", n, n, n); font = n; subfont = 0; lasthorscale = horscale = 1.0; } /* End of setfont */ /*****************************************************************************/ static void endvec(struct afmtab *a, int n) { fprintf(gf, "] def\n"); fprintf(gf, "\ /%s findfont\n\ dup length dict begin\n\ {1 index /FID ne {def} {pop pop} ifelse} forall\n\ /Encoding Encoding-@%s@%d def\n\ currentdict\n\ end\n", a->fontname, a->Font.intname, n); if (a->spec & SPEC_S) { fprintf(gf, "/%s-tmp-@%s", a->fontname, a->Font.intname); if (n) fprintf(gf, "@%d", n); fprintf(gf, " exch definefont pop\n"); fprintf(gf, "_Sdefsadj\n"); fprintf(gf, "/%s-tmp-@%s", a->fontname, a->Font.intname); if (n) fprintf(gf, "@%d", n); fprintf(gf, " /%s-@%s", a->fontname, a->Font.intname); if (n) fprintf(gf, "@%d", n); fprintf(gf, " Sdefs cf\n"); fprintf(gf, "/%s-tmp-@%s", a->fontname, a->Font.intname); if (n) fprintf(gf, "@%d", n); fprintf(gf, " undefinefont\n"); } else if (a->spec & SPEC_S1) { fprintf(gf, "/%s-tmp-@%s", a->fontname, a->Font.intname); if (n) fprintf(gf, "@%d", n); fprintf(gf, " exch definefont pop\n"); fprintf(gf, "/%s-tmp-@%s", a->fontname, a->Font.intname); if (n) fprintf(gf, "@%d", n); fprintf(gf, " /%s-@%s", a->fontname, a->Font.intname); if (n) fprintf(gf, "@%d", n); fprintf(gf, " S1defs cf\n"); fprintf(gf, "/%s-tmp-@%s", a->fontname, a->Font.intname); if (n) fprintf(gf, "@%d", n); fprintf(gf, " undefinefont\n"); } else if (n) fprintf(gf, "/%s-@%s@%d exch definefont pop\n", a->fontname, a->Font.intname, n); else fprintf(gf, "/%s-@%s exch definefont pop\n", a->fontname, a->Font.intname); fprintf(gf, "/@%s", a->Font.intname); if (n) fprintf(gf, "@%d", n); fprintf(gf, " /%s-@%s", a->fontname, a->Font.intname); if (n) fprintf(gf, "@%d", n); fprintf(gf, " def\n"); fprintf(gf, "/&%s", a->Font.intname); if (n) fprintf(gf, "@%d", n); fprintf(gf, " {@%s", a->Font.intname); if (n) fprintf(gf, "@%d", n); fprintf(gf, " F} bind def\n"); } static void printencsep(int *colp) { if (*colp >= 60) { putc('\n', gf); *colp = 0; } else { putc(' ', gf); (*colp)++; } } static int * printencvector(struct afmtab *a) { int i, j, k, n, col = 0, s; int *encmap = NULL; fprintf(gf, "/Encoding-@%s@0 [\n", a->Font.intname); col = 0; /* * First, write excess entries into the positions from 1 to 31 * for later squeezing of characters >= 0400. */ s = 128 - 32; encmap = calloc(256 + nchtab + a->nchars, sizeof *encmap); col += fprintf(gf, "/.notdef"); printencsep(&col); for (j = 1; j < 32; j++) { while (s < a->nchars + 128 - 32 + nchtab && ((k = a->fitab[s]) == 0 || a->nametab[k] == NULL)) s++; if (s < a->nchars + 128 - 32 + nchtab && (k = a->fitab[s]) != 0 && k < a->nchars && a->nametab[k] != NULL) { encmap[s - 128 + 32] = j; col += fprintenc(gf, a->nametab[k]); printencsep(&col); s++; } else { col += fprintf(gf, "/.notdef"); printencsep(&col); } } col += fprintf(gf, "/space"); printencsep(&col); for (i = 1; i < a->nchars + 128 - 32 + nchtab && i < 256 - 32; i++) { if (i < 128 - 32 && (k = a->fitab[i]) != 0 && k < a->nchars && a->nametab[k] != NULL) { col += fprintenc(gf, a->nametab[k]); printencsep(&col); } else { while (s < a->nchars + 128 - 32 + nchtab && ((k = a->fitab[s]) == 0 || a->nametab[k] == NULL)) s++; if (s < a->nchars + 128 - 32 + nchtab && (k = a->fitab[s]) != 0 && k < a->nchars && a->nametab[k] != NULL) { encmap[s - 128 + 32] = i + 32; col += fprintenc(gf, a->nametab[k]); printencsep(&col); s++; } else { col += fprintf(gf, "/.notdef"); printencsep(&col); } } } endvec(a, 0); n = 1; while (s < a->nchars + 128 - 32 + nchtab) { fprintf(gf, "/Encoding-@%s@%d [\n", a->Font.intname, n); col = 0; for (i = 0; i < 256; i++) { while (s < a->nchars + 128 - 32 + nchtab && ((k = a->fitab[s]) == 0 || a->nametab[k] == NULL)) s++; if (s < a->nchars + 128 - 32 + nchtab && (k = a->fitab[s]) != 0 && k < a->nchars && a->nametab[k] != NULL) { encmap[s - 128 + 32] = i | n << 8; col += fprintenc(gf, a->nametab[k]); printencsep(&col); s++; } else { col += fprintf(gf, "/.notdef"); printencsep(&col); } } endvec(a, n++); } return encmap; } /*****************************************************************************/ void t_sf(int forceflush) { int fnum; /* internal font number */ int cmd; /* command to execute */ /* * * Called whenever we need to use a new font or size. Only done right before we * print a character. The seenfonts[] array keeps track of the fonts we've used. * Helps manage host resident fonts and the DOCUMENTFONTS comment that's put out * at the end of the job. The array is indexed by internal number. Only works for * fonts that have internal numbers less than or equal to MAXINTERNAL. * */ if ( fontname[font].name == NULL ) return; endtext(); if ( (fnum = fontname[font].number) > MAXINTERNAL || fnum < 0 ) fnum = 0; if ( fnum > 0 && seenfonts[fnum] == 0 && hostfontdir != NULL ) { snprintf(temp, sizeof temp, "%s/%s", hostfontdir, fontname[font].name); if ( access(temp, 04) == 0 ) doglobal(temp); } /* End if */ cmd = 'f'; if (forceflush == 0) { if (font == lastfont && subfont == lastsubfont) cmd = 's'; else if (size == lastsize && fractsize == lastfractsize) cmd = 'F'; } if (horscale != 1.0) cmd = 'h'; if ( tf == stdout ) { lastfont = font; lastsubfont = subfont; lastsize = size; lastfractsize = fractsize; lasthorscale = horscale; if ( seenfonts[fnum] == 0 ) { documentfonts(); } if (fontname[font].afm && fontname[font].afm->encmap == NULL) fontname[font].afm->encmap = printencvector(fontname[font].afm); seenfonts[fnum] = 1; } /* End if */ if (cmd == 'f' || cmd == 's' || cmd == 'h') { if (size != FRACTSIZE) fprintf(tf, "%d ", pstab[size-1]); else fprintf(tf, "%g ", (double)fractsize); } if (fontname[font].afm && cmd == 'F') { if (subfont) fprintf(tf, "&%s@%d\n", fontname[font].afm->Font.intname, subfont); else fprintf(tf, "&%s\n", fontname[font].afm->Font.intname); cmd = 0; } else if (cmd == 'f' || cmd == 'F' || cmd == 'h') { if (fontname[font].afm && subfont) fprintf(tf, "@%s@%d ", fontname[font].afm->Font.intname, subfont); else if (fontname[font].afm) fprintf(tf, "@%s ", fontname[font].afm->Font.intname); else fprintf(tf, "%s ", fontname[font].name); } if (cmd == 'h') fprintf(tf, "%g ", horscale); if (cmd) fprintf(tf, "%c\n", cmd); if ( fontname[font].fontheight != 0 || fontname[font].fontslant != 0 ) { if (size != FRACTSIZE) fprintf(tf, "%d %g changefont\n", fontname[font].fontslant, (fontname[font].fontheight != 0) ? (double)fontname[font].fontheight : pstab[size-1]); else fprintf(tf, "%d %g changefont\n", fontname[font].fontslant, (fontname[font].fontheight != 0) ? (double)fontname[font].fontheight : (double)fractsize); } if (tracked < 0 || (tracked > 0 && forceflush)) t_strack(); } /* End of t_sf */ /*****************************************************************************/ void t_charht ( int n, float f /* use this as the character height */ ) { /* * * Remembers the requested height, from 'x H n'. Forces a call to t_sf(), which * is where the real work is done, by setting lastfont to -1. * */ if (n == FRACTSIZE) fontname[font].fontheight = f; else fontname[font].fontheight = (n == pstab[size-1]) ? 0 : n; lastfont = lastsubfont = -1; } /* End of t_charht */ /*****************************************************************************/ void t_slant ( int n /* slant characters this many degrees */ ) { /* * * Remembers the requested slant, from 'x X n'. Forces a call to t_sf(), which * is where the real work is done, by setting lastfont to -1. * */ fontname[font].fontslant = n; lastfont = lastsubfont = -1; } /* End of t_slant */ /*****************************************************************************/ void t_reset ( int c __unused /* pause or restart */ ) { /* * * Found an "x stop" or "x pause" command. Although nothing's done here we could * add code to reset everything so dpost could handle multiple files formatted for * different devices. * */ } /* End of t_reset */ /*****************************************************************************/ void t_trailer(void) { /* * * Called after we find an "x trailer" in the input file. Forcing out the last * page is done at the end of conv(), but probably belongs here. * */ endtext(); } /* End of t_trailer */ /*****************************************************************************/ void hgoto ( int n /* new horizontal position */ ) { /* * * Want to be at this absolute horizontal position next. Actual motion commands * are generated in oput(), charlib(), and the drawing routines. * */ hpos = n; } /* End of hgoto */ /*****************************************************************************/ void hmot ( int n /* move this far horizontally */ ) { /* * * Handles relative horizontal motion. troff's current positon, as recorded in * in hpos, is changed by n units. Usually called right before we're supposed to * print a character. * */ hpos += n; } /* End of hmot */ /*****************************************************************************/ void vgoto ( int n /* new vertical position */ ) { /* * * Moves vertically in troff's coordinate system to absolute position n. * */ vpos = n; } /* End of vgoto */ /*****************************************************************************/ void vmot ( int n /* move this far vertically */ ) { /* * * Handles relative vertical motion of n units in troff's coordinate system. * */ vpos += n; } /* End of vmot */ /*****************************************************************************/ void xymove ( int x, int y /* this is where we want to be */ ) { /* * * Makes sure the post-processor and printer agree about the current position. * */ hgoto(x); vgoto(y); fprintf(tf, "%d %d m\n", hpos, vpos); lastx = hpos; savey = lasty = vpos; } /* End of xymove */ /*****************************************************************************/ void put1s ( register char *s /* find and print this character */ ) { static int i = 0; /* last one we found - usually */ /* * * *s points to the start of a two character string that represents one of troff's * special characters. To print it we first look for *s in the chname[] array using * chtab[i] to find the string representing character i in chname[]. If the lookup * is successful we add 128 to i and ask put1() to finish printing the character. * We remember the index where the last character was found because requests to * print a special character often come in bunches (eg. drawing lines with \(ru). * */ if (s[0] == 'P' && s[1] == 'S' && s[2] != 0) { /* PostScript name */ int m; struct namecache *np; struct afmtab *a; if ((a = fontname[font].afm) != NULL && (np = afmnamelook(a, &s[2])) != NULL && ((m = np->fival[0]) != NOCODE || (m = np->fival[1]) != NOCODE)) { put1(m+32); return; } } if ( strcmp(s, &chname[chtab[i]]) != 0 ) for ( i = 0; i < nchtab; i++ ) if ( strcmp(&chname[chtab[i]], s) == 0 ) break; if ( i < nchtab ) put1(i + 128); else i = 0; } /* End of put1s */ /*****************************************************************************/ void put1 ( register int c /* want to print this character */ ) { register int i = 0; /* character code from fitab */ register int j; /* number of fonts we've checked so far */ register int k; /* font we're currently looking at */ int *pw = NULL; /* font widthtab and */ unsigned short *p = NULL; /* and codetab where c was found */ int code; /* code used to get c printed */ int ofont; /* font when we started */ /* * * Arranges to have character c printed. If c < 128 it's a simple ASCII character, * otherwise it's a special character. Things done here have to agree with the way * the font tables were built by makedev, and work as follows. First we subtract * 32 from c because the tables don't record the non-graphic ASCII characters. * If fitab[k][c] isn't zero the character is on font k and the value is an index * that can be used to recover width and character code data from the other two * tables. If fitab[k][c] is zero the character isn't defined on font k and we * check the next font, which is found as follows. The current font is the first * one we check, and it's followed by a circular search of all the remaining fonts * that starts with the first special font and skips font position 0. If character * c is found somewhere besides the current font we change to that font and use * fitab[k][c] to locate missing data in the other two tables. The width of the * character can be found at fontab[k][c] while codetab[k][c] is whatever we * need to tell the printer to have character c printed. lastc records the real * name of the character because it's lost by the time oput() gets called but * charlib() may need it. * * Took all the debugging stuff out because at least this part of the program is * reasonably solid. * */ lastc = c; /* charlib() needs the name not the code */ if ( (c -= 32) <= 0 ) /* probably never happens */ return; k = ofont = font; if ( fitab[k] && (i = fitab[k][c]) != 0 ) { /* it's on this font */ p = codetab[font]; pw = fontab[font]; } else if ( smnt > 0 ) { /* on special (we hope) */ for ( k=smnt, j=0; j <= nfonts; j++, k = (k+1) % (nfonts+1) ) { if ( k == 0 ) continue; if ( fitab[k] && (i = fitab[k][c]) != 0 ) { p = codetab[k]; pw = fontab[k]; setfont(k); break; } /* End if */ } /* End for */ } /* End else */ lastw = 0; if ( i != 0 && (code = p[i]) != 0 ) { if (size != FRACTSIZE) lastw = horscale * widthfac * ((pw[i] * pstab[size-1] + unitwidth/2) / unitwidth); else lastw = horscale * widthfac * (int)((pw[i] * fractsize + unitwidth/2) / unitwidth); if (widthfac == 1) /* ignore fractional parts since troff */ lastw = (int)lastw; /* does the same */ if (track && encoding != MAXENCODING+2) lastw += track; if (code == NOCODE && fontname[k].afm) code = c + 32; oput(code); } /* End if */ if ( font != ofont ) setfont(ofont); } /* End of put1 */ /*****************************************************************************/ static void oprep(int stext) { if ( textcount > MAXSTACK ) /* don't put too much on the stack? */ endtext(); if ( font != lastfont || size != lastsize || subfont != lastsubfont || (size == FRACTSIZE && fractsize != lastfractsize) || horscale != lasthorscale) { t_sf(0); } if (tracked < 0) t_strack(); if ( vpos != lasty ) endline(); if (stext) { starttext(); if ( fabsf(hpos - lastx) > slop ) endstring(); } wordspace = 0; } void oput ( int c /* want to print this character */ ) { /* * * Arranges to print the character whose code is c in the current font. All the * actual positioning is done here, in charlib(), or in the drawing routines. * */ if ( asciichar(c) && printchar(c) ) switch ( c ) { case '(': case ')': case '\\': if (encoding != 5) addchar('\\'); default: addchar(c); } /* End switch */ else if ( c > 040 ) addoctal(c); else charlib(c); lastx += lastw; } /* End of oput */ /*****************************************************************************/ void starttext(void) { /* * Called whenever we want to be sure we're ready to start collecting characters * for the next call to PostScript procedure t (ie. the one that prints them). If * textcount is positive we've already started, so there's nothing to do. The more * complicated encoding schemes save text strings in the strings[] array and need * detailed information about the strings when they're written to the output file * in endtext(). * */ if ( textcount < 1 ) { switch ( encoding ) { case 0: case 1: case 4: putc('(', tf); charcount = 1; break; case 5: strptr = strings; break; case 2: case 3: strptr = strings; spacecount = 0; line[1].str = strptr; line[1].dx = 0; line[1].spaces = 0; line[1].start = hpos; line[1].width = 0; charcount = 0; break; case MAXENCODING+1: /* reverse video */ if ( lastend == -1 ) lastend = hpos; putc('(', tf); charcount = 1; break; case MAXENCODING+2: /* follow a funny baseline */ putc('(', tf); charcount = 1; break; } /* End switch */ textcount = 1; lastx = stringstart = hpos; laststrstart = INT_MIN; } /* End if */ } /* End of starttext */ /*****************************************************************************/ void endtext(void) { char buf[STRINGSPACE+100]; int i; /* loop index */ int n, m; /* * * Generates a call to the PostScript procedure that processes all the text we've * accumulated - provided textcount is positive. * */ if ( textcount > 0 ) { /* started working on some text */ switch ( encoding ) { case 0: fprintf(tf, ")%d t\n", stringstart); break; case 4: if (laststrstart != INT_MIN) fprintf(tf, ")%d %d t\n", stringstart - laststrstart, stringstart); else fprintf(tf, ")%d t\n", stringstart); break; case 5: putstring(strings, strptr - strings, tf); strptr = strings; if (laststrstart != INT_MIN) putint(stringstart - laststrstart, tf); putint(stringstart, tf); putc('t', tf); putc('\n', tf); break; case 1: fprintf(tf, ")%d %d t\n", stringstart, lasty); break; case 2: *strptr = '\0'; line[textcount].width = lastx - line[textcount].start; if ( spacecount != 0 || textcount != 1 ) { n = 0; for ( i = textcount; i > 0; i-- ) { m = snprintf(buf, sizeof buf, "(%s)%d %d", line[i].str, line[i].spaces, line[i].width); if (i < textcount && n + m >= 80) { putc('\n', tf); n = 0; } fputs(buf, tf); n += m; } if (lasty != savey) fprintf(tf, " %d %d %d t\n", textcount, stringstart, lasty); else fprintf(tf, " %d %d u\n", textcount, stringstart); } else { if (lasty != savey) fprintf(tf, "(%s)%d %d w\n", line[1].str, stringstart, lasty); else fprintf(tf, "(%s)%d v\n", line[1].str, stringstart); } savey = lasty; break; case 3: *strptr = '\0'; if ( spacecount != 0 || textcount != 1 ) { n = 0; for ( i = textcount; i > 0; i-- ) { m = snprintf(buf, sizeof buf, "(%s)%d", line[i].str, line[i].dx); if (i < textcount && n + m >= 80) { putc('\n', tf); n = 0; } fputs(buf, tf); n += m; } if (lasty != savey) fprintf(tf, " %d %d %d t\n", textcount, stringstart, lasty); else fprintf(tf, " %d %d u\n", textcount, stringstart); } else { if (lasty != savey) fprintf(tf, "(%s)%d %d w\n", line[1].str, stringstart, lasty); else fprintf(tf, "(%s)%d v\n", line[1].str, stringstart); } savey = lasty; break; case MAXENCODING+1: fprintf(tf, ")%d ", stringstart); fprintf(tf, "%d %d drawrvbox ", lastend - rvslop, (int)(lastx + .5) + rvslop); fprintf(tf, "t\n"/*, stringstart*/); lastend = (lastx + .5) + 2 * rvslop; break; case MAXENCODING+2: fprintf(tf, ")%d %d t\n", stringstart, lasty); break; } /* End switch */ charcount = 0; } /* End if */ textcount = 0; } /* End of endtext */ /*****************************************************************************/ void endstring(void) { int dx; /* * * Horizontal positions are out of sync. End the last open string, adjust the * printer's position, and start a new string. Assumes we've already started * accumulating text. * */ switch ( encoding ) { case 4: if (laststrstart != INT_MIN) charcount += fprintf(tf, ")%d", stringstart - laststrstart); else { putc(')', tf); charcount++; } laststrstart = stringstart; goto nx; case 5: putstring(strings, strptr - strings, tf); strptr = strings; charcount++; if (laststrstart != INT_MIN) charcount += putint(stringstart - laststrstart, tf); laststrstart = stringstart; textcount++; lastx = stringstart = hpos; break; case 0: case 1: charcount += fprintf(tf, ")%d", stringstart); nx: if (charcount >= 60) { putc('\n', tf); charcount = 0; } putc('(', tf); charcount++; textcount++; lastx = stringstart = hpos; break; case 2: case 3: if (!wordspace) { endtext(); starttext(); break; } dx = hpos - lastx; if ( spacecount++ == 0 ) line[textcount].dx = dx; if ( line[textcount].dx != dx ) { *strptr++ = '\0'; line[textcount].width = lastx - line[textcount].start; line[++textcount].str = strptr; *strptr++ = ' '; line[textcount].dx = dx; line[textcount].start = lastx; line[textcount].width = 0; line[textcount].spaces = 1; charcount = 1; } else { *strptr++ = ' '; line[textcount].spaces++; charcount++; } /* End else */ lastx += dx; break; case MAXENCODING+1: charcount += fprintf(tf, ")%d", stringstart); if (charcount >= 60) { putc('\n', tf); charcount = 0; } putc('(', tf); charcount++; textcount++; lastx = stringstart = hpos; break; case MAXENCODING+2: endtext(); starttext(); break; } /* End switch */ } /* End of endstring */ /*****************************************************************************/ void endline(void) { /* * * The vertical position has changed. Dump any accumulated text, then adjust * the printer's vertical position. * */ endtext(); if ( encoding == 0 || encoding == 4 || encoding == MAXENCODING+1 ) { fprintf(tf, "%d %d m\n", hpos, vpos); savey = vpos; } else if (encoding == 5) { putint(hpos, tf); putint(vpos, tf); putc('m', tf); putc('\n', tf); } lastx = stringstart = lastend = hpos; lasty = vpos; } /* End of endline */ /*****************************************************************************/ void addchar ( int c /* next character in current string */ ) { /* * * Does whatever is needed to add character c to the current string. * */ static int lastc; subfont = 0; if (lastc != '\\') oprep(1); lastc = c; switch ( encoding ) { case 0: case 1: case 4: putc(c, tf); if (charcount++ >= 72 && c != '\\') { putc('\\', tf); putc('\n', tf); charcount = 0; } break; case 5: *strptr++ = c; break; case 2: case 3: *strptr++ = c; if (charcount++ >= 72 && c != '\\') { *strptr++ = '\\'; *strptr++ = '\n'; charcount = 0; } break; case MAXENCODING+1: case MAXENCODING+2: putc(c, tf); if (charcount++ >= 72 && c != '\\') { putc('\\', tf); putc('\n', tf); charcount = 0; } break; } /* End switch */ } /* End of addchar */ /*****************************************************************************/ void addoctal ( int c /* add it as an octal escape */ ) { int n; /* * * Adds c to the current string as an octal escape \ddd. * * * If c is not a byte, try to squeeze it into the control area. */ oprep(0); if (c >= 128 && fontname[font].afm && fontname[font].afm->encmap) { c = fontname[font].afm->encmap[c - 128]; subfont = c >> 8; c &= 0377; } else subfont = 0; oprep(1); switch ( encoding ) { case 0: case 1: case 4: charcount += fprintf(tf, "\\%03o", c); if (charcount >= 72) { putc('\\', tf); putc('\n', tf); charcount = 0; } break; case 5: *strptr++ = c; break; case 2: case 3: snprintf(strptr, sizeof strings - (strptr - strings), "\\%03o", c); n = strlen(strptr); strptr += n; charcount += n; if (charcount >= 72) { *strptr++ = '\\'; *strptr++ = '\n'; charcount = 0; } break; case MAXENCODING+1: case MAXENCODING+2: charcount += fprintf(tf, "\\%03o", c); if (charcount >= 72) { putc('\\', tf); putc('\n', tf); charcount = 0; } break; } /* End switch */ } /* End of addoctal */ /*****************************************************************************/ void charlib ( int code /* either 1 or 2 */ ) { char *name; /* name of the character */ char tname[10]; /* in case it's a single ASCII character */ const char *filename; /* real file name */ /* * * Called from oput() for characters having codes less than 040. Special files * that define PostScript procedures for certain characters can be found in * directory *fontdir/devpost/charlib. If there's a file that has the same name as * the character we're trying to print it's copied to the output file, otherwise * nothing, except some positioning, is done. * * All character definitions are only made once. Subsequent requests to print the * character generate a call to a procedure that begins with the prefix build_ and * ends with the character's name. Special characters that are assigned codes * other than 1 are assumed to have additional data files that should be copied * to the output file immediately after the build_ call. Those data files should * end in the suffix .map, and usually will be a hex representation of a bitmap. * */ subfont = 0; oprep(1); endtext(); if ( lastc < 128 ) { /* just a simple ASCII character */ snprintf(tname, sizeof tname, "%.3o", lastc); name = tname; } else name = &chname[chtab[lastc - 128]]; /* * This is just a kludge of course. But since only one file exists which * needs a name mapping, no more general method had been implemented. */ if (*name == 'L' && name[1] == 'H' && !name[2]) filename = "LH_uc"; else filename = name; if ( downloaded[lastc] == 0 ) { snprintf(temp, sizeof temp, "%s/dev%s/charlib/%s", fontdir, realdev, filename); if ( access(temp, 04) == 0 && doglobal(temp) == TRUE ) { downloaded[lastc] = 1; t_sf(0); } /* End if */ } /* End if */ if ( downloaded[lastc] == 1 ) { xymove(hpos, vpos); fprintf(tf, "%d build_%s\n", (int) lastw, name); if ( code != 1 ) { /* get the bitmap or whatever */ snprintf(temp, sizeof temp, "%s/dev%s/charlib/%s.map", fontdir, realdev, name); if ( access(temp, 04) == 0 && tf == stdout ) cat(temp, tf); } /* End if */ fprintf(tf, "%d %d m\n", stringstart = hpos + lastw, vpos); savey = vpos; } /* End if */ } /* End of charlib */ /*****************************************************************************/ int doglobal ( const char *name /* copy this to the output - globally */ ) { int val = FALSE; /* returned to the caller */ /* * * Copies file *name to the output file and brackets it with whatever commands are * needed to have it exported to the global environment. TRUE is returned if we * successfully add file *name to the output file. * * Actually, all files included this way are procsets, so they go into * the resource section of the PostScript output and not in the global * setup file. * */ if ( tf == stdout ) { val = cat(name, rf); reset(); } /* End if */ return(val); } /* End of doglobal */ /*****************************************************************************/ void documentfont(const char *name) { static FILE *fp_out; /* PostScript name added to this file */ static int pos; static struct fn { struct fn *next; const char *name; } *fn; struct fn *ft; int n; if ( temp_file == NULL ) /* generate a temp file name */ if ( (temp_file = tempname("dpost")) == NULL ) return; if ( fp_out == NULL && (fp_out = fopen(temp_file, "w")) == NULL ) return; for (ft = fn; ft; ft = ft->next) if (strcmp(name, ft->name) == 0) return; ft = calloc(1, sizeof *ft); ft->name = strdup(name); ft->next = fn; fn = ft; if ( docfonts++ == 0 ) pos += fprintf(fp_out, "%s", DOCUMENTFONTS); else { n = strlen(name); if (pos + n >= 80) { fprintf(fp_out, "\n%s", CONTINUECOMMENT); pos = 0; } } pos += fprintf(fp_out, " %s", name); fflush(fp_out); t_dosupply(name); } void documentfonts(void) { FILE *fp_in = NULL; /* PostScript font name read from here */ /* * * Whenever a new font is used we try to record the appropriate PostScript font * name in *temp_file for the DOCUMENTFONTS comment that's put out in done(). * By default PostScript font names are found in /usr/lib/font/devpost. Fonts * that have a .name file are recorded in *temp_file. The first string in that * file is expected to be that font's (long) PostScript name. * */ snprintf(temp, sizeof temp, "%s/dev%s/%s.name", fontdir, realdev, fontname[font].name); if (fontname[font].afm == NULL && (fp_in = fopen(temp, "r")) != NULL ) { if ( sget(temp, sizeof temp, fp_in) == 1 ) { documentfont(temp); } /* End if */ if (fp_in != NULL) fclose(fp_in); } else if (fontname[font].afm != NULL){ documentfont(fontname[font].afm->fontname); } /* End if */ } /* End of documentfonts */ /*****************************************************************************/ void redirect ( int pg /* next page we're printing */ ) { static FILE *fp_null = NULL; /* if output is turned off */ /* * * If we're not supposed to print page pg, tf will be directed to /dev/null, * otherwise output goes to stdout. * */ if ( pg >= 0 && in_olist(pg) == ON ) tf = stdout; else if ( (tf = fp_null) == NULL ) tf = fp_null = fopen("/dev/null", "w"); } /* End of redirect */ /*****************************************************************************/ static char * mbs2pdf(char *mp) { char *ustr, *tp; int c, i, sz; #ifdef EUC int n = 0, w; wchar_t wc; #endif for (tp = mp; *tp && (*tp&~0177) == 0 && *tp&~037; tp++); if (*tp == 0) { ustr = malloc(sz = 16); *ustr = '('; c = i = 1; while (*mp) { switch (*mp) { case '(': case ')': case '\\': ustr[i++] = '\\'; c++; /*FALLTHRU*/ default: ustr[i++] = *mp++; c++; } if (i + 4 >= sz) ustr = realloc(ustr, sz += 16); if (c >= 60) { ustr[i++] = '\\'; ustr[i++] = '\n'; c = 0; } } ustr[i++] = ')'; ustr[i++] = 0; return ustr; } #ifdef EUC ustr = malloc(sz = 16); c = i = snprintf(ustr, sz, " 0xFFFF) { error(NON_FATAL, "only BMP values allowed for PDFMark"); continue; } if (i + 8 >= sz) ustr = realloc(ustr, sz += 16); w = snprintf(&ustr[i], sz - i * sizeof(*ustr), "%04X", (int)wc); i += w; c += w; if (c >= 60) { ustr[i++] = '\n'; c = 0; } } ustr[i++] = '>'; ustr[i] = 0; return ustr; #else /* !EUC */ error(NON_FATAL, "this instance of dpost only supports ASCII with PDFMark"); return NULL; #endif /* !EUC */ } static void t_pdfmark(char *buf) { char *bp, *tp; int n; while (spacechar(*buf&0377)) buf++; for (bp = buf; *bp && !spacechar(*bp&0377); bp++); *bp++ = '\0'; while (spacechar(*bp&0377)) bp++; for (tp = bp; *tp; tp++) if (*tp == '\n') { *tp = '\0'; break; } if (strcmp(buf, "Author") == 0) Author = mbs2pdf(bp); else if (strcmp(buf, "Title") == 0) Title = mbs2pdf(bp); else if (strcmp(buf, "Subject") == 0) Subject = mbs2pdf(bp); else if (strcmp(buf, "Keywords") == 0) Keywords = mbs2pdf(bp); else if (strcmp(buf, "Bookmark") == 0 || strcmp(buf, "BookmarkClosed") == 0) { n = strtol(bp, &bp, 10); while (spacechar(*bp&0377)) bp++; if (n < 0 || n > MAXBOOKMARKLEVEL) { error(NON_FATAL, "invalid PDFMark Bookmark level %d," "maximum is %d\n", n, MAXBOOKMARKLEVEL); return; } Bookmarks = realloc(Bookmarks, ++nBookmarks*sizeof *Bookmarks); Bookmarks[nBookmarks-1].level = n; Bookmarks[nBookmarks-1].Title = mbs2pdf(bp); Bookmarks[nBookmarks-1].title = strdup(bp); Bookmarks[nBookmarks-1].Count = 0; Bookmarks[nBookmarks-1].closed = strcmp(buf, "BookmarkClosed") == 0; endtext(); fprintf(tf, "[ /Dest /Bookmark$%ld\n" " /View [/XYZ -4 %g 0]\n" "/DEST pdfmark\n", (long)nBookmarks - 1, pagelength - (lasty >= 0 ? vpos * 72.0 / res : -4)); } else error(NON_FATAL, "unknown PDFMark attribute %s", buf); } static void orderbookmarks(void) { int counts[MAXBOOKMARKLEVEL+1]; int refs[MAXBOOKMARKLEVEL+1]; size_t i, j, k, t; - int lvl = 0; + size_t lvl = 0; /* * Generate the Count parameter from the given levels. */ memset(&counts, 0, sizeof counts); for (i = 0; i <= MAXBOOKMARKLEVEL; i++) refs[i] = -1; for (i = 0; i <= nBookmarks; i++) { k = i < nBookmarks ? Bookmarks[i].level : 0; if (i == nBookmarks || k <= lvl) { for (j = k+1; j <= MAXBOOKMARKLEVEL; j++) { t = j - 1; if (refs[t] >= 0) { Bookmarks[refs[t]].Count += counts[j]; refs[t] = -1; } counts[j] = 0; } } if (k > 0 && refs[k-1] < 0) { while (k > 0 && refs[k-1] < 0) k--; error(NON_FATAL, "PDFMark Bookmark \"%s\" at level %d " "has no direct parent, " "using level %d\n", Bookmarks[i].title, Bookmarks[i].level, k); } counts[k]++; refs[k] = i; lvl = k; } } static void t_locale(char *lp) { static char *savlp; if (savlp && strcmp(lp, savlp) == 0) return; free(savlp); savlp = malloc(strlen(lp) + 1); sscanf(lp, "%s", savlp); setlocale(LC_CTYPE, savlp); mb_cur_max = MB_CUR_MAX; } static void pref(const char *lp, FILE *fp) { int c; while ((c = *lp++ & 0377) != 0 && c != '\n') { if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) putc(c, fp); else fprintf(fp, "$%2x", c); } } static void pref_uri(const char *lp, FILE *fp) { int c; /* Don't do any escaping here to avoid double-escaping. */ while ((c = *lp++ & 0377) != 0 && c != '\n') { putc(c, fp); } } static void t_anchor(char *lp) { int v; v = strtol(lp, &lp, 10); if ((lp = strchr(lp, ' ')) != NULL) { lp++; endtext(); fprintf(tf, "[ /Dest /Anchor$"); pref(lp, tf); fprintf(tf, "\n" " /View [/XYZ -4 %g 0]\n" "/DEST pdfmark\n", pagelength - (v >= 0 ? v * 72.0 / res : -4)); } } static char linkcolor[60] = "0 0 1"; static char linkborder[60] = "0 0 1"; static char * t_linkborderstyle(char *arg) { char c, *s; s = arg; for (s = arg; (c = *s) && c != '\n'; s++); *s = 0; return strdup(arg); } static void t_link(char *lp) { int llx, lly, urx, ury; llx = strtol(lp, &lp, 10); if (*lp) { while (*lp == ',') lp++; lly = strtol(lp, &lp, 10); if (*lp) { while (*lp == ',') lp++; urx = strtol(lp, &lp, 10); if (*lp) { while (*lp == ',') lp++; ury = strtol(lp, &lp, 10); if ((lp = strchr(lp, ' ')) != NULL) { lp++; endtext(); fprintf(tf, "[ /Dest /Anchor$"); pref(lp, tf); fprintf(tf, "\n" "/Rect [%d %d %d %d]\n" "/Color [%s]\n", llx, -lly, urx, -ury, linkcolor); if (linkborderstyle) fprintf(tf, "/BS << %s >>\n", linkborderstyle); else fprintf(tf, "/Border [%s]\n", linkborder); fprintf(tf, "/Subtype /Link\n" "/ANN pdfmark\n"); } } } } } static void t_linkcolor(char *lp) { float r, g, b; r = strtod(lp, &lp); g = strtod(lp, &lp); b = strtod(lp, &lp); snprintf(linkcolor, sizeof linkcolor, "%g %g %g", r, g, b); } static void t_linkborder(char *lp) { float bx, by, c; bx = strtod(lp, &lp); by = strtod(lp, &lp); c = strtod(lp, &lp); snprintf(linkborder, sizeof linkborder, "%g %g %g", bx, by, c); free(linkborderstyle); linkborderstyle = NULL; } static char ulinkcolor[60] = "0 0 1"; static char ulinkborder[60] = "0 0 1"; static void t_ulink(char *lp) { int llx, lly, urx, ury; llx = strtol(lp, &lp, 10); if (*lp) { while (*lp == ',') lp++; lly = strtol(lp, &lp, 10); if (*lp) { while (*lp == ',') lp++; urx = strtol(lp, &lp, 10); if (*lp) { while (*lp == ',') lp++; ury = strtol(lp, &lp, 10); if ((lp = strchr(lp, ' ')) != NULL) { lp++; endtext(); fprintf(tf, "[ /Rect [%d %d %d %d]\n" "/Color [%s]\n", llx, -lly, urx, -ury, ulinkcolor); if (ulinkborderstyle) fprintf(tf, "/BS << %s >>\n", ulinkborderstyle); else fprintf(tf, "/Border [%s]\n", ulinkborder); fprintf(tf, "/Action << /Subtype /URI\n" "/URI ("); pref_uri(lp, tf); fprintf(tf, ") >>\n" "/Subtype /Link\n" "/ANN pdfmark\n"); } } } } } static void t_ulinkcolor(char *lp) { float r, g, b; r = strtod(lp, &lp); g = strtod(lp, &lp); b = strtod(lp, &lp); snprintf(ulinkcolor, sizeof ulinkcolor, "%g %g %g", r, g, b); } static void t_ulinkborder(char *lp) { float bx, by, c; bx = strtod(lp, &lp); by = strtod(lp, &lp); c = strtod(lp, &lp); snprintf(ulinkborder, sizeof ulinkborder, "%g %g %g", bx, by, c); free(ulinkborderstyle); ulinkborderstyle = NULL; } Index: vendor/heirloom-doctools/dist/troff/troff.d/dpost.d/misc.c =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/dpost.d/misc.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/dpost.d/misc.c (revision 310550) @@ -1,388 +1,389 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright 2002 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* from OpenSolaris "misc.c 1.6 05/06/08 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)misc.c 1.14 (gritter) 12/25/06 */ /* * * A few general purpose routines. * */ #include #include #include #include #include #include #include #include "global.h" #include "gen.h" /* a few general purpose definitions */ #include "ext.h" /* external variable declarations */ #include "path.h" #include "asciitype.h" +void errprint(char *fmt, ...); static size_t nolist = 0; /* number of specified ranges */ static int olist[512]; /* processing range pairs */ void error(int kind, const char *mesg, ...) { /* * * Called when we've run into some kind of program error. *mesg is printed using * the control string arguments a?. We'll quit if we're not ignoring errors and * kind is FATAL. * */ if ( mesg != NULL && *mesg != '\0' ) { va_list ap; fprintf(stderr, "%s: ", prog_name); va_start(ap, mesg); vfprintf(stderr, mesg, ap); va_end(ap); if ( lineno > 0 ) fprintf(stderr, " (line %ld)", lineno); if ( position > 0 ) fprintf(stderr, " (near byte %ld)", position); if ( printed > 0 ) fprintf(stderr, " (page %d)", printed); putc('\n', stderr); } /* End if */ if ( kind == FATAL && ignore == OFF ) { if ( temp_file != NULL ) unlink(temp_file); exit(x_stat | 01); } /* End if */ } /* End of error */ /*****************************************************************************/ /* for the AFM handling functions from troff */ static void verrprint(char *fmt, va_list ap) { fprintf(stderr, "%s: ", prog_name); vfprintf(stderr, fmt, ap); putc('\n', stderr); } void errprint(char *fmt, ...) { va_list ap; va_start(ap, fmt); verrprint(fmt, ap); va_end(ap); } /*****************************************************************************/ void out_list ( char *str /* process ranges in this string */ ) { int start, stop; /* end points */ /* * * Called to get the processing ranges that were specified by using the -o option. * The range syntax should be identical to the one used in nroff and troff. * */ while ( *str && nolist < sizeof(olist) - 2 ) { start = stop = str_convert(&str, 0); if ( *str == '-' && *str++ ) stop = str_convert(&str, 9999); if ( start > stop ) error(FATAL, "illegal range %d-%d", start, stop); olist[nolist++] = start; olist[nolist++] = stop; if ( *str != '\0' ) str++; } /* End while */ olist[nolist] = 0; } /* End of out_list */ /*****************************************************************************/ int in_olist ( int num /* should we print this page? */ ) { size_t i; /* just a loop index */ /* * * Returns ON if num represents a page that we're supposed to print. If no ranges * were selected nolist will be 0 and we'll print everything. * */ if ( nolist == 0 ) /* everything's included */ return(ON); for ( i = 0; i < nolist; i += 2 ) if ( num >= olist[i] && num <= olist[i+1] ) return(ON); return(OFF); } /* End of in_olist */ /*****************************************************************************/ int cat ( const char *file, /* copy this file to out */ FILE *out ) { int fd_in; /* for the input */ int fd_out; /* and output files */ char buf[512]; /* buffer for reads and writes */ int count; /* number of bytes we just read */ /* * * Copies *file to stdout - mostly for the prologue. Returns FALSE if there was a * problem and TRUE otherwise. * */ fflush(out); if ( (fd_in = open(file, O_RDONLY)) == -1 ) return(FALSE); fd_out = fileno(out); while ( (count = read(fd_in, buf, sizeof(buf))) > 0 ) write(fd_out, buf, count); close(fd_in); return(TRUE); } /* End of cat */ /*****************************************************************************/ int str_convert ( char **str, /* get next number from this string */ int err /* value returned on error */ ) { int i; /* just a loop index */ int c; /* * * Gets the next integer from **str and returns its value to the caller. If **str * isn't an integer err is returned. *str is updated after each digit is processed. * */ if ( ! isdigit(c = **str) ) /* something's wrong */ return(err); for ( i = 0; isdigit(c = **str); *str += 1 ) i = 10 * i + c - '0'; return(i); } /* End of str_convert */ /*****************************************************************************/ void interrupt( int sig __unused) /* signal that we caught */ { /* * * Called when we get a signal that we're supposed to catch. * */ if ( temp_file != NULL ) unlink(temp_file); exit(1); } /* End of interrupt */ /*****************************************************************************/ char * tempname(const char *sfx) { size_t l = strlen(TEMPDIR) + strlen(sfx) + 10; char *pat = malloc(l); snprintf(pat, l, "%s/%sXXXXXX", TEMPDIR, sfx); if (close(mkstemp(pat)) < 0) return NULL; return pat; } /*****************************************************************************/ #define LSIZE 512 int psskip(size_t n, FILE *fp) { return fseek(fp, n, SEEK_CUR); } char *psgetline(char **line, size_t *linesize, size_t *llen, FILE *fp) { int c; size_t n = 0; int nl = 0; if (*line == NULL || *linesize < LSIZE + n + 1) *line = realloc(*line, *linesize = LSIZE + n + 1); for (;;) { if (n >= *linesize - LSIZE / 2) *line = realloc(*line, *linesize += LSIZE); c = getc(fp); if (c != EOF) { if (nl && c != '\n') { ungetc(c, fp); break; } (*line)[n++] = c; (*line)[n] = '\0'; if (c == '\n') break; if (c == '\r') nl = 1; } else { if (n > 0) break; else return NULL; } } if (llen) *llen = n; return *line; } /*****************************************************************************/ int sget(char *buf, size_t size, FILE *fp) { int c; size_t n = 0; do c = getc(fp); while (spacechar(c)); if (c != EOF) do { if (n+1 < size) buf[n++] = c; c = getc(fp); } while (c != EOF && !spacechar(c)); ungetc(c, fp); buf[n] = 0; return n > 1 ? 1 : c == EOF ? EOF : 0; } Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/B =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/B (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/B (nonexistent) @@ -1,2 +0,0 @@ -name B -fontname Times-Bold Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/C =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/C (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/C (nonexistent) @@ -1,2 +0,0 @@ -name C -fontname Courier Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CB =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CB (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CB (nonexistent) @@ -1,2 +0,0 @@ -name CB -fontname Courier-Bold Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/H =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/H (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/H (nonexistent) @@ -1,2 +0,0 @@ -name H -fontname Helvetica Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/I =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/I (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/I (nonexistent) @@ -1,2 +0,0 @@ -name I -fontname Times-Italic Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/HB =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/HB (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/HB (nonexistent) @@ -1,2 +0,0 @@ -name HB -fontname Helvetica-Bold Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/BI =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/BI (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/BI (nonexistent) @@ -1,2 +0,0 @@ -name BI -fontname Times-BoldItalic Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CI =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CI (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CI (nonexistent) @@ -1,2 +0,0 @@ -name CI -fontname Courier-Oblique Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/HI =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/HI (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/HI (nonexistent) @@ -1,2 +0,0 @@ -name HI -fontname Helvetica-Oblique Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/R =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/R (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/R (nonexistent) @@ -1,2 +0,0 @@ -name R -fontname Times-Roman Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/S =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/S (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/S (nonexistent) @@ -1,2 +0,0 @@ -name S -fontname Symbol Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CR =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CR (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CR (nonexistent) @@ -1,2 +0,0 @@ -name CR -fontname Courier Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CW =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CW (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CW (nonexistent) @@ -1,2 +0,0 @@ -name CW -fontname Courier Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/B.in =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/B.in (nonexistent) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/B.in (revision 310550) @@ -0,0 +1,2 @@ +name B +fontname Times-Bold Property changes on: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/B.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/BI.in =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/BI.in (nonexistent) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/BI.in (revision 310550) @@ -0,0 +1,2 @@ +name BI +fontname Times-BoldItalic Property changes on: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/BI.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/C.in =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/C.in (nonexistent) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/C.in (revision 310550) @@ -0,0 +1,2 @@ +name C +fontname Courier Property changes on: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/C.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CB.in =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CB.in (nonexistent) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CB.in (revision 310550) @@ -0,0 +1,2 @@ +name CB +fontname Courier-Bold Property changes on: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CB.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CI.in =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CI.in (nonexistent) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CI.in (revision 310550) @@ -0,0 +1,2 @@ +name CI +fontname Courier-Oblique Property changes on: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CI.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CR.in =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CR.in (nonexistent) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CR.in (revision 310550) @@ -0,0 +1,2 @@ +name CR +fontname Courier Property changes on: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CR.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CW.in =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CW.in (nonexistent) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CW.in (revision 310550) @@ -0,0 +1,2 @@ +name CW +fontname Courier Property changes on: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/CW.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/H.in =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/H.in (nonexistent) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/H.in (revision 310550) @@ -0,0 +1,2 @@ +name H +fontname Helvetica Property changes on: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/H.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/HB.in =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/HB.in (nonexistent) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/HB.in (revision 310550) @@ -0,0 +1,2 @@ +name HB +fontname Helvetica-Bold Property changes on: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/HB.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/HI.in =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/HI.in (nonexistent) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/HI.in (revision 310550) @@ -0,0 +1,2 @@ +name HI +fontname Helvetica-Oblique Property changes on: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/HI.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/I.in =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/I.in (nonexistent) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/I.in (revision 310550) @@ -0,0 +1,2 @@ +name I +fontname Times-Italic Property changes on: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/I.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/Makefile.mk =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/Makefile.mk (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/Makefile.mk (revision 310550) @@ -1,23 +1,27 @@ BIN= makefont OBJS= $(BIN).o FONTS= R I B BI C CW CR CI CB H HI HB S -all: $(BIN) +.SUFFIXES: .in +.in: ${BIN} + cat $< > $@ + ./${BIN} $@ >> $@ +all: $(BIN) ${FONTS} + install: d=$(ROOT)$(FNTDIR)/devhtml; test -d $$d || mkdir $$d; \ install -m 644 CHAR DESC $$d/; \ echo charset >> $$d/DESC; \ sed '1,2d;s/[[:space:]].*//' charset >> $$d/DESC; \ for i in $(FONTS); do \ install -m 644 $$i $$d/; \ - ./$(BIN) $$i >> $$d/$$i; \ done clean: - rm -rf $(BIN) $(OBJS) + rm -rf $(BIN) $(OBJS) $(FONTS) mrproper: clean $(BIN): $(OBJS) $(CC) $(_CFLAGS) $(_LDFLAGS) $(OBJS) -o $@ Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/R.in =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/R.in (nonexistent) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/R.in (revision 310550) @@ -0,0 +1,2 @@ +name R +fontname Times-Roman Property changes on: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/R.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/S.in =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/S.in (nonexistent) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/S.in (revision 310550) @@ -0,0 +1,2 @@ +name S +fontname Symbol Property changes on: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/S.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/makefont.c =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/makefont.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/font/devhtml/makefont.c (revision 310550) @@ -1,195 +1,197 @@ /* * Copyright (c) 2015, Carsten Kunze * 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #include #include #include #include #include #include static int find_font(char **, ssize_t *); static char *get_word(char **, ssize_t *, int *); static void next_line(char **, ssize_t *); static void out_font(char *, ssize_t, int); static ssize_t read_file(char **); static int usage(void); static char *progname; static char *fontname; static char *charfile = "charset"; int main(int argc, char **argv) { int i; char *b, *b0; ssize_t s; progname = argv[0]; - if (argc != 2) return usage(); + if (argc < 2 || argc > 3) return usage(); fontname = argv[1]; + if (argc == 3) + charfile = argv[2]; s = read_file(&b0); b = b0; if (!(i = find_font(&b, &s))) { fprintf(stderr, "%s: Font %s not found in %s.\n", progname, fontname, charfile); exit(EXIT_FAILURE); } out_font(b, s, i); free(b0); return EXIT_SUCCESS; } static ssize_t read_file(char **b) { int f; struct stat s; ssize_t n; if ((f = open(charfile, O_RDONLY)) == -1) { fprintf(stderr, "%s: open(%s) failed: ", progname, charfile); perror(NULL); exit(EXIT_FAILURE); } if (fstat(f, &s) == -1) { fprintf(stderr, "%s: fstat(%s) failed: ", progname, charfile); perror(NULL); exit(EXIT_FAILURE); } if (!(*b = malloc(s.st_size + 1))) exit(EXIT_FAILURE); if ((n = read(f, *b, s.st_size)) == -1) { fprintf(stderr, "%s: read(%s) failed: ", progname, charfile); perror(NULL); exit(EXIT_FAILURE); } close(f); return n; } static int find_font(char **b, ssize_t *s) { int i; int f; char *w; for (i = 1; ; i++) { w = get_word(b, s, &f); if (!w) return 0; if (!strcmp(w, fontname)) break; if (f || !*s) return 0; } if (!f) next_line(b, s); return i; } static void out_font(char *b, ssize_t s, int i) { int l; for (l = 0; s;) { int j; char *w; int f; w = get_word(&b, &s, &f); if (!w) exit(EXIT_SUCCESS); fputs(w, stdout); if (f || !s) { fprintf(stderr, "%s: Unexpected end of line or file.\n", progname); exit(EXIT_FAILURE); } for (j = 0; j < i; j++) { w = get_word(&b, &s, &f); if (!w) { fprintf(stderr, "%s: Unexpected end of line or file.\n", progname); exit(EXIT_FAILURE); } } printf("\t%s%s\n", w, l && strcmp(w, "\"") ? "\t0\t0" : ""); if (!f) next_line(&b, &s); if (!l) { l++; puts("charset"); } } } static char * get_word(char **b, ssize_t *s, int *f) { /* buffer, size, flags */ char *w = NULL; char *p = *b; ssize_t n = *s; unsigned t = 0; int c; while (n && (!(c = *p) || c == ' ' || c == '\t')) { n--; p++; } if (c == '\n') { t = 1; goto r; } if (!n) goto r; w = p; while (n && (c = *p) && c != ' ' && c != '\t' && c != '\n') { n--; p++; } if (c == '\n') t = 1; *p = 0; r: *b = p; *s = n; if (f) *f = t; return w; } static void next_line(char **b, ssize_t *s) { char *p = *b; ssize_t n = *s; while (n && *p != '\n') { n--; p++; } if (n) { n--; p++; } *b = p; *s = n; } static int usage(void) { fprintf(stderr, -"Usage: ./%s >> \n" +"Usage: ./%s [charsetfile] >> \n" , progname); return EXIT_FAILURE; } Index: vendor/heirloom-doctools/dist/troff/troff.d/otf.c =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/otf.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/otf.c (revision 310550) @@ -1,3608 +1,3609 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)otf.c 1.68 (gritter) 3/17/10 */ #include #include #include #include #include #include #include #include #include #include #include #include #include "dev.h" #include "afm.h" #ifndef __unused #define __unused __attribute__((unused)) #endif extern struct dev dev; extern char *chname; extern short *chtab; extern int nchtab; extern void errprint(const char *, ...); extern void verrprint(const char *, va_list); static jmp_buf breakpoint; static char *contents; static size_t size; static unsigned short numTables; static int ttf; static const char *filename; unsigned short unitsPerEm; static short xMin, yMin, xMax, yMax; static short indexToLocFormat; static struct afmtab *a; -static int nc; +static unsigned long nc; static int fsType; static int WeightClass; static int isFixedPitch; static int minMemType42; static int maxMemType42; static int numGlyphs; static char *PostScript_name; static char *Copyright; static char *Notice; static struct table_directory { char tag[4]; unsigned long checkSum; unsigned long offset; unsigned long length; } *table_directories; static int pos_CFF; static int pos_head; static int pos_hhea; static int pos_loca; static int pos_prep; static int pos_fpgm; static int pos_vhea; static int pos_glyf; static int pos_cvt; static int pos_maxp; static int pos_vmtx; static int pos_hmtx; static int pos_OS_2; static int pos_GSUB; static int pos_GPOS; static int pos_post; static int pos_kern; static int pos_name; static int pos_cmap; static struct table { const char *name; int *pos; int in_sfnts; uint32_t checksum; } tables[] = { { "CFF ", &pos_CFF, 0, 0 }, { "cmap", &pos_cmap, 0, 0 }, { "cvt ", &pos_cvt, 1, 0 }, { "fpgm", &pos_fpgm, 1, 0 }, { "GPOS", &pos_GPOS, 0, 0 }, { "GSUB", &pos_GSUB, 0, 0 }, { "head", &pos_head, 2, 0 }, { "hhea", &pos_hhea, 1, 0 }, { "hmtx", &pos_hmtx, 1, 0 }, { "kern", &pos_kern, 0, 0 }, { "loca", &pos_loca, 1, 0 }, { "maxp", &pos_maxp, 1, 0 }, { "name", &pos_name, 0, 0 }, { "OS/2", &pos_OS_2, 0, 0 }, { "post", &pos_post, 0, 0 }, { "prep", &pos_prep, 1, 0 }, { "vhea", &pos_vhea, 1, 0 }, { "vmtx", &pos_vmtx, 1, 0 }, { "glyf", &pos_glyf, 3, 0 }, /* holds glyph data */ { NULL, NULL, 0, 0 } }; static unsigned short *gid2sid; struct INDEX { unsigned short count; int offSize; int *offset; char *data; }; static struct CFF { struct INDEX *Name; struct INDEX *Top_DICT; struct INDEX *String; struct INDEX *Global_Subr; struct INDEX *CharStrings; int Charset; int baseoffset; } CFF; static const int ExpertCharset[] = { 0, 1, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 13, 14, 15, 99, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 27, 28, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 109, 110, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 158, 155, 163, 319, 320, 321, 322, 323, 324, 325, 326, 150, 164, 169, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378 }; static const int ExpertSubsetCharset[] = { 0, 1, 231, 232, 235, 236, 237, 238, 13, 14, 15, 99, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 27, 28, 249, 250, 251, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 109, 110, 267, 268, 269, 270, 272, 300, 301, 302, 305, 314, 315, 158, 155, 163, 320, 321, 322, 323, 324, 325, 326, 150, 164, 169, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346 }; static const char *const StandardStrings[] = { ".notdef", /* 0 */ "space", /* 1 */ "exclam", /* 2 */ "quotedbl", /* 3 */ "numbersign", /* 4 */ "dollar", /* 5 */ "percent", /* 6 */ "ampersand", /* 7 */ "quoteright", /* 8 */ "parenleft", /* 9 */ "parenright", /* 10 */ "asterisk", /* 11 */ "plus", /* 12 */ "comma", /* 13 */ "hyphen", /* 14 */ "period", /* 15 */ "slash", /* 16 */ "zero", /* 17 */ "one", /* 18 */ "two", /* 19 */ "three", /* 20 */ "four", /* 21 */ "five", /* 22 */ "six", /* 23 */ "seven", /* 24 */ "eight", /* 25 */ "nine", /* 26 */ "colon", /* 27 */ "semicolon", /* 28 */ "less", /* 29 */ "equal", /* 30 */ "greater", /* 31 */ "question", /* 32 */ "at", /* 33 */ "A", /* 34 */ "B", /* 35 */ "C", /* 36 */ "D", /* 37 */ "E", /* 38 */ "F", /* 39 */ "G", /* 40 */ "H", /* 41 */ "I", /* 42 */ "J", /* 43 */ "K", /* 44 */ "L", /* 45 */ "M", /* 46 */ "N", /* 47 */ "O", /* 48 */ "P", /* 49 */ "Q", /* 50 */ "R", /* 51 */ "S", /* 52 */ "T", /* 53 */ "U", /* 54 */ "V", /* 55 */ "W", /* 56 */ "X", /* 57 */ "Y", /* 58 */ "Z", /* 59 */ "bracketleft", /* 60 */ "backslash", /* 61 */ "bracketright", /* 62 */ "asciicircum", /* 63 */ "underscore", /* 64 */ "quoteleft", /* 65 */ "a", /* 66 */ "b", /* 67 */ "c", /* 68 */ "d", /* 69 */ "e", /* 70 */ "f", /* 71 */ "g", /* 72 */ "h", /* 73 */ "i", /* 74 */ "j", /* 75 */ "k", /* 76 */ "l", /* 77 */ "m", /* 78 */ "n", /* 79 */ "o", /* 80 */ "p", /* 81 */ "q", /* 82 */ "r", /* 83 */ "s", /* 84 */ "t", /* 85 */ "u", /* 86 */ "v", /* 87 */ "w", /* 88 */ "x", /* 89 */ "y", /* 90 */ "z", /* 91 */ "braceleft", /* 92 */ "bar", /* 93 */ "braceright", /* 94 */ "asciitilde", /* 95 */ "exclamdown", /* 96 */ "cent", /* 97 */ "sterling", /* 98 */ "fraction", /* 99 */ "yen", /* 100 */ "florin", /* 101 */ "section", /* 102 */ "currency", /* 103 */ "quotesingle", /* 104 */ "quotedblleft", /* 105 */ "guillemotleft", /* 106 */ "guilsinglleft", /* 107 */ "guilsinglright", /* 108 */ "fi", /* 109 */ "fl", /* 110 */ "endash", /* 111 */ "dagger", /* 112 */ "daggerdbl", /* 113 */ "periodcentered", /* 114 */ "paragraph", /* 115 */ "bullet", /* 116 */ "quotesinglbase", /* 117 */ "quotedblbase", /* 118 */ "quotedblright", /* 119 */ "guillemotright", /* 120 */ "ellipsis", /* 121 */ "perthousand", /* 122 */ "questiondown", /* 123 */ "grave", /* 124 */ "acute", /* 125 */ "circumflex", /* 126 */ "tilde", /* 127 */ "macron", /* 128 */ "breve", /* 129 */ "dotaccent", /* 130 */ "dieresis", /* 131 */ "ring", /* 132 */ "cedilla", /* 133 */ "hungarumlaut", /* 134 */ "ogonek", /* 135 */ "caron", /* 136 */ "emdash", /* 137 */ "AE", /* 138 */ "ordfeminine", /* 139 */ "Lslash", /* 140 */ "Oslash", /* 141 */ "OE", /* 142 */ "ordmasculine", /* 143 */ "ae", /* 144 */ "dotlessi", /* 145 */ "lslash", /* 146 */ "oslash", /* 147 */ "oe", /* 148 */ "germandbls", /* 149 */ "onesuperior", /* 150 */ "logicalnot", /* 151 */ "mu", /* 152 */ "trademark", /* 153 */ "Eth", /* 154 */ "onehalf", /* 155 */ "plusminus", /* 156 */ "Thorn", /* 157 */ "onequarter", /* 158 */ "divide", /* 159 */ "brokenbar", /* 160 */ "degree", /* 161 */ "thorn", /* 162 */ "threequarters", /* 163 */ "twosuperior", /* 164 */ "registered", /* 165 */ "minus", /* 166 */ "eth", /* 167 */ "multiply", /* 168 */ "threesuperior", /* 169 */ "copyright", /* 170 */ "Aacute", /* 171 */ "Acircumflex", /* 172 */ "Adieresis", /* 173 */ "Agrave", /* 174 */ "Aring", /* 175 */ "Atilde", /* 176 */ "Ccedilla", /* 177 */ "Eacute", /* 178 */ "Ecircumflex", /* 179 */ "Edieresis", /* 180 */ "Egrave", /* 181 */ "Iacute", /* 182 */ "Icircumflex", /* 183 */ "Idieresis", /* 184 */ "Igrave", /* 185 */ "Ntilde", /* 186 */ "Oacute", /* 187 */ "Ocircumflex", /* 188 */ "Odieresis", /* 189 */ "Ograve", /* 190 */ "Otilde", /* 191 */ "Scaron", /* 192 */ "Uacute", /* 193 */ "Ucircumflex", /* 194 */ "Udieresis", /* 195 */ "Ugrave", /* 196 */ "Yacute", /* 197 */ "Ydieresis", /* 198 */ "Zcaron", /* 199 */ "aacute", /* 200 */ "acircumflex", /* 201 */ "adieresis", /* 202 */ "agrave", /* 203 */ "aring", /* 204 */ "atilde", /* 205 */ "ccedilla", /* 206 */ "eacute", /* 207 */ "ecircumflex", /* 208 */ "edieresis", /* 209 */ "egrave", /* 210 */ "iacute", /* 211 */ "icircumflex", /* 212 */ "idieresis", /* 213 */ "igrave", /* 214 */ "ntilde", /* 215 */ "oacute", /* 216 */ "ocircumflex", /* 217 */ "odieresis", /* 218 */ "ograve", /* 219 */ "otilde", /* 220 */ "scaron", /* 221 */ "uacute", /* 222 */ "ucircumflex", /* 223 */ "udieresis", /* 224 */ "ugrave", /* 225 */ "yacute", /* 226 */ "ydieresis", /* 227 */ "zcaron", /* 228 */ "exclamsmall", /* 229 */ "Hungarumlautsmall", /* 230 */ "dollaroldstyle", /* 231 */ "dollarsuperior", /* 232 */ "ampersandsmall", /* 233 */ "Acutesmall", /* 234 */ "parenleftsuperior", /* 235 */ "parenrightsuperior", /* 236 */ "twodotenleader", /* 237 */ "onedotenleader", /* 238 */ "zerooldstyle", /* 239 */ "oneoldstyle", /* 240 */ "twooldstyle", /* 241 */ "threeoldstyle", /* 242 */ "fouroldstyle", /* 243 */ "fiveoldstyle", /* 244 */ "sixoldstyle", /* 245 */ "sevenoldstyle", /* 246 */ "eightoldstyle", /* 247 */ "nineoldstyle", /* 248 */ "commasuperior", /* 249 */ "threequartersemdash", /* 250 */ "periodsuperior", /* 251 */ "questionsmall", /* 252 */ "asuperior", /* 253 */ "bsuperior", /* 254 */ "centsuperior", /* 255 */ "dsuperior", /* 256 */ "esuperior", /* 257 */ "isuperior", /* 258 */ "lsuperior", /* 259 */ "msuperior", /* 260 */ "nsuperior", /* 261 */ "osuperior", /* 262 */ "rsuperior", /* 263 */ "ssuperior", /* 264 */ "tsuperior", /* 265 */ "ff", /* 266 */ "ffi", /* 267 */ "ffl", /* 268 */ "parenleftinferior", /* 269 */ "parenrightinferior", /* 270 */ "Circumflexsmall", /* 271 */ "hyphensuperior", /* 272 */ "Gravesmall", /* 273 */ "Asmall", /* 274 */ "Bsmall", /* 275 */ "Csmall", /* 276 */ "Dsmall", /* 277 */ "Esmall", /* 278 */ "Fsmall", /* 279 */ "Gsmall", /* 280 */ "Hsmall", /* 281 */ "Ismall", /* 282 */ "Jsmall", /* 283 */ "Ksmall", /* 284 */ "Lsmall", /* 285 */ "Msmall", /* 286 */ "Nsmall", /* 287 */ "Osmall", /* 288 */ "Psmall", /* 289 */ "Qsmall", /* 290 */ "Rsmall", /* 291 */ "Ssmall", /* 292 */ "Tsmall", /* 293 */ "Usmall", /* 294 */ "Vsmall", /* 295 */ "Wsmall", /* 296 */ "Xsmall", /* 297 */ "Ysmall", /* 298 */ "Zsmall", /* 299 */ "colonmonetary", /* 300 */ "onefitted", /* 301 */ "rupiah", /* 302 */ "Tildesmall", /* 303 */ "exclamdownsmall", /* 304 */ "centoldstyle", /* 305 */ "Lslashsmall", /* 306 */ "Scaronsmall", /* 307 */ "Zcaronsmall", /* 308 */ "Dieresissmall", /* 309 */ "Brevesmall", /* 310 */ "Caronsmall", /* 311 */ "Dotaccentsmall", /* 312 */ "Macronsmall", /* 313 */ "figuredash", /* 314 */ "hypheninferior", /* 315 */ "Ogoneksmall", /* 316 */ "Ringsmall", /* 317 */ "Cedillasmall", /* 318 */ "questiondownsmall", /* 319 */ "oneeighth", /* 320 */ "threeeighths", /* 321 */ "fiveeighths", /* 322 */ "seveneighths", /* 323 */ "onethird", /* 324 */ "twothirds", /* 325 */ "zerosuperior", /* 326 */ "foursuperior", /* 327 */ "fivesuperior", /* 328 */ "sixsuperior", /* 329 */ "sevensuperior", /* 330 */ "eightsuperior", /* 331 */ "ninesuperior", /* 332 */ "zeroinferior", /* 333 */ "oneinferior", /* 334 */ "twoinferior", /* 335 */ "threeinferior", /* 336 */ "fourinferior", /* 337 */ "fiveinferior", /* 338 */ "sixinferior", /* 339 */ "seveninferior", /* 340 */ "eightinferior", /* 341 */ "nineinferior", /* 342 */ "centinferior", /* 343 */ "dollarinferior", /* 344 */ "periodinferior", /* 345 */ "commainferior", /* 346 */ "Agravesmall", /* 347 */ "Aacutesmall", /* 348 */ "Acircumflexsmall", /* 349 */ "Atildesmall", /* 350 */ "Adieresissmall", /* 351 */ "Aringsmall", /* 352 */ "AEsmall", /* 353 */ "Ccedillasmall", /* 354 */ "Egravesmall", /* 355 */ "Eacutesmall", /* 356 */ "Ecircumflexsmall", /* 357 */ "Edieresissmall", /* 358 */ "Igravesmall", /* 359 */ "Iacutesmall", /* 360 */ "Icircumflexsmall", /* 361 */ "Idieresissmall", /* 362 */ "Ethsmall", /* 363 */ "Ntildesmall", /* 364 */ "Ogravesmall", /* 365 */ "Oacutesmall", /* 366 */ "Ocircumflexsmall", /* 367 */ "Otildesmall", /* 368 */ "Odieresissmall", /* 369 */ "OEsmall", /* 370 */ "Oslashsmall", /* 371 */ "Ugravesmall", /* 372 */ "Uacutesmall", /* 373 */ "Ucircumflexsmall", /* 374 */ "Udieresissmall", /* 375 */ "Yacutesmall", /* 376 */ "Thornsmall", /* 377 */ "Ydieresissmall", /* 378 */ "001.000", /* 379 */ "001.001", /* 380 */ "001.002", /* 381 */ "001.003", /* 382 */ "Black", /* 383 */ "Bold", /* 384 */ "Book", /* 385 */ "Light", /* 386 */ "Medium", /* 387 */ "Regular", /* 388 */ "Roman", /* 389 */ "Semibold" /* 390 */ }; static const int nStdStrings = 391; static const char *const MacintoshStrings[] = { ".notdef", /* 0 */ ".null", /* 1 */ "nonmarkingreturn", /* 2 */ "space", /* 3 */ "exclam", /* 4 */ "quotedbl", /* 5 */ "numbersign", /* 6 */ "dollar", /* 7 */ "percent", /* 8 */ "ampersand", /* 9 */ "quotesingle", /* 10 */ "parenleft", /* 11 */ "parenright", /* 12 */ "asterisk", /* 13 */ "plus", /* 14 */ "comma", /* 15 */ "hyphen", /* 16 */ "period", /* 17 */ "slash", /* 18 */ "zero", /* 19 */ "one", /* 20 */ "two", /* 21 */ "three", /* 22 */ "four", /* 23 */ "five", /* 24 */ "six", /* 25 */ "seven", /* 26 */ "eight", /* 27 */ "nine", /* 28 */ "colon", /* 29 */ "semicolon", /* 30 */ "less", /* 31 */ "equal", /* 32 */ "greater", /* 33 */ "question", /* 34 */ "at", /* 35 */ "A", /* 36 */ "B", /* 37 */ "C", /* 38 */ "D", /* 39 */ "E", /* 40 */ "F", /* 41 */ "G", /* 42 */ "H", /* 43 */ "I", /* 44 */ "J", /* 45 */ "K", /* 46 */ "L", /* 47 */ "M", /* 48 */ "N", /* 49 */ "O", /* 50 */ "P", /* 51 */ "Q", /* 52 */ "R", /* 53 */ "S", /* 54 */ "T", /* 55 */ "U", /* 56 */ "V", /* 57 */ "W", /* 58 */ "X", /* 59 */ "Y", /* 60 */ "Z", /* 61 */ "bracketleft", /* 62 */ "backslash", /* 63 */ "bracketright", /* 64 */ "asciicircum", /* 65 */ "underscore", /* 66 */ "grave", /* 67 */ "a", /* 68 */ "b", /* 69 */ "c", /* 70 */ "d", /* 71 */ "e", /* 72 */ "f", /* 73 */ "g", /* 74 */ "h", /* 75 */ "i", /* 76 */ "j", /* 77 */ "k", /* 78 */ "l", /* 79 */ "m", /* 80 */ "n", /* 81 */ "o", /* 82 */ "p", /* 83 */ "q", /* 84 */ "r", /* 85 */ "s", /* 86 */ "t", /* 87 */ "u", /* 88 */ "v", /* 89 */ "w", /* 90 */ "x", /* 91 */ "y", /* 92 */ "z", /* 93 */ "braceleft", /* 94 */ "bar", /* 95 */ "braceright", /* 96 */ "asciitilde", /* 97 */ "Adieresis", /* 98 */ "Aring", /* 99 */ "Ccedilla", /* 100 */ "Eacute", /* 101 */ "Ntilde", /* 102 */ "Odieresis", /* 103 */ "Udieresis", /* 104 */ "aacute", /* 105 */ "agrave", /* 106 */ "acircumflex", /* 107 */ "adieresis", /* 108 */ "atilde", /* 109 */ "aring", /* 110 */ "ccedilla", /* 111 */ "eacute", /* 112 */ "egrave", /* 113 */ "ecircumflex", /* 114 */ "edieresis", /* 115 */ "iacute", /* 116 */ "igrave", /* 117 */ "icircumflex", /* 118 */ "idieresis", /* 119 */ "ntilde", /* 120 */ "oacute", /* 121 */ "ograve", /* 122 */ "ocircumflex", /* 123 */ "odieresis", /* 124 */ "otilde", /* 125 */ "uacute", /* 126 */ "ugrave", /* 127 */ "ucircumflex", /* 128 */ "udieresis", /* 129 */ "dagger", /* 130 */ "degree", /* 131 */ "cent", /* 132 */ "sterling", /* 133 */ "section", /* 134 */ "bullet", /* 135 */ "paragraph", /* 136 */ "germandbls", /* 137 */ "registered", /* 138 */ "copyright", /* 139 */ "trademark", /* 140 */ "acute", /* 141 */ "dieresis", /* 142 */ "notequal", /* 143 */ "AE", /* 144 */ "Oslash", /* 145 */ "infinity", /* 146 */ "plusminus", /* 147 */ "lessequal", /* 148 */ "greaterequal", /* 149 */ "yen", /* 150 */ "mu", /* 151 */ "partialdiff", /* 152 */ "summation", /* 153 */ "product", /* 154 */ "pi", /* 155 */ "integral", /* 156 */ "ordfeminine", /* 157 */ "ordmasculine", /* 158 */ "Omega", /* 159 */ "ae", /* 160 */ "oslash", /* 161 */ "questiondown", /* 162 */ "exclamdown", /* 163 */ "logicalnot", /* 164 */ "radical", /* 165 */ "florin", /* 166 */ "approxequal", /* 167 */ "Delta", /* 168 */ "guillemotleft", /* 169 */ "guillemotright", /* 170 */ "ellipsis", /* 171 */ "nonbreakingspace", /* 172 */ "Agrave", /* 173 */ "Atilde", /* 174 */ "Otilde", /* 175 */ "OE", /* 176 */ "oe", /* 177 */ "endash", /* 178 */ "emdash", /* 179 */ "quotedblleft", /* 180 */ "quotedblright", /* 181 */ "quoteleft", /* 182 */ "quoteright", /* 183 */ "divide", /* 184 */ "lozenge", /* 185 */ "ydieresis", /* 186 */ "Ydieresis", /* 187 */ "fraction", /* 188 */ "currency", /* 189 */ "guilsinglleft", /* 190 */ "guilsinglright", /* 191 */ "fi", /* 192 */ "fl", /* 193 */ "daggerdbl", /* 194 */ "periodcentered", /* 195 */ "quotesinglbase", /* 196 */ "quotedblbase", /* 197 */ "perthousand", /* 198 */ "Acircumflex", /* 199 */ "Ecircumflex", /* 200 */ "Aacute", /* 201 */ "Edieresis", /* 202 */ "Egrave", /* 203 */ "Iacute", /* 204 */ "Icircumflex", /* 205 */ "Idieresis", /* 206 */ "Igrave", /* 207 */ "Oacute", /* 208 */ "Ocircumflex", /* 209 */ "apple", /* 210 */ "Ograve", /* 211 */ "Uacute", /* 212 */ "Ucircumflex", /* 213 */ "Ugrave", /* 214 */ "dotlessi", /* 215 */ "circumflex", /* 216 */ "tilde", /* 217 */ "macron", /* 218 */ "breve", /* 219 */ "dotaccent", /* 220 */ "ring", /* 221 */ "cedilla", /* 222 */ "hungarumlaut", /* 223 */ "ogonek", /* 224 */ "caron", /* 225 */ "Lslash", /* 226 */ "lslash", /* 227 */ "Scaron", /* 228 */ "scaron", /* 229 */ "Zcaron", /* 230 */ "zcaron", /* 231 */ "brokenbar", /* 232 */ "Eth", /* 233 */ "eth", /* 234 */ "Yacute", /* 235 */ "yacute", /* 236 */ "Thorn", /* 237 */ "thorn", /* 238 */ "minus", /* 239 */ "multiply", /* 240 */ "onesuperior", /* 241 */ "twosuperior", /* 242 */ "threesuperior", /* 243 */ "onehalf", /* 244 */ "onequarter", /* 245 */ "threequarters", /* 246 */ "franc", /* 247 */ "Gbreve", /* 248 */ "gbreve", /* 249 */ "Idotaccent", /* 250 */ "Scedilla", /* 251 */ "scedilla", /* 252 */ "Cacute", /* 253 */ "cacute", /* 254 */ "Ccaron", /* 255 */ "ccaron", /* 256 */ "dcroat" /* 257 */ }; static const int nMacintoshStrings = 258; static const struct WGL { int u; const char *s; } WGL[] = { /* WGL4 */ { 0x0000, ".notdef" }, { 0x0020, "space" }, { 0x0021, "exclam" }, { 0x0022, "quotedbl" }, { 0x0023, "numbersign" }, { 0x0024, "dollar" }, { 0x0025, "percent" }, { 0x0026, "ampersand" }, { 0x0027, "quotesingle" }, { 0x0028, "parenleft" }, { 0x0029, "parenright" }, { 0x002a, "asterisk" }, { 0x002b, "plus" }, { 0x002c, "comma" }, { 0x002d, "hyphen" }, { 0x002e, "period" }, { 0x002f, "slash" }, { 0x0030, "zero" }, { 0x0031, "one" }, { 0x0032, "two" }, { 0x0033, "three" }, { 0x0034, "four" }, { 0x0035, "five" }, { 0x0036, "six" }, { 0x0037, "seven" }, { 0x0038, "eight" }, { 0x0039, "nine" }, { 0x003a, "colon" }, { 0x003b, "semicolon" }, { 0x003c, "less" }, { 0x003d, "equal" }, { 0x003e, "greater" }, { 0x003f, "question" }, { 0x0040, "at" }, { 0x0041, "A" }, { 0x0042, "B" }, { 0x0043, "C" }, { 0x0044, "D" }, { 0x0045, "E" }, { 0x0046, "F" }, { 0x0047, "G" }, { 0x0048, "H" }, { 0x0049, "I" }, { 0x004a, "J" }, { 0x004b, "K" }, { 0x004c, "L" }, { 0x004d, "M" }, { 0x004e, "N" }, { 0x004f, "O" }, { 0x0050, "P" }, { 0x0051, "Q" }, { 0x0052, "R" }, { 0x0053, "S" }, { 0x0054, "T" }, { 0x0055, "U" }, { 0x0056, "V" }, { 0x0057, "W" }, { 0x0058, "X" }, { 0x0059, "Y" }, { 0x005a, "Z" }, { 0x005b, "bracketleft" }, { 0x005c, "backslash" }, { 0x005d, "bracketright" }, { 0x005e, "asciicircum" }, { 0x005f, "underscore" }, { 0x0060, "grave" }, { 0x0061, "a" }, { 0x0062, "b" }, { 0x0063, "c" }, { 0x0064, "d" }, { 0x0065, "e" }, { 0x0066, "f" }, { 0x0067, "g" }, { 0x0068, "h" }, { 0x0069, "i" }, { 0x006a, "j" }, { 0x006b, "k" }, { 0x006c, "l" }, { 0x006d, "m" }, { 0x006e, "n" }, { 0x006f, "o" }, { 0x0070, "p" }, { 0x0071, "q" }, { 0x0072, "r" }, { 0x0073, "s" }, { 0x0074, "t" }, { 0x0075, "u" }, { 0x0076, "v" }, { 0x0077, "w" }, { 0x0078, "x" }, { 0x0079, "y" }, { 0x007a, "z" }, { 0x007b, "braceleft" }, { 0x007c, "bar" }, { 0x007d, "braceright" }, { 0x007e, "asciitilde" }, { 0x00a1, "exclamdown" }, { 0x00a2, "cent" }, { 0x00a3, "sterling" }, { 0x00a4, "currency" }, { 0x00a5, "yen" }, { 0x00a6, "brokenbar" }, { 0x00a7, "section" }, { 0x00a8, "dieresis" }, { 0x00a9, "copyright" }, { 0x00aa, "ordfeminine" }, { 0x00ab, "guillemotleft" }, { 0x00ac, "logicalnot" }, { 0x00ae, "registered" }, { 0x00af, "macron" }, { 0x00b0, "degree" }, { 0x00b1, "plusminus" }, { 0x00b2, "twosuperior" }, { 0x00b3, "threesuperior" }, { 0x00b4, "acute" }, { 0x00b5, "mu" }, { 0x00b6, "paragraph" }, { 0x00b7, "periodcentered" }, { 0x00b8, "cedilla" }, { 0x00b9, "onesuperior" }, { 0x00ba, "ordmasculine" }, { 0x00bb, "guillemotright" }, { 0x00bc, "onequarter" }, { 0x00bd, "onehalf" }, { 0x00be, "threequarters" }, { 0x00bf, "questiondown" }, { 0x00c0, "Agrave" }, { 0x00c1, "Aacute" }, { 0x00c2, "Acircumflex" }, { 0x00c3, "Atilde" }, { 0x00c4, "Adieresis" }, { 0x00c5, "Aring" }, { 0x00c6, "AE" }, { 0x00c7, "Ccedilla" }, { 0x00c8, "Egrave" }, { 0x00c9, "Eacute" }, { 0x00ca, "Ecircumflex" }, { 0x00cb, "Edieresis" }, { 0x00cc, "Igrave" }, { 0x00cd, "Iacute" }, { 0x00ce, "Icircumflex" }, { 0x00cf, "Idieresis" }, { 0x00d0, "Eth" }, { 0x00d1, "Ntilde" }, { 0x00d2, "Ograve" }, { 0x00d3, "Oacute" }, { 0x00d4, "Ocircumflex" }, { 0x00d5, "Otilde" }, { 0x00d6, "Odieresis" }, { 0x00d7, "multiply" }, { 0x00d8, "Oslash" }, { 0x00d9, "Ugrave" }, { 0x00da, "Uacute" }, { 0x00db, "Ucircumflex" }, { 0x00dc, "Udieresis" }, { 0x00dd, "Yacute" }, { 0x00de, "Thorn" }, { 0x00df, "germandbls" }, { 0x00e0, "agrave" }, { 0x00e1, "aacute" }, { 0x00e2, "acircumflex" }, { 0x00e3, "atilde" }, { 0x00e4, "adieresis" }, { 0x00e5, "aring" }, { 0x00e6, "ae" }, { 0x00e7, "ccedilla" }, { 0x00e8, "egrave" }, { 0x00e9, "eacute" }, { 0x00ea, "ecircumflex" }, { 0x00eb, "edieresis" }, { 0x00ec, "igrave" }, { 0x00ed, "iacute" }, { 0x00ee, "icircumflex" }, { 0x00ef, "idieresis" }, { 0x00f0, "eth" }, { 0x00f1, "ntilde" }, { 0x00f2, "ograve" }, { 0x00f3, "oacute" }, { 0x00f4, "ocircumflex" }, { 0x00f5, "otilde" }, { 0x00f6, "odieresis" }, { 0x00f7, "divide" }, { 0x00f8, "oslash" }, { 0x00f9, "ugrave" }, { 0x00fa, "uacute" }, { 0x00fb, "ucircumflex" }, { 0x00fc, "udieresis" }, { 0x00fd, "yacute" }, { 0x00fe, "thorn" }, { 0x00ff, "ydieresis" }, { 0x0100, "Amacron" }, { 0x0101, "amacron" }, { 0x0102, "Abreve" }, { 0x0103, "abreve" }, { 0x0104, "Aogonek" }, { 0x0105, "aogonek" }, { 0x0106, "Cacute" }, { 0x0107, "cacute" }, { 0x0108, "Ccircumflex" }, { 0x0109, "ccircumflex" }, { 0x010a, "Cdotaccent" }, { 0x010b, "cdotaccent" }, { 0x010c, "Ccaron" }, { 0x010d, "ccaron" }, { 0x010e, "Dcaron" }, { 0x010f, "dcaron" }, { 0x0110, "Dcroat" }, { 0x0111, "dcroat" }, { 0x0112, "Emacron" }, { 0x0113, "emacron" }, { 0x0114, "Ebreve" }, { 0x0115, "ebreve" }, { 0x0116, "Edotaccent" }, { 0x0117, "edotaccent" }, { 0x0118, "Eogonek" }, { 0x0119, "eogonek" }, { 0x011a, "Ecaron" }, { 0x011b, "ecaron" }, { 0x011c, "Gcircumflex" }, { 0x011d, "gcircumflex" }, { 0x011e, "Gbreve" }, { 0x011f, "gbreve" }, { 0x0120, "Gdotaccent" }, { 0x0121, "gdotaccent" }, { 0x0122, "Gcommaaccent" }, { 0x0123, "gcommaaccent" }, { 0x0124, "Hcircumflex" }, { 0x0125, "hcircumflex" }, { 0x0126, "Hbar" }, { 0x0127, "hbar" }, { 0x0128, "Itilde" }, { 0x0129, "itilde" }, { 0x012a, "Imacron" }, { 0x012b, "imacron" }, { 0x012c, "Ibreve" }, { 0x012d, "ibreve" }, { 0x012e, "Iogonek" }, { 0x012f, "iogonek" }, { 0x0130, "Idotaccent" }, { 0x0131, "dotlessi" }, { 0x0132, "IJ" }, { 0x0133, "ij" }, { 0x0134, "Jcircumflex" }, { 0x0135, "jcircumflex" }, { 0x0136, "Kcommaaccent" }, { 0x0137, "kcommaaccent" }, { 0x0138, "kgreenlandic" }, { 0x0139, "Lacute" }, { 0x013a, "lacute" }, { 0x013b, "Lcommaaccent" }, { 0x013c, "lcommaaccent" }, { 0x013d, "Lcaron" }, { 0x013e, "lcaron" }, { 0x013f, "Ldot" }, { 0x0140, "ldot" }, { 0x0141, "Lslash" }, { 0x0142, "lslash" }, { 0x0143, "Nacute" }, { 0x0144, "nacute" }, { 0x0145, "Ncommaaccent" }, { 0x0146, "ncommaaccent" }, { 0x0147, "Ncaron" }, { 0x0148, "ncaron" }, { 0x0149, "napostrophe" }, { 0x014a, "Eng" }, { 0x014b, "eng" }, { 0x014c, "Omacron" }, { 0x014d, "omacron" }, { 0x014e, "Obreve" }, { 0x014f, "obreve" }, { 0x0150, "Ohungarumlaut" }, { 0x0151, "ohungarumlaut" }, { 0x0152, "OE" }, { 0x0153, "oe" }, { 0x0154, "Racute" }, { 0x0155, "racute" }, { 0x0156, "Rcommaaccent" }, { 0x0157, "rcommaaccent" }, { 0x0158, "Rcaron" }, { 0x0159, "rcaron" }, { 0x015a, "Sacute" }, { 0x015b, "sacute" }, { 0x015c, "Scircumflex" }, { 0x015d, "scircumflex" }, { 0x015e, "Scedilla" }, { 0x015f, "scedilla" }, { 0x0160, "Scaron" }, { 0x0161, "scaron" }, { 0x0164, "Tcaron" }, { 0x0165, "tcaron" }, { 0x0166, "Tbar" }, { 0x0167, "tbar" }, { 0x0168, "Utilde" }, { 0x0169, "utilde" }, { 0x016a, "Umacron" }, { 0x016b, "umacron" }, { 0x016c, "Ubreve" }, { 0x016d, "ubreve" }, { 0x016e, "Uring" }, { 0x016f, "uring" }, { 0x0170, "Uhungarumlaut" }, { 0x0171, "uhungarumlaut" }, { 0x0172, "Uogonek" }, { 0x0173, "uogonek" }, { 0x0174, "Wcircumflex" }, { 0x0175, "wcircumflex" }, { 0x0176, "Ycircumflex" }, { 0x0177, "ycircumflex" }, { 0x0178, "Ydieresis" }, { 0x0179, "Zacute" }, { 0x017a, "zacute" }, { 0x017b, "Zdotaccent" }, { 0x017c, "zdotaccent" }, { 0x017d, "Zcaron" }, { 0x017e, "zcaron" }, { 0x017f, "longs" }, { 0x0192, "florin" }, { 0x01fa, "Aringacute" }, { 0x01fb, "aringacute" }, { 0x01fc, "AEacute" }, { 0x01fd, "aeacute" }, { 0x01fe, "Oslashacute" }, { 0x01ff, "oslashacute" }, { 0x02c6, "circumflex" }, { 0x02c7, "caron" }, { 0x02d8, "breve" }, { 0x02d9, "dotaccent" }, { 0x02da, "ring" }, { 0x02db, "ogonek" }, { 0x02dc, "tilde" }, { 0x02dd, "hungarumlaut" }, { 0x0384, "tonos" }, { 0x0385, "dieresistonos" }, { 0x0386, "Alphatonos" }, { 0x0387, "anoteleia" }, { 0x0388, "Epsilontonos" }, { 0x0389, "Etatonos" }, { 0x038a, "Iotatonos" }, { 0x038c, "Omicrontonos" }, { 0x038e, "Upsilontonos" }, { 0x038f, "Omegatonos" }, { 0x0390, "iotadieresistonos" }, { 0x0391, "Alpha" }, { 0x0392, "Beta" }, { 0x0393, "Gamma" }, { 0x0395, "Epsilon" }, { 0x0396, "Zeta" }, { 0x0397, "Eta" }, { 0x0398, "Theta" }, { 0x0399, "Iota" }, { 0x039a, "Kappa" }, { 0x039b, "Lambda" }, { 0x039c, "Mu" }, { 0x039d, "Nu" }, { 0x039e, "Xi" }, { 0x039f, "Omicron" }, { 0x03a0, "Pi" }, { 0x03a1, "Rho" }, { 0x03a3, "Sigma" }, { 0x03a4, "Tau" }, { 0x03a5, "Upsilon" }, { 0x03a6, "Phi" }, { 0x03a7, "Chi" }, { 0x03a8, "Psi" }, { 0x03aa, "Iotadieresis" }, { 0x03ab, "Upsilondieresis" }, { 0x03ac, "alphatonos" }, { 0x03ad, "epsilontonos" }, { 0x03ae, "etatonos" }, { 0x03af, "iotatonos" }, { 0x03b0, "upsilondieresistonos" }, { 0x03b1, "alpha" }, { 0x03b2, "beta" }, { 0x03b3, "gamma" }, { 0x03b4, "delta" }, { 0x03b5, "epsilon" }, { 0x03b6, "zeta" }, { 0x03b7, "eta" }, { 0x03b8, "theta" }, { 0x03b9, "iota" }, { 0x03ba, "kappa" }, { 0x03bb, "lambda" }, { 0x03bd, "nu" }, { 0x03be, "xi" }, { 0x03bf, "omicron" }, { 0x03c0, "pi" }, { 0x03c1, "rho" }, { 0x03c2, "sigma1" }, { 0x03c3, "sigma" }, { 0x03c4, "tau" }, { 0x03c5, "upsilon" }, { 0x03c6, "phi" }, { 0x03c7, "chi" }, { 0x03c8, "psi" }, { 0x03c9, "omega" }, { 0x03ca, "iotadieresis" }, { 0x03cb, "upsilondieresis" }, { 0x03cc, "omicrontonos" }, { 0x03cd, "upsilontonos" }, { 0x03ce, "omegatonos" }, { 0x0401, "afii10023" }, { 0x0402, "afii10051" }, { 0x0403, "afii10052" }, { 0x0404, "afii10053" }, { 0x0405, "afii10054" }, { 0x0406, "afii10055" }, { 0x0407, "afii10056" }, { 0x0408, "afii10057" }, { 0x0409, "afii10058" }, { 0x040a, "afii10059" }, { 0x040b, "afii10060" }, { 0x040c, "afii10061" }, { 0x040e, "afii10062" }, { 0x040f, "afii10145" }, { 0x0410, "afii10017" }, { 0x0411, "afii10018" }, { 0x0412, "afii10019" }, { 0x0413, "afii10020" }, { 0x0414, "afii10021" }, { 0x0415, "afii10022" }, { 0x0416, "afii10024" }, { 0x0417, "afii10025" }, { 0x0418, "afii10026" }, { 0x0419, "afii10027" }, { 0x041a, "afii10028" }, { 0x041b, "afii10029" }, { 0x041c, "afii10030" }, { 0x041d, "afii10031" }, { 0x041e, "afii10032" }, { 0x041f, "afii10033" }, { 0x0420, "afii10034" }, { 0x0421, "afii10035" }, { 0x0422, "afii10036" }, { 0x0423, "afii10037" }, { 0x0424, "afii10038" }, { 0x0425, "afii10039" }, { 0x0426, "afii10040" }, { 0x0427, "afii10041" }, { 0x0428, "afii10042" }, { 0x0429, "afii10043" }, { 0x042a, "afii10044" }, { 0x042b, "afii10045" }, { 0x042c, "afii10046" }, { 0x042d, "afii10047" }, { 0x042e, "afii10048" }, { 0x042f, "afii10049" }, { 0x0430, "afii10065" }, { 0x0431, "afii10066" }, { 0x0432, "afii10067" }, { 0x0433, "afii10068" }, { 0x0434, "afii10069" }, { 0x0435, "afii10070" }, { 0x0436, "afii10072" }, { 0x0437, "afii10073" }, { 0x0438, "afii10074" }, { 0x0439, "afii10075" }, { 0x043a, "afii10076" }, { 0x043b, "afii10077" }, { 0x043c, "afii10078" }, { 0x043d, "afii10079" }, { 0x043e, "afii10080" }, { 0x043f, "afii10081" }, { 0x0440, "afii10082" }, { 0x0441, "afii10083" }, { 0x0442, "afii10084" }, { 0x0443, "afii10085" }, { 0x0444, "afii10086" }, { 0x0445, "afii10087" }, { 0x0446, "afii10088" }, { 0x0447, "afii10089" }, { 0x0448, "afii10090" }, { 0x0449, "afii10091" }, { 0x044a, "afii10092" }, { 0x044b, "afii10093" }, { 0x044c, "afii10094" }, { 0x044d, "afii10095" }, { 0x044e, "afii10096" }, { 0x044f, "afii10097" }, { 0x0451, "afii10071" }, { 0x0452, "afii10099" }, { 0x0453, "afii10100" }, { 0x0454, "afii10101" }, { 0x0455, "afii10102" }, { 0x0456, "afii10103" }, { 0x0457, "afii10104" }, { 0x0458, "afii10105" }, { 0x0459, "afii10106" }, { 0x045a, "afii10107" }, { 0x045b, "afii10108" }, { 0x045c, "afii10109" }, { 0x045e, "afii10110" }, { 0x045f, "afii10193" }, { 0x0490, "afii10050" }, { 0x0491, "afii10098" }, { 0x1e80, "Wgrave" }, { 0x1e81, "wgrave" }, { 0x1e82, "Wacute" }, { 0x1e83, "wacute" }, { 0x1e84, "Wdieresis" }, { 0x1e85, "wdieresis" }, { 0x1ef2, "Ygrave" }, { 0x1ef3, "ygrave" }, { 0x2013, "endash" }, { 0x2014, "emdash" }, { 0x2015, "afii00208" }, { 0x2017, "underscoredbl" }, { 0x2018, "quoteleft" }, { 0x2019, "quoteright" }, { 0x201a, "quotesinglbase" }, { 0x201b, "quotereversed" }, { 0x201c, "quotedblleft" }, { 0x201d, "quotedblright" }, { 0x201e, "quotedblbase" }, { 0x2020, "dagger" }, { 0x2021, "daggerdbl" }, { 0x2022, "bullet" }, { 0x2026, "ellipsis" }, { 0x2030, "perthousand" }, { 0x2032, "minute" }, { 0x2033, "second" }, { 0x2039, "guilsinglleft" }, { 0x203a, "guilsinglright" }, { 0x203c, "exclamdbl" }, { 0x203e, "uni203E" }, { 0x2044, "fraction" }, { 0x207f, "nsuperior" }, { 0x20a3, "franc" }, { 0x20a4, "lira" }, { 0x20a7, "peseta" }, { 0x20ac, "Euro" }, { 0x2105, "afii61248" }, { 0x2113, "afii61289" }, { 0x2116, "afii61352" }, { 0x2122, "trademark" }, { 0x2126, "Omega" }, { 0x212e, "estimated" }, { 0x215b, "oneeighth" }, { 0x215c, "threeeighths" }, { 0x215d, "fiveeighths" }, { 0x215e, "seveneighths" }, { 0x2190, "arrowleft" }, { 0x2191, "arrowup" }, { 0x2192, "arrowright" }, { 0x2193, "arrowdown" }, { 0x2194, "arrowboth" }, { 0x2195, "arrowupdn" }, { 0x21a8, "arrowupdnbse" }, { 0x2202, "partialdiff" }, { 0x2206, "Delta" }, { 0x220f, "product" }, { 0x2211, "summation" }, { 0x2212, "minus" }, { 0x221a, "radical" }, { 0x221e, "infinity" }, { 0x221f, "orthogonal" }, { 0x2229, "intersection" }, { 0x222b, "integral" }, { 0x2248, "approxequal" }, { 0x2260, "notequal" }, { 0x2261, "equivalence" }, { 0x2264, "lessequal" }, { 0x2265, "greaterequal" }, { 0x2302, "house" }, { 0x2310, "revlogicalnot" }, { 0x2320, "integraltp" }, { 0x2321, "integralbt" }, { 0x2500, "SF100000" }, { 0x2502, "SF110000" }, { 0x250c, "SF010000" }, { 0x2510, "SF030000" }, { 0x2514, "SF020000" }, { 0x2518, "SF040000" }, { 0x251c, "SF080000" }, { 0x2524, "SF090000" }, { 0x252c, "SF060000" }, { 0x2534, "SF070000" }, { 0x253c, "SF050000" }, { 0x2550, "SF430000" }, { 0x2551, "SF240000" }, { 0x2552, "SF510000" }, { 0x2553, "SF520000" }, { 0x2554, "SF390000" }, { 0x2555, "SF220000" }, { 0x2556, "SF210000" }, { 0x2557, "SF250000" }, { 0x2558, "SF500000" }, { 0x2559, "SF490000" }, { 0x255a, "SF380000" }, { 0x255b, "SF280000" }, { 0x255c, "SF270000" }, { 0x255d, "SF260000" }, { 0x255e, "SF360000" }, { 0x255f, "SF370000" }, { 0x2560, "SF420000" }, { 0x2561, "SF190000" }, { 0x2562, "SF200000" }, { 0x2563, "SF230000" }, { 0x2564, "SF470000" }, { 0x2565, "SF480000" }, { 0x2566, "SF410000" }, { 0x2567, "SF450000" }, { 0x2568, "SF460000" }, { 0x2569, "SF400000" }, { 0x256a, "SF540000" }, { 0x256b, "SF530000" }, { 0x256c, "SF440000" }, { 0x2580, "upblock" }, { 0x2584, "dnblock" }, { 0x2588, "block" }, { 0x258c, "lfblock" }, { 0x2590, "rtblock" }, { 0x2591, "ltshade" }, { 0x2592, "shade" }, { 0x2593, "dkshade" }, { 0x25a0, "filledbox" }, { 0x25a1, "H22073" }, { 0x25aa, "H18543" }, { 0x25ab, "H18551" }, { 0x25ac, "filledrect" }, { 0x25b2, "triagup" }, { 0x25ba, "triagrt" }, { 0x25bc, "triagdn" }, { 0x25c4, "triaglf" }, { 0x25ca, "lozenge" }, { 0x25cb, "circle" }, { 0x25cf, "H18533" }, { 0x25d8, "invbullet" }, { 0x25d9, "invcircle" }, { 0x25e6, "openbullet" }, { 0x263a, "smileface" }, { 0x263b, "invsmileface" }, { 0x263c, "sun" }, { 0x2640, "female" }, { 0x2642, "male" }, { 0x2660, "spade" }, { 0x2663, "club" }, { 0x2665, "heart" }, { 0x2666, "diamond" }, { 0x266a, "musicalnote" }, { 0x266b, "musicalnotedbl" }, { 0xfb01, "fi" }, { 0xfb02, "fl" }, { -1, NULL } }; static int nWGL = 642; static char **ExtraStrings; static char *ExtraStringSpace; static int ExtraStringSpacePos; static int nExtraStrings; static char * getSID(int n) { if (ttf == 3) { /*EMPTY*/; } else if (ttf == 2) { if (n >= 0 && n < nWGL) return (char *)WGL[n].s; n -= nWGL; } else if (ttf == 1) { if (n >= 0 && n < nMacintoshStrings) return (char *)MacintoshStrings[n]; n -= nMacintoshStrings; } else { if (n >= 0 && n < nStdStrings) return (char *)StandardStrings[n]; n -= nStdStrings; } if (n < nExtraStrings) return ExtraStrings[n]; return NULL; } static void error(const char *fmt, ...) { char buf[4096]; va_list ap; int n; n = snprintf(buf, sizeof buf, "%s: ", filename); va_start(ap, fmt); vsnprintf(&buf[n], sizeof buf - n, fmt, ap); errprint("%s", buf); va_end(ap); longjmp(breakpoint, 1); } #define _pbe16(cp) ((uint16_t)((cp)[1]&0377) + ((uint16_t)((cp)[0]&0377) << 8)) static uint32_t pbe16(const char *cp) { return (uint16_t)(cp[1]&0377) + ((uint16_t)(cp[0]&0377) << 8); } static uint32_t pbe24(const char *cp) { return (uint32_t)(cp[3]&0377) + ((uint32_t)(cp[2]&0377) << 8) + ((uint32_t)(cp[1]&0377) << 16); } static uint32_t pbe32(const char *cp) { return (uint32_t)(cp[3]&0377) + ((uint32_t)(cp[2]&0377) << 8) + ((uint32_t)(cp[1]&0377) << 16) + ((uint32_t)(cp[0]&0377) << 24); } static uint32_t pbeXX(const char *cp, int n) { switch (n) { default: error("invalid number size %d", n); case 1: return *cp&0377; case 2: return _pbe16(cp); case 3: return pbe24(cp); case 4: return pbe32(cp); } } static double cffoper(long *op) { int b0; int n = 0; double v = 0; b0 = contents[*op]&0377; if (b0 >= 32 && b0 <= 246) { n = 1; v = b0 - 139; } else if (b0 >= 247 && b0 <= 250) { n = 2; v = (b0 - 247) * 256 + (contents[*op+1]&0377) + 108; } else if (b0 >= 251 && b0 <= 254) { n = 2; v = -(b0 - 251) * 256 - (contents[*op+1]&0377) - 108; } else if (b0 == 28) { n = 3; v = (int16_t)((contents[*op+1]&0377)<<8 | (contents[*op+2]&0377)); } else if (b0 == 29) { n = 5; v = (int32_t)pbe32(&contents[*op+1]); } else if (b0 == 30) { char buf[100], *xp; int c, i = 0, s = 0; n = 1; for (;;) { if (i == sizeof buf - 2) error("floating point operand too long"); c = (contents[*op+n]&0377) >> (s ? 8 : 0) & 0xf; if (c >= 0 && c <= 9) buf[i++] = c + '0'; else if (c == 0xa) buf[i++] = '.'; else if (c == 0xb) buf[i++] = 'E'; else if (c == 0xc) { buf[i++] = 'E'; buf[i++] = '-'; } else if (c == 0xd) error("reserved nibble d in floating point " "operand"); else if (c == 0xe) buf[i++] = '-'; else if (c == 0xf) { buf[i++] = 0; if (s == 0) n++; break; } if ((s = !s) == 0) n++; } v = strtod(buf, &xp); if (*xp != 0) error("invalid floating point operand <%s>", buf); } else error("invalid operand b0 range %d", b0); *op += n; return v; } static void get_offset_table(void) { char buf[12]; if (size < 12) error("no offset table"); memcpy(buf, contents, 12); if (pbe32(buf) == 0x00010000 || memcmp(buf, "true", 4) == 0) { ttf = 1; } else if (memcmp(buf, "OTTO", 4) == 0) { ttf = 0; } else error("unknown font type"); numTables = pbe16(&buf[4]); } static void get_table_directories(void) { - int i, j, o; + int i, j; + size_t o; char buf[16]; free(table_directories); table_directories = calloc(numTables, sizeof *table_directories); o = 12; for (i = 0; tables[i].pos; i++) *tables[i].pos = -1; for (i = 0; i < numTables; i++) { if (o + 16 >= size) error("cannot get %dth table directory", i); memcpy(buf, &contents[o], 16); for (j = 0; tables[j].name; j++) if (memcmp(buf, tables[j].name, 4) == 0) { *tables[j].pos = i; break; } o += 16; memcpy(table_directories[i].tag, buf, 4); table_directories[i].checkSum = pbe32(&buf[4]); table_directories[i].offset = pbe32(&buf[8]); table_directories[i].length = pbe32(&buf[12]); if (table_directories[i].offset + table_directories[i].length > size) error("invalid table directory, " "size for entry %4.4s too large", table_directories[i].tag); } } static void free_INDEX(struct INDEX *ip) { if (ip) { free(ip->offset); free(ip); } } static struct INDEX * get_INDEX(unsigned long *op) { struct INDEX *ip; int i; if (*op + 3 >= size) error("no index at position %ld", *op); ip = calloc(1, sizeof *ip); ip->count = pbe16(&contents[*op]); *op += 2; if (ip->count != 0) { ip->offSize = contents[(*op)++] & 0377; ip->offset = calloc(ip->count+1, sizeof *ip->offset); for (i = 0; i < ip->count+1; i++) { if (*op + ip->offSize >= size) { free_INDEX(ip); error("no index offset at position %ld", *op); } ip->offset[i] = pbeXX(&contents[*op], ip->offSize); *op += ip->offSize; } ip->data = &contents[*op]; for (i = 0; i < ip->count+1; i++) ip->offset[i] += *op - 1; *op = ip->offset[ip->count]; } return ip; } static void get_bb(int gid, int B[4]) { int k, o; if (pos_loca < 0 || pos_glyf < 0) return; o = table_directories[pos_loca].offset; k = indexToLocFormat ? pbe32(&contents[o+4*gid]) : pbe16(&contents[o+2*gid]) * 2; o = table_directories[pos_glyf].offset; B[0] = (int16_t)pbe16(&contents[o+k+2]); B[1] = (int16_t)pbe16(&contents[o+k+4]); B[2] = (int16_t)pbe16(&contents[o+k+6]); B[3] = (int16_t)pbe16(&contents[o+k+8]); } static void -onechar(int gid, int sid) +onechar(unsigned long gid, int sid) { long o; int w, tp; char *N; int *b = NULL, B[4] = { 0, 0, 0, 0}; if ((gid == 0 && sid != 0) || (sid == 0 && gid != 0)) return; /* require .notdef to be GID 0 */ if (gid >= nc) return; if (pos_hmtx < 0) error("no hmtx table"); if (table_directories[pos_hmtx].length < 4) error("empty hmtx table"); o = table_directories[pos_hmtx].offset; if (isFixedPitch) w = pbe16(&contents[o]); else { if (table_directories[pos_hmtx].length < 4 * (gid+1)) return; /* just ignore this glyph */ w = pbe16(&contents[o + 4 * gid]); } if (sid != 0 && gid2sid[gid] != 0) return; if (a) { if ((N = getSID(sid)) != NULL) { a->nspace += strlen(N) + 1; tp = afmmapname(N, a->spec); } else tp = 0; if (ttf) get_bb(gid, b = B); afmaddchar(a, gid, tp, 0, w, b, N, a->spec, gid); } gid2sid[gid] = sid; } static int get_CFF_Top_DICT_Entry(int e) { long o; int d = 0; if (CFF.Top_DICT == NULL || CFF.Top_DICT->offset == NULL) error("no Top DICT INDEX"); o = CFF.Top_DICT->offset[0]; while (o < CFF.Top_DICT->offset[1] && contents[o] != e) { if (contents[o] < 0 || contents[o] > 27) d = cffoper(&o); else { d = 0; if (contents[o] == 12) o++; o++; } } return d; } static void get_CFF_Charset(void) { int d = 0; - int gid, i, j, first, nLeft; + unsigned long gid, i, j, first, nLeft; d = get_CFF_Top_DICT_Entry(15); if (d == 0) { for (i = 0; i < nc && i <= 228; i++) onechar(i, i); } else if (d == 1) { for (i = 0; i < nc && i <= 166; i++) onechar(i, ExpertCharset[i]); } else if (d == 2) { for (i = 0; i < nc && i <= 87; i++) onechar(i, ExpertSubsetCharset[i]); } else if (d > 2) { d = CFF.Charset = d + CFF.baseoffset; onechar(0, 0); gid = 1; switch (contents[d++]) { case 0: for (i = 1; i < nc; i++) { j = pbe16(&contents[d]); d += 2; onechar(gid++, j); } break; case 1: i = nc - 1; while (i > 0) { first = pbe16(&contents[d]); d += 2; nLeft = contents[d++] & 0377; for (j = 0; j <= nLeft && gid < nc; j++) onechar(gid++, first + j); i -= nLeft + 1; } break; default: error("unknown Charset table format %d", contents[d-1]); case 2: i = nc - 1; while (i > 0) { first = pbe16(&contents[d]); d += 2; nLeft = pbe16(&contents[d]); d += 2; for (j = 0; j <= nLeft && gid < nc; j++) onechar(gid++, first + j); i -= nLeft + 1; } } } else error("invalid Charset offset"); } static void build_ExtraStrings(void) { int c, i; char *sp; if (CFF.String == NULL || CFF.String->count == 0) return; ExtraStrings = calloc(CFF.String->count, sizeof *ExtraStrings); sp = ExtraStringSpace = malloc(CFF.String->count + CFF.String->offset[CFF.String->count]); for (c = 0; c < CFF.String->count; c++) { ExtraStrings[c] = sp; for (i = CFF.String->offset[c]; i < CFF.String->offset[c+1]; i++) *sp++ = contents[i]; *sp++ = 0; } nExtraStrings = c; } static void otfalloc(int _nc) { nc = _nc; gid2sid = calloc(nc, sizeof *gid2sid); if (a) { afmalloc(a, nc); a->gid2tr = calloc(nc, sizeof *a->gid2tr); } } static void get_CFF(void) { size_t o; char buf[4]; if (pos_CFF < 0) error("no CFF table"); CFF.baseoffset = o = table_directories[pos_CFF].offset; if (o + 4 >= size) error("no CFF header"); memcpy(buf, &contents[o], 4); o += 4; if (buf[0] != 1) error("can only handle CFF major version 1"); CFF.Name = get_INDEX(&o); CFF.Top_DICT = get_INDEX(&o); CFF.String = get_INDEX(&o); build_ExtraStrings(); CFF.Global_Subr = get_INDEX(&o); o = get_CFF_Top_DICT_Entry(17); o += CFF.baseoffset; CFF.CharStrings = get_INDEX(&o); if (CFF.Name->count != 1) error("cannot handle CFF data with more than one font"); a->fontname = malloc(CFF.Name->offset[1] - CFF.Name->offset[0] + 1); memcpy(a->fontname, &contents[CFF.Name->offset[0]], CFF.Name->offset[1] - CFF.Name->offset[0]); a->fontname[CFF.Name->offset[1] - CFF.Name->offset[0]] = 0; #ifdef DUMP print(SHOW_NAME, "name %s", a->fontname); #endif if (CFF.CharStrings == NULL || CFF.CharStrings->count == 0) error("no characters in font"); otfalloc(CFF.CharStrings->count); get_CFF_Charset(); afmremap(a); } /*ARGSUSED*/ static void get_ttf_post_1_0(int o __unused) { int i; otfalloc(numGlyphs); for (i = 0; i < numGlyphs; i++) onechar(i, i); } static void get_ttf_post_2_0(int o) { size_t numberOfGlyphs; size_t numberNewGlyphs; size_t i, j, n; char *cp, *sp; numberOfGlyphs = pbe16(&contents[o+32]); if (34+2*numberOfGlyphs > table_directories[pos_post].length) error("numberOfGlyphs value in post table too large"); otfalloc(numberOfGlyphs); numberNewGlyphs = 0; for (i = 0; i < numberOfGlyphs; i++) { n = pbe16(&contents[o+34+2*i]); if (n >= 258) { n -= 258; if (n >= numberNewGlyphs) numberNewGlyphs = n + 1; } } ExtraStrings = calloc(numberNewGlyphs, sizeof *ExtraStrings); sp = ExtraStringSpace = malloc(table_directories[pos_post].length - 34 - 2*numberOfGlyphs); cp = &contents[o+34+2*numberOfGlyphs]; for (i = 0; i < numberNewGlyphs; i++) { if (cp >= &contents[o + table_directories[pos_post].length]) break; ExtraStrings[i] = sp; n = *cp++ & 0377; if (&cp[n] > &contents[o + table_directories[pos_post].length]) break; for (j = 0; j < n; j++) *sp++ = *cp++; *sp++ = 0; } nExtraStrings = i; for (i = 0; i < numberOfGlyphs; i++) { n = pbe16(&contents[o+34+2*i]); onechar(i, n); } } static void get_ttf_post_2_5(int o) { size_t numberOfGlyphs, i; int offset; numberOfGlyphs = pbe16(&contents[o+32]); if (34+numberOfGlyphs > table_directories[pos_post].length) error("numberOfGlyphs value in post table too large"); otfalloc(numberOfGlyphs); for (i = 0; i < numberOfGlyphs; i++) { offset = ((signed char *)contents)[o+34+i]; onechar(i, i + offset); } } static void unichar(int gid, int c) { int i; char *sp; for (i = 0; WGL[i].s; i++) if (WGL[i].u == c) { onechar(gid, i); return; } if (ExtraStrings == NULL) ExtraStrings = calloc(nc, sizeof *ExtraStrings); if (ExtraStringSpace == NULL) ExtraStringSpace = malloc(nc * 12); sp = &ExtraStringSpace[ExtraStringSpacePos]; ExtraStrings[nExtraStrings] = sp; ExtraStringSpacePos += snprintf(sp, 10, "uni%04X", c) + 1; onechar(gid, nWGL + nExtraStrings++); } #if !defined (DPOST) && !defined (DUMP) #include "unimap.h" static void addunimap(int gid, int c) { struct unimap ***up, *u, *ut; int x, y; if (c != 0 && (c&~0xffff) == 0) { if (a->unimap == NULL) a->unimap = calloc(256, sizeof *up); up = a->unimap; x = c >> 8; y = c & 0377; if (up[x] == NULL) up[x] = calloc(256, sizeof **up); u = calloc(1, sizeof *u); u->u.code = gid; if (up[x][y] != NULL) { for (ut = up[x][y]; ut->next; ut = ut->next); ut->next = u; } else up[x][y] = u; } } #endif /* !DPOST && !DUMP */ #if defined(DPOST) || defined(DUMP) #define __actual_use __unused #else #define __actual_use #endif static void addunitab(int c __actual_use, int u __actual_use) { #if !defined (DPOST) && !defined (DUMP) if (c >= a->nunitab) { a->unitab = realloc(a->unitab, (c+1) * sizeof *a->unitab); memset(&a->unitab[a->nunitab], 0, (c+1-a->nunitab) * sizeof *a->unitab); a->nunitab = c+1; } a->unitab[c] = u; addunimap(c, u); #endif } static char *got_gid; static void -got_mapping(int c, int gid, int addchar) +got_mapping(int c, unsigned long gid, int addchar) { if (gid < nc) { if (addchar) { if (!got_gid[gid]) { unichar(gid, c); got_gid[gid] = 1; } } else { addunitab(a->gid2tr[gid].ch1, c); addunitab(a->gid2tr[gid].ch2, c); } } } static int get_ms_unicode_cmap4(int o, int addchar) { /* int length; */ int segCount; int endCount; int startCount; int idDelta; int idRangeOffset; /* int glyphIdArray; */ int c, e, i, d, r, s, gid; size_t x; /* length = */ pbe16(&contents[o+2]); segCount = pbe16(&contents[o+6]) / 2; endCount = o + 14; startCount = endCount + 2*segCount + 2; idDelta = startCount + 2*segCount; idRangeOffset = idDelta + 2*segCount; /* glyphIdArray = idRangeOffset + 2*segCount; */ for (i = 0; i < segCount; i++) { s = pbe16(&contents[startCount+2*i]); e = pbe16(&contents[endCount+2*i]); d = pbe16(&contents[idDelta+2*i]); r = pbe16(&contents[idRangeOffset+2*i]); for (c = s; c <= e; c++) { if (r) { x = r + 2*(c - s) + idRangeOffset+2*i; if (x+1 >= table_directories[pos_cmap].offset + table_directories[pos_cmap].length) continue; gid = pbe16(&contents[x]); if (gid != 0) gid += d; } else gid = c + d; gid &= 0xffff; if (gid != 0) got_mapping(c, gid, addchar); } } return 1; } static int get_ms_unicode_cmap12(int o, int addchar) { /* int length; */ int nGroups; int startCharCode; int endCharCode; int startGlyphID; int c, i, gid; /* length = */ pbe32(&contents[o+4]); nGroups = pbe32(&contents[o+12]); o += 16; for (i = 0; i < nGroups; i++) { startCharCode = pbe32(&contents[o]); endCharCode = pbe32(&contents[o+4]); startGlyphID = pbe32(&contents[o+8]); for (c = startCharCode, gid = startGlyphID; c <= endCharCode; c++, gid++) got_mapping(c, gid, addchar); o += 12; } return 1; } static int get_ms_unicode_cmap(int o, int addchar) { int format; format = pbe16(&contents[o]); switch (format) { case 4: return get_ms_unicode_cmap4(o, addchar); case 12: return get_ms_unicode_cmap12(o, addchar); default: return 0; } } static int get_cmap(int addchar) { size_t nTables, i; int platformID; int encodingID; int offset; int o; int want_tbl; int gotit = 0; if (pos_cmap < 0) { if (addchar) error("no cmap table"); return gotit; } o = table_directories[pos_cmap].offset; if (pbe16(&contents[o]) != 0) { if (addchar) error("can only handle version 0 cmap tables"); return gotit; } nTables = pbe16(&contents[o+2]); if (4 + 8*nTables > table_directories[pos_cmap].length) { if (addchar) error("cmap table too small for values inside"); return gotit; } if (addchar) otfalloc(numGlyphs); want_tbl = -1; for (i = 0; i < nTables; i++) { platformID = pbe16(&contents[o+4+8*i]); encodingID = pbe16(&contents[o+4+8*i+2]); if ((platformID == 3 && encodingID == 10) || (want_tbl < 0 && ((platformID == 3 && (encodingID == 0 || encodingID == 1)) || platformID == 0))) want_tbl = i; } if (want_tbl >= 0) { offset = pbe32(&contents[o+4+8*want_tbl+4]); gotit |= get_ms_unicode_cmap(o + offset, addchar); } return gotit; } static void get_ttf_post_3_0(int o __unused) { int i, n; int gotit; char *sp; size_t l; ttf = 2; got_gid = calloc(numGlyphs, sizeof *got_gid); gotit = get_cmap(1); if (gotit <= 0) { ttf = 3; ExtraStrings = calloc(numGlyphs, sizeof *ExtraStrings); l = n = 12 * numGlyphs; sp = ExtraStringSpace = malloc(l); n_strcpy(sp, ".notdef", l); ExtraStrings[0] = sp; sp += 8; nExtraStrings = 1; onechar(0, 0); for (i = 1; i < numGlyphs; i++) { ExtraStrings[i] = sp; sp += snprintf(sp, n - (sp - ExtraStringSpace), "index0x%02X", i) + 1; if (sp >= &ExtraStringSpace[n]) sp = &ExtraStringSpace[n]; nExtraStrings++; onechar(i, i); } } else { n = numGlyphs * 12; if (ExtraStrings == NULL) ExtraStrings = calloc(numGlyphs, sizeof *ExtraStrings); if (ExtraStringSpace == NULL) ExtraStringSpace = malloc(n); sp = &ExtraStringSpace[ExtraStringSpacePos]; for (i = 0; i < numGlyphs; i++) if (got_gid[i] == 0) { ExtraStrings[nExtraStrings] = sp; sp += snprintf(sp, n - (sp - ExtraStringSpace), "index0x%02X", i) + 1; if (sp >= &ExtraStringSpace[n]) sp = &ExtraStringSpace[n]; onechar(i, nWGL + nExtraStrings++); } } free(got_gid); got_gid = NULL; } static void ttfname(void) { if (a) { if (PostScript_name && strchr(PostScript_name, ' ') == NULL) a->fontname = strdup(PostScript_name); else { const char *base = a->Font.namefont[0] ? a->Font.namefont : a->base; size_t l = strlen(base) + 5; a->fontname = malloc(l); n_strcpy(a->fontname, base, l); n_strcat(a->fontname, ".TTF", l); } #ifdef DUMP print(SHOW_NAME, "name %s", a->fontname); #endif } } static void get_ttf(void) { long o; int Version; if (pos_post < 0) error("no post table"); o = table_directories[pos_post].offset; switch (Version = pbe32(&contents[o])) { case 0x00010000: ttfname(); get_ttf_post_1_0(o); break; case 0x00020000: ttfname(); get_ttf_post_2_0(o); break; case 0x00025000: ttfname(); get_ttf_post_2_5(o); break; case 0x00030000: ttfname(); get_ttf_post_3_0(o); break; default: error("cannot handle TrueType fonts with " "version %d.%d post table", Version>>16, (Version&0xffff) >> 12); } if (a) afmremap(a); } static void get_head(void) { long o; if (pos_head < 0) error("no head table"); o = table_directories[pos_head].offset; if (pbe32(&contents[o]) != 0x00010000) error("can only handle version 1.0 head tables"); unitsPerEm = pbe16(&contents[o + 18]); xMin = (int16_t)pbe16(&contents[o + 36]); yMin = (int16_t)pbe16(&contents[o + 38]); xMax = (int16_t)pbe16(&contents[o + 40]); yMax = (int16_t)pbe16(&contents[o + 42]); indexToLocFormat = pbe16(&contents[o + 50]); } static void get_post(void) { long o; isFixedPitch = 0; minMemType42 = maxMemType42 = -1; if (pos_post < 0) return; o = table_directories[pos_post].offset; if (pbe32(&contents[o]) > 0x00030000) return; if (table_directories[pos_post].length >= 16) isFixedPitch = pbe32(&contents[o+12]); if (a) a->isFixedPitch = isFixedPitch; if (table_directories[pos_post].length >= 20) minMemType42 = pbe32(&contents[o+16]); if (table_directories[pos_post].length >= 24) maxMemType42 = pbe32(&contents[o+20]); } static void get_maxp(void) { if (pos_maxp < 0) error("no maxp table"); numGlyphs = pbe16(&contents[table_directories[pos_maxp].offset+4]); } static char * build_string(int o, int length, int ucs) { char *string, *sp; int i; int ch; sp = string = malloc(3*length + 1); for (i = 0; i < length; i++) { if (ucs) { ch = pbe16(&contents[o+i]); i++; } else ch = contents[o+i]&0377; if ((ch & 0200) == 0) { switch (ch) { case '\\': case '(': case ')': *sp++ = '\\'; /*FALLTHRU*/ default: *sp++ = ch; } } else if (ch == 169) { /* * 169 happens to be COPYRIGHT SIGN in both MacRoman and * Unicode. */ *sp++ = '('; *sp++ = 'c'; *sp++ = ')'; } } *sp = 0; return string; } static void get_name(void) { char **sp; long o; int count; int stringOffset; int i; int platformID; int encodingID; int languageID; int nameID; int length; int offset; if (pos_name < 0) return; o = table_directories[pos_name].offset; if (pbe16(&contents[o]) != 0) return; count = pbe16(&contents[o+2]); stringOffset = o + pbe16(&contents[o+4]); for (i = 0; i < count; i++) { platformID = pbe16(&contents[o+6+12*i]); encodingID = pbe16(&contents[o+6+12*i+2]); languageID = pbe16(&contents[o+6+12*i+4]); nameID = pbe16(&contents[o+6+12*i+6]); length = pbe16(&contents[o+6+12*i+8]); offset = pbe16(&contents[o+6+12*i+10]); switch (nameID) { case 0: sp = &Copyright; break; case 6: sp = &PostScript_name; break; case 7: sp = &Notice; break; default: sp = NULL; } if (sp != NULL && *sp == NULL) { if (platformID == 1 && encodingID == 0 && languageID == 0) *sp = build_string(stringOffset+offset, length, 0); else if (platformID == 3 && languageID == 0x409) *sp = build_string(stringOffset+offset, length, 1); } } } static void get_OS_2(void) { long o; if (pos_OS_2 < 0) goto dfl; o = table_directories[pos_OS_2].offset; if (pbe16(&contents[o]) > 0x0003) goto dfl; if (table_directories[pos_OS_2].length >= 6) WeightClass = pbe16(&contents[o+4]); else WeightClass = -1; if (table_directories[pos_OS_2].length >= 10) fsType = pbe16(&contents[o+8]); else fsType = -1; if (table_directories[pos_OS_2].length >= 72) { if (a) { a->ascender = _unitconv((int16_t)pbe16(&contents[o + 68])); a->descender = _unitconv((int16_t)pbe16(&contents[o + 70])); } } if (table_directories[pos_OS_2].length >= 92) { if (a) { a->xheight = _unitconv(pbe16(&contents[o + 88])); a->capheight = _unitconv(pbe16(&contents[o + 90])); } } else { dfl: if (a) { a->xheight = 500; a->capheight = 700; } } } static char * -GID2SID(int gid) +GID2SID(unsigned long gid) { - if (gid < 0 || gid >= nc) + if (gid >= nc) return NULL; return getSID(gid2sid[gid]); } int fprintenc(FILE *fd, const char *enc) { const char *cp; for (cp = enc; *cp && !isspace(*cp); cp++); if (*cp) { return fprintf(fd, "(%s) cvn", enc); } else { return fprintf(fd, "/%s", enc); } } #ifndef DPOST static int ScriptList; static int FeatureList; static int LookupList; struct cov { int offset; int CoverageFormat; int RangeCount; int GlyphCount; int cnt; int gid; }; static struct cov * open_cov(int o) { struct cov *cp; cp = calloc(1, sizeof *cp); cp->offset = o; switch (cp->CoverageFormat = pbe16(&contents[o])) { default: free(cp); return NULL; case 1: cp->GlyphCount = pbe16(&contents[o+2]); return cp; case 2: cp->RangeCount = pbe16(&contents[o+2]); cp->gid = -1; return cp; } } -static int +static unsigned long get_cov(struct cov *cp) { int Start, End; switch (cp->CoverageFormat) { default: - return -1; + return (unsigned long)-1; case 1: if (cp->cnt < cp->GlyphCount) return pbe16(&contents[cp->offset+4+2*cp->cnt++]); - return -1; + return (unsigned long)-1; case 2: while (cp->cnt < cp->RangeCount) { Start = pbe16(&contents[cp->offset+4+6*cp->cnt]); End = pbe16(&contents[cp->offset+4+6*cp->cnt+2]); if (cp->gid > End) { cp->gid = -1; cp->cnt++; continue; } if (cp->gid < Start) cp->gid = Start; return cp->gid++; } - return -1; + return (unsigned long)-1; } } static void free_cov(struct cov *cp) { free(cp); } struct class { int offset; int ClassFormat; int StartGlyph; int GlyphCount; int ClassRangeCount; int cnt; int gid; }; static struct class * open_class(int o) { struct class *cp; cp = calloc(1, sizeof *cp); cp->offset = o; switch (cp->ClassFormat = pbe16(&contents[o])) { default: free(cp); return NULL; case 1: cp->StartGlyph = pbe16(&contents[o+2]); cp->GlyphCount = pbe16(&contents[o+4]); return cp; case 2: cp->ClassRangeCount = pbe16(&contents[o+2]); cp->gid = -1; return cp; } } static inline void get_class(struct class *cp, int *gp, int *vp) { int Start, End; switch (cp->ClassFormat) { case 1: if (cp->cnt < cp->GlyphCount) { *gp = cp->StartGlyph + cp->cnt; *vp = _pbe16(&contents[cp->offset+6+2*cp->cnt]); cp->cnt++; return; } goto dfl; case 2: while (cp->cnt < cp->ClassRangeCount) { Start = _pbe16(&contents[cp->offset+4+6*cp->cnt]); End = _pbe16(&contents[cp->offset+4+6*cp->cnt+2]); if (cp->gid > End) { cp->gid = -1; cp->cnt++; continue; } if (cp->gid < Start) cp->gid = Start; *gp = cp->gid++; *vp = _pbe16(&contents[cp->offset+4+6*cp->cnt+4]); return; } /*FALLTHRU*/ default: dfl: *gp = -1; *vp = -1; return; } } static void free_class(struct class *cp) { free(cp); } static int get_value_size(int ValueFormat1, int ValueFormat2) { int i, sz = 0; for (i = 0; i < 16; i++) if (ValueFormat1 & (1<= nc ? NULL : nametable[gid]) static inline void -kernpair(int first, int second, int x) +kernpair(unsigned long first, unsigned long second, int x) { struct namecache *np1, *np2; if (x == 0 || (x = _unitconv(x)) == 0) return; np1 = GID2name(first); np2 = GID2name(second); if (np1 == NULL || np2 == NULL) return; if (np1->fival[0] != NOCODE && np2->fival[0] != NOCODE) afmaddkernpair(a, np1->fival[0], np2->fival[0], x); if (np1->fival[0] != NOCODE && np2->fival[1] != NOCODE) afmaddkernpair(a, np1->fival[0], np2->fival[1], x); if (np1->fival[1] != NOCODE && np2->fival[0] != NOCODE) afmaddkernpair(a, np1->fival[1], np2->fival[0], x); if (np1->fival[1] != NOCODE && np2->fival[1] != NOCODE) afmaddkernpair(a, np1->fival[1], np2->fival[1], x); } static void kernfinish(void) { free(nametable); } #endif /* !DUMP */ static void -get_PairValueRecord(int first, int ValueFormat1, int ValueFormat2, int o) +get_PairValueRecord(int first, int ValueFormat1, int ValueFormat2 __unused, int o) { int second; int x; second = _pbe16(&contents[o]); x = get_x_adj(ValueFormat1, o+2); kernpair(first, second, x); } static void get_PairSet(int first, int ValueFormat1, int ValueFormat2, int o) { int PairValueCount; int i; int sz; PairValueCount = _pbe16(&contents[o]); sz = get_value_size(ValueFormat1, ValueFormat2); for (i = 0; i < PairValueCount; i++) get_PairValueRecord(first, ValueFormat1, ValueFormat2, o+2+(2+sz)*i); } static void get_PairPosFormat1(int o) { struct cov *cp; int Coverage; int ValueFormat1, ValueFormat2; int PairSetCount; int first; int i; Coverage = o + pbe16(&contents[o+2]); if ((cp = open_cov(Coverage)) == NULL) return; ValueFormat1 = pbe16(&contents[o+4]); ValueFormat2 = pbe16(&contents[o+6]); PairSetCount = pbe16(&contents[o+8]); for (i = 0; i < PairSetCount && (first = get_cov(cp)) >= 0; i++) get_PairSet(first, ValueFormat1, ValueFormat2, o + pbe16(&contents[o+10+2*i])); free_cov(cp); } static void get_PairPosFormat2(int o) { struct class *c1, *c2; int ValueFormat1, ValueFormat2; int ClassDef1, ClassDef2; int Class1Count, Class2Count; int g, *g2 = NULL; int v, *v2 = NULL; int sz; int i, n, a; int x; ValueFormat1 = pbe16(&contents[o+4]); ValueFormat2 = pbe16(&contents[o+6]); ClassDef1 = o + pbe16(&contents[o+8]); ClassDef2 = o + pbe16(&contents[o+10]); Class1Count = pbe16(&contents[o+12]); Class2Count = pbe16(&contents[o+14]); sz = get_value_size(ValueFormat1, ValueFormat2); if ((c1 = open_class(ClassDef1)) != NULL) { if ((c2 = open_class(ClassDef2)) != NULL) { n = a = 0; while (get_class(c2, &g, &v), g >= 0) { if (v < 0 || v >= Class2Count) continue; if (n >= a) { a = a ? 2*a : 128; g2 = realloc(g2, a * sizeof *g2); v2 = realloc(v2, a * sizeof *v2); } g2[n] = g; v2[n] = v; n++; } while (get_class(c1, &g, &v), g >= 0) { if (v < 0 || v >= Class1Count) continue; for (i = 0; i < n; i++) { x = get_x_adj(ValueFormat1, o + 16 + v*Class2Count*sz + v2[i]*sz); kernpair(g, g2[i], x); } } free_class(c2); } free_class(c1); } free(g2); free(v2); } static void -get_GPOS_kern1(int _t, int o, const char *_name) +get_GPOS_kern1(int _t __unused, int o, const char *_name __unused) { int PosFormat; got_kern = 1; switch (PosFormat = pbe16(&contents[o])) { case 1: get_PairPosFormat1(o); break; } } static void -get_GPOS_kern2(int _t, int o, const char *_name) +get_GPOS_kern2(int _t __unused, int o, const char *_name __unused) { int PosFormat; got_kern = 1; switch (PosFormat = pbe16(&contents[o])) { case 2: get_PairPosFormat2(o); break; } } static void get_Ligature(int first, int o) { int LigGlyph; - int CompCount; + unsigned int CompCount; int Component[16]; - int i; + unsigned int i; char *gn; LigGlyph = pbe16(&contents[o]); CompCount = pbe16(&contents[o+2]); for (i = 0; i < CompCount - 1 && i < sizeof Component / sizeof *Component - 1; i++) { Component[i] = pbe16(&contents[o+4+2*i]); } Component[i] = -1; gn = GID2SID(first); if (gn && gn[0] == 'f' && gn[1] == 0 && CompCount > 1) { gn = GID2SID(Component[0]); if (gn && gn[0] && gn[1] == 0) switch (gn[0]) { case 'f': if (CompCount == 2) { gn = GID2SID(LigGlyph); if (gn && (strcmp(gn, "ff") == 0 || strcmp(gn, "f_f") == 0)) a->Font.ligfont |= LFF; } else if (CompCount == 3) { gn = GID2SID(Component[1]); if (gn[0] && gn[1] == 0) switch (gn[0]) { case 'i': gn = GID2SID(LigGlyph); if (gn && (strcmp(gn, "ffi") == 0 || strcmp(gn, "f_f_i") == 0)) a->Font.ligfont |= LFFI; break; case 'l': gn = GID2SID(LigGlyph); if (gn && (strcmp(gn, "ffl") == 0 || strcmp(gn, "f_f_l") == 0)) a->Font.ligfont |= LFFL; break; } } break; case 'i': if (CompCount == 2) { gn = GID2SID(LigGlyph); if (gn && (strcmp(gn, "fi") == 0 || strcmp(gn, "f_i") == 0)) a->Font.ligfont |= LFI; } break; case 'l': if (CompCount == 2) { gn = GID2SID(LigGlyph); if (gn && (strcmp(gn, "fl") == 0 || strcmp(gn, "f_l") == 0)) a->Font.ligfont |= LFL; } break; } } } static void get_LigatureSet(int first, int o) { int LigatureCount; int i; LigatureCount = pbe16(&contents[o]); for (i = 0; i < LigatureCount; i++) get_Ligature(first, o + pbe16(&contents[o+2+2*i])); } static void -get_LigatureSubstFormat1(int _t, int o, const char *_name) +get_LigatureSubstFormat1(int _t __unused, int o, const char *_name __unused) { struct cov *cp; int Coverage; int LigSetCount; int i; int first; if (pbe16(&contents[o]) != 1) return; Coverage = o + pbe16(&contents[o+2]); if ((cp = open_cov(Coverage)) == NULL) return; LigSetCount = pbe16(&contents[o+4]); for (i = 0; i < LigSetCount && (first = get_cov(cp)) >= 0; i++) get_LigatureSet(first, o + pbe16(&contents[o+6+2*i])); free_cov(cp); } static struct feature * add_feature(const char *name) { int i; char *np; if (a->features == NULL) a->features = calloc(1, sizeof *a->features); for (i = 0; a->features[i]; i++) if (strcmp(a->features[i]->name, name) == 0) return a->features[i]; a->features = realloc(a->features, (i+2) * sizeof *a->features); a->features[i] = calloc(1, sizeof **a->features); a->features[i]->name = strdup(name); for (np = a->features[i]->name; *np; np++) if (*np == ' ') { *np = 0; break; } a->features[i+1] = NULL; return a->features[i]; } static void add_substitution_pair1(struct feature *fp, int ch1, int ch2) { fp->pairs = realloc(fp->pairs, (fp->npairs+1) * sizeof *fp->pairs); fp->pairs[fp->npairs].ch1 = ch1; fp->pairs[fp->npairs].ch2 = ch2; fp->npairs++; } static void add_substitution_pair(struct feature *fp, int ch1, int ch2) { if (ch1 && ch2) { #ifdef DUMP print(SHOW_SUBSTITUTIONS, "feature %s substitution %s %s", fp->name, GID2SID(ch1), GID2SID(ch2)); #endif if (a->gid2tr[ch1].ch1) { if (a->gid2tr[ch2].ch1) add_substitution_pair1(fp, a->gid2tr[ch1].ch1, a->gid2tr[ch2].ch1); if (a->gid2tr[ch2].ch2) add_substitution_pair1(fp, a->gid2tr[ch1].ch1, a->gid2tr[ch2].ch2); } if (a->gid2tr[ch1].ch2) { if (a->gid2tr[ch2].ch1) add_substitution_pair1(fp, a->gid2tr[ch1].ch2, a->gid2tr[ch2].ch1); if (a->gid2tr[ch2].ch2) add_substitution_pair1(fp, a->gid2tr[ch1].ch2, a->gid2tr[ch2].ch2); } } } static void get_SingleSubstitutionFormat1(int o, const char *name) { struct feature *fp; struct cov *cp; - int c, d; + unsigned long c, d; int Coverage; - int DeltaGlyphID; + unsigned long DeltaGlyphID; if (pbe16(&contents[o]) != 1) return; Coverage = o + pbe16(&contents[o+2]); if ((cp = open_cov(Coverage)) == NULL) return; DeltaGlyphID = pbe16(&contents[o+4]); fp = add_feature(name); - while ((c = get_cov(cp)) >= 0) + while ((c = get_cov(cp)) != (unsigned long)-1) if ((d = c + DeltaGlyphID) < nc) add_substitution_pair(fp, c, d); free_cov(cp); } static void get_SingleSubstitutionFormat2(int o, const char *name) { struct feature *fp; struct cov *cp; int Coverage; int GlyphCount; int c, i; if (pbe16(&contents[o]) != 2) return; Coverage = o + pbe16(&contents[o+2]); if ((cp = open_cov(Coverage)) == NULL) return; GlyphCount = pbe16(&contents[o+4]); fp = add_feature(name); for (i = 0; i < GlyphCount && (c = get_cov(cp)) >= 0; i++) add_substitution_pair(fp, c, pbe16(&contents[o+6+2*i])); free_cov(cp); } static void get_substitutions(int type, int o, const char *name) { int format; format = pbe16(&contents[o]); switch (type) { case 1: switch (format) { case 1: get_SingleSubstitutionFormat1(o, name); break; case 2: get_SingleSubstitutionFormat2(o, name); break; } } } static void get_lookup(int o, int type, const char *name, void (*func)(int, int, const char *)) { int i, j, t, x, y; int LookupCount; int SubTableCount; LookupCount = pbe16(&contents[o+2]); for (i = 0; i < LookupCount; i++) { x = pbe16(&contents[o+4+2*i]); y = pbe16(&contents[LookupList+2+2*x]); if ((t = pbe16(&contents[LookupList+y])) == type || type < 0) { SubTableCount = pbe16(&contents[LookupList+y+4]); for (j = 0; j < SubTableCount; j++) func(t, LookupList+y + pbe16(&contents[LookupList+y+6+2*j]), name); } } } static void get_LangSys(int o, const char *name, int type, void (*func)(int, int, const char *)) { char nb[5]; int i, x; int FeatureCount; int ReqFeatureIndex; ReqFeatureIndex = pbe16(&contents[o+2]); FeatureCount = pbe16(&contents[o+4]); if (ReqFeatureIndex != 0xFFFF) FeatureCount += ReqFeatureIndex; for (i = 0; i < FeatureCount; i++) { x = pbe16(&contents[o+6+2*i]); if (name == NULL || memcmp(&contents[FeatureList+2+6*x], name, 4) == 0) { memcpy(nb, &contents[FeatureList+2+6*x], 4); nb[4] = 0; get_lookup(FeatureList + pbe16(&contents[FeatureList+2+6*x+4]), type, nb, func); } } } static void get_feature(int table, const char *name, int type, void (*func)(int, int, const char *)) { long o; int i; int DefaultLangSys; int ScriptCount; int Script; if (table < 0) return; o = table_directories[table].offset; if (pbe32(&contents[o]) != 0x00010000) return; ScriptList = o + pbe16(&contents[o+4]); FeatureList = o + pbe16(&contents[o+6]); LookupList = o + pbe16(&contents[o+8]); ScriptCount = pbe16(&contents[ScriptList]); for (i = 0; i < ScriptCount; i++) if (memcmp(&contents[ScriptList+2+6*i], "DFLT", 4) == 0 || memcmp(&contents[ScriptList+2+6*i], "latn", 4) == 0) { Script = ScriptList + pbe16(&contents[ScriptList+2+6*i+4]); DefaultLangSys = Script + pbe16(&contents[Script]); get_LangSys(DefaultLangSys, name, type, func); } } static void get_kern_subtable(int o) { int length; int coverage; int nPairs; int i; int left, right, value; if (pbe16(&contents[o]) != 0) return; length = pbe16(&contents[o+2]); coverage = pbe16(&contents[o+4]); if ((coverage&1) != 1 || /* check: horizontal data */ (coverage&2) != 0 || /* . . . kerning values */ (coverage&4) != 0 || /* . . . not perpendicular */ ((coverage&0xff00) != 0)) /* . . . format 0 */ return; got_kern = 1; nPairs = pbe16(&contents[o+6]); for (i = 0; i < nPairs; i++) { if (o + 14 + 6 * (i+1) > o + length) break; left = pbe16(&contents[o+14+6*i]); right = pbe16(&contents[o+14+6*i+2]); value = (int16_t)pbe16(&contents[o+14+6*i+4]); kernpair(left, right, value); } } static void get_kern(void) { - long o; + unsigned long o; int nTables; int i, length; if (pos_kern < 0) return; o = table_directories[pos_kern].offset; if (pbe16(&contents[o]) != 0) return; nTables = pbe16(&contents[o+2]); o += 4; for (i = 0; i < nTables; i++) { if (o + 6 > table_directories[pos_kern].offset + table_directories[pos_kern].length) return; length = pbe16(&contents[o+2]); if (o + length > table_directories[pos_kern].offset + table_directories[pos_kern].length) return; get_kern_subtable(o); o += length; } } #endif /* !DPOST */ #ifdef DPOST static void checkembed(void) { /* * Do not check the embedding bits under the assumption that the * resulting PostScript file is sent to a printer. This follows * Adobe's "Font Embedding Guidelines for Adobe Third-party * Developers", 5/16/05, p. 8. * * It is the responsibility of a following distiller command or * the like to check the fsType bit then. * if (fsType != -1 && (fsType&0x030e) == 0x0002 || fsType & 0x0200) error("embedding not allowed"); */ } int otfcff(const char *path, char *_contents, size_t _size, size_t *offset, size_t *length) { int ok = 0; (void) &ok; a = NULL; filename = path; contents = _contents; size = _size; if (setjmp(breakpoint) == 0) { get_offset_table(); get_table_directories(); get_OS_2(); if (pos_CFF < 0) error("no CFF table"); checkembed(); *offset = table_directories[pos_CFF].offset; *length = table_directories[pos_CFF].length; } else ok = -1; return ok; } static uint32_t CalcTableChecksum(uint32_t sum, const char *cp, int length) { while (length > 0) { sum += pbe32(cp); cp += 4; length -= 4; } return sum; } static void sfnts1(struct table *tp, int *offset, uint32_t *ccs, FILE *fp __unused) { int o, length; o = table_directories[*tp->pos].offset; length = table_directories[*tp->pos].length; if (tp->in_sfnts == 2) /* head table */ memset(&contents[o+8], 0, 4); /* checkSumAdjustment */ tp->checksum = CalcTableChecksum(0, &contents[o], length); *ccs = CalcTableChecksum(*ccs, tp->name, 4); *ccs += tp->checksum; *ccs += *offset; *ccs += length; *offset += length; } static void sfnts1a(struct table *tp, int *offset, uint32_t *ccs, FILE *fp) { int o, length, m; o = table_directories[*tp->pos].offset; length = table_directories[*tp->pos].length; if (tp->in_sfnts == 2) { *ccs -= 0xB1B0AFBA; contents[o+8] = (*ccs&0xff000000) >> 24; contents[o+9] = (*ccs&0x00ff0000) >> 16; contents[o+10] = (*ccs&0x0000ff00) >> 8; contents[o+11] = (*ccs&0x000000ff); } fprintf(fp, "%08X%08X%08X%08X", pbe32(tp->name), (unsigned int)tp->checksum, *offset, length); if ((m = length % 4) != 0) length += 4 - m; *offset += length; } static int start_of_next_glyph(int *start, int offset) { int i = *start; int last = INT_MAX; int cur; int o; int tms = 0; if (pos_loca < 0) error("no loca table"); o = table_directories[pos_loca].offset; for (;;) { if (i >= numGlyphs) { i = 0; if (tms++ == 4) return -1; } cur = indexToLocFormat ? pbe32(&contents[o + 4*i]) : pbe16(&contents[o + 2*i]) * 2; if (offset > last && offset < cur) { *start = i; return cur; } if (cur < last) last = cur; i++; } } static void sfnts2(struct table *tp, FILE *fp) { const char hex[] = "0123456789ABCDEF"; int i, o, length, next = -1; int start = 0; o = table_directories[*tp->pos].offset; length = table_directories[*tp->pos].length; putc('<', fp); for (i = 0; i < length; i++) { if (i && i % 36 == 0) putc('\n', fp); if (i && i % 60000 == 0 && tp->in_sfnts == 3) { /* split string at start of next glyph */ next = start_of_next_glyph(&start, i); } if (i == next) fprintf(fp, "00><"); if (i && i % 65534 == 0 && tp->in_sfnts != 3) fprintf(fp, "00>\n<"); putc(hex[(contents[o+i]&0360)>>4], fp); putc(hex[contents[o+i]&017], fp); } while (i++ % 4) fprintf(fp, "00"); fprintf(fp, "00>\n"); } static void build_sfnts(FILE *fp) { int i, o, n; unsigned short nTables; unsigned short searchRange; unsigned short entrySelector; unsigned short rangeShift; uint32_t ccs; nTables = 0; for (i = 0; tables[i].name; i++) if (tables[i].in_sfnts && *tables[i].pos >= 0) nTables++; entrySelector = 0; for (searchRange = 1; searchRange*2 < nTables; searchRange *= 2) entrySelector++; searchRange *= 16; rangeShift = nTables * 16 - searchRange; fprintf(fp, "<%08X%04hX%04hX%04hX%04hX\n", 0x00010000, nTables, searchRange, entrySelector, rangeShift); ccs = 0x00010000 + (nTables<<16) + searchRange + (entrySelector<<16) + rangeShift; o = 12 + nTables * 16; for (i = 0; tables[i].name; i++) if (tables[i].in_sfnts && *tables[i].pos >= 0) sfnts1(&tables[i], &o, &ccs, fp); o = 12 + nTables * 16; n = 0; for (i = 0; tables[i].name; i++) { if (tables[i].in_sfnts && *tables[i].pos >= 0) { if (n++) putc('\n', fp); sfnts1a(&tables[i], &o, &ccs, fp); } } fprintf(fp, "00>\n"); for (i = 0; tables[i].name; i++) if (tables[i].in_sfnts && *tables[i].pos >= 0) sfnts2(&tables[i], fp); } int otft42(char *font, char *path, char *_contents, size_t _size, FILE *fp) { const char *cp; int ok = 0; - int i; + unsigned long i; (void) &ok; a = NULL; filename = path; contents = _contents; size = _size; if (setjmp(breakpoint) == 0) { get_offset_table(); get_table_directories(); get_head(); get_OS_2(); get_post(); get_maxp(); get_name(); if (ttf == 0) error("not a TrueType font file"); checkembed(); get_ttf(); if (minMemType42 >= 0 && maxMemType42 >= 0 && (minMemType42 || maxMemType42)) fprintf(fp, "%%%%VMUsage: %d %d\n", minMemType42, maxMemType42); fprintf(fp, "11 dict begin\n"); fprintf(fp, "/FontType 42 def\n"); fprintf(fp, "/FontMatrix [1 0 0 1 0 0] def\n"); fprintf(fp, "/FontName /%s def\n", font); fprintf(fp, "/FontBBox [%d %d %d %d] def\n", xMin * 1000 / unitsPerEm, yMin * 1000 / unitsPerEm, xMax * 1000 / unitsPerEm, yMax * 1000 / unitsPerEm); fprintf(fp, "/PaintType 0 def\n"); fprintf(fp, "/Encoding StandardEncoding def\n"); if (fsType != -1 || Notice || Copyright || WeightClass) { fprintf(fp, "/FontInfo 4 dict dup begin\n"); if (fsType != -1) fprintf(fp, "/FSType %d def\n", fsType); if (Notice) fprintf(fp, "/Notice (%s) readonly def\n", Notice); if (Copyright) fprintf(fp, "/Copyright (%s) readonly def\n", Copyright); if (WeightClass) { if (WeightClass <= 350) cp = "Light"; else if (WeightClass <= 550) cp = "Medium"; else if (WeightClass <= 750) cp = "Bold"; else if (WeightClass <= 850) cp = "Ultra"; else cp = "Heavy"; fprintf(fp, "/Weight (%s) readonly def\n", cp); } fprintf(fp, "end readonly def\n"); } - fprintf(fp, "/CharStrings %d dict dup begin\n", nc); + fprintf(fp, "/CharStrings %lu dict dup begin\n", nc); for (i = 0; i < nc; i++) { if ((cp = GID2SID(i)) != NULL && (i == 0 || strcmp(cp, ".notdef"))) { fprintenc(fp, cp); - fprintf(fp, " %d def\n", i); + fprintf(fp, " %lu def\n", i); } else - fprintf(fp, "/index0x%02X %d def\n", i, i); + fprintf(fp, "/index0x%02lX %lu def\n", i, i); } fprintf(fp, "end readonly def\n"); fprintf(fp, "/sfnts["); build_sfnts(fp); fprintf(fp, "]def\n"); fprintf(fp, "FontName currentdict end definefont pop\n"); } else ok = -1; free(PostScript_name); PostScript_name = 0; free(Copyright); Copyright = 0; free(Notice); Notice = 0; free(ExtraStringSpace); ExtraStringSpace = NULL; ExtraStringSpacePos = 0; free(ExtraStrings); ExtraStrings = NULL; nExtraStrings = 0; return ok; } #endif /* DPOST */ int otfget(struct afmtab *_a, char *_contents, size_t _size) { int ok = 0; (void) &ok; a = _a; filename = a->path; contents = _contents; size = _size; if (setjmp(breakpoint) == 0) { get_offset_table(); get_table_directories(); get_head(); get_OS_2(); get_post(); if (ttf == 0) { a->type = TYPE_OTF; get_CFF(); } else { a->type = TYPE_TTF; get_maxp(); get_name(); get_ttf(); } #ifndef DPOST kerninit(); get_feature(pos_GSUB, "liga", 4, get_LigatureSubstFormat1); get_feature(pos_GPOS, "kern", 2, get_GPOS_kern1); get_feature(pos_GPOS, "kern", 2, get_GPOS_kern2); get_feature(pos_GSUB, NULL, -1, get_substitutions); if (ttf && got_kern == 0) get_kern(); kernfinish(); get_cmap(0); #endif /* !DPOST */ a->Font.nwfont = a->nchars > 255 ? 255 : a->nchars; } else ok = -1; free(PostScript_name); PostScript_name = 0; free(Copyright); Copyright = 0; free(Notice); Notice = 0; free_INDEX(CFF.Name); CFF.Name = 0; free_INDEX(CFF.Top_DICT); CFF.Top_DICT = 0; free_INDEX(CFF.String); CFF.String = 0; free_INDEX(CFF.Global_Subr); CFF.Global_Subr = 0; free_INDEX(CFF.CharStrings); CFF.CharStrings = 0; free(ExtraStringSpace); ExtraStringSpace = NULL; ExtraStringSpacePos = 0; free(ExtraStrings); ExtraStrings = NULL; nExtraStrings = 0; free(a->gid2tr); a->gid2tr = NULL; return ok; } Index: vendor/heirloom-doctools/dist/troff/troff.d/otfdump.c =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/otfdump.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/otfdump.c (revision 310550) @@ -1,213 +1,215 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)otfdump.c 1.15 (gritter) 3/16/06 */ static enum show { SHOW_CHARS = 001, SHOW_KERNPAIRS = 002, SHOW_SUBSTITUTIONS = 004, SHOW_NAME = 010 } show; #include static void print(enum show, const char *, ...); #define DUMP #include #include #include "otf.c" #include "afm.c" #include static const char *progname; struct dev dev; char *chname; short *chtab; int nchtab; static int prname; static void print(enum show s, const char *fmt, ...) { va_list ap; if (show & s) { if (prname) printf("%s: ", filename); va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); putchar('\n'); } } void verrprint(const char *s, va_list ap) { fprintf(stderr, "%s: ", progname); vfprintf(stderr, s, ap); putc('\n', stderr); } void errprint(const char *s, ...) { va_list ap; va_start(ap, s); verrprint(s, ap); va_end(ap); } static void devinit(void) { dev.res = 72000; dev.hor = dev.vert = 1; dev.unitwidth = 1; dev.afmfonts = 1; } static void usage(void) { errprint("usage: %s [-ckns] font ...", progname); exit(2); } static int dump(const char *name) { struct afmtab A; struct stat st; FILE *fp; char *cp; if ((fp = fopen(filename = name, "r")) == NULL) { errprint("%s: cannot open", filename); return 1; } memset(&A, 0, sizeof A); a = &A; a->file = a->path = (char *)filename; a->base = strdup(filename); a->base = basename(a->base); if ((cp = strrchr(a->base, '.')) != NULL) *cp = '\0'; if (fstat(fileno(fp), &st) < 0) { errprint("%s: cannot stat", filename); return 1; } size = st.st_size; contents = malloc(size); if (fread(contents, 1, size, fp) != size) { errprint("%s: cannot read", filename); return 1; } fclose(fp); return otfget(a, contents, size) != 0; } int main(int argc, char **argv) { int i, e = 0; progname = basename(argv[0]); devinit(); while ((i = getopt(argc, argv, "ckns")) != EOF) { switch (i) { case 'c': show |= SHOW_CHARS; break; case 'k': show |= SHOW_KERNPAIRS; break; case 'n': show |= SHOW_NAME; break; case 's': show |= SHOW_SUBSTITUTIONS; break; default: usage(); } } if (show == 0) show = 0xFFFFFFFF; if (argc < optind + 1) usage(); prname = argc > optind + 1; for (i = optind; i < argc; i++) e |= dump(argv[i]); return e; } void -afmaddchar(struct afmtab *a, int C, int tp, int cl, int WX, int B[4], char *N, - enum spec s, int gid) +afmaddchar(struct afmtab *a __unused, int C __unused, int tp __unused, + int cl __unused, int WX, int B[4] __unused, char *N, + enum spec s __unused, int gid __unused) { if (N) print(SHOW_CHARS, "char %s width %d", N, _unitconv(WX)); } void -afmalloc(struct afmtab *a, int n) +afmalloc(struct afmtab *a __unused, int n __unused) { } void -afmaddkernpair(struct afmtab *a, int ch1, int ch2, int k) +afmaddkernpair(struct afmtab *a __unused, int ch1 __unused, int ch2 __unused, + int k __unused) { } static void kernpair(int first, int second, int x) { char *s1, *s2; if (x) { s1 = GID2SID(first); s2 = GID2SID(second); if (s1 && s2) print(SHOW_KERNPAIRS, "kernpair %s %s width %d", s1, s2, _unitconv(x)); } } static void kerninit(void) { } static void kernfinish(void) { } Index: vendor/heirloom-doctools/dist/troff/troff.d/pt.h =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/pt.h (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/pt.h (revision 310550) @@ -1,96 +1,96 @@ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)pt.h 1.54 (gritter) 8/19/08 */ /* t6.c */ extern int width(register tchar); extern void zapwcache(int); -extern int getcw(register int); +extern int getcw(size_t); extern int abscw(int); extern int onfont(tchar); extern int getascender(void); extern int getdescender(void); extern int kernadjust(tchar, tchar); extern void xbits(register tchar, int); extern tchar setch(int); extern tchar setabs(void); extern int findft(register int, int); extern void caseps(void); extern void casps1(register int); extern int findps(register int); extern void mchbits(void); extern void setps(void); extern tchar setht(void); extern tchar setslant(void); extern void caseft(void); extern void setfont(int); extern void setwd(void); extern tchar vmot(void); extern tchar hmot(void); extern tchar mot(void); extern tchar sethl(int); extern tchar makem(register int); extern tchar getlg(tchar); extern int strlg(int, int *, int); extern void caselg(void); extern void caseflig(int); extern void casefdeferlig(void); extern void casefp(int); extern void casefps(void); extern int setfp(int, int, char *); extern int nextfp(void); extern void casecs(void); extern void casebd(void); extern void casevs(void); extern void casess(int); extern void caseminss(void); extern void caseletadj(void); extern void casefspacewidth(void); extern void casespacewidth(void); extern tchar xlss(void); extern void casetrack(void); extern void casefallback(void); extern void casehidechar(void); extern void casefzoom(void); extern double getfzoom(void); extern void casekern(void); extern void casefkern(void); extern void casepapersize(void); extern void casemediasize(void); extern void casetrimat(void); extern void casebleedat(void); extern void casecropat(void); extern void caselhang(void); extern void caserhang(void); extern void casekernpair(void); extern void casekernafter(void); extern void casekernbefore(void); extern void caseftr(void); extern void casefeature(void); extern int un2tr(int, int *); extern int tr2un(tchar, int); extern tchar setuc0(int); extern tchar setanchor(void); extern tchar setlink(void); extern tchar setulink(void); extern int pts2u(int); extern double u2pts(int); /* t10.c */ extern void ptinit(void); extern void specnames(void); extern int findch(register const char *); -extern void ptout(register tchar); +void ptout(register tchar); extern tchar *ptout0(tchar *, tchar *); extern void ptps(void); extern void ptfont(void); extern void ptfpcmd(int, const char *, char *, int); extern void ptlead(void); extern void ptesc(void); extern void newpage(int); extern void ptsupplyfont(char *, char *); extern void ptlocale(const char *); extern void pttrailer(void); extern void ptstop(void); extern void dostop(void); Index: vendor/heirloom-doctools/dist/troff/troff.d/t10.c =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/t10.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/t10.c (revision 310550) @@ -1,1139 +1,1139 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 1989 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* from OpenSolaris "t10.c 1.11 05/06/08 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)t10.c 1.98 (gritter) 8/19/08 */ /* * Changes Copyright (c) 2014 Carsten Kunze (carsten.kunze at arcor.de) */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved * * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. */ #include #include "tdef.h" #include #include #include #include #ifdef EUC #include #endif #include "ext.h" #include "dev.h" #include "afm.h" #include "pt.h" #include "troff.h" #include "unimap.h" #include "fontmap.h" /* * troff10.c * * typesetter interface */ int vpos = 0; /* absolute vertical position on page */ int hpos = 0; /* ditto horizontal */ int initbdtab[NFONT+1]; short *chtab; char *chname; int **fontab; char **kerntab; unsigned short **fitab; unsigned short **codetab; int Inch; int Hor; int Vert; int Unitwidth; int nfonts; static int nsizes; -int nchtab; +size_t nchtab; int lettrack; float horscale; static float mzoom; static int mtrack; static float mhorscale; /* these characters are used as various signals or values * in miscellaneous places. * values are set in specnames in t10.c */ int c_hyphen; int c_emdash; int c_endash; int c_rule; int c_minus; int c_fi; int c_fl; int c_ff; int c_ffi; int c_ffl; int c_acute; int c_grave; int c_under; int c_rooten; int c_boxrule; int c_lefthand; int c_dagger; struct dev dev; struct Font **fontbase; int Nfont; static int okern(tchar *, tchar *, int); static void pthorscale(int); static void pttrack(int); static void ptanchor(int); static void ptlink(int); static void ptulink(int); static void ptyon(int); static void ptchar(int, int); -static void pnc(int, struct afmtab *); +static void pnc(size_t, struct afmtab *); void growfonts(int n) { int i, j; fontbase = realloc(fontbase, n * sizeof *fontbase); memset(&fontbase[Nfont], 0, (n - Nfont) * sizeof *fontbase); fontab = realloc(fontab, n * sizeof *fontab); memset(&fontab[Nfont], 0, (n - Nfont) * sizeof *fontab); kerntab = realloc(kerntab, n * sizeof *kerntab); memset(&kerntab[Nfont], 0, (n - Nfont) * sizeof *kerntab); codetab = realloc(codetab, n * sizeof *codetab); memset(&codetab[Nfont], 0, (n - Nfont) * sizeof *codetab); fitab = realloc(fitab, n * sizeof *fitab); memset(&fitab[Nfont], 0, (n - Nfont) * sizeof *fitab); fontlab = realloc(fontlab, n * sizeof *fontlab); memset(&fontlab[Nfont], 0, (n - Nfont) * sizeof *fontlab); cstab = realloc(cstab, n * sizeof *cstab); memset(&cstab[Nfont], 0, (n - Nfont) * sizeof *cstab); ccstab = realloc(ccstab, n * sizeof *ccstab); memset(&ccstab[Nfont], 0, (n - Nfont) * sizeof *ccstab); bdtab = realloc(bdtab, n * sizeof *bdtab); memset(&bdtab[Nfont], 0, (n - Nfont) * sizeof *bdtab); tracktab = realloc(tracktab, n * sizeof *tracktab); memset(&tracktab[Nfont], 0, (n - Nfont) * sizeof *tracktab); fallbacktab = realloc(fallbacktab, n * sizeof *fallbacktab); memset(&fallbacktab[Nfont], 0, (n - Nfont) * sizeof *fallbacktab); zoomtab = realloc(zoomtab, n * sizeof *zoomtab); memset(&zoomtab[Nfont], 0, (n - Nfont) * sizeof *zoomtab); lhangtab = realloc(lhangtab, n * sizeof *lhangtab); memset(&lhangtab[Nfont], 0, (n - Nfont) * sizeof *lhangtab); rhangtab = realloc(rhangtab, n * sizeof *rhangtab); memset(&rhangtab[Nfont], 0, (n - Nfont) * sizeof *rhangtab); kernafter = realloc(kernafter, n * sizeof *kernafter); memset(&kernafter[Nfont], 0, (n - Nfont) * sizeof *kernafter); kernbefore = realloc(kernbefore, n * sizeof *kernbefore); memset(&kernbefore[Nfont], 0, (n - Nfont) * sizeof *kernbefore); ftrtab = realloc(ftrtab, n * sizeof *ftrtab); for (i = Nfont; i < n; i++) { ftrtab[i] = malloc(NCHARS * sizeof **ftrtab); for (j = 0; j < NCHARS; j++) ftrtab[i][j] = j; } lgtab = realloc(lgtab, n * sizeof *lgtab); memset(&lgtab[Nfont], 0, (n - Nfont) * sizeof *lgtab); lgrevtab = realloc(lgrevtab, n * sizeof *lgrevtab); memset(&lgrevtab[Nfont], 0, (n - Nfont) * sizeof *lgrevtab); Nfont = n; } void ptinit(void) { int i, nw; char *filebase, *p, *ap, *descp; char *p2; size_t l; size_t l2; if (!strcmp(devname, "html")) html = 1; growfonts(NFONT+1); memcpy(bdtab, initbdtab, max((NFONT+1) * sizeof *bdtab, sizeof initbdtab)); uninit(); /* open table for device, * read in resolution, size info, font info, etc. * and set params */ l = strlen(termtab) + strlen(devname) + 10; l2 = l + 3; p = malloc(l); p2 = malloc(l2); n_strcpy(p, termtab, l); termtab = p; n_strcat(termtab, "/dev", l); n_strcat(termtab, devname, l); n_strcpy(p2, termtab, l2); n_strcat(p2, "/FONTMAP", l2); rdftmap(p2); free(p2); n_strcat(termtab, "/DESC", l); /* makes "..../devXXX/DESC" */ if ((descp = readdesc(termtab)) == NULL) done3(1); memcpy(&dev, descp, sizeof dev); Inch = dev.res; Hor = dev.hor; Vert = dev.vert; Unitwidth = dev.unitwidth; nfonts = dev.nfonts; nsizes = dev.nsizes; nchtab = dev.nchtab; - if (nchtab >= NCHARS - 128) { + if (nchtab >= (size_t)NCHARS - 128) { errprint("too many special characters in file %s", termtab); done3(1); } filebase = malloc(dev.filesize + 3*EXTRAFONT); /* enough room for whole file */ memcpy(filebase, &descp[sizeof dev], dev.filesize); /* all at once */ free(descp); pstab = (int *) filebase; for (i = 0; pstab[i]; i++) pstab[i] = pts2u(pstab[i]); chtab = (short *)(pstab + nsizes + 1); chname = (char *) (chtab + dev.nchtab); p = chname + dev.lchname; specnames(); /* install names like "hyphen", etc. */ for (i = 1; i <= nfonts; i++) { fontbase[i] = (struct Font *) p; nw = *p & BYTEMASK; /* 1st thing is width count */ fontlab[i] = PAIR(fontbase[i]->namefont[0], fontbase[i]->namefont[1]); /* for now, still 2 char names */ if (smnt == 0 && fontbase[i]->specfont == 1) smnt = i; /* first special font */ p += sizeof(struct Font); /* that's what's on the beginning */ if ((ap = strstr(fontbase[i]->namefont, ".afm")) != NULL) { *ap = 0; if (ap == &fontbase[i]->namefont[1]) fontlab[i] &= BYTEMASK; loadafm(i, fontlab[i], fontbase[i]->namefont, NULL, 1, SPEC_NONE); } else { makefont(i, p, p + nw, p + 2 * nw, p + 3 * nw, nw); } p += 3 * nw + dev.nchtab + 128 - 32; } fontbase[0] = (struct Font *) p; /* the last shall be first */ memset(fontbase[0], 0, sizeof *fontbase[0]); nw = EXTRAFONT - dev.nchtab - (128-32) - sizeof (struct Font); fontbase[0]->nwfont = nw; makefont(0, p, p + nw, p + 2 * nw, p + 3 * nw, nw); /* there are a lot of things that used to be constant * that now require code to be executed. */ sps = SPS; ses = SES; for (i = 0; i < 16; i++) tabtab[i] = DTAB * (i + 1); pl = 11 * INCH; po = PO; spacesz = SS; sesspsz = SSS; lss = lss1 = VS; ll = ll1 = lt = lt1 = LL; apts = pts2u(apts); apts1 = pts2u(apts1); pts = pts2u(pts); pts1 = pts2u(pts1); ics = ICS; for (i = 0; i <= nfonts; i++) setlig(i, fontbase[i]->ligfont); kern = xflag; if (ascii) return; fdprintf(ptid, "x T %s\n", devname); fdprintf(ptid, "x res %d %d %d\n", Inch, Hor, Vert); fdprintf(ptid, "x init\n"); /* do initialization for particular device */ /* for (i = 1; i <= nfonts; i++) fdprintf(ptid, "x font %d %s\n", i, fontbase[i]->namefont); fdprintf(ptid, "x xxx fonts=%d sizes=%d unit=%d\n", nfonts, nsizes, Unitwidth); fdprintf(ptid, "x xxx nchtab=%d lchname=%d nfitab=%d\n", dev.nchtab, dev.lchname, dev.nchtab+128-32); fdprintf(ptid, "x xxx sizes:\nx xxx "); for (i = 0; i < nsizes; i++) fdprintf(ptid, " %d", pstab[i]); fdprintf(ptid, "\nx xxx chars:\nx xxx "); for (i = 0; i < dev.nchtab; i++) fdprintf(ptid, " %s", &chname[chtab[i]]); fdprintf(ptid, "\nx xxx\n"); */ #ifdef EUC ptlocale(setlocale(LC_CTYPE, NULL)); #endif /* EUC */ free(termtab); } void specnames(void) { static struct { int *n; const char *v; } spnames[] = { { &c_hyphen , "hy" }, { &c_emdash , "em" }, { &c_endash , "en" }, { &c_rule , "ru" }, { &c_minus , "\\-"}, { &c_fi , "fi" }, { &c_fl , "fl" }, { &c_ff , "ff" }, { &c_ffi , "Fi" }, { &c_ffl , "Fl" }, { &c_acute , "aa" }, { &c_grave , "ga" }, { &c_under , "ul" }, { &c_rooten , "rn" }, { &c_boxrule , "br" }, { &c_lefthand, "lh" }, { &c_dagger , "dg" }, { 0 , 0 } }; static int twice; int i; if (twice++) return; for (i = 0; spnames[i].n; i++) *spnames[i].n = findch(spnames[i].v); } int findch(register const char *s) /* find char s in chname */ { - register int i; + size_t i; for (i = 0; i < nchtab; i++) if (strcmp(s, &chname[chtab[i]]) == 0) return(i + 128); return(0); } void ptout(register tchar i) { register int dv; register tchar *k; int temp, a, b; if (isadjspc(i)) return; if (olinep >= &oline[olinesz]) { olinesz += 100; k = realloc(oline, olinesz * sizeof *oline); olinep = (tchar *)((char *)olinep + ((char *)k-(char *)oline)); oline = k; } if (cbits(i) != '\n') { *olinep++ = i; return; } if (olinep == oline) { lead += lss; return; } hpos = po; /* ??? */ esc = 0; /* ??? */ ptesc(); /* the problem is to get back to the left end of the line */ dv = 0; for (k = oline; k < olinep; k++) { if (ismot(*k) && isvmot(*k)) { temp = absmot(*k); if (isnmot(*k)) temp = -temp; dv += temp; } } if (dv) { vflag++; *olinep++ = makem(-dv); vflag = 0; } b = dip->blss + lss; lead += dip->blss + lss; dip->blss = 0; if (linkout) linkhp = hpos; for (k = oline; k < olinep; ) k = ptout0(k, olinep); /* now passing a pointer! */ olinep = oline; lead += dip->alss; a = dip->alss; dip->alss = 0; if (linkout) ptlink(linkout); /* fdprintf(ptid, "x xxx end of line: hpos=%d, vpos=%d\n", hpos, vpos); */ fdprintf(ptid, "n%d %d\n", b, a); /* be nice to chuck */ } tchar * ptout0(tchar *pi, tchar *pend) { struct afmtab *a; register int j; register int k, w = 0; int z, dx, dy, dx2, dy2, n, c; register tchar i; int outsize; /* size of object being printed */ double f; int tfont; outsize = 1; /* default */ i = *pi; k = cbits(i); if (k == FILLER) return(pi+outsize); if (ismot(i)) { j = absmot(i); if (isnmot(i)) j = -j; if (isvmot(i)) lead += j; else esc += j; return(pi+outsize); } if (k == XON) { if (xfont != mfont) ptfont(); if (xpts != mpts || zoomtab[xfont] != mzoom) ptps(); if (lead) ptlead(); if (esc) ptesc(); fdprintf(ptid, "x X "); /* * not guaranteed of finding a XOFF if a word overflow * error occured, so also bound this loop by olinep */ pi++; while( cbits(*pi) != XOFF && pi < olinep ) outascii(*pi++); oput('\n'); if ( cbits(*pi) == XOFF ) pi++; return pi; } ; if (k == CHARHT) { if (xflag) { xfont = fbits(i); if (xfont != mfont) ptfont(); } if (xpts != mpts || zoomtab[xfont] != mzoom) ptps(); j = f = u2pts(sbits(i)); if (j != f && xflag && dev.anysize) fdprintf(ptid, "x H -23 %g\n", f); else fdprintf(ptid, "x H %d\n", j); return(pi+outsize); } if (k == SLANT) { if (xflag) { xfont = fbits(i); if (xfont != mfont) ptfont(); } fdprintf(ptid, "x S %d\n", (int)sbits(i)-180); return(pi+outsize); } if (k == WORDSP) { oput('w'); return(pi+outsize); } if (k == FONTPOS) { n = i >> 22; ptfpcmd(0, macname(n), NULL, 0); return(pi+outsize); } if (k == XFUNC) { switch (fbits(i)) { case ANCHOR: ptanchor(sbits(i)); return(pi+outsize); case LINKON: linkout = sbits(i); linkhp = hpos + esc; if (html) ptlink(sbits(i)); return(pi+outsize); case LINKOFF: ptlink(html ? 0 : sbits(i)); linkout = 0; return(pi+outsize); case ULINKON: linkout = sbits(i); linkhp = hpos + esc; if (html) ptulink(sbits(i)); return(pi+outsize); case ULINKOFF: ptulink(html ? 0 : sbits(i)); linkout = 0; return(pi+outsize); case INDENT: if (linkout) linkhp += sbits(i); return(pi+outsize); case LETSP: lettrack = sbits(i); return(pi+outsize); case NLETSP: lettrack = -sbits(i); return(pi+outsize); case LETSH: horscale = 1 + (double)sbits(i) / LAFACT; return(pi+outsize); case NLETSH: horscale = 1 - (double)sbits(i) / LAFACT; return(pi+outsize); case YON: if (&pi[outsize] >= pend) return(pi+outsize); ptyon(fetchrq(&pi[outsize])); return(pi+outsize+1); case CHAR: ptchar(sbits(i), iszbit(i) != 0); if (!iszbit(i)) esc += okern(pi, pend, outsize); return(pi+outsize); default: return(pi+outsize); } } if (sfbits(i) == oldbits) { xfont = pfont; xpts = ppts; } else xbits(i, 2); if (k < 040 && k != DRAWFCN) return(pi+outsize); if (k >= 32) { if (html && k >= NCHARS) w = getcw(0); else if (widcache[k-32].fontpts == xfont + (xpts<<8) && !setwdf && kern == 0 && horscale == 0) { w = widcache[k-32].width; lasttrack = widcache[k-32].track; bd = 0; cs = 0; } else { tfont = xfont; w = getcw(k-32); if (tfont != xfont) k = ftrans(xfont, k); } } if (xfont != mfont) ptfont(); if (xpts != mpts || zoomtab[xfont] != mzoom) ptps(); if (lead) ptlead(); if (lettrack || lasttrack || mtrack) pttrack(0); if (horscale || mhorscale) pthorscale(0); w += okern(pi, pend, outsize); if (afmtab && (j = (fontbase[xfont]->afmpos) - 1) >= 0) a = afmtab[j]; else a = NULL; j = z = 0; if (k != DRAWFCN) { if (cs && !fmtchar) { if (bd) w += (bd - 1) * HOR; j = (cs - w) / 2; w = cs - j; if (bd) w -= (bd - 1) * HOR; } if (iszbit(i)) { if (cs && !fmtchar) w = -j; else w = 0; z = 1; } } esc += j; /* put out the real character here */ if (k == DRAWFCN) { if (esc) ptesc(); dx = absmot(pi[3]); if (isnmot(pi[3])) dx = -dx; dy = absmot(pi[4]); if (isnmot(pi[4])) dy = -dy; switch ((c=cbits(pi[1]))) { case DRAWCIRCLE: /* circle */ case DRAWCIRCLEFI: fdprintf(ptid, "D%c %d\n", c, dx); /* dx is diameter */ w = 0; hpos += dx; break; case DRAWELLIPSE: case DRAWELLIPSEFI: fdprintf(ptid, "D%c %d %d\n", c, dx, dy); w = 0; hpos += dx; break; case DRAWLINE: /* line */ k = cbits(pi[2]); fdprintf(ptid, "D%c %d %d ", DRAWLINE, dx, dy); if (k < 128) fdprintf(ptid, "%c\n", k); else fdprintf(ptid, "%s\n", &chname[chtab[k - 128]]); w = 0; hpos += dx; vpos += dy; break; case DRAWARC: /* arc */ dx2 = absmot(pi[5]); if (isnmot(pi[5])) dx2 = -dx2; dy2 = absmot(pi[6]); if (isnmot(pi[6])) dy2 = -dy2; fdprintf(ptid, "D%c %d %d %d %d\n", DRAWARC, dx, dy, dx2, dy2); w = 0; hpos += dx + dx2; vpos += dy + dy2; break; case DRAWSPLINE: /* spline */ default: /* something else; copy it like spline */ fdprintf(ptid, "D%c %d %d", (int)cbits(pi[1]), dx, dy); w = 0; hpos += dx; vpos += dy; if (cbits(pi[3]) == DRAWFCN || cbits(pi[4]) == DRAWFCN) { /* it was somehow defective */ fdprintf(ptid, "\n"); break; } for (n = 5; cbits(pi[n]) != DRAWFCN; n += 2) { dx = absmot(pi[n]); if (isnmot(pi[n])) dx = -dx; dy = absmot(pi[n+1]); if (isnmot(pi[n+1])) dy = -dy; fdprintf(ptid, " %d %d", dx, dy); hpos += dx; vpos += dy; } fdprintf(ptid, "\n"); break; } for (n = 3; cbits(pi[n]) != DRAWFCN; n++) ; outsize = n + 1; } else if (k < 128) { /* try to go faster and compress output */ /* by printing nnc for small positive motion followed by c */ /* kludgery; have to make sure set all the vars too */ if (esc > 0 && esc < 100) { oput(esc / 10 + '0'); oput(esc % 10 + '0'); oput(k); hpos += esc; esc = 0; } else { if (esc) ptesc(); oput('c'); oput(k); oput('\n'); } } else { if (esc) ptesc(); pnc(k, a); } if (bd && !fmtchar) { bd -= HOR; if (esc += bd) ptesc(); if (k < 128) { fdprintf(ptid, "c%c\n", k); } else pnc(k, a); if (z) esc -= bd; } esc += w; lettrack = 0; horscale = 0; return(pi+outsize); } static void -pnc(int k, struct afmtab *a) { +pnc(size_t k, struct afmtab *a) { int j; if (k >= nchtab + 128) { if (a && (j = a->fitab[k-nchtab-128-32]) < a->nchars && a->nametab[j] != NULL) { fdprintf(ptid, "CPS%s\n", a->nametab[j]); } else { fdprintf(ptid, "N%d\n", k - (html ? 0 : (nchtab + 128)) ); } } else { fdprintf(ptid, "C%s\n", &chname[chtab[k - 128]]); } } static int okern(tchar *pi, tchar *pend, int outsize) { int j; for (j = outsize; &pi[j] < pend; j++) if (cbits(pi[j]) != XFUNC || (fbits(pi[j]) != LETSP && fbits(pi[j]) != NLETSP && fbits(pi[j]) != LETSH && fbits(pi[j]) != NLETSH)) break; if (&pi[j] < pend) return getkw(pi[0], pi[j]); else return 0; } static void pthorscale(int always) { if (horscale || mhorscale) { if (always || mhorscale != horscale) fdprintf(ptid, "x X HorScale %g\n", horscale ? horscale : 1.0); mhorscale = horscale; } else mhorscale = 0; } static void pttrack(int always) { if (xflag && (lasttrack || lettrack || mtrack)) { if (always || mtrack != (lasttrack + lettrack)) fdprintf(ptid, "x X Track %d\n", lasttrack + lettrack); mtrack = lasttrack + lettrack; } else mtrack = 0; } void ptps(void) { register int i, j, k; double s, z; int found; i = xpts; for (j = 0; i > (k = pstab[j]); j++) if (!k) { k = pstab[--j]; break; } found = k == i; if (dev.anysize && xflag) k = i; s = u2pts(k); if ((z = zoomtab[xfont]) != 0 && dev.anysize && xflag) s *= z; if (dev.anysize && xflag && (!found || (z != 0 && z != 1))) fdprintf(ptid, "s-23 %g\n", s); else fdprintf(ptid, "s%d\n", (int)s); /* really should put out string rep of size */ mpts = i; mzoom = z; pttrack(0); pthorscale(0); } void ptfont(void) { mfont = xfont; fdprintf(ptid, "f%d\n", xfont); mtrack = 0; pttrack(1); pthorscale(1); } void ptfpcmd(int f, const char *s, char *path, int flags) { if (ascii) return; fdprintf(ptid, "x font %d %s", f, s); if (path) { fdprintf(ptid, " %s", path); if (flags) fdprintf(ptid, " %d", flags); } fdprintf(ptid, "\n"); ptfont(); /* make sure that it gets noticed */ } void ptlead(void) { vpos += lead; if (!ascii) fdprintf(ptid, "V%d\n", vpos); lead = 0; } void ptesc(void) { hpos += esc; if (esc > 0) { oput('h'); if (esc>=10 && esc<100) { oput(esc/10 + '0'); oput(esc%10 + '0'); } else fdprintf(ptid, "%d", esc); } else fdprintf(ptid, "H%d\n", hpos); esc = 0; } void ptsupplyfont(char *fontname, char *file) { if (ascii) return; fdprintf(ptid, "x X SupplyFont %s %s\n", fontname, file); } void ptpapersize(void) { if (ascii || mediasize.flag == 0) return; fdprintf(ptid, "x X PaperSize %d %d %d\n", mediasize.val[2], mediasize.val[3], mediasize.flag&2?1:0); } static void cut1(const char *name, struct box *bp) { if (bp->flag) fdprintf(ptid, "x X %s %d %d %d %d\n", name, bp->val[0], bp->val[1], bp->val[2], bp->val[3]); } void ptcut(void) { if (ascii) return; cut1("TrimAt", &trimat); cut1("BleedAt", &bleedat); cut1("CropAt", &cropat); } void ptlocale(const char *cp) { static char *lp; if (cp != NULL) { size_t l; free(lp); l = strlen(cp) + 1; lp = malloc(l); n_strcpy(lp, cp, l); } if (ascii || realpage == 0 || lp == NULL || dev.lc_ctype == 0) return; fdprintf(ptid, "x X LC_CTYPE %s\n", lp); } static void ptanchor(int n) { struct ref *rp; if (ascii) return; for (rp = anchors; rp; rp = rp->next) if (rp->cnt == n) { if (html) { fdprintf(ptid, "x X Anchor %s\n", rp->name); } else { fdprintf(ptid, "x X Anchor %d,%d %s\n", vpos + lead - lss, hpos + esc, rp->name); } break; } } static void _ptlink(int n, struct ref *rstart, const char *type) { struct ref *rp; if (ascii) return; if (html && !n) { fdprintf(ptid, "x X %s\n", type); return; } for (rp = rstart; rp; rp = rp->next) if (rp->cnt == n) { if (html) fdprintf(ptid, "x X %s %s\n", type, rp->name); else fdprintf(ptid, "x X %s %d,%d,%d,%d %s\n", type, linkhp, vpos + pts2u(1), hpos + esc, vpos - pts * 8 / 10, rp->name); break; } } static void ptlink(int n) { _ptlink(n, links, "Link"); } static void ptulink(int n) { _ptlink(n, ulinks, "ULink"); } static void ptyon(int i) { struct contab *cp; tchar c; int k, nl; filep savip; if ((cp = findmx(i)) == NULL || !cp->mx) { nosuch(i); return; } if (xfont != mfont) ptfont(); if (xpts != mpts || zoomtab[xfont] != mzoom) ptps(); if (lead) ptlead(); if (esc) ptesc(); fdprintf(ptid, "x X "); savip = ip; ip = (filep)cp->mx; app = 1; k = -1; nl = 0; while ((c = rbf()) != 0) { if ((k = cbits(c)) != '\n') { while (nl--) oputs("\n+"); nl = 0; outascii(c); } else nl++; } while (nl-- > 1) oputs("\n+"); oput('\n'); app = 0; ip = savip; } static void ptchar1(struct charout *cp, int z) { filep savip; tchar i, *k, *savoline, *savolinep; size_t savolinesz; int savhpos, savvpos, savlettrack; savoline = oline; savolinep = olinep; savolinesz = olinesz; olinep = oline = NULL; olinesz = 0; savlettrack = lettrack; lettrack = 0; savhpos = hpos + esc; savvpos = vpos + lead; savip = ip; ip = cp->op; app++; fmtchar++; while ((i = rbf()) != 0 && cbits(i) != '\n' && cbits(i) != FLSS) pchar(i); for (k = oline; k < olinep; ) k = ptout0(k, olinep); fmtchar--; app--; ip = savip; free(oline); oline = savoline; olinep = savolinep; olinesz = savolinesz; lettrack = savlettrack; esc = savhpos - hpos; if (!z) esc += cs ? cs : cp->width + lettrack; lead = savvpos - vpos; } static void ptchar(int n, int z) { struct charout *cp = &charout[n]; int savbd; ptchar1(cp, z); if (bd) { bd -= HOR; if (esc += bd) ptesc(); savbd = bd; bd = 0; ptchar1(cp, z); bd = savbd; if (iszbit(cp->ch)) esc -= bd; } lettrack = 0; } void newpage(int n) /* called at end of each output page (we hope) */ { int i; realpage++; ptlead(); vpos = 0; if (ascii) return; fdprintf(ptid, "p%d\n", n); /* new page */ for (i = 0; i <= nfonts; i++) { if (fontbase[i] == NULL) continue; if (afmtab && fontbase[i]->afmpos) { struct afmtab *a = afmtab[(fontbase[i]->afmpos)-1]; if (a->encpath == NULL) a->encpath = afmencodepath(a->path); fdprintf(ptid, "x font %d %s %s %d\n", i, macname(fontlab[i]), a->encpath, (int)a->spec); if (a->supply) ptsupplyfont(a->fontname, a->supply); } else if (fontbase[i]->namefont[0]) fdprintf(ptid, "x font %d %s\n", i, macname(fontlab[i])); } ptps(); ptfont(); ptpapersize(); ptcut(); ptlocale(NULL); } void pttrailer(void) { fdprintf(ptid, "x trailer\n"); } void ptstop(void) { fdprintf(ptid, "x stop\n"); } void dostop(void) { if (ascii) return; ptlead(); vpos = 0; /* fdprintf(ptid, "x xxx end of page\n");*/ if (!nofeed) pttrailer(); ptlead(); fdprintf(ptid, "x pause\n"); flusho(); mpts = mfont = 0; ptesc(); esc = po; hpos = vpos = 0; /* probably in wrong place */ } Index: vendor/heirloom-doctools/dist/troff/troff.d/t6.c =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/t6.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/t6.c (revision 310550) @@ -1,3030 +1,3034 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* from OpenSolaris "t6.c 1.9 05/06/08 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)t6.c 1.194 (gritter) 2/7/10 */ /* * Changes Copyright (c) 2014 Carsten Kunze */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved * * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. */ /* * t6.c * * width functions, sizes and fonts */ #include #include #include #include #include #include "tdef.h" #include "dev.h" #include #include #include #include #include "ext.h" #include "afm.h" #include "pt.h" #include "troff.h" #include "fontmap.h" +int ps2cc(const char *name); + /* fitab[f][c] is 0 if c is not on font f */ /* if it's non-zero, c is in fontab[f] at position * fitab[f][c]. */ int *fontlab; int *pstab; int *cstab; int *ccstab; int **fallbacktab; float *zoomtab; int *bdtab; int **lhangtab; int **rhangtab; int **kernafter; int **kernbefore; int **ftrtab; struct lgtab **lgtab; int ***lgrevtab; struct tracktab *tracktab; static int sbold = 0; int kern = 0; struct box mediasize, bleedat, trimat, cropat; int psmaxcode; struct ref *anchors, *links, *ulinks; static int _minflg; int lastrst; int lastrsb; static int spacewidth; static void kernsingle(int **); static int _ps2cc(const char *name, int create); int width(register tchar j) { - register int i, k; + size_t i, k; _minflg = minflg; minflg = minspc = 0; lasttrack = 0; rawwidth = 0; lastrst = lastrsb = 0; if (isadjspc(j)) return(0); if (j & (ZBIT|MOT)) { if (iszbit(j)) return(0); if (isvmot(j)) return(0); k = absmot(j); if (isnmot(j)) k = -k; return(k); } i = cbits(j); - if (html && i >= NCHARS) + if (html && i >= (size_t)NCHARS) i = ' '; if (i < ' ') { if (i == '\b') return(-widthp); if (i == PRESC) i = eschar; else if (iscontrol(i)) return(0); else if (isxfunc(j, CHAR)) { k = charout[sbits(j)].width + lettrack; lastrst = charout[sbits(j)].height; lastrsb = -charout[sbits(j)].depth; goto set; } } else if (i == ' ' && issentsp(j)) { _minflg = 0; return(ses); } if (i==ohc) return(0); if (!xflag || !isdi(j)) { if (i == STRETCH) setcbits(j, ' '); i = trtab[i]; i = ftrans(fbits(j), i); } if (i < 32) return(0); lasttrack = 0; if (sfbits(j) == oldbits) { xfont = pfont; xpts = ppts; } else xbits(j, 0); if (widcache[i-32].fontpts == xfont + (xpts<<8) && (i > 32 || widcache[i-32].evid == evname) && !setwdf && !_minflg && !horscale) { rawwidth = widcache[i-32].width - widcache[i-32].track; k = widcache[i-32].width + lettrack; lastrst = widcache[i-32].rst; lastrsb = widcache[i-32].rsb; lasttrack = widcache[i-32].track; } else { if (_minflg && i == 32 && cbits(j) != 32) _minflg = 0; k = getcw(i-32); if (i == 32 && _minflg && !cs) { _minflg = 0; minspc = getcw(0) - k; } _minflg = 0; set: if (bd && !fmtchar) k += (bd - 1) * HOR; if (cs && !fmtchar) k = cs; } widthp = k; return(k); } /* * clear width cache-- s means just space */ void zapwcache(int s) { register int i; if (s) { widcache[0].fontpts = 0; return; } for (i=0; i= nchtab + 128-32) { if (afmtab && fontbase[xfont]->afmpos - 1 >= 0) { cd = nchtab + 128; i -= cd; } else { j = abscw(i + 32 - (nchtab+128)); goto g0; } } if (i == 0) { /* a blank */ if (_minflg) { j = minspsz; nocache = 1; } else j = spacesz; if (fontbase[xfont]->cspacewidth >= 0) k = fontbase[xfont]->cspacewidth; else if (spacewidth || gflag) k = fontbase[xfont]->spacewidth; else k = fontab[xfont][0]; k = (k * j + 6) / 12; lastrst = lastrsb = 0; /* this nonsense because .ss cmd uses 1/36 em as its units */ /* and default is 12 */ goto g1; } if ((j = fitab[xfont][i]) == 0) { /* it's not on current font */ int ii, jj, _t; /* search through search list of xfont * to see what font it ought to be on. * first searches explicit fallbacks, then * searches S, then remaining fonts in wraparound order. */ nocache = 1; if (fallbacktab[xfont]) { for (jj = 0; fallbacktab[xfont][jj] != 0; jj++) { if ((ii = findft(fallbacktab[xfont][jj],0)) < 0) continue; _t = ftrans(ii, i + 32) - 32; j = fitab[ii][_t]; if (j != 0) { xfont = ii; goto found; } } } if (smnt) { for (ii=smnt, jj=0; jj < nfonts; jj++, ii=ii % nfonts + 1) { if (fontbase[ii] == NULL) continue; _t = ftrans(ii, i + 32) - 32; j = fitab[ii][_t]; if (j != 0) { /* * troff traditionally relies on the * device postprocessor to find the * appropriate character since it * searches the fonts in the same * order. This does not work with the * new requests anymore, so change * the font explicitly. */ if (xflag) xfont = ii; found: p = fontab[ii]; k = *(p + j); if (afmtab && (_t=fontbase[ii]->afmpos-1)>=0) { a = afmtab[_t]; if (a->bbtab[j]) { lastrst = a->bbtab[j][3]; lastrsb = a->bbtab[j][1]; } else { lastrst = a->ascender; lastrsb = a->descender; } } if (xfont == sbold) bd = bdtab[ii]; if (setwdf) numtab[CT].val |= kerntab[ii][j]; goto g1; } } } k = fontab[xfont][0]; /* leave a space-size space */ lastrst = lastrsb = 0; goto g1; } g0: p = fontab[xfont]; if (setwdf) numtab[CT].val |= kerntab[xfont][j]; if (afmtab && (t = fontbase[xfont]->afmpos-1) >= 0) { a = afmtab[t]; if (a->bbtab[j]) { lastrst = a->bbtab[j][3]; lastrsb = a->bbtab[j][1]; } else { /* * Avoid zero values by all means. In many use * cases, endless loops will result unless values * are non-zero. */ lastrst = a->ascender; lastrsb = a->descender; } } k = *(p + j); if (dev.anysize == 0 || xflag == 0 || (z = zoomtab[xfont]) == 0) z = 1; g1: zv = z; if (horscale) { z *= horscale; nocache = 1; } if (!bd) bd = bdtab[ofont]; if ((cs = cstab[ofont])) { nocache = 1; if ((ccs = ccstab[ofont])) x = pts2u(ccs); else x = xpts; cs = (cs * EMPTS(x)) / 36; } k = (k * z * u2pts(xpts) + (Unitwidth / 2)) / Unitwidth; lastrst = (lastrst * zv * u2pts(xpts) + (Unitwidth / 2)) / Unitwidth; lastrsb = (lastrsb * zv * u2pts(xpts) + (Unitwidth / 2)) / Unitwidth; rawwidth = k; s = xpts; lasttrack = 0; if (s <= tracktab[ofont].s1 && tracktab[ofont].n1) lasttrack = tracktab[ofont].n1; else if (s >= tracktab[ofont].s2 && tracktab[ofont].n2) lasttrack = tracktab[ofont].n2; else if (s > tracktab[ofont].s1 && s < tracktab[ofont].s2) { int r; r = (s * tracktab[ofont].n2 - s * tracktab[ofont].n1 + tracktab[ofont].s2 * tracktab[ofont].n1 - tracktab[ofont].s1 * tracktab[ofont].n2) / (tracktab[ofont].s2 - tracktab[ofont].s1); if (r != 0) lasttrack = r; } k += lasttrack + lettrack; i += cd; if (nocache|bd) widcache[i].fontpts = 0; else { widcache[i].fontpts = xfont + (xpts<<8); widcache[i].width = k - lettrack; widcache[i].rst = lastrst; widcache[i].rsb = lastrsb; widcache[i].track = lasttrack; widcache[i].evid = evname; } return(k); /* Unitwidth is Units/Point, where * Units is the fundamental digitization * of the character set widths, and * Point is the number of goobies in a point * e.g., for cat, Units=36, Point=6, so Unitwidth=36/6=6 * In effect, it's the size at which the widths * translate directly into units. */ } int abscw(int n) /* return index of abs char n in fontab[], etc. */ { register int i, ncf; ncf = fontbase[xfont]->nwfont & BYTEMASK; for (i = 0; i < ncf; i++) if (codetab[xfont][i] == n) return i; return 0; } int onfont(tchar c) { - int k = cbits(c); + size_t k = cbits(c); int f = fbits(c); if (k <= ' ') return 1; k -= 32; if (k >= nchtab + 128-32) { if (afmtab && fontbase[f]->afmpos - 1 >= 0) k -= nchtab + 128; else return abscw(k + 32 - (nchtab+128)) != 0; } return fitab[f][k] != 0; } static int fvert2pts(int f, int s, int k) { double z; if (k != 0) { k = (k * u2pts(s) + (Unitwidth / 2)) / Unitwidth; if (dev.anysize && xflag && (z = zoomtab[f]) != 0) k *= z; } return k; } int getascender(void) { struct afmtab *a; int n; if ((n = fontbase[font]->afmpos - 1) >= 0) { a = afmtab[n]; return fvert2pts(font, pts, a->ascender); } else return 0; } int getdescender(void) { struct afmtab *a; int n; if ((n = fontbase[font]->afmpos - 1) >= 0) { a = afmtab[n]; return fvert2pts(font, pts, a->descender); } else return 0; } int kernadjust(tchar c, tchar e) { lastkern = 0; if (!kern || ismot(c) || ismot(e) || html) return 0; if (!isdi(c)) { c = trtab[cbits(c)] | (c & SFMASK); c = ftrans(fbits(c), cbits(c)) | (c & SFMASK); } if (!isdi(e)) { e = trtab[cbits(e)] | (e & SFMASK); e = ftrans(fbits(e), cbits(e)) | (e & SFMASK); } return getkw(c, e); } #define kprime 1021 #define khash(c, d) (((2654435769U * (c) * (d) >> 16)&0x7fffffff) % kprime) static struct knode { struct knode *next; tchar c; tchar d; int n; } **ktable; static void kadd(tchar c, tchar e, int n) { struct knode *kn; int h; if (ktable == NULL) ktable = calloc(kprime, sizeof *ktable); h = khash(c, e); kn = calloc(1, sizeof *kn); kn->c = c; kn->d = e; kn->n = n; kn->next = ktable[h]; ktable[h] = kn; } static void kzap(int f) { struct knode *kp; int i; if (ktable == NULL) return; for (i = 0; i < kprime; i++) for (kp = ktable[i]; kp; kp = kp->next) if (fbits(kp->c) == f || fbits(kp->d) == f) kp->n = INT_MAX; } static tchar findchar(tchar c) { - int f, i; + int f; + size_t i; f = fbits(c); c = cbits(c); i = c - 32; if (c != ' ' && i > 0 && i < nchtab + 128 - 32 && fitab[f][i] == 0) { int ii, jj; if (fallbacktab[f]) { for (jj = 0; fallbacktab[f][jj] != 0; jj++) { if ((ii = findft(fallbacktab[f][jj], 0)) < 0) continue; if (fitab[ii][i] != 0) { f = ii; goto found; } } } if (smnt) { for (ii=smnt, jj=0; jj < nfonts; jj++, ii=ii % nfonts + 1) { if (fontbase[ii] == NULL) continue; if (fitab[ii][i] != 0) { f = ii; goto found; } } } return 0; } found: setfbits(c, f); return c; } static struct knode * klook(tchar c, tchar e) { struct knode *kp; int h; c = findchar(c); e = findchar(e); h = khash(c, e); for (kp = ktable[h]; kp; kp = kp->next) if (kp->c == c && kp->d == e) break; return kp && kp->n != INT_MAX ? kp : NULL; } int getkw(tchar c, tchar e) { struct knode *kp; struct afmtab *a; - int f, g, i, j, k, n, s, I, J; + int f, g, i, j, k, n, s; + size_t I, J; double z; if (isxfunc(c, CHAR)) c = charout[sbits(c)].ch; if (isxfunc(e, CHAR)) e = charout[sbits(e)].ch; lastkern = 0; if (!kern || iszbit(c) || iszbit(e) || ismot(c) || ismot(e)) return 0; if (sbits(c) != sbits(e)) return 0; f = fbits(c); g = fbits(e); if ((s = sbits(c)) == 0) { s = xpts; if (f == 0) f = xfont; } i = cbits(c); j = cbits(e); if (i == SLANT || j == SLANT || i == XFUNC || j == XFUNC || cstab[f]) return 0; k = 0; if (i >= 32 && j >= 32) { if (ktable != NULL && (kp = klook(c, e)) != NULL) k = kp->n; else if ((n = (fontbase[f]->afmpos)-1) >= 0 && n == (fontbase[g]->afmpos)-1 && fontbase[f]->kernfont >= 0) { a = afmtab[n]; I = i - 32; J = j - 32; if (I >= nchtab + 128) I -= nchtab + 128; if (J >= nchtab + 128) J -= nchtab + 128; k = afmgetkern(a, I, J); if (abs(k) < fontbase[f]->kernfont) k = 0; } if (j>32 && kernafter != NULL && kernafter[fbits(c)] != NULL) k += kernafter[fbits(c)][i]; if (i>32 && kernbefore != NULL && kernbefore[fbits(e)] != NULL) k += kernbefore[fbits(e)][j]; } if (k != 0) { k = (k * u2pts(s) + (Unitwidth / 2)) / Unitwidth; if (dev.anysize && xflag && (z = zoomtab[f]) != 0) k *= z; } lastkern = k; return k; } void xbits(register tchar i, int bitf) { register int k; xfont = fbits(i); k = sbits(i); if (k) { xpts = dev.anysize && xflag ? k : pstab[--k]; oldbits = sfbits(i); pfont = xfont; ppts = xpts; return; } switch (bitf) { case 0: xfont = font; xpts = pts; break; case 1: xfont = pfont; xpts = ppts; break; case 2: xfont = mfont; xpts = mpts; } } static tchar postchar1(const char *temp, int f) { struct namecache *np; struct afmtab *a; int i; if (afmtab && (i = (fontbase[f]->afmpos) - 1) >= 0) { a = afmtab[i]; np = afmnamelook(a, temp); if (np->afpos != 0) { if (np->fival[0] != NOCODE && fitab[f][np->fival[0]]) return np->fival[0] + 32 + nchtab + 128; else if (np->fival[1] != NOCODE && fitab[f][np->fival[1]]) return np->fival[1] + 32 + nchtab + 128; else return 0; } } return(0); } static tchar postchar(const char *temp, int *fp) { int i, j; tchar c; *fp = font; if ((c = postchar1(temp, *fp)) != 0) return c; if (fallbacktab[font]) { for (j = 0; fallbacktab[font][j] != 0; j++) { if ((i = findft(fallbacktab[font][j], 0)) < 0) continue; if ((c = postchar1(temp, i)) != 0 && fchartab[c] == 0) { *fp = i; return c; } } } if (smnt) { for (i=smnt, j=0; j < nfonts; j++, i=i % nfonts + 1) { if (fontbase[i] == NULL) continue; if ((c = postchar1(temp, i)) != 0 && fchartab[c] == 0) { *fp = i; return c; } } } return 0; } static const struct amap { const char *alias; const char *trname; } amap[] = { { "lq", "``" }, { "rq", "''" }, { NULL, NULL } }; tchar setch(int delim) { - register int j; + size_t j; char temp[NC]; tchar c, e[2] = {0, 0}; int f; size_t n; const struct amap *ap; n = 0; if (delim == 'C') e[0] = getach(); do { c = getach(); if (c == 0 && n < 2) return(0); if (n >= sizeof temp) { temp[n-1] = 0; break; } if ((delim == '[' && c == ']') || (delim == 'C' && c == e[0])) { temp[n] = 0; break; } temp[n++] = c; if (delim == '(' && n == 2) { temp[n] = 0; break; } } while (c); for (ap = amap; ap->alias; ap++) if (!strcmp(ap->alias, temp)) { size_t l; const char *s = ap->trname; if ((l = strlen(s) + 1) > NC) { fprintf(stderr, "%s %i: strlen(%s)+1 > %d\n", __FILE__, __LINE__, s, NC); break; } memcpy(temp, s, l); break; } if (delim == '[' && c != ']') { nodelim(']'); return ' '; } if (delim == 'C' && c != e[0]) { nodelim(e[0]); return ' '; } c = 0; if (delim == '[' || delim == 'C') { size_t l = strlen(temp); if (gemu) { if (l == 5 && *temp == 'u' && isxdigit((unsigned)temp[1]) && isxdigit((unsigned)temp[2]) && isxdigit((unsigned)temp[3]) && isxdigit((unsigned)temp[4])) { n = strtol(temp + 1, NULL, 16); if (n) c = setuc0(n); } else if ((l == 6 || (l == 7 && isdigit((unsigned)temp[6]))) && isdigit((unsigned)temp[5]) && isdigit((unsigned)temp[4]) && !strncmp(temp, "char", 4)) { int i = atoi(temp + 4); if (i <= 127) c = i + nchtab + 128; } } if (!c && (c = postchar(temp, &f))) { c |= chbits & ~FMASK; setfbits(c, f); } } if (c == 0) for (j = 0; j < nchtab; j++) if (strcmp(&chname[chtab[j]], temp) == 0) { c = (j + 128) | chbits; break; } if (c == 0 && delim == '(') if ((c = postchar(temp, &f)) != 0) { c |= chbits & ~FMASK; setfbits(c, f); } if (c == 0 && (c = _ps2cc(temp, 0)) != 0) { c += nchtab + 128 + 32 + 128 - 32 + nchtab; if (chartab[c] == NULL) c = 0; } if (c == 0 && warn & WARN_CHAR) errprint("missing glyph \\%c%s%s%s%s", delim, e, temp, e, delim == '[' ? "]" : ""); if (c == 0 && !tryglf) c = ' '; return c; } tchar setabs(void) /* set absolute char from \C'...' */ { int n; getch(); n = 0; n = inumb(&n); getch(); - if (nonumb || n + nchtab + 128 >= NCHARS) + if (nonumb || n + nchtab + 128 >= (size_t)NCHARS) return 0; return n + nchtab + 128; } int findft(register int i, int required) { register int k; int nk; const char *mn; char *mp; if ((k = i - '0') >= 0 && k <= nfonts && k < smnt && fontbase[k]) return(k); for (k = 0; k > nfonts || fontlab[k] != i; k++) if (k > nfonts) { mn = macname(i); nk = k; if ((k = strtol(mn, &mp, 10)) >= 0 && *mp == 0 && mp > mn && k <= nfonts && fontbase[k]) break; if (setfp(nk, i, NULL) == -1) return -1; else { fontlab[nk] = i; return nk; } if (required && warn & WARN_FONT) errprint("%s: no such font", mn); return(-1); } return(k); } void caseps(void) { register int i; if (skip(0)) i = apts1; else { if (xflag == 0) { noscale++; apts = u2pts(apts); } else { dfact = INCH; dfactd = 72; res = VERT; } i = inumb(&apts); if (xflag == 0) { noscale--; i = pts2u(i); apts = pts2u(apts); } if (nonumb) return; } casps1(i); } void casps1(register int i) { /* * in olden times, it used to ignore changes to 0 or negative. * this is meant to allow the requested size to be anything, * in particular so eqn can generate lots of \s-3's and still * get back by matching \s+3's. if (i <= 0) return; */ apts1 = apts; apts = i; pts1 = pts; pts = findps(i); mchbits(); } int findps(register int i) { register int j, k; if (dev.anysize && xflag) { if (i <= 0) i = pstab[0]; return i; } for (j=k=0 ; pstab[j] != 0 ; j++) if (abs(pstab[j]-i) < abs(pstab[k]-i)) k = j; return(pstab[k]); } void mchbits(void) { register int i, j, k; i = pts; if (dev.anysize && xflag) j = i - 1; else for (j = 0; i > (k = pstab[j]); j++) if (!k) { k = pstab[--j]; break; } chbits = 0; setsbits(chbits, ++j); setfbits(chbits, font); zapwcache(1); if (minspsz) { k = spacesz; spacesz = minspsz; minsps = width(' ' | chbits); spacesz = k; zapwcache(1); } if (letspsz) { k = spacesz; spacesz = letspsz; letsps = width(' ' | chbits); spacesz = k; zapwcache(1); } k = spacesz; spacesz = sesspsz; ses = width(' ' | chbits); spacesz = k; zapwcache(1); sps = width(' ' | chbits); zapwcache(1); } void setps(void) { tchar c; register int i, j = 0; int k; i = cbits(c = getch()); if (ismot(c) && xflag) return; if (ischar(i) && isdigit(i)) { /* \sd or \sdd */ i -= '0'; if (i == 0) /* \s0 */ j = apts1; else if (i <= 3 && ischar(j = cbits(ch = getch())) && isdigit(j)) { /* \sdd */ j = 10 * i + j - '0'; ch = 0; j = pts2u(j); } else /* \sd */ j = pts2u(i); } else if (i == '(') { /* \s(dd */ j = cbits(getch()) - '0'; j = 10 * j + cbits(getch()) - '0'; if (j == 0) /* \s(00 */ j = apts1; else j = pts2u(j); } else if (i == '+' || i == '-') { /* \s+, \s- */ j = cbits(c = getch()); if (ischar(j) && isdigit(j)) { /* \s+d, \s-d */ j -= '0'; j = pts2u(j); } else if (j == '(') { /* \s+(dd, \s-(dd */ j = cbits(getch()) - '0'; j = 10 * j + cbits(getch()) - '0'; j = pts2u(j); } else if (xflag) { /* \s+[dd], */ k = j == '[' ? ']' : j; /* \s-'dd' */ setcbits(c, k); dfact = INCH; dfactd = 72; res = HOR; j = hatoi(); res = dfactd = dfact = 1; if (nonumb) return; if (!issame(getch(), c)) nodelim(k); } if (i == '-') j = -j; j += apts; } else if (xflag) { /* \s'+dd', \s[dd] */ if (i == '[') { i = ']'; setcbits(c, i); } dfact = INCH; dfactd = 72; res = HOR; j = inumb2(&apts, &k); if (nonumb) return; if (j == 0 && k == 0) j = apts1; if (!issame(getch(), c)) nodelim(i); } casps1(j); } tchar setht(void) /* set character height from \H'...' */ { int n; tchar c; getch(); dfact = INCH; dfactd = 72; res = VERT; n = inumb(&apts); getch(); if (n == 0 || nonumb) n = apts; /* does this work? */ c = CHARHT; c |= ZBIT; setfbits(c, font); setsbits(c, n); return(c); } tchar setslant(void) /* set slant from \S'...' */ { int n; tchar c; getch(); n = 0; n = inumb(&n); getch(); if (nonumb) n = 0; c = SLANT; c |= ZBIT; setfbits(c, font); setsbits(c, n+180); return(c); } void caseft(void) { skip(0); setfont(1); } void setfont(int a) { register int i, j; if (a) i = getrq(3); else i = getsn(1); if (!i || i == 'P') { j = font1; goto s0; } if (/* i == 'S' || */ i == '0') return; if ((j = findft(i, 0)) == -1) if ((j = setfp(0, i, 0)) == -1) { /* try to put it in position 0 */ if (xflag) { font1 = font; } return; } s0: font1 = font; font = j; mchbits(); } void setwd(void) { register int base, wid; register tchar i; tchar delim, lasti = 0; int emsz, k; int savhp, savapts, savapts1, savfont, savfont1, savpts, savpts1; int savlgf; int rst = 0, rsb = 0; int n; base = numtab[SB].val = numtab[ST].val = wid = numtab[CT].val = 0; if (ismot(i = getch())) return; delim = i; argdelim = delim; n = noschr; noschr = 0; savhp = numtab[HP].val; numtab[HP].val = 0; savapts = apts; savapts1 = apts1; savfont = font; savfont1 = font1; savpts = pts; savpts1 = pts1; savlgf = lgf; lgf = 0; setwdf++; while (i = getch(), !issame(i, delim) && !nlflg) { k = width(i); k += kernadjust(lasti, i); lasti = i; wid += k; numtab[HP].val += k; if (!ismot(i)) { emsz = POINT * u2pts(xpts); } else if (isvmot(i)) { k = absmot(i); if (isnmot(i)) k = -k; base -= k; emsz = 0; } else continue; if (base < numtab[SB].val) numtab[SB].val = base; if ((k = base + emsz) > numtab[ST].val) numtab[ST].val = k; if (lastrst > rst) rst = lastrst; if (lastrsb < rsb) rsb = lastrsb; } if (!issame(i, delim)) nodelim(delim); argdelim = 0; noschr = n; setn1(wid, 0, (tchar) 0); prwatchn(&numtab[CT]); prwatchn(&numtab[SB]); prwatchn(&numtab[ST]); setnr("rst", rst, 0); setnr("rsb", rsb, 0); numtab[HP].val = savhp; apts = savapts; apts1 = savapts1; font = savfont; font1 = savfont1; pts = savpts; pts1 = savpts1; lgf = savlgf; mchbits(); setwdf = 0; } tchar vmot(void) { dfact = lss; vflag++; return(mot()); } tchar hmot(void) { dfact = EM; return(mot()); } tchar mot(void) { register int j, n; register tchar i; tchar c, delim; j = HOR; delim = getch(); /*eat delim*/ if ((n = hatoi())) { if (vflag) j = VERT; i = makem(quant(n, j)); } else i = 0; c = getch(); if (!issame(c, delim)) nodelim(delim); vflag = 0; dfact = 1; return(i); } tchar sethl(int k) { register int j; tchar i; j = EM / 2; if (k == 'u') j = -j; else if (k == 'r') j = -2 * j; vflag++; i = makem(j); vflag = 0; return(i); } tchar makem(register int i) { register tchar j; if ((j = i) < 0) j = -j; j = sabsmot(j) | MOT; if (i < 0) j |= NMOT; if (vflag) j |= VMOT; return(j); } tchar getlg(tchar i) { tchar j, k, pb[NC]; struct lgtab *lp; int c, f; size_t n, lgn; f = fbits(i); if (lgtab[f] == NULL) /* font lacks ligatures */ return(i); c = cbits(i); lp = &lgtab[f][c]; if (lp->from != c || (lp = lp->link) == NULL) return(i); k = i; n = 1; lgn = lg == 2 ? 2 : 1000; for (;;) { j = getch0(); if (n < sizeof pb) pb[n-1] = j; c = cbits(j); while (lp != NULL && lp->from != c) lp = lp->next; if (lp == NULL || lp->to == 0) { pbbuf[pbp++] = j; return(k); } if (lp->to == -1) { /* fdeferlig request */ pb[n < sizeof pb ? n : sizeof pb - 1] = 0; pushback(pb); return(i); } k = (i & SFMASK) | lp->to | AUTOLIG; if (lp->link == NULL || ++n > lgn) return(k); lp = lp->link; } } int strlg(int f, int *tp, int n) { struct lgtab *lp; int i; if (n == 1) return tp[0]; if (lgtab[f] == NULL) return 0; lp = &lgtab[f][tp[0]]; if (lp->from != tp[0]) return 0; for (i = 1; i < n; i++) { if ((lp = lp->link) == NULL) return 0; while (lp != NULL && lp->from != tp[i]) lp = lp->next; if (lp == NULL || lp->to == 0) return 0; } return lp->to > 0 ? lp->to : 0; } void caselg(void) { lg = 1; if (skip(0)) return; lg = hatoi(); } static void addlig(int f, tchar *from, int to) { int i, j; struct lgtab *lp; if (from[0] == 0 || from[1] == 0) { if (warn & WARN_FONT) errprint("short ligature has no effect"); return; } if (lgtab[f] == NULL) lgtab[f] = calloc(NCHARS, sizeof **lgtab); i = cbits(from[0]); gchtab[i] |= LGBIT; lp = &lgtab[f][i]; lp->from = i; j = 1; for (;;) { i = cbits(from[j]); if (lp->link == NULL) { if (from[j+1] != 0) { if (warn & WARN_FONT) errprint("ligature step missing"); return; } lp->link = calloc(1, sizeof *lp->link); lp = lp->link; lp->from = i; lp->to = to; break; } lp = lp->link; if (++j >= 4) { if (warn & WARN_FONT) errprint("ignoring ligature of length >4"); return; } while (lp->from != i && lp->next) lp = lp->next; if (lp->from != i) { if (from[j] != 0) { if (warn & WARN_FONT) errprint("ligature step missing"); return; } lp->next = calloc(1, sizeof *lp->next); lp = lp->next; lp->from = i; } if (from[j] == 0) { lp->to = to; break; } } if (to >= 0) { if (lgrevtab[f] == NULL) lgrevtab[f] = calloc(NCHARS, sizeof **lgrevtab); lgrevtab[f][to] = malloc((j+2) * sizeof ***lgrevtab); j = 0; while ((lgrevtab[f][to][j] = cbits(from[j]))) j++; } /* * If the font still contains the charlib substitutes for ff, * Fi, and Fl, hide them. The ".flig" request is intended for * use in combination with expert fonts only. */ if ((to == LIG_FF || (cbits(from[0]) == 'f' && cbits(from[1]) == 'f' && cbits(from[2]) == 0)) && fitab[f][LIG_FF-32] != NOCODE) if (codetab[f][fitab[f][LIG_FF-32]] < 32) fitab[f][LIG_FF-32] = 0; if ((to == LIG_FFI || (cbits(from[0]) == 'f' && cbits(from[1]) == 'f' && cbits(from[2]) == 'i' && cbits(from[3]) == 0)) && fitab[f][LIG_FFI-32] != NOCODE) if (codetab[f][fitab[f][LIG_FFI-32]] < 32) fitab[f][LIG_FFI-32] = 0; if ((to == LIG_FFL || (cbits(from[0]) == 'f' && cbits(from[1]) == 'f' && cbits(from[2]) == 'l' && cbits(from[3]) == 0)) && fitab[f][LIG_FFL-32] != NOCODE) if (codetab[f][fitab[f][LIG_FFL-32]] < 32) fitab[f][LIG_FFL-32] = 0; } static void dellig(int f, tchar *from) { struct lgtab *lp, *lq; int i, j; if (from[0] == 0 || from[1] == 0) return; if (lgtab[f] == NULL) return; i = cbits(from[0]); lp = lq = &lgtab[f][i]; j = 1; for (;;) { i = cbits(from[j]); if (lp->link == NULL) break; lq = lp; lp = lp->link; while (lp->from != i && lp->next) { lq = lp; lp = lp->next; } if (lp->from != i) break; if (from[++j] == 0) { if (lq->link == lp) lq->link = lp->next; else if (lq->next == lp) lq->next = lp->next; if (lp->link) if (warn & WARN_FONT) errprint("deleted ligature cuts chain"); free(lgrevtab[f][lp->to]); lgrevtab[f][lp->to] = NULL; free(lp); break; } } } void setlig(int f, int j) { tchar from[4], to; free(lgrevtab[f]); lgrevtab[f] = NULL; free(lgtab[f]); lgtab[f] = NULL; from[0] = 'f'; from[2] = from[3] = 0; from[1] = 'f'; to = LIG_FF; if (j & LFF) addlig(f, from, to); from[1] = 'i'; to = LIG_FI; if (j & LFI) addlig(f, from, to); from[1] = 'l'; to = LIG_FL; if (j & LFL) addlig(f, from, to); from[1] = 'f'; from[2] = 'i'; to = LIG_FFI; if (j & LFFI) addlig(f, from, to); from[2] = 'l'; to = LIG_FFL; if (j & LFFL) addlig(f, from, to); } static int getflig(int f, int mode) { int delete, allnum; tchar from[NC], to; int c; size_t i, j; char number[NC]; if (skip(0)) return 0; switch (cbits(c = getch())) { case '-': c = getch(); delete = 1; break; case '+': c = getch(); /*FALLTHRU*/ default: delete = 0; break; case 0: return 0; } allnum = 1; for (i = 0; i < sizeof from - 2; i++) { from[i] = c; j = cbits(c); if (c == 0 || ismot(c) || j == ' ' || j == '\n') { from[i] = 0; ch = j; break; } if (j < '0' || j > '9') allnum = 0; c = getch(); } if (mode == 0 && allnum == 1) { /* backwards compatibility */ if (skip(0) == 0) goto new; for (j = 0; j <= i+1; j++) number[j] = cbits(from[j]); j = strtol(number, NULL, 10); setlig(f, j); return 0; } if (delete == 0) { if (mode >= 0) { if (skip(1)) return 0; new: to = cbits(getch()); } else to = -1; addlig(f, from, to); } else dellig(f, from); return 1; } void caseflig(int defer) { int i, j; lgf++; if (skip(1)) return; i = getrq(2); if ((j = findft(i, 1)) < 0) return; i = 0; while (getflig(j, defer ? -1 : i++) != 0); } void casefdeferlig(void) { caseflig(1); } void casefp(int spec) { register int i, j; char *file, *supply; lgf++; skip(0); if ((i = xflag ? hatoi() : cbits(getch()) - '0') < 0 || i > 255) bad: errprint("fp: bad font position %d", i); else if (skip(0) || !(j = getrq(3))) errprint("fp: no font name"); else { if (skip(0) || !getname()) { if (i == 0) goto bad; setfp(i, j, 0); } else { /* 3rd argument = filename */ file = strdup(nextf); if (!skip(0) && getname()) { supply = strdup(nextf); } else supply = NULL; if (loadafm(i?i:-1, j, file, supply, 0, spec) == 0) { if (i == 0) { if (warn & WARN_FONT) errprint("fp: cannot mount %s", file); } else setfp(i, j, file); } free(file); free(supply); } } } void casefps(void) { const struct { enum spec spec; const char *name; } tab[] = { { SPEC_MATH, "math" }, { SPEC_GREEK, "greek" }, { SPEC_PUNCT, "punct" }, { SPEC_LARGE, "large" }, { SPEC_S1, "S1" }, { SPEC_S, "S" }, { SPEC_NONE, NULL } }; char name[NC]; int c = 0; size_t i; enum spec s = SPEC_NONE; if (skip(1)) return; do { for (i = 0; i < sizeof name - 2; i++) { if ((c = getach()) == 0 || c == ':' || c == ',') break; name[i] = c; } name[i] = 0; for (i = 0; tab[i].name; i++) if (strcmp(tab[i].name, name) == 0) { s |= tab[i].spec; break; } if (tab[i].name == NULL) errprint("fps: unknown special set %s", name); } while (c); casefp(s); } int setfp(int pos, int f, char *truename) /* mount font f at position pos[0...nfonts] */ { char longname[4096], *ap; const char *shortname; char *fpout; int i, nw; zapwcache(0); if (truename) shortname = truename; else shortname = macname(f); shortname = mapft(shortname); snprintf(longname, sizeof longname, "%s/dev%s/%s", fontfile, devname, shortname); if ((fpout = readfont(longname, &dev, warn & WARN_FONT)) == NULL) return(-1); if (pos >= Nfont) growfonts(pos+1); if (pos > nfonts) nfonts = pos; fontbase[pos] = (struct Font *)fpout; if ((ap = strstr(fontbase[pos]->namefont, ".afm")) != NULL) { *ap = 0; if (ap == &fontbase[pos]->namefont[1]) f &= BYTEMASK; loadafm(pos, f, fontbase[pos]->namefont, NULL, 1, SPEC_NONE); free(fpout); } else { nw = fontbase[pos]->nwfont & BYTEMASK; makefont(pos, &((char *)fontbase[pos])[sizeof(struct Font)], &((char *)fontbase[pos])[sizeof(struct Font) + nw], &((char *)fontbase[pos])[sizeof(struct Font) + 2*nw], &((char *)fontbase[pos])[sizeof(struct Font) + 3*nw], nw); setlig(pos, fontbase[pos]->ligfont); } if (pos == smnt) { smnt = 0; sbold = 0; } if ((fontlab[pos] = f) == 'S') smnt = pos; bdtab[pos] = cstab[pos] = ccstab[pos] = 0; zoomtab[pos] = 0; fallbacktab[pos] = NULL; free(lhangtab[pos]); lhangtab[pos] = NULL; free(rhangtab[pos]); rhangtab[pos] = NULL; memset(&tracktab[pos], 0, sizeof tracktab[pos]); for (i = 0; i < NCHARS; i++) ftrtab[pos][i] = i; kzap(pos); /* if there is a directory, no place to store its name. */ /* if position isn't zero, no place to store its value. */ /* only time a FONTPOS is pushed back is if it's a */ /* standard font on position 0 (i.e., mounted implicitly. */ /* there's a bug here: if there are several input lines */ /* that look like .ft XX in short successtion, the output */ /* will all be in the last one because the "x font ..." */ /* comes out too soon. pushing back FONTPOS doesn't work */ /* with .ft commands because input is flushed after .xx cmds */ if (realpage && ap == NULL) ptfpcmd(pos, shortname, NULL, 0); if (pos == 0) ch = (tchar) FONTPOS | (tchar) f << 22; return(pos); } int nextfp(void) { int i; for (i = 1; i <= nfonts; i++) if (fontbase[i] == NULL) return i; if (i <= 255) return i; return 0; } void casecs(void) { register int i, j; noscale++; if (skip(1)) goto rtn; if (!(i = getrq(2))) goto rtn; if ((i = findft(i, 1)) < 0) goto rtn; skip(0); cstab[i] = hatoi(); skip(0); j = hatoi(); if (nonumb) ccstab[i] = 0; else ccstab[i] = findps(j); rtn: zapwcache(0); noscale = 0; } void casebd(void) { register int i, j = 0, k; zapwcache(0); k = 0; bd0: if (skip(1) || !(i = getrq(2)) || (j = findft(i, 1)) == -1) { if (k) goto bd1; else return; } if (j == smnt) { k = smnt; goto bd0; } if (k) { sbold = j; j = k; } bd1: skip(0); noscale++; bdtab[j] = hatoi(); noscale = 0; } void casevs(void) { register int i; skip(0); vflag++; dfact = INCH; /* default scaling is points! */ dfactd = 72; res = VERT; i = inumb(&lss); if (nonumb) i = lss1; if (xflag && i < 0) { if (warn & WARN_RANGE) errprint("negative vertical spacing ignored"); i = lss1; } if (i < VERT) i = VERT; lss1 = lss; lss = i; } void casess(int flg) { register int i, j; noscale++; if (skip(flg == 0)) minsps = minspsz = 0; else if ((i = hatoi()) != 0 && !nonumb) { if (xflag && flg == 0 && !skip(0)) { j = hatoi(); if (!nonumb) { sesspsz = j & 0177; spacesz = sesspsz; zapwcache(1); ses = width(' ' | chbits); } } if (flg) { j = spacesz; minspsz = i & 0177; spacesz = minspsz; zapwcache(1); minsps = width(' ' | chbits); spacesz = j; zapwcache(0); sps = width(' ' | chbits); } else { spacesz = i & 0177; zapwcache(0); sps = width(' ' | chbits); if (minspsz > spacesz) minsps = minspsz = 0; } } noscale = 0; } void caseminss(void) { casess(1); } void caseletadj(void) { int s, n, x, l, h; dfact = LAFACT / 100; if (skip(0) || (n = hatoi()) == 0) { letspsz = 0; letsps = 0; lspmin = 0; lspmax = 0; lshmin = 0; lshmax = 0; goto ret; } if (skip(1)) goto ret; dfact = LAFACT / 100; l = hatoi(); if (skip(1)) goto ret; noscale++; s = hatoi(); noscale--; if (skip(1)) goto ret; dfact = LAFACT / 100; x = hatoi(); if (skip(1)) goto ret; dfact = LAFACT / 100; h = hatoi(); letspsz = s; lspmin = LAFACT - n; lspmax = x - LAFACT; lshmin = LAFACT - l; lshmax = h - LAFACT; s = spacesz; spacesz = letspsz; zapwcache(1); letsps = width(' ' | chbits); spacesz = s; zapwcache(1); sps = width(' ' | chbits); zapwcache(1); ret: dfact = 1; } void casefspacewidth(void) { int f, n, i; lgf++; if (skip(1)) return; i = getrq(2); if ((f = findft(i, 1)) < 0) return; if (skip(0)) { fontbase[f]->cspacewidth = -1; fontab[f][0] = fontbase[f]->spacewidth; } else { noscale++; n = hatoi(); noscale--; unitsPerEm = 1000; if (n >= 0) fontbase[f]->cspacewidth = fontab[f][0] = _unitconv(n); else if (warn & WARN_RANGE) errprint("ignoring negative space width %d", n); } zapwcache(1); } void casespacewidth(void) { noscale++; spacewidth = skip(0) || hatoi(); noscale--; } tchar xlss(void) { /* stores \x'...' into * two successive tchars. * the first contains HX, the second the value, * encoded as a vertical motion. * decoding is done in n2.c by pchar(). */ int i; getch(); dfact = lss; i = quant(hatoi(), VERT); dfact = 1; getch(); if (i >= 0) pbbuf[pbp++] = MOT | VMOT | sabsmot(i); else pbbuf[pbp++] = MOT | VMOT | NMOT | sabsmot(-i); return(HX); } struct afmtab **afmtab; int nafm; static char * onefont(char *prefix, char *file, char *type) { char *path, *fp, *tp; size_t l; l = strlen(prefix) + strlen(file) + 2; path = malloc(l); n_strcpy(path, prefix, l); n_strcat(path, "/", l); n_strcat(path, file, l); if (type) { for (fp = file; *fp; fp++); for (tp = type; *tp; tp++); while (tp >= type && fp >= file && *fp-- == *tp--); if (tp >= type) { l = strlen(path) + strlen(type) + 2; tp = malloc(l); n_strcpy(tp, path, l); n_strcat(tp, ".", l); n_strcat(tp, type, l); free(path); path = tp; } } return path; } static char * getfontpath(char *file, char *type) { char *path, *troffonts, *tp, *tq, c; size_t l; if ((troffonts = getenv("TROFFONTS")) != NULL) { tp = strdup(troffonts); troffonts = tp; do { for (tq = tp; *tq && *tq != ':'; tq++); c = *tq; *tq = 0; path = onefont(tp, file, type); if (access(path, 0) == 0) { free(troffonts); return path; } free(path); tp = &tq[1]; } while (c); free(troffonts); } l = strlen(fontfile) + strlen(devname) + 10; tp = malloc(l); snprintf(tp, l, "%s/dev%s", fontfile, devname); path = onefont(tp, file, type); free(tp); return path; } static void checkenminus(int f) { /* * A fix for a very special case: If the font supplies punctuation * characters but is not S1, only one of \- and \(en is present * since the PostScript character "endash" is mapped to both of * them. */ enum spec spec; int i; if (afmtab == NULL || (i = fontbase[f]->afmpos - 1) < 0) return; if (c_endash == 0 || c_minus == 0) specnames(); spec = afmtab[i]->spec; if ((spec&(SPEC_PUNCT|SPEC_S1)) == SPEC_PUNCT) { if (fitab[f][c_endash-32] == 0 && ftrtab[f][c_minus-32]) ftrtab[f][c_endash] = c_minus; else if (fitab[f][c_endash-32] && ftrtab[f][c_minus-32] != 0) ftrtab[f][c_minus] = c_endash; } } int loadafm(int nf, int rq, char *file, char *supply, int required, enum spec spec) { struct stat st; int fd; char *path, *contents; struct afmtab *a; int i, have = 0; struct namecache *np; - size_t l; zapwcache(0); if (nf < 0) nf = nextfp(); path = getfontpath(file, "afm"); if (access(path, 0) < 0) { path = getfontpath(file, "otf"); if (access(path, 0) < 0) path = getfontpath(file, "ttf"); } if (dev.allpunct) spec |= SPEC_PUNCT; a = calloc(1, sizeof *a); for (i = 0; i < nafm; i++) if (strcmp(afmtab[i]->path, path) == 0 && afmtab[i]->spec == spec) { *a = *afmtab[i]; have = 1; break; } a->path = path; a->file = strdup(file); a->spec = spec; a->rq = rq; a->Font.namefont[0] = rq&0377; a->Font.namefont[1] = (rq>>8)&0377; snprintf(a->Font.intname, sizeof(a->Font.intname), "%d", nf); if (have) goto done; if ((fd = open(path, O_RDONLY)) < 0) { if (required) errprint("Can't open %s", path); free(a->file); free(a); free(path); return 0; } if (fstat(fd, &st) < 0) { errprint("Can't stat %s", path); free(a->file); free(a); free(path); return -1; } contents = malloc(st.st_size + 1); if (read(fd, contents, st.st_size) != st.st_size) { errprint("Can't read %s", path); free(a->file); free(a); free(path); free(contents); return -1; } contents[st.st_size] = 0; close(fd); if (afmget(a, contents, st.st_size) < 0) { free(path); free(contents); return -1; } free(contents); morechars(a->nchars+32+1+128-32+nchtab+32+nchtab+128+psmaxcode+1); done: afmtab = realloc(afmtab, (nafm+1) * sizeof *afmtab); afmtab[nafm] = a; if (nf >= Nfont) growfonts(nf+1); a->Font.afmpos = nafm+1; if ((np = afmnamelook(a, "space")) != NULL) a->Font.spacewidth = a->fontab[np->afpos]; else a->Font.spacewidth = a->fontab[0]; a->Font.cspacewidth = -1; fontbase[nf] = &afmtab[nafm]->Font; fontlab[nf] = rq; free(fontab[nf]); free(kerntab[nf]); free(codetab[nf]); free(fitab[nf]); fontab[nf] = malloc(a->nchars * sizeof *fontab[nf]); kerntab[nf] = malloc(a->nchars * sizeof *kerntab[nf]); codetab[nf] = malloc(a->nchars * sizeof *codetab[nf]); fitab[nf] = calloc(NCHARS, sizeof *fitab[nf]); memcpy(fontab[nf], a->fontab, a->nchars * sizeof *fontab[nf]); memcpy(kerntab[nf], a->kerntab, a->nchars * sizeof *kerntab[nf]); memcpy(codetab[nf], a->codetab, a->nchars * sizeof *codetab[nf]); memcpy(fitab[nf], a->fitab, a->fichars * sizeof *fitab[nf]); bdtab[nf] = cstab[nf] = ccstab[nf] = 0; zoomtab[nf] = 0; fallbacktab[nf] = NULL; free(lhangtab[nf]); lhangtab[nf] = NULL; free(rhangtab[nf]); rhangtab[nf] = NULL; memset(&tracktab[nf], 0, sizeof tracktab[nf]); setlig(nf, a->Font.ligfont); for (i = 0; i < NCHARS; i++) ftrtab[nf][i] = i; kzap(nf); nafm++; if (nf > nfonts) nfonts = nf; if (supply) { char *data; if (strcmp(supply, "pfb") == 0 || strcmp(supply, "pfa") == 0 || strcmp(supply, "t42") == 0 || strcmp(supply, "otf") == 0 || strcmp(supply, "ttf") == 0) data = getfontpath(file, supply); else data = getfontpath(supply, NULL); a->supply = afmencodepath(data); free(data); if (realpage) ptsupplyfont(a->fontname, a->supply); } checkenminus(nf); if (realpage) ptfpcmd(nf, macname(fontlab[nf]), a->path, (int)a->spec); return 1; } static int tracknum(void) { skip(1); dfact = INCH; dfactd = 72; res = VERT; return inumb(NULL); } void casetrack(void) { int i, j, s1, n1, s2, n2; if (skip(1)) return; i = getrq(2); if ((j = findft(i, 1)) < 0) return; s1 = tracknum(); if (!nonumb) { n1 = tracknum(); if (!nonumb) { s2 = tracknum(); if (!nonumb) { n2 = tracknum(); if (!nonumb) { tracktab[j].s1 = s1; tracktab[j].n1 = n1; tracktab[j].s2 = s2; tracktab[j].n2 = n2; zapwcache(0); } } } } } void casefallback(void) { int *fb = NULL; int i, j, n = 0; if (skip(1)) return; i = getrq(2); if ((j = findft(i, 1)) < 0) return; do { skip(0); i = getrq(2); fb = realloc(fb, (n+2) * sizeof *fb); fb[n++] = i; } while (i); fallbacktab[j] = fb; } void casehidechar(void) { int savfont = font, savfont1 = font1; - int i, j; + int j; + size_t i; tchar k; if (skip(1)) return; i = getrq(2); if ((j = findft(i, 1)) < 0) return; font = font1 = j; mchbits(); while ((i = cbits(k = getch())) != '\n') { if (fbits(k) != j || ismot(k) || i == ' ') continue; if (i >= nchtab + 128-32 && afmtab && fontbase[j]->afmpos - 1 >= 0) i -= nchtab + 128; fitab[j][i - 32] = 0; } font = savfont; font1 = savfont1; mchbits(); zapwcache(0); } void casefzoom(void) { int i, j; float f; if (skip(1)) return; i = getrq(2); if ((j = findft(i, 1)) < 0) return; skip(1); f = atof(); if (!nonumb && f >= 0) { zoomtab[j] = f; zapwcache(0); if (realpage && j == xfont && !ascii) ptps(); } } double getfzoom(void) { return zoomtab[font]; } void casekern(void) { kern = skip(0) || hatoi() ? 1 : 0; } void casefkern(void) { int f, i, j; lgf++; if (skip(1)) return; i = getrq(2); if ((f = findft(i, 1)) < 0) return; if (skip(0)) fontbase[f]->kernfont = 0; else { j = hatoi(); if (!nonumb) fontbase[f]->kernfont = j ? j : -1; } } static void setpapersize(int setmedia) { const struct { const char *name; int width; int heigth; } papersizes[] = { { "executive", 518, 756 }, { "letter", 612, 792 }, { "legal", 612, 992 }, { "ledger", 1224, 792 }, { "tabloid", 792, 1224 }, { "a0", 2384, 3370 }, { "a1", 1684, 2384 }, { "a2", 1191, 1684 }, { "a3", 842, 1191 }, { "a4", 595, 842 }, { "a5", 420, 595 }, { "a6", 298, 420 }, { "a7", 210, 298 }, { "a8", 147, 210 }, { "a9", 105, 147 }, { "a10", 74, 105 }, { "b0", 2835, 4008 }, { "b1", 2004, 2835 }, { "b2", 1417, 2004 }, { "b3", 1000, 1417 }, { "b4", 709, 1000 }, { "b5", 499, 709 }, { "b6", 354, 499 }, { "b7", 249, 354 }, { "b8", 176, 249 }, { "b9", 125, 176 }, { "b10", 87, 125 }, { "c0", 2599, 3677 }, { "c1", 1837, 2599 }, { "c2", 1298, 1837 }, { "c3", 918, 1298 }, { "c4", 649, 918 }, { "c5", 459, 649 }, { "c6", 323, 459 }, { "c7", 230, 323 }, { "c8", 162, 230 }, { NULL, 0, 0 } }; int c; int x = 0, y = 0; size_t n; char buf[NC]; lgf++; if (skip(1)) return; c = cbits(ch); if (isdigit(c) || c == '(') { x = hatoi(); if (!nonumb) { skip(1); y = hatoi(); } if (nonumb || x == 0 || y == 0) return; } else { n = 0; do { c = getach(); if (n+1 < sizeof buf) buf[n++] = c; } while (c); buf[n] = 0; for (n = 0; papersizes[n].name != NULL; n++) if (strcmp(buf, papersizes[n].name) == 0) { x = papersizes[n].width * INCH / 72; y = papersizes[n].heigth * INCH / 72; break; } if (x == 0 || y == 0) { errprint("Unknown paper size %s", buf); return; } } pl = defaultpl = y; if (numtab[NL].val > pl) { numtab[NL].val = pl; prwatchn(&numtab[NL]); } po = x > 6 * PO ? PO : x / 8; ll = ll1 = lt = lt1 = x - 2 * po; setnel(); mediasize.val[2] = x; mediasize.val[3] = y; mediasize.flag |= 1; if (setmedia) mediasize.flag |= 2; if (realpage) ptpapersize(); } void casepapersize(void) { setpapersize(0); } void casemediasize(void) { setpapersize(1); } static void cutat(struct box *bp) { int c[4], i; for (i = 0; i < 4; i++) { if (skip(1)) return; dfact = INCH; dfactd = 72; c[i] = inumb(NULL); if (nonumb) return; } for (i = 0; i < 4; i++) bp->val[i] = c[i]; bp->flag |= 1; if (realpage) ptcut(); } void casetrimat(void) { cutat(&trimat); } void casebleedat(void) { cutat(&bleedat); } void casecropat(void) { cutat(&cropat); } void caselhang(void) { kernsingle(lhangtab); } void caserhang(void) { kernsingle(rhangtab); } void casekernpair(void) { int savfont = font, savfont1 = font1; int f, g, i, j, n; tchar c, e, *cp = NULL, *dp = NULL; int a = 0, b = 0; lgf++; if (skip(1)) return; i = getrq(2); if ((f = findft(i, 1)) < 0) return; font = font1 = f; mchbits(); if (skip(1)) goto done; while ((j = cbits(c = getch())) > ' ' || j == UNPAD) { if (fbits(c) != f) { if (warn & WARN_CHAR) errprint("glyph %C not in font %s", c, macname(i)); continue; } cp = realloc(cp, ++a * sizeof *cp); cp[a-1] = c; } if (a == 0 || skip(1)) goto done; i = getrq(2); if ((g = findft(i, 1)) < 0) goto done; font = font1 = g; mchbits(); if (skip(1)) goto done; while ((j = cbits(c = getch())) > ' ' || j == UNPAD) { if (fbits(c) != g) { if (warn & WARN_CHAR) errprint("glyph %C not in font %s", c, macname(i)); continue; } dp = realloc(dp, ++b * sizeof *dp); dp[b-1] = c; } if (b == 0 || skip(1)) goto done; noscale++; n = hatoi(); noscale--; unitsPerEm = 1000; n = _unitconv(n); for (i = 0; i < a; i++) for (j = 0; j < b; j++) { if ((c = cbits(cp[i])) == 0) continue; if (c == UNPAD) c = ' '; setfbits(c, f); if ((e = cbits(dp[j])) == 0) continue; if (e == UNPAD) e = ' '; setfbits(e, g); kadd(c, e, n); } done: free(cp); free(dp); font = savfont; font1 = savfont1; mchbits(); } static void kernsingle(int **tp) { int savfont = font, savfont1 = font1; int f, i, j, n; int twice = 0; tchar c, *cp = NULL; int a; lgf++; if (skip(1)) return; i = getrq(2); if ((f = findft(i, 1)) < 0) return; font = font1 = f; mchbits(); while (!skip(twice++ == 0)) { a = 0; while ((j = cbits(c = getch())) > ' ') { if (fbits(c) != f) { if (warn & WARN_CHAR) errprint("glyph %C not in font %s", c, macname(i)); continue; } cp = realloc(cp, ++a * sizeof *cp); cp[a-1] = c; } if (skip(1)) break; noscale++; n = hatoi(); noscale--; if (tp[f] == NULL) tp[f] = calloc(NCHARS, sizeof *tp); unitsPerEm = 1000; n = _unitconv(n); for (j = 0; j < a; j++) tp[f][cbits(cp[j])] = n; } free(cp); font = savfont; font1 = savfont1; mchbits(); } void casekernafter(void) { kernsingle(kernafter); } void casekernbefore(void) { kernsingle(kernbefore); } void caseftr(void) { int savfont = font, savfont1 = font1; int f, i, j; tchar k; lgf++; if (skip(1)) return; i = getrq(2); if ((f = findft(i, 1)) < 0) return; font = font1 = f; mchbits(); if (skip(1)) goto done; while ((i = cbits(k=getch())) != '\n') { if (ismot(k)) goto done; if (ismot(k = getch())) goto done; if ((j = cbits(k)) == '\n') j = ' '; ftrtab[f][i] = j; } done: checkenminus(f); font = savfont; font1 = savfont1; mchbits(); } static int getfeature(struct afmtab *a, int f) { char name[NC]; int ch1, ch2, c, j, minus; size_t i; struct feature *fp; if (skip(0)) return 0; switch (c = getach()) { case '-': c = getach(); minus = 1; break; case '+': c = getach(); /*FALLTHRU*/ default: minus = 0; break; case 0: return 0; } for (i = 0; i < sizeof name - 2; i++) { name[i] = c; if ((c = getach()) == 0) break; } name[i+1] = 0; for (i = 0; (fp = a->features[i]); i++) if (strcmp(fp->name, name) == 0) { for (j = 0; j < fp->npairs; j++) { ch1 = fp->pairs[j].ch1; ch2 = fp->pairs[j].ch2; if (minus) { if (ftrtab[f][ch1] == ch2) ftrtab[f][ch1] = ch1; } else { ftrtab[f][ch1] = ch2; } } break; } if (fp == NULL) errprint("no feature named %s in font %s", name, a->fontname); return 1; } void casefeature(void) { struct afmtab *a; int f, i, j; lgf++; if (skip(1)) return; i = getrq(2); if ((f = findft(i, 1)) < 0) return; if ((j = (fontbase[f]->afmpos) - 1) < 0 || ((a = afmtab[j])->type != TYPE_OTF && a->type != TYPE_TTF)) { errprint("font %s is not an OpenType font", macname(i)); return; } if (a->features == NULL) { errprint("font %s has no OpenType features", a->fontname); return; } while (getfeature(a, f) != 0); } #include "unimap.h" static int ufmap(int c, int f, int *fp) { struct unimap *up, ***um; struct afmtab *a; int i; if ((c&~0xffff) == 0 && (i = (fontbase[f]->afmpos) - 1) >= 0 && (um = (a = afmtab[i])->unimap) != NULL && um[c>>8] != NULL && (up = um[c>>8][c&0377]) != NULL) { *fp = f; return up->u.code; } return 0; } int un2tr(int c, int *fp) { extern char ifilt[]; struct unimap *um, *up; int i, j; switch (c) { case 0x00A0: *fp = font; return UNPAD; case 0x00AD: *fp = font; return ohc; case 0x2002: return makem((int)(EM)/2); case 0x2003: return makem((int)EM); case 0x2004: return makem((int)EM/3); case 0x2005: return makem((int)EM/4); case 0x2006: return makem((int)EM/6); case 0x2007: return makem(width('0' | chbits)); case 0x2008: return makem(width('.' | chbits)); case 0x2009: return makem((int)EM/6); case 0x200A: return makem((int)EM/12); case 0x2010: *fp = font; return '-'; case 0x2027: *fp = font; return OHC | BLBIT; case 0x2060: *fp = font; return FILLER; default: if ((i = ufmap(c, font, fp)) != 0) return i; if ((c&~0xffff) == 0 && unimap[c>>8] != NULL && (um = unimap[c>>8][c&0377]) != NULL) { up = um; do if ((j = postchar1(up->u.psc, font)) != 0) { *fp = font; return j; } while ((up = up->next) != NULL); up = um; do if ((j = postchar(up->u.psc, fp)) != 0) return j; while ((up = up->next) != NULL); up = um; do if ((j = _ps2cc(up->u.psc, 0)) != 0) { j += nchtab + 128 + 32 + 128 - 32 + nchtab; if (chartab[j] != NULL) return j; } while ((up = up->next) != NULL); } if (fallbacktab[font]) for (j = 0; fallbacktab[font][j] != 0; j++) { if ((i = findft(fallbacktab[font][j], 0)) < 0) continue; if ((i = ufmap(c, i, fp)) != 0) return i; } if (smnt) for (i = smnt, j=0; j < nfonts; j++, i = i % nfonts + 1) { if (fontbase[i] == NULL) continue; if ((i = ufmap(c, i, fp)) != 0) return i; } *fp = font; if ((c < 040 && c == ifilt[c]) || (c >= 040 && c < 0177)) return c; else if ((c & ~0177) == 0) { illseq(c, NULL, 0); return 0; } else if (defcf && (c & ~0xffff) == 0) { char buf[20]; snprintf(buf, sizeof(buf), "[uni%04X]", c); cpushback(buf); unadd(c, NULL); return WORDSP; } else if (html) { return c; } else { if (warn & WARN_CHAR) errprint("no glyph available for %U", c); return tryglf ? 0 : ' '; } } } int tr2un(tchar i, int f) { struct afmtab *a; int c, n; if (i < 32) return -1; else if (i < 128) return i; if ((n = (fontbase[f]->afmpos) - 1) >= 0) { a = afmtab[n]; if (a->unitab && i < a->nunitab && a->unitab[i]) return a->unitab[i]; - if (i - 32 >= nchtab + 128) + if ((size_t)i - 32 >= nchtab + 128) i -= nchtab + 128; if ((n = a->fitab[i - 32]) < a->nchars && a->nametab[n] != NULL) for (c = 0; rawunimap[c].psc; c++) if (strcmp(rawunimap[c].psc, a->nametab[n])==0) return rawunimap[c].code; } return -1; } tchar setuc0(int n) { int f; tchar c; if ((c = un2tr(n, &f)) != 0 && !ismot(c)) { c |= chbits & ~FMASK; setfbits(c, f); } return c; } static char * getref(void) { int a = 0, i, c, delim; char *np = NULL; if ((delim = getach()) != 0) { for (i = 0; ; i++) { if (i + 1 >= a) np = realloc(np, a += 32); if ((c = getach()) == 0) { if (cbits(ch) == ' ') { ch = 0; c = ' '; } else { nodelim(delim); break; } } if (c == delim) break; np[i] = c; } np[i] = 0; } return np; } tchar setanchor(void) { static int cnt; struct ref *rp; char *np; if ((np = getref()) != NULL) { rp = calloc(1, sizeof *rp); rp->cnt = ++cnt; rp->name = np; rp->next = anchors; anchors = rp; return mkxfunc(ANCHOR, cnt); } else return mkxfunc(ANCHOR, 0); } static tchar _setlink(struct ref **rstart, int oncode, int offcode, int *cnt) { struct ref *rp; char *np; int _sv; _sv = linkin; if ((linkin = !linkin)) { if ((np = getref()) != NULL) { rp = calloc(1, sizeof *rp); rp->cnt = ++*cnt; rp->name = np; rp->next = *rstart; *rstart = rp; linkin = *cnt; return mkxfunc(oncode, *cnt); } else { linkin = -1; return mkxfunc(oncode, 0); } } else return mkxfunc(offcode, _sv > 0 ? _sv : 0); } tchar setlink(void) { static int cnt; return _setlink(&links, LINKON, LINKOFF, &cnt); } tchar setulink(void) { static int cnt; return _setlink(&ulinks, ULINKON, ULINKOFF, &cnt); } int pts2u(int p) { return p * INCH / 72; } double u2pts(int u) { return u * 72.0 / INCH; } #define psnprime 1021 static struct psnnode { struct psnnode *next; const char *name; int code; } **psntable; static int _ps2cc(const char *name, int create) { struct psnnode *pp; unsigned h; if (psntable == NULL) psntable = calloc(psnprime, sizeof *psntable); h = pjw(name) % psnprime; for (pp = psntable[h]; pp; pp = pp->next) if (strcmp(name, pp->name) == 0) return pp->code; if (create == 0) return 0; pp = calloc(1, sizeof *pp); pp->name = strdup(name); pp->next = psntable[h]; psntable[h] = pp; return pp->code = ++psmaxcode; } int ps2cc(const char *name) { return _ps2cc(name, 1); } Index: vendor/heirloom-doctools/dist/troff/troff.d/ta.c =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/ta.c (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/ta.c (revision 310550) @@ -1,886 +1,888 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* from OpenSolaris "ta.c 1.10 05/06/08 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany */ #if __GNUC__ >= 3 && __GNUC_MINOR__ >= 4 || __GNUC__ >= 4 #define USED __attribute__ ((used)) #elif defined __GNUC__ #define USED __attribute__ ((unused)) #else #define USED #endif static const char sccsid[] USED = "@(#)/usr/ucb/ta.sl 1.8 (gritter) 12/25/06"; /* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved * * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. */ /* * drive hp2621 terminal * just to see stuff quickly. like troff -a */ /* output language from troff: all numbers are character strings sn size in points fn font as number from 1-n cx ascii character x Cxyz funny char xyz. terminated by white space Hn go to absolute horizontal position n Vn go to absolute vertical position n (down is positive) hn go n units horizontally (relative) vn ditto vertically nnc move right nn (exactly 2 digits!), then print c (this wart is an optimization that shrinks output file size about 35% and run-time about 15% while preserving ascii-ness) w paddable word space - no action needed nb a end of line (information only -- no action needed) b = space before line, a = after pn begin page n #...\n comment Dt ...\n draw operation 't': Dl x y line from here by x,y Dc d circle of diameter d with left side here De x y ellipse of axes x,y with left side here Da x y u v arc counter-clockwise from here to u,v from center with center x,y from here D~ x y x y ... wiggly line by x,y then x,y ... x ...\n device control functions: x i init x T s name of device is s x r n h v resolution is n/inch h = min horizontal motion, v = min vert x p pause (can restart) x s stop -- done for ever x t generate trailer x f n s font position n contains font s x H n set character height to n x S n set character slant to n Subcommands like "i" are often spelled out like "init". */ #include #include #include #include #include #include #include #include #include "dev.h" #define NFONT 10 int output = 0; /* do we do output at all? */ -int nolist = 0; /* output page list if > 0 */ +size_t nolist = 0; /* output page list if > 0 */ int olist[20]; /* pairs of page numbers */ int erase = 1; float aspect = 1.5; /* default aspect ratio */ int wflag = 0; /* wait, looping, for new input if on */ void (*sigint)(int); void (*sigquit)(int); void done(void); struct dev dev; struct font *fontbase[NFONT]; short psizes[] ={ 11, 16, 22, 36, 0}; /* approx sizes available */ short *pstab = psizes; int nsizes = 1; int nfonts; int smnt; /* index of first special font */ int nchtab; char *chname; short *chtab; char *fitab[NFONT]; char *widthtab[NFONT]; /* widtab would be a better name */ char *codetab[NFONT]; /* device codes */ #define FATAL 1 #define BMASK 0377 int dbg = 0; int res = 972; /* input assumed computed according to this resolution */ /* initial value to avoid 0 divide */ FILE *tf; /* output file */ char *fontdir = FNTDIR; #define devname troff_devname char devname[20] = "hp2621"; FILE *fp; /* input file pointer */ int nowait = 0; /* 0 => wait at bottom of each page */ void drawline(int, int, char *); void drawwig(char *); void drawcirc(int); void drawarc(int, int, int, int); void drawellip(int, int); void outlist(char *); int in_olist(int); void conv(register FILE *); void devcntrl(FILE *); void fileinit(void); void fontprint(int); void loadcode(int, int); void loadfont(int, char *); void error(int, const char *, ...); void t_init(int); void t_push(void); void t_pop(void); void t_page(int); void putpage(void); void t_newline(void); int t_size(int); int t_font(char *); void t_text(char *); void t_reset(int); void t_trailer(void); void hgoto(int); void hmot(int); void hflush(void); void vgoto(int); void vmot(int); void put1s(char *); void put1(int); void setsize(double); void t_fp(int, char *); void setfont(int); void done(void); void callunix(char []); int readch(void); static int sget(char *, size_t, FILE *); int main(int argc, char **argv) { char buf[BUFSIZ]; fp = stdin; tf = stdout; setbuf(stdout, buf); while (argc > 1 && argv[1][0] == '-') { switch (argv[1][1]) { case 'a': aspect = atof(&argv[1][2]); break; case 'e': erase = 0; break; case 'o': outlist(&argv[1][2]); break; case 'd': dbg = atoi(&argv[1][2]); if (dbg == 0) dbg = 1; break; case 'w': /* no wait at bottom of page */ nowait = 1; break; } argc--; argv++; } if (argc <= 1) conv(stdin); else while (--argc > 0) { if (strcmp(*++argv, "-") == 0) fp = stdin; else if ((fp = fopen(*argv, "r")) == NULL) error(FATAL, "can't open %s", *argv); conv(fp); fclose(fp); } done(); /*NOTREACHED*/ return 0; } void outlist(char *s) /* process list of page numbers to be printed */ { - int n1, n2, i; + int n1, n2; + size_t i; nolist = 0; while (*s && nolist < sizeof olist/sizeof *olist - 1) { n1 = 0; if (isdigit((unsigned char)*s)) do n1 = 10 * n1 + *s++ - '0'; while (isdigit((unsigned char)*s)); else n1 = -9999; n2 = n1; if (*s == '-') { s++; n2 = 0; if (isdigit((unsigned char)*s)) do n2 = 10 * n2 + *s++ - '0'; while (isdigit((unsigned char)*s)); else n2 = 9999; } olist[nolist++] = n1; olist[nolist++] = n2; if (*s != '\0') s++; } olist[nolist] = 0; if (dbg) for (i=0; i= olist[i] && n <= olist[i+1]) return(1); return(0); } void conv(register FILE *fp) { register int c, k; int m, n, n1, m1; char str[4096], buf[4096]; while ((c = getc(fp)) != EOF) { switch (c) { case '\n': /* when input is text */ case ' ': case 0: /* occasional noise creeps in */ break; case '{': /* push down current environment */ t_push(); break; case '}': t_pop(); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': /* two motion digits plus a character */ hmot((c-'0')*10 + getc(fp)-'0'); put1(getc(fp)); break; case 'c': /* single ascii character */ put1(getc(fp)); break; case 'C': sget(str, sizeof str, fp); put1s(str); break; case 't': /* straight text */ fgets(buf, sizeof(buf), fp); t_text(buf); break; case 'D': /* draw function */ fgets(buf, sizeof(buf), fp); switch (buf[0]) { case 'l': /* draw a line */ sscanf(buf+1, "%d %d", &n, &m); drawline(n, m, "."); break; case 'c': /* circle */ sscanf(buf+1, "%d", &n); drawcirc(n); break; case 'e': /* ellipse */ sscanf(buf+1, "%d %d", &m, &n); drawellip(m, n); break; case 'a': /* arc */ sscanf(buf+1, "%d %d %d %d", &n, &m, &n1, &m1); drawarc(n, m, n1, m1); break; case '~': /* wiggly line */ drawwig(buf+1); break; default: error(FATAL, "unknown drawing function %s\n", buf); break; } break; case 's': fscanf(fp, "%d", &n); if (n == -23) { float f; fscanf(fp, "%f", &f); setsize(f); } else setsize(t_size(n));/* ignore fractional sizes */ break; case 'f': sget(str, sizeof str, fp); setfont(t_font(str)); break; case 'H': /* absolute horizontal motion */ /* fscanf(fp, "%d", &n); */ while ((c = getc(fp)) == ' ') ; k = 0; do { k = 10 * k + c - '0'; } while (isdigit(c = getc(fp))); ungetc(c, fp); hgoto(k); break; case 'h': /* relative horizontal motion */ /* fscanf(fp, "%d", &n); */ while ((c = getc(fp)) == ' ') ; k = 0; do { k = 10 * k + c - '0'; } while (isdigit(c = getc(fp))); ungetc(c, fp); hmot(k); break; case 'w': /* word space */ putc(' ', stdout); break; case 'V': fscanf(fp, "%d", &n); vgoto(n); break; case 'v': fscanf(fp, "%d", &n); vmot(n); break; case 'p': /* new page */ fscanf(fp, "%d", &n); t_page(n); break; case 'n': /* end of line */ while (getc(fp) != '\n') ; t_newline(); break; case '#': /* comment */ while (getc(fp) != '\n') ; break; case 'x': /* device control */ devcntrl(fp); break; default: error(!FATAL, "unknown input character %o %c\n", c, c); done(); } } } void devcntrl(FILE *fp) /* interpret device control functions */ { char str[4096]; int n; sget(str, sizeof str, fp); switch (str[0]) { /* crude for now */ case 'i': /* initialize */ fileinit(); t_init(0); break; case 'T': /* device name */ sget(devname, sizeof devname, fp); break; case 't': /* trailer */ t_trailer(); break; case 'p': /* pause -- can restart */ t_reset('p'); break; case 's': /* stop */ t_reset('s'); break; case 'r': /* resolution assumed when prepared */ fscanf(fp, "%d", &res); break; case 'f': /* font used */ fscanf(fp, "%d", &n); sget(str, sizeof str, fp); loadfont(n, str); break; } while (getc(fp) != '\n') /* skip rest of input line */ ; } void fileinit(void) /* read in font and code files, etc. */ { } void -fontprint(int i) /* debugging print of font i (0,...) */ +fontprint(int i __unused) /* debugging print of font i (0,...) */ { } void -loadcode(int n, int nw) /* load codetab on position n (0...); #chars is nw */ +loadcode(int n __unused, int nw __unused) /* load codetab on position n (0...); #chars is nw */ { } void -loadfont(int n, char *s) /* load font info for font s on position n (1...) */ +loadfont(int n __unused, char *s __unused) /* load font info for font s on position n (1...) */ { } void error(int f, const char *s, ...) { va_list ap; fprintf(stderr, "ta: "); va_start(ap, s); vfprintf(stderr, s, ap); va_end(ap); fprintf(stderr, "\n"); if (f) exit(1); } /* Here beginneth all the stuff that really depends on the 202 (we hope). */ #define ESC 033 #define HOME 'H' #define CLEAR 'J' #define FF 014 int size = 1; int font = 1; /* current font */ int hpos; /* horizontal position where we are supposed to be next (left = 0) */ int vpos; /* current vertical position (down positive) */ int horig; /* h origin of current block; hpos rel to this */ int vorig; /* v origin of current block; vpos rel to this */ int DX = 10; /* step size in x for drawing */ int DY = 10; /* step size in y for drawing */ int drawdot = '.'; /* draw with this character */ int drawsize = 1; /* shrink by this factor when drawing */ void -t_init(int reinit) /* initialize device */ +t_init(int reinit __unused) /* initialize device */ { fflush(stdout); hpos = vpos = 0; } #define MAXSTATE 5 struct state { int ssize; int sfont; int shpos; int svpos; int shorig; int svorig; }; struct state state[MAXSTATE]; struct state *statep = state; void t_push(void) /* begin a new block */ { hflush(); statep->ssize = size; statep->sfont = font; statep->shorig = horig; statep->svorig = vorig; statep->shpos = hpos; statep->svpos = vpos; horig = hpos; vorig = vpos; hpos = vpos = 0; if (statep++ >= state+MAXSTATE) error(FATAL, "{ nested too deep"); hpos = vpos = 0; } void t_pop(void) /* pop to previous state */ { if (--statep < state) error(FATAL, "extra }"); size = statep->ssize; font = statep->sfont; hpos = statep->shpos; vpos = statep->svpos; horig = statep->shorig; vorig = statep->svorig; } int np; /* number of pages seen */ int npmax; /* high-water mark of np */ int pgnum[40]; /* their actual numbers */ long pgadr[40]; /* their seek addresses */ void t_page(int n) /* do whatever new page functions */ { int m, i; char buf[1024], *bp; pgnum[np++] = n; pgadr[np] = ftell(fp); if (np > npmax) npmax = np; if (output == 0) { output = in_olist(n); t_init(1); return; } /* have just printed something, and seen p for next one */ putpage(); fflush(stdout); if (nowait) return; next: for (bp = buf; (*bp = readch()); ) if (*bp++ == '\n' || bp >= &buf[sizeof buf - 1]) break; *bp = 0; switch (buf[0]) { case 0: done(); break; case '\n': output = in_olist(n); t_init(1); return; case '!': callunix(&buf[1]); fputs("!\n", stderr); break; case 'e': erase = 1 - erase; break; case 'w': wflag = 1 - wflag; break; case 'a': aspect = atof(&buf[1]); break; case '-': case 'p': m = atoi(&buf[1]) + 1; if (fp == stdin) { fputs("you can't; it's not a file\n", stderr); break; } if (np - m <= 0) { fputs("too far back\n", stderr); break; } np -= m; fseek(fp, pgadr[np], 0); output = 1; t_init(1); return; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': m = atoi(&buf[0]); for (i = 0; i < npmax; i++) if (m == pgnum[i]) break; if (i >= npmax || fp == stdin) { fputs("you can't\n", stderr); break; } np = i + 1; fseek(fp, pgadr[np], 0); output = 1; t_init(1); return; case 'o': outlist(&buf[1]); output = 0; t_init(1); return; case '?': fputs("!cmd unix cmd\n", stderr); fputs("p print this page again\n", stderr); fputs("-n go back n pages\n", stderr); fputs("n print page n (previously printed)\n", stderr); fputs("o... set the -o output list to ...\n", stderr); fputs("en n=0 -> don't erase; n=1 -> erase\n", stderr); fputs("an sets aspect ratio to n\n", stderr); break; default: fputs("?\n", stderr); break; } goto next; } void putpage(void) { fflush(stdout); } void t_newline(void) /* do whatever for the end of a line */ { printf("\n"); hpos = 0; } int -t_size(int n) /* convert integer to internal size number*/ +t_size(int n __unused) /* convert integer to internal size number*/ { return 0; } int -t_font(char *s) /* convert string to internal font number */ +t_font(char *s __unused) /* convert string to internal font number */ { return 0; } void t_text(char *s) /* print string s as text */ { int c, w=0; char str[100]; if (!output) return; while ((c = *s++) != '\n') { if (c == '\\') { switch (c = *s++) { case '\\': case 'e': put1('\\'); break; case '(': str[0] = *s++; str[1] = *s++; str[2] = '\0'; put1s(str); break; } } else { put1(c); } hmot(w); } } void t_reset(int c) { output = 1; fflush(stdout); if (c == 's') t_page(9999); } void t_trailer(void) { } void hgoto(int n) { hpos = n; /* this is where we want to be */ /* before printing a character, */ /* have to make sure it's true */ } void hmot(int n) /* generate n units of horizontal motion */ { hgoto(hpos + n); } void hflush(void) /* actual horizontal output occurs here */ { } void vgoto(int n) { vpos = n; } void vmot(int n) /* generate n units of vertical motion */ { vgoto(vpos + n); /* ignores rounding */ } void put1s(char *s) /* s is a funny char name */ { int i; char *p; extern char *spectab[]; static char prev[10] = ""; static int previ; if (!output) return; if (strcmp(s, prev) != 0) { previ = -1; for (i = 0; spectab[i] != 0; i += 2) if (strcmp(spectab[i], s) == 0) { n_strcpy(prev, s, sizeof(prev)); previ = i; break; } } if (previ >= 0) { for (p = spectab[previ+1]; *p; p++) putc(*p, stdout); } else prev[0] = 0; } void put1(int c) /* output char c */ { if (!output) return; putc(c, stdout); } void -setsize(double n) /* set point size to n (internal) */ +setsize(double n __unused) /* set point size to n (internal) */ { } void -t_fp(int n, char *s) /* font position n now contains font s */ +t_fp(int n __unused, char *s __unused) /* font position n now contains font s */ { } void -setfont(int n) /* set font to n */ +setfont(int n __unused) /* set font to n */ { } void done(void) { output = 1; putpage(); fflush(stdout); exit(0); } void callunix(char line[]) { int rc, status, unixpid; if( (unixpid=fork())==0 ) { signal(SIGINT,sigint); signal(SIGQUIT,sigquit); close(0); dup(2); execl("/bin/sh", "-sh", "-c", line, NULL); exit(255); } else if(unixpid == -1) return; else{ signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); while( (rc = wait(&status)) != unixpid && rc != -1 ) ; signal(SIGINT,(void(*)(int))done); signal(SIGQUIT,(void(*)(int))sigquit); } } int readch(void){ char c; if (read(2,&c,1)<1) c=0; return(c); } char *spectab[] ={ "em", "-", "hy", "-", "en", "-", "ru", "_", "l.", ".", "br", "|", "vr", "|", "fm", "'", "or", "|", 0, 0, }; static int sget(char *buf, size_t size, FILE *fp) { - int c, n = 0; + int c; + size_t n = 0; do c = getc(fp); while (isspace(c)); if (c != EOF) do { if (n+1 < size) buf[n++] = c; c = getc(fp); } while (c != EOF && !isspace(c)); ungetc(c, fp); buf[n] = 0; return n > 1 ? 1 : c == EOF ? EOF : 0; } Index: vendor/heirloom-doctools/dist/troff/troff.d/tmac.d/mcolor.7 =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/tmac.d/mcolor.7 (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/tmac.d/mcolor.7 (nonexistent) @@ -1,121 +0,0 @@ -.\" -.\" Changes by Gunnar Ritter, Freiburg i. Br., Germany, September 2005. -.\" -.\" Derived from Plan 9 v4 /opt/unix/plan9v4/sys/src/cmd/postscript/mcolor/mcolor.5 -.\" -.\" Copyright (C) 2003, Lucent Technologies Inc. and others. -.\" All Rights Reserved. -.\" -.\" Distributed under the terms of the Lucent Public License Version 1.02. -.\" -.\" Sccsid @(#)mcolor.7 1.5 (gritter )2/2/07 -.TH MCOLOR 7 "2/2/07" "Heirloom Documentation Tools" "Macro Packages" -.ds dP /usr/ucblib/doctools/font/devpost/postscript -.ds dT /usr/ucblib/doctools/tmac -.SH NAME -mcolor \- color and reverse video macro -.SH SYNOPSIS -.B troff \-mcolor -[ -.I options -] -.I file ... -.SH DESCRIPTION -.I mcolor -is a macro package for color selection and reverse video printing -on PostScript printers. -The package is compatible with most existing macro packages -and includes the following macro: -.TP 1.25i -.BI .CL "\0color\0text" -Prints -.I text -in -.IR color . -No arguments restores the default color (black in RGB color space). -If -.I text -is omitted the selected -.I color -remains in effect until another -.I color -is selected. -If two arguments are given the -.I text -is printed in -.I color -and then the default color is restored. -.PP -Both the text and background color can be selected. -A -.I color -argument of -.RI `` color1 -.B on -.IR color2 '' -prints text in -.I color1 -on a background in -.I color2 . -.PP -Once a color is in effect, -it is re-installed at the top of each output page. -.PP -Arbitrary PostScript color parameters -can be set by using -.I color -arguments like -.RS -.TP -.PD 0 -\fIred green blue \fBrgb\fR -e.\^g. `.CL ".2 .3 .4 rgb"' -.TP -\fIhue saturation brightness \fBhsb\fR -e.\^g. `.CL ".5 .6 .7 hsb"' -.TP -\fIcyan magenta yellow black \fBcmyk\fR -e.\^g. `.CL ".1 .2 .3 .4 cmyk"' -.TP -\fIgray \fBsetgray\fR -e.\^g. `.CL ".5 setgray"' -.TP -[\fB$\fIsetcolorspace\fR] \fIcomp1 comp2 .\|.\|. compn \fBsetcolor\fR -where \fB$\fIsetcolorspace\fR may be a PostScript procedure -defined in the setup section using a -`\eX\'PSSetup: $setcolorspace { .\|.\|. } bind def\'' -escape sequence. -This parameter is required if the color space changes -in the document. -Otherwise, it may be sufficient -to install the color space once in the setup section. -.PD -.RE -.PP -Each parameter must be a number in the range between 0.0 and 1.0. -In the most general case, the value of the -.I color -argument is passed uninterpreted to the PostScript output. -.PP -Named colors (RGB only) must be listed in the -``colordict'' -dictionary in file -.BR \*(dP/color.ps . -.SH FILES -.B \*(dT/color -.br -.B \*(dP/color.ps -.SH SEE ALSO -.BR troff (1), -.BR dpost (1) -.SH NOTES -Use of the -.I .CL -macro is not always appropriate -since it may (as every macro) result in added spaces. -The \fB\eX\'SetColor: \fIcolor\fB\'\fR -can also be used directly to avoid this; its -.I color -argument has exactly the same syntax as the first argument to -.IR .CL , -e.\^g. `\eX\'SetColor: .2 .3 .4 rgb\''. Property changes on: vendor/heirloom-doctools/dist/troff/troff.d/tmac.d/mcolor.7 ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/troff.d/tmac.d/Makefile.mk =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/tmac.d/Makefile.mk (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/tmac.d/Makefile.mk (revision 310550) @@ -1,32 +1,37 @@ MACS= acm.me bib chars.me deltext.me e eqn.me \ float.me footnote.me index.me local.me m mmn mmt ms.acc \ ms.cov ms.eqn ms.ref ms.tbl ms.ths ms.toc null.me refer.me \ s sh.me tbl.me thesis.me v vgrind \ an andoc doc doc-common doc-ditroff doc-nroff doc-syms \ pictures color pm srefs ptx safe g padj taa naa \ tmac.gchar an-ext MAN= mcolor.7 mpictures.7 man.7 mdoc.7 .SUFFIXES: .in .in: sed 's:@MACDIR@:$(MACDIR):; s:@LIBDIR@:$(LIBDIR):' $< >$@ all: $(MACS) $(MAN) install: all $(ROOT)$(MACDIR) $(ROOT)$(MANDIR)/man7 for i in $(MACS); do \ $(INSTALL) -m 644 $$i $(ROOT)$(MACDIR)/ || exit; \ done for i in $(MAN); do \ $(INSTALL) -m 644 $$i $(ROOT)$(MANDIR)/man7/ || exit; \ done clean: - rm -f andoc bib doc e g m s pm an doc-ditroff + rm -f andoc bib doc e g m s pm an doc-ditroff mcolor.7 mrproper: clean + +mcolor.7: mcolor.7.in + sed -e 's"/usr/ucblib/doctools/font/devpost/postscript"$(ROOT)$(PSTDIR)"' \ + -e 's"/usr/ucblib/doctools/tmac"$(ROOT)$(MACDIR)"' \ + mcolor.7.in > $@ $(ROOT)$(MACDIR) $(ROOT)$(MANDIR)/man7: mkdir -p $@ Index: vendor/heirloom-doctools/dist/troff/troff.d/tmac.d/mcolor.7.in =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/tmac.d/mcolor.7.in (nonexistent) +++ vendor/heirloom-doctools/dist/troff/troff.d/tmac.d/mcolor.7.in (revision 310550) @@ -0,0 +1,121 @@ +.\" +.\" Changes by Gunnar Ritter, Freiburg i. Br., Germany, September 2005. +.\" +.\" Derived from Plan 9 v4 /opt/unix/plan9v4/sys/src/cmd/postscript/mcolor/mcolor.5 +.\" +.\" Copyright (C) 2003, Lucent Technologies Inc. and others. +.\" All Rights Reserved. +.\" +.\" Distributed under the terms of the Lucent Public License Version 1.02. +.\" +.\" Sccsid @(#)mcolor.7 1.5 (gritter )2/2/07 +.TH MCOLOR 7 "2/2/07" "Heirloom Documentation Tools" "Macro Packages" +.ds dP /usr/ucblib/doctools/font/devpost/postscript +.ds dT /usr/ucblib/doctools/tmac +.SH NAME +mcolor \- color and reverse video macro +.SH SYNOPSIS +.B troff \-mcolor +[ +.I options +] +.I file ... +.SH DESCRIPTION +.I mcolor +is a macro package for color selection and reverse video printing +on PostScript printers. +The package is compatible with most existing macro packages +and includes the following macro: +.TP 1.25i +.BI .CL "\0color\0text" +Prints +.I text +in +.IR color . +No arguments restores the default color (black in RGB color space). +If +.I text +is omitted the selected +.I color +remains in effect until another +.I color +is selected. +If two arguments are given the +.I text +is printed in +.I color +and then the default color is restored. +.PP +Both the text and background color can be selected. +A +.I color +argument of +.RI `` color1 +.B on +.IR color2 '' +prints text in +.I color1 +on a background in +.I color2 . +.PP +Once a color is in effect, +it is re-installed at the top of each output page. +.PP +Arbitrary PostScript color parameters +can be set by using +.I color +arguments like +.RS +.TP +.PD 0 +\fIred green blue \fBrgb\fR +e.\^g. `.CL ".2 .3 .4 rgb"' +.TP +\fIhue saturation brightness \fBhsb\fR +e.\^g. `.CL ".5 .6 .7 hsb"' +.TP +\fIcyan magenta yellow black \fBcmyk\fR +e.\^g. `.CL ".1 .2 .3 .4 cmyk"' +.TP +\fIgray \fBsetgray\fR +e.\^g. `.CL ".5 setgray"' +.TP +[\fB$\fIsetcolorspace\fR] \fIcomp1 comp2 .\|.\|. compn \fBsetcolor\fR +where \fB$\fIsetcolorspace\fR may be a PostScript procedure +defined in the setup section using a +`\eX\'PSSetup: $setcolorspace { .\|.\|. } bind def\'' +escape sequence. +This parameter is required if the color space changes +in the document. +Otherwise, it may be sufficient +to install the color space once in the setup section. +.PD +.RE +.PP +Each parameter must be a number in the range between 0.0 and 1.0. +In the most general case, the value of the +.I color +argument is passed uninterpreted to the PostScript output. +.PP +Named colors (RGB only) must be listed in the +``colordict'' +dictionary in file +.BR \*(dP/color.ps . +.SH FILES +.B \*(dT/color +.br +.B \*(dP/color.ps +.SH SEE ALSO +.BR troff (1), +.BR dpost (1) +.SH NOTES +Use of the +.I .CL +macro is not always appropriate +since it may (as every macro) result in added spaces. +The \fB\eX\'SetColor: \fIcolor\fB\'\fR +can also be used directly to avoid this; its +.I color +argument has exactly the same syntax as the first argument to +.IR .CL , +e.\^g. `\eX\'SetColor: .2 .3 .4 rgb\''. Property changes on: vendor/heirloom-doctools/dist/troff/troff.d/tmac.d/mcolor.7.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/troff.d/troff.1.in =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/troff.1.in (nonexistent) +++ vendor/heirloom-doctools/dist/troff/troff.d/troff.1.in (revision 310550) @@ -0,0 +1,308 @@ +.\" +.\" Sccsid @(#)troff.1b 1.22 (gritter) 9/4/06 +.\" Derived from troff(1), Unix 7th edition: +.\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" Redistributions of source code and documentation must retain the +.\" above copyright notice, this list of conditions and the following +.\" disclaimer. +.\" 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. +.\" All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" Neither the name of Caldera International, Inc. nor the names of +.\" other contributors may be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. 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 CALDERA INTERNATIONAL, INC. 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. +.TH TROFF 1 "9/4/06" "Heirloom Documentation Tools" "BSD System Compatibility" +.SH NAME +troff \- typeset or format documents +.SH SYNOPSIS +.HP +.ad l +.nh +\fBtroff\fR +[\fB\-af\&izV\fR] +[\fB\-d\fIaS\fR] +[\fB\-d\fIa\fB=\fIS\fR] +[\fB\-F\fIfontdir\fR] +[\fB\-m\fIname\fR] +[\fB\-n\fIN\fR] +[\fB\-o\fIlist\fR] +[\fB\-r\fIaN\fR] +[\fB\-r\fIa\fB=\fIN\fR] +[\fB\-s\fIN\fR] +[\fB\-T\fIdevice\fR] +[\fB\-u\fIN\fR] +[\fB\-x\fIN\fR] +.br +.hy 1 +.ad b +.SH DESCRIPTION +.I troff +formats text in the named +.I files +for printing on phototypesetter devices. +Its capabilities are described in the +.I Nroff/Troff user's manual. +.PP +.I troff +generates output in an intermediate ASCII format +which must be passed through a device-dependent post-processor +before it can be printed; +see the description of the +.I \-T +option +and the example +below. +.PP +If no +.I file +argument is present, the standard input is read. +An argument consisting of a single minus +.RB ( \- ) +is taken to be +a file name corresponding to the standard input. +The options, which may appear in any order so long as they appear +before the files, are: +.TP "\w'\f3\-F\f1fontdir 'u" +.BI \-o list +Print only pages whose page numbers appear in +the comma-separated +.I list +of numbers and ranges. +A range +.IB N \- M +means pages +.I N +through +.IR M ; +an initial +.I \-N +means +from the beginning to page +.IR N ; +and a final +.IR N \- +means +from +.I N +to the end. +.TP +.BI \-n N +Number first generated page +.IR N . +.TP +.BI \-s N +Stop every +.I N +pages. +.I Troff +will stop the phototypesetter every +.I N +pages, +produce a trailer to allow changing cassettes, +and resume when the typesetter's start button is pressed. +.TP +.BI \-m name +Prepend the macro file +.BI /usr/ucblib/doctools/tmac/tmac. name +to the input +.IR files . +.TP +.BI \-r aN +Set register +.I a +(one-character) to +.IR N . +.TP +.BI \-r a = N +Set register +.I a +(may be more than one character) to +.IR N . +.TP +.BI \-d aS +Define string +.I a +(one-character) to +.IR S . +.TP +.BI \-d a = S +Define string +.I a +(may be more than one character) to +.IR S . +.TP +.B \-i +Read standard input after the input files are exhausted. +.TP +.B \-z +Check syntax only; +do not generate any output +except for error messages. +.TP +.BI \-F fontdir +Use the directory +.I fontdir +to locate font files. +.TP +.B \-u N +Set the emboldening amount, +i.e. the number of times a character is printed +to simulate bold output, +to +.IR N . +.TP +.BI \-T device +Prepare output for the specified device. +Available +.I devices +are: +.RS +.TP 8n +.PD 0 +.B ps +for PostScript output with 72,000\ dpi +and AFM fonts (default), +with +.I dpost +as post-processor +.TP +.B psmed +for PostScript output with 3,600\ dpi +and AFM fonts, +with +.I dpost +as post-processor +.TP +.B pslow +for PostScript output with 432\ dpi +and AFM fonts, +with +.I dpost +as post-processor +.TP +.B post +for PostScript output with 720\ dpi +and +.I ditroff +fonts, +with +.I dpost +as post-processor +.TP +.B html +for HTML output, +with +.I dhtml +as post-processor +.ig \" aps is not installed any longer +.TP +.B aps +for the Autologic APS-5, +with +.I daps +as post-processor +.. +.PD +.RE +.TP +.B \-f +Refrain from feeding out paper and stopping +phototypesetter at the end of the run. +.TP +.B \-a +Send a printable text-only approximation +of the results to the standard output. +.TP +.BI \-x N +Enable extensions to previous versions of +.I troff +at level +.IR N . +Level 0 disables any extensions; +level 1 enables all extensions +except for long requests and request arguments; +level 2 enables these in addition +but executes short requests which are prefixes of undefined long requests; +level 3 ignores undefined long requests. +.TP +.B \-V +Print troff version. +.SH "ENVIRONMENT VARIABLES" +.TP +.BR LANG ", " LC_ALL +See +.IR locale (7). +.TP +.B LC_CTYPE +Determines the mapping +of bytes to characters. +.TP +.B TYPESETTER +Specifies a device name as with the +.I \-T +option. +.TP +.B TROFFONTS +A colon-separated list of directory names +to search for PostScript fonts +before the device font directory. +.TP +.B TROFFMACS +Specifies the location to search for macro files with the +.I \-m +option. +This string forms a prefix to which the macro package name +is immediately appended. +Thus to make `\-mname' work with a file `/path/to/tmac.name', +use `TROFFMACS=/path/to/tmac.' +.SH FILES +.ta \w'/usr/ucblib/doctools/tmac/* 'u +/tmp/ta* temporary file +.br +/usr/ucblib/doctools/tmac/* standard macro files +.br +/usr/ucblib/doctools/font/* font width tables +.SH EXAMPLES +To generate a PostScript file +from input that contains equations and tables, use +.RS +.nf +.sp +output.ps +.sp +.fi +.RE +The resulting file can then be sent to a printer, +displayed by a previewer, +or passed to further post-processing utilities, +such as a PDF distiller. +.SH "SEE ALSO" +J. F. Ossanna, +.I Nroff/Troff user's manual +.br +B. W. Kernighan, +.I +A TROFF Tutorial +.br +eqn(1), tbl(1) Property changes on: vendor/heirloom-doctools/dist/troff/troff.d/troff.1.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/troff/troff.d/troff.h =================================================================== --- vendor/heirloom-doctools/dist/troff/troff.d/troff.h (revision 310549) +++ vendor/heirloom-doctools/dist/troff/troff.d/troff.h (revision 310550) @@ -1,67 +1,67 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)troff.h 1.27 (gritter) 8/19/08 */ extern struct tracktab { int s1; int n1; int s2; int n2; } *tracktab; extern struct box { int val[4]; int flag; } mediasize, bleedat, trimat, cropat; extern struct ref { struct ref *next; char *name; int cnt; } *anchors, *links, *ulinks; extern struct dev dev; extern int Nfont; extern int *cstab; extern int *ccstab; extern int **fallbacktab; extern float *zoomtab; -extern int nchtab; +extern size_t nchtab; extern char *chname; extern int c_endash; extern int kern; extern int lettrack; extern float horscale; extern void growfonts(int); extern void setlig(int, int); extern int loadafm(int, int, char *, char *, int, enum spec); extern int getkw(tchar, tchar); extern void ptpapersize(void); extern void ptcut(void); Index: vendor/heirloom-doctools/dist/vgrind/vgrind.1 =================================================================== --- vendor/heirloom-doctools/dist/vgrind/vgrind.1 (revision 310549) +++ vendor/heirloom-doctools/dist/vgrind/vgrind.1 (nonexistent) @@ -1,228 +0,0 @@ -.\" -.\" This code contains changes by -.\" Gunnar Ritter, Freiburg i. Br., Germany, 2005. All rights reserved. -.\" -.\" Conditions 1, 2, and 4 and the no-warranty notice below apply -.\" to these changes. -.\" -.\" -.\" Copyright (c) 1980 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 acknowedgement: -.\" 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. -.\" -.\" from 4.3BSD-Tahoe vgrind.1 6.2 (Berkeley) 5/5/86 -.\".TH VGRIND 1 "May 5, 1986" -.\" -.\" Sccsid @(#)vgrind.1b 1.3 (gritter) 11/6/05 -.\" -.TH VGRIND 1 "11/6/05" "Heirloom Documentation Tools" "BSD System Compatibility" -.UC 4 -.SH NAME -vgrind \- grind nice listings of programs -.SH SYNOPSIS -.HP -.ad l -.nh -\fBvgrind\fR -[\fB\-2ftnxw\fR] -[\fB\-s\fIn\fR] -[\fB\-h\ \fIheader\fR] -[\fB\-d\ \fIfile\fR] -[\fB\-l\ \fIlanguage\fR] -[\fB\-P\ \fIprinter\fR] -[\fB\-T\ \fIdevice\fR] -[\fB\-o\ \fIlist\fR] -\fIname\fR\ ... -.br -.hy 1 -.ad b -.SH DESCRIPTION -.I Vgrind -formats the program sources which are arguments -in a nice style using -.IR troff (1). -Comments are placed in italics, keywords in bold face, -and the name of the current function is listed down the margin of each -page as it is encountered. -.PP -.I Vgrind -runs in two basic modes, filter mode or regular mode. In filter mode -.I vgrind -acts as a filter in a manner similar to -.IR tbl (1). -The standard input is passed directly to the standard output except -for lines bracketed by the -.I troff-like -macros: -.IP .vS -\- starts processing -.IP .vE -\- ends processing -.LP -These lines are formatted as described above. The output from this -filter can be passed to -.I troff -for output. There need be no particular ordering with -.IR eqn (1) -or -.IR tbl (1). -.PP -In regular mode -.I vgrind -accepts input files, processes them, and passes them to -.IR troff (1) -for output. -.PP -In both modes -.I vgrind -passes any lines beginning with a decimal point without conversion. -.PP -The options are: -.IP \fB\-2\fP -produce two-column output -.IP \fB\-f\fP -forces filter mode -.IP \fB\-t\fP -similar to the same option in -.I troff -causing formatted text to go to the standard output -.IP \fB\-n\fP -forces no keyword bolding -.IP \fB\-x\fP -outputs the index file in a ``pretty'' format. -The index file itself is produced whenever -.I vgrind -is run with a file called -.I index -in the current directory. -The index of function -definitions can then be run off by giving -.I vgrind -the -.B \-x -option and the file -.I index -as argument. -.IP \fB\-s\fP -specifies a point size to use on output (exactly the same as the argument -of a .ps) -.IP \fB\-h\fP -specifies a particular header to put on every output page (default is -the file name) -.IP \fB\-d\fP -specifies an alternate language definitions -file (default is /usr/lib/vgrindefs) -.IP \fB\-l\fP -specifies the language to use. Currently known are PASCAL -.RB ( \-lp ), -MODEL -.RB ( \-lm ), -C -.RB ( \-lc -or the default), -C++ -.RB ( \-lc++ ), -CSH -.RB ( \-lcsh ), -SHELL -.RB ( \-lsh ), -RATFOR -.RB ( \-lr ), -MODULA2 -.RB ( \-lmod2 ), -YACC -.RB ( \-lyacc ), -ISP -.RB ( \-lisp ), -and ICON -.RB ( \-lI ). -.IP \fB\-P\fP -specifies that output is directed to the named printer. -.IP \fB\-T\fP -is passed to -.I troff -and specifies the device to use. -.IP \fB\-o\fP -is passed to -.I troff -and specifies selected pages to print. -.IP \fB\-w\fP -Sets the size of tabulators to four instead of the default eight. -.SH FILES -.\".ta \w'/usr/ucblib/tmac/vgrind 'u -index file where source for index is created -.br -/usr/ucblib/tmac/vgrind macro package -.br -/usr/ucblib/vfontedpr preprocessor -.br -/usr/ucblib/vgrindefs language descriptions -.SH SEE ALSO -troff(1) -.SH NOTES -Vfontedpr assumes that a certain programming style is followed: -.PP -For -.B C -and -.B C++ -\- function names can be preceded on a line only by spaces, tabs, or an -asterisk. The parenthesized arguments must also be on the same line. -.PP -For -.B PASCAL -\- function names need to appear on the same line as the keywords -.I function -or -.I procedure. -.PP -For -.B MODEL -\- function names need to appear on the same line as the keywords -.I is -.I beginproc. -.PP -If these conventions are not followed, the indexing and marginal function -name comment mechanisms will fail. -.sp -More generally, arbitrary formatting styles for programs mostly look bad. -The use of spaces to align source code fails miserably; if you plan to -.I vgrind -your program you should use tabs. This is somewhat inevitable since the -font used by -.I vgrind -is variable width. -.PP -The mechanism of ctags in recognizing functions should be used here. -.PP -Filter mode does not work in documents using the \-me or \-ms macros. -(So what use is it anyway?) -.PP -Written by Dave Presotto & William Joy. Property changes on: vendor/heirloom-doctools/dist/vgrind/vgrind.1 ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/vgrind/Makefile.mk =================================================================== --- vendor/heirloom-doctools/dist/vgrind/Makefile.mk (revision 310549) +++ vendor/heirloom-doctools/dist/vgrind/Makefile.mk (revision 310550) @@ -1,34 +1,38 @@ OBJ = regexp.o vfontedpr.o vgrindefs.o version.o FLAGS = $(EUC) -DLIBDIR='"$(LIBDIR)"' $(DEFINES) -I../include .c.o: $(CC) $(_CFLAGS) $(FLAGS) -c $< -all: vgrind vfontedpr +all: vgrind vfontedpr vgrind.1 vfontedpr: $(OBJ) $(CC) $(_CFLAGS) $(_LDFLAGS) $(OBJ) $(LIBS) -o vfontedpr vgrind: vgrind.sh rm -f $@ echo "#!$(SHELL)" >>$@ echo "_TROFF=$(BINDIR)/troff" >>$@ echo "_VFONTEDPR=$(LIBDIR)/vfontedpr" >>$@ echo "_TMAC_VGRIND=$(MACDIR)/vgrind" >>$@ echo "_DPOST=$(BINDIR)/dpost" >>$@ cat vgrind.sh >>$@ chmod 755 $@ install: $(INSTALL) -c vgrind $(ROOT)$(BINDIR)/vgrind test -d $(ROOT)$(LIBDIR) || mkdir -p $(ROOT)$(LIBDIR) $(INSTALL) -c vfontedpr $(ROOT)$(LIBDIR)/vfontedpr $(STRIP) $(ROOT)$(LIBDIR)/vfontedpr $(INSTALL) -c -m 644 vgrindefs.src $(ROOT)$(LIBDIR)/vgrindefs $(INSTALL) -c -m 644 vgrind.1 $(ROOT)$(MANDIR)/man1/vgrind.1 clean: - rm -f $(OBJ) vfontedpr vgrind retest retest.o core log *~ + rm -f $(OBJ) vfontedpr vgrind retest retest.o core log *~ vgrind.1 mrproper: clean + +vgrind.1: vgrind.1.in + sed -e 's"/usr/ucblib/tmac/"$(ROOT)$(MACDIR)/"' \ + -e 's"/usr/ucblib/"$(ROOT)$(LIBDIR)/"' vgrind.1.in > $@ Index: vendor/heirloom-doctools/dist/vgrind/regexp.c =================================================================== --- vendor/heirloom-doctools/dist/vgrind/regexp.c (revision 310549) +++ vendor/heirloom-doctools/dist/vgrind/regexp.c (revision 310550) @@ -1,569 +1,573 @@ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* from OpenSolaris "regexp.c 1.11 92/07/21 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)regexp.c 1.3 (gritter) 10/22/05 */ /* from UCB 5.1 (Berkeley) 6/5/85 */ #include #include #include +int STRNCMP(register char *s1, register char *s2, register int len); +char * expmatch ( register char *s, register char *re, register char *mstring); +char *convexp( char *re); + typedef int boolean; #define TRUE 1 #define FALSE 0 #define NIL 0 extern boolean l_onecase; /* true if upper and lower equivalent */ extern char *l_idchars; /* set of characters legal in identifiers in addition to letters and digits */ static void expconv(void); #define isidchr(c) \ (isalnum(c) || ((c) != NIL && strchr(l_idchars, (c)) != NIL)) #define makelower(c) (isupper((int)(c)) ? tolower((int)(c)) : (c)) /* STRNCMP - like strncmp except that we convert the * first string to lower case before comparing * if l_onecase is set. */ int STRNCMP(register char *s1, register char *s2, register int len) { if (l_onecase) { do if (*s2 - makelower(*s1)) return (*s2 - makelower(*s1)); else { s2++; s1++; } while (--len); } else { do if (*s2 - *s1) return (*s2 - *s1); else { s2++; s1++; } while (--len); } return(0); } /* The following routine converts an irregular expression to * internal format. * * Either meta symbols (\a \d or \p) or character strings or * operations ( alternation or parenthesizing ) can be * specified. Each starts with a descriptor byte. The descriptor * byte has STR set for strings, META set for meta symbols * and OPER set for operations. * The descriptor byte can also have the OPT bit set if the object * defined is optional. Also ALT can be set to indicate an alternation. * * For metasymbols the byte following the descriptor byte identities * the meta symbol (containing an ascii 'a', 'd', 'p', '|', or '('). For * strings the byte after the descriptor is a character count for * the string: * * meta symbols := descriptor * symbol * * strings := descriptor * character count * the string * * operations := descriptor * symbol * character count */ /* * handy macros for accessing parts of match blocks */ #define MSYM(A) (*(A+1)) /* symbol in a meta symbol block */ #define MNEXT(A) (A+2) /* character following a metasymbol block */ #define OSYM(A) (*(A+1)) /* symbol in an operation block */ #define OCNT(A) (*(A+2)) /* character count */ #define ONEXT(A) (A+3) /* next character after the operation */ #define OPTR(A) (A+*(A+2)) /* place pointed to by the operator */ #define SCNT(A) (*(A+1)) /* byte count of a string */ #define SSTR(A) (A+2) /* address of the string */ #define SNEXT(A) (A+2+*(A+1)) /* character following the string */ /* * bit flags in the descriptor */ #define OPT 1 #define STR 2 #define META 4 #define ALT 8 #define OPER 16 static char *ure; /* pointer current position in unconverted exp */ static char *ccre; /* pointer to current position in converted exp*/ char * convexp( char *re /* unconverted irregular expression */ ) { register char *cre; /* pointer to converted regular expression */ /* allocate room for the converted expression */ if (re == NIL) return (NIL); if (*re == '\0') return (NIL); cre = malloc (4 * strlen(re) + 3); ccre = cre; ure = re; /* start the conversion with a \a */ *cre = META | OPT; MSYM(cre) = 'a'; ccre = MNEXT(cre); /* start the conversion (its recursive) */ expconv (); *ccre = 0; return (cre); } static void expconv(void) { register char *cs; /* pointer to current symbol in converted exp */ register char c; /* character being processed */ register char *acs; /* pinter to last alternate */ register int temp; /* let the conversion begin */ acs = NIL; cs = NIL; while (*ure != NIL) { switch (c = *ure++) { case '\\': switch (c = *ure++) { /* escaped characters are just characters */ default: if (cs == NIL || (*cs & STR) == 0) { cs = ccre; *cs = STR; SCNT(cs) = 1; ccre += 2; } else SCNT(cs)++; *ccre++ = c; break; /* normal(?) metacharacters */ case 'a': case 'd': case 'e': case 'p': if (acs != NIL && acs != cs) { do { temp = OCNT(acs); OCNT(acs) = ccre - acs; acs -= temp; } while (temp != 0); acs = NIL; } cs = ccre; *cs = META; MSYM(cs) = c; ccre = MNEXT(cs); break; } break; /* just put the symbol in */ case '^': case '$': if (acs != NIL && acs != cs) { do { temp = OCNT(acs); OCNT(acs) = ccre - acs; acs -= temp; } while (temp != 0); acs = NIL; } cs = ccre; *cs = META; MSYM(cs) = c; ccre = MNEXT(cs); break; /* mark the last match sequence as optional */ case '?': if (cs) *cs = *cs | OPT; break; /* recurse and define a subexpression */ case '(': if (acs != NIL && acs != cs) { do { temp = OCNT(acs); OCNT(acs) = ccre - acs; acs -= temp; } while (temp != 0); acs = NIL; } cs = ccre; *cs = OPER; OSYM(cs) = '('; ccre = ONEXT(cs); expconv (); OCNT(cs) = ccre - cs; /* offset to next symbol */ break; /* return from a recursion */ case ')': if (acs != NIL) { do { temp = OCNT(acs); OCNT(acs) = ccre - acs; acs -= temp; } while (temp != 0); acs = NIL; } cs = ccre; *cs = META; MSYM(cs) = c; ccre = MNEXT(cs); return; /* mark the last match sequence as having an alternate */ /* the third byte will contain an offset to jump over the */ /* alternate match in case the first did not fail */ case '|': if (acs != NIL && acs != cs) OCNT(ccre) = ccre - acs; /* make a back pointer */ else OCNT(ccre) = 0; *cs |= ALT; cs = ccre; *cs = OPER; OSYM(cs) = '|'; ccre = ONEXT(cs); acs = cs; /* remember that the pointer is to be filles */ break; /* if its not a metasymbol just build a scharacter string */ default: if (cs == NIL || (*cs & STR) == 0) { cs = ccre; *cs = STR; SCNT(cs) = 1; ccre = SSTR(cs); } else SCNT(cs)++; *ccre++ = c; break; } } if (acs != NIL) { do { temp = OCNT(acs); OCNT(acs) = ccre - acs; acs -= temp; } while (temp != 0); acs = NIL; } return; } /* end of convertre */ /* * The following routine recognises an irregular expresion * with the following special characters: * * \? - means last match was optional * \a - matches any number of characters * \d - matches any number of spaces and tabs * \p - matches any number of alphanumeric * characters. The * characters matched will be copied into * the area pointed to by 'name'. * \| - alternation * \( \) - grouping used mostly for alternation and * optionality * * The irregular expression must be translated to internal form * prior to calling this routine * * The value returned is the pointer to the first non \a * character matched. */ extern boolean escaped; /* true if we are currently escaped */ extern char *Start; /* start of string */ char * expmatch ( register char *s, /* string to check for a match in */ register char *re, /* a converted irregular expression */ register char *mstring /* where to put whatever matches a \p */ ) { register char *cs; /* the current symbol */ register char *ptr,*s1; /* temporary pointer */ boolean matched; /* a temporary boolean */ /* initial conditions */ if (re == NIL) return (NIL); cs = re; matched = FALSE; /* loop till expression string is exhausted (or at least pretty tired) */ while (*cs) { switch (*cs & (OPER | STR | META)) { /* try to match a string */ case STR: matched = !STRNCMP (s, SSTR(cs), SCNT(cs)); if (matched) { /* hoorah it matches */ s += SCNT(cs); cs = SNEXT(cs); } else if (*cs & ALT) { /* alternation, skip to next expression */ cs = SNEXT(cs); } else if (*cs & OPT) { /* the match is optional */ cs = SNEXT(cs); matched = 1; /* indicate a successful match */ } else { /* no match, error return */ return (NIL); } break; /* an operator, do something fancy */ case OPER: switch (OSYM(cs)) { /* this is an alternation */ case '|': if (matched) /* last thing in the alternation was a match, skip ahead */ cs = OPTR(cs); else /* no match, keep trying */ cs = ONEXT(cs); break; /* this is a grouping, recurse */ case '(': ptr = expmatch (s, ONEXT(cs), mstring); if (ptr != NIL) { /* the subexpression matched */ matched = 1; s = ptr; } else if (*cs & ALT) { /* alternation, skip to next expression */ matched = 0; } else if (*cs & OPT) { /* the match is optional */ matched = 1; /* indicate a successful match */ } else { /* no match, error return */ return (NIL); } cs = OPTR(cs); break; } break; /* try to match a metasymbol */ case META: switch (MSYM(cs)) { /* try to match anything and remember what was matched */ case 'p': /* * This is really the same as trying the match the * remaining parts of the expression to any subset * of the string. */ s1 = s; do { ptr = expmatch (s1, MNEXT(cs), mstring); if (ptr != NIL && s1 != s) { /* we have a match, remember the match */ strncpy (mstring, s, s1 - s); mstring[s1 - s] = '\0'; return (ptr); } else if (ptr != NIL && (*cs & OPT)) { /* it was aoptional so no match is ok */ return (ptr); } else if (ptr != NIL) { /* not optional and we still matched */ return (NIL); } if (!isidchr((int)*s1)) return (NIL); if (*s1 == '\\') escaped = escaped ? FALSE : TRUE; else escaped = FALSE; } while (*s1++); return (NIL); /* try to match anything */ case 'a': /* * This is really the same as trying the match the * remaining parts of the expression to any subset * of the string. */ s1 = s; do { ptr = expmatch (s1, MNEXT(cs), mstring); if (ptr != NIL && s1 != s) { /* we have a match */ return (ptr); } else if (ptr != NIL && (*cs & OPT)) { /* it was aoptional so no match is ok */ return (ptr); } else if (ptr != NIL) { /* not optional and we still matched */ return (NIL); } if (*s1 == '\\') escaped = escaped ? FALSE : TRUE; else escaped = FALSE; } while (*s1++); return (NIL); /* fail if we are currently escaped */ case 'e': if (escaped) return(NIL); cs = MNEXT(cs); break; /* match any number of tabs and spaces */ case 'd': ptr = s; while (*s == ' ' || *s == '\t') s++; if (s != ptr || s == Start) { /* match, be happy */ matched = 1; cs = MNEXT(cs); } else if (*s == '\n' || *s == '\0') { /* match, be happy */ matched = 1; cs = MNEXT(cs); } else if (*cs & ALT) { /* try the next part */ matched = 0; cs = MNEXT(cs); } else if (*cs & OPT) { /* doesn't matter */ matched = 1; cs = MNEXT(cs); } else /* no match, error return */ return (NIL); break; /* check for end of line */ case '$': if (*s == '\0' || *s == '\n') { /* match, be happy */ s++; matched = 1; cs = MNEXT(cs); } else if (*cs & ALT) { /* try the next part */ matched = 0; cs = MNEXT(cs); } else if (*cs & OPT) { /* doesn't matter */ matched = 1; cs = MNEXT(cs); } else /* no match, error return */ return (NIL); break; /* check for start of line */ case '^': if (s == Start) { /* match, be happy */ matched = 1; cs = MNEXT(cs); } else if (*cs & ALT) { /* try the next part */ matched = 0; cs = MNEXT(cs); } else if (*cs & OPT) { /* doesn't matter */ matched = 1; cs = MNEXT(cs); } else /* no match, error return */ return (NIL); break; /* end of a subexpression, return success */ case ')': return (s); } break; } } return (s); } Index: vendor/heirloom-doctools/dist/vgrind/vgrind.1.in =================================================================== --- vendor/heirloom-doctools/dist/vgrind/vgrind.1.in (nonexistent) +++ vendor/heirloom-doctools/dist/vgrind/vgrind.1.in (revision 310550) @@ -0,0 +1,228 @@ +.\" +.\" This code contains changes by +.\" Gunnar Ritter, Freiburg i. Br., Germany, 2005. All rights reserved. +.\" +.\" Conditions 1, 2, and 4 and the no-warranty notice below apply +.\" to these changes. +.\" +.\" +.\" Copyright (c) 1980 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 acknowedgement: +.\" 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. +.\" +.\" from 4.3BSD-Tahoe vgrind.1 6.2 (Berkeley) 5/5/86 +.\".TH VGRIND 1 "May 5, 1986" +.\" +.\" Sccsid @(#)vgrind.1b 1.3 (gritter) 11/6/05 +.\" +.TH VGRIND 1 "11/6/05" "Heirloom Documentation Tools" "BSD System Compatibility" +.UC 4 +.SH NAME +vgrind \- grind nice listings of programs +.SH SYNOPSIS +.HP +.ad l +.nh +\fBvgrind\fR +[\fB\-2ftnxw\fR] +[\fB\-s\fIn\fR] +[\fB\-h\ \fIheader\fR] +[\fB\-d\ \fIfile\fR] +[\fB\-l\ \fIlanguage\fR] +[\fB\-P\ \fIprinter\fR] +[\fB\-T\ \fIdevice\fR] +[\fB\-o\ \fIlist\fR] +\fIname\fR\ ... +.br +.hy 1 +.ad b +.SH DESCRIPTION +.I Vgrind +formats the program sources which are arguments +in a nice style using +.IR troff (1). +Comments are placed in italics, keywords in bold face, +and the name of the current function is listed down the margin of each +page as it is encountered. +.PP +.I Vgrind +runs in two basic modes, filter mode or regular mode. In filter mode +.I vgrind +acts as a filter in a manner similar to +.IR tbl (1). +The standard input is passed directly to the standard output except +for lines bracketed by the +.I troff-like +macros: +.IP .vS +\- starts processing +.IP .vE +\- ends processing +.LP +These lines are formatted as described above. The output from this +filter can be passed to +.I troff +for output. There need be no particular ordering with +.IR eqn (1) +or +.IR tbl (1). +.PP +In regular mode +.I vgrind +accepts input files, processes them, and passes them to +.IR troff (1) +for output. +.PP +In both modes +.I vgrind +passes any lines beginning with a decimal point without conversion. +.PP +The options are: +.IP \fB\-2\fP +produce two-column output +.IP \fB\-f\fP +forces filter mode +.IP \fB\-t\fP +similar to the same option in +.I troff +causing formatted text to go to the standard output +.IP \fB\-n\fP +forces no keyword bolding +.IP \fB\-x\fP +outputs the index file in a ``pretty'' format. +The index file itself is produced whenever +.I vgrind +is run with a file called +.I index +in the current directory. +The index of function +definitions can then be run off by giving +.I vgrind +the +.B \-x +option and the file +.I index +as argument. +.IP \fB\-s\fP +specifies a point size to use on output (exactly the same as the argument +of a .ps) +.IP \fB\-h\fP +specifies a particular header to put on every output page (default is +the file name) +.IP \fB\-d\fP +specifies an alternate language definitions +file (default is /usr/lib/vgrindefs) +.IP \fB\-l\fP +specifies the language to use. Currently known are PASCAL +.RB ( \-lp ), +MODEL +.RB ( \-lm ), +C +.RB ( \-lc +or the default), +C++ +.RB ( \-lc++ ), +CSH +.RB ( \-lcsh ), +SHELL +.RB ( \-lsh ), +RATFOR +.RB ( \-lr ), +MODULA2 +.RB ( \-lmod2 ), +YACC +.RB ( \-lyacc ), +ISP +.RB ( \-lisp ), +and ICON +.RB ( \-lI ). +.IP \fB\-P\fP +specifies that output is directed to the named printer. +.IP \fB\-T\fP +is passed to +.I troff +and specifies the device to use. +.IP \fB\-o\fP +is passed to +.I troff +and specifies selected pages to print. +.IP \fB\-w\fP +Sets the size of tabulators to four instead of the default eight. +.SH FILES +.\".ta \w'/usr/ucblib/tmac/vgrind 'u +index file where source for index is created +.br +/usr/ucblib/tmac/vgrind macro package +.br +/usr/ucblib/vfontedpr preprocessor +.br +/usr/ucblib/vgrindefs language descriptions +.SH SEE ALSO +troff(1) +.SH NOTES +Vfontedpr assumes that a certain programming style is followed: +.PP +For +.B C +and +.B C++ +\- function names can be preceded on a line only by spaces, tabs, or an +asterisk. The parenthesized arguments must also be on the same line. +.PP +For +.B PASCAL +\- function names need to appear on the same line as the keywords +.I function +or +.I procedure. +.PP +For +.B MODEL +\- function names need to appear on the same line as the keywords +.I is +.I beginproc. +.PP +If these conventions are not followed, the indexing and marginal function +name comment mechanisms will fail. +.sp +More generally, arbitrary formatting styles for programs mostly look bad. +The use of spaces to align source code fails miserably; if you plan to +.I vgrind +your program you should use tabs. This is somewhat inevitable since the +font used by +.I vgrind +is variable width. +.PP +The mechanism of ctags in recognizing functions should be used here. +.PP +Filter mode does not work in documents using the \-me or \-ms macros. +(So what use is it anyway?) +.PP +Written by Dave Presotto & William Joy. Property changes on: vendor/heirloom-doctools/dist/vgrind/vgrind.1.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/heirloom-doctools/dist/vgrind/vgrindefs.c =================================================================== --- vendor/heirloom-doctools/dist/vgrind/vgrindefs.c (revision 310549) +++ vendor/heirloom-doctools/dist/vgrind/vgrindefs.c (revision 310550) @@ -1,314 +1,319 @@ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* from OpenSolaris "vgrindefs.c 1.10 92/07/21 SMI" */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)vgrindefs.c 1.3 (gritter) 10/22/05 */ /* from UCB 5.1 (Berkeley) 6/5/85 */ #define BUFSIZ 1024 #define MAXHOP 32 /* max number of tc= indirections */ #include #include #include #include #include #include #include #include "global.h" /* * grindcap - routines for dealing with the language definitions data base * (code stolen almost totally from termcap) * * BUG: Should use a "last" pointer in tbuf, so that searching * for capabilities alphabetically would not be a n**2/2 * process when large numbers of capabilities are given. * Note: If we add a last pointer now we will screw up the * tc capability. We really should compile termcap. * * Essentially all the work here is scanning and decoding escapes * in string capabilities. We don't use stdio because the editor * doesn't, and because living w/o it is not hard. */ +int tgetent(char *bp, char *name, char *file); +int tgetnum(char *id); +int tgetflag(char *id); +char * tgetstr(char *id, char **area); + static char *tbuf; static char *filename; static int hopcount; /* detect infinite loops in termcap, init 0 */ static char *vgrind_msg; static int tnchktc(void); static int tnamatch(char *); static char *tskip(register char *); static char *tdecode(register char *, char **); /* * Get an entry for terminal name in buffer bp, * from the termcap file. Parse is very rudimentary; * we just notice escaped newlines. */ int tgetent(char *bp, char *name, char *file) { register char *cp; register int c; register int i = 0, cnt = 0; char ibuf[BUFSIZ]; int tf; tbuf = bp; tf = 0; filename = file; tf = open(filename, O_RDONLY); if (tf < 0) return (-1); for (;;) { cp = bp; for (;;) { if (i == cnt) { cnt = read(tf, ibuf, BUFSIZ); if (cnt <= 0) { close(tf); return (0); } i = 0; } c = ibuf[i++]; if (c == '\n') { if (cp > bp && cp[-1] == '\\'){ cp--; continue; } break; } if (cp >= bp+BUFSIZ) { vgrind_msg = "Vgrind entry too long\n"; write(2, vgrind_msg, strlen(vgrind_msg)); break; } else *cp++ = c; } *cp = 0; /* * The real work for the match. */ if (tnamatch(name)) { close(tf); return(tnchktc()); } } } /* * tnchktc: check the last entry, see if it's tc=xxx. If so, * recursively find xxx and append that entry (minus the names) * to take the place of the tc=xxx entry. This allows termcap * entries to say "like an HP2621 but doesn't turn on the labels". * Note that this works because of the left to right scan. */ static int tnchktc(void) { register char *p, *q; char tcname[16]; /* name of similar terminal */ char tcbuf[BUFSIZ]; char *holdtbuf = tbuf; int l; p = tbuf + strlen(tbuf) - 2; /* before the last colon */ while (*--p != ':') if (p MAXHOP) { vgrind_msg = "Infinite tc= loop\n"; write(2, vgrind_msg, strlen(vgrind_msg)); return (0); } if (tgetent(tcbuf, tcname, filename) != 1) return(0); for (q=tcbuf; *q != ':'; q++) ; l = p - holdtbuf + strlen(q); if (l > BUFSIZ) { vgrind_msg = "Vgrind entry too long\n"; write(2, vgrind_msg, strlen(vgrind_msg)); q[BUFSIZ - (p-tbuf)] = 0; } n_strcpy(p, q+1, BUFSIZ - (p - holdtbuf)); tbuf = holdtbuf; return(1); } /* * Tnamatch deals with name matching. The first field of the termcap * entry is a sequence of names separated by |'s, so we compare * against each such name. The normal : terminator after the last * name (before the first field) stops us. */ static int tnamatch(char *np) { register char *Np, *Bp; Bp = tbuf; if (*Bp == '#') return(0); for (;;) { for (Np = np; *Np && *Bp == *Np; Bp++, Np++) continue; if (*Np == 0 && (*Bp == '|' || *Bp == ':' || *Bp == 0)) return (1); while (*Bp && *Bp != ':' && *Bp != '|') Bp++; if (*Bp == 0 || *Bp == ':') return (0); Bp++; } } /* * Skip to the next field. Notice that this is very dumb, not * knowing about \: escapes or any such. If necessary, :'s can be put * into the termcap file in octal. */ static char * tskip(register char *bp) { while (*bp && *bp != ':') bp++; if (*bp == ':') bp++; return (bp); } /* * Return the (numeric) option id. * Numeric options look like * li#80 * i.e. the option string is separated from the numeric value by * a # character. If the option is not found we return -1. * Note that we handle octal numbers beginning with 0. */ int tgetnum(char *id) { register int i, base; register char *bp = tbuf; for (;;) { bp = tskip(bp); if (*bp == 0) return (-1); if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1]) continue; if (*bp == '@') return(-1); if (*bp != '#') continue; bp++; base = 10; if (*bp == '0') base = 8; i = 0; while (isdigit((int)*bp)) i *= base, i += *bp++ - '0'; return (i); } } /* * Handle a flag option. * Flag options are given "naked", i.e. followed by a : or the end * of the buffer. Return 1 if we find the option, or 0 if it is * not given. */ int tgetflag(char *id) { register char *bp = tbuf; for (;;) { bp = tskip(bp); if (!*bp) return (0); if (*bp++ == id[0] && *bp != 0 && *bp++ == id[1]) { if (!*bp || *bp == ':') return (1); else if (*bp == '@') return(0); } } } /* * Get a string valued option. * These are given as * cl=^Z * Much decoding is done on the strings, and the strings are * placed in area, which is a ref parameter which is updated. * No checking on area overflow. */ char * tgetstr(char *id, char **area) { register char *bp = tbuf; for (;;) { bp = tskip(bp); if (!*bp) return (0); if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1]) continue; if (*bp == '@') return(0); if (*bp != '=') continue; bp++; return (tdecode(bp, area)); } } /* * Tdecode does the grung work to decode the * string capability escapes. */ static char * tdecode(register char *str, char **area) { register char *cp; register int c; cp = *area; while ((c = *str++)) { if (c == ':' && *(cp-1) != '\\') break; *cp++ = c; } *cp++ = 0; str = *area; *area = cp; return (str); }