/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1996-2012 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* troff to html filter
*
* NOTE: not handled in state.groff mode
*
* \?anything\?
*/
static const char usage[] =
"[-?\n@(#)$Id: troff2html (AT&T Research) 2004-04-26 $\n]"
"[+DESCRIPTION?\btroff2html\b converts \btroff\b(1) (or \bgroff\b(1),"
" depending on the processing mode) input documents to an \bhtml\b"
" document on the standard output. Although a full \atroff\a parse"
" is done, many features are ignored in the mapping to \bhtml\b.]"
"[+?The \atroff\a \bt\b condition test evaluates \btrue\b, the \bn\b"
" condition tests evaluates \bfalse\b, and the \agroff\a compatibility"
" register \b\\\\n[.C]]\b evaluates to 0 (enable \agroff\a parsing)"
" if it is referenced before the first \agroff\a \b.cp\b (compatibility"
" mode) request.]"
" browsers don't care.]"
"[i:identify?Reads identification options from \afile\a. Unknown options"
" are silently ignored. See the \b.xx\b request below for a description"
" of the options.]:[file]"
"[I:include?Appends \adirectory\a to the list of directories searched"
" for \b--macros\b and \b.so\b request files.]:[directory]"
"[m:macros?Locates and reads the macro package file \apackage\a. In order"
" to accomodate different \atroff\a installation styles the file search"
" order is fairly involved:]:[package]{"
" [+./package?]"
" [+directory/tmac.package?for all \b--include\b directories]"
" [+../lib/tmac/tmac.package?for all directories on \b$PATH\b]"
" [+../lib/html/mpackage.tr?for all directories on \b$PATH\b]"
" [+../share/groff/tmac/tmac.package?for all directories on \b$PATH\b]"
" [+../groff/share/groff/tmac/tmac.package?for all directories on \b$PATH\b]"
"}"
"[r:register?Initializes the number \aregister\a to \aN\a.]:[registerN]"
"[s:script?Reads \ascript\a as if it came from a file. \b--script='.nr A 123'\b"
" is equivalent to \b-rA123\b.]:[script]"
"[v:verbose?Enables verbose error and warning messages. Following \atroff\a"
" tradition, \btroff2html\b by default does not warn about unknown"
" requests; \b--verbose\b enables such warnings.]"
"[+EXTENSIONS?\b.xx\b \aname\a[=\avalue\a]] is a special \btroff2html\b"
" request that handles program tracing, \bhtml\b extensions and \atroff\a"
" macro package magic that went way past the author's willingness"
" to understand. Supported operations are:]{"
" [+author=text?Specifies the contact information for the document"
" HEAD section.]"
" [+background=URL?Specifies the document background URL.]"
" [+debug=level?The debug trace \alevel\a; higher levels produce"
" more output.]"
" [+get=+-register?Traces each \bget\b for the named number"
" \aregister\a. \b-\b turns tracing off.]"
" [+hot='word ...'?Adds (\b+\b) or removes (\b-\b) \aword\a ... from"
" the hot-word list. Constructs that match (\ahot-word\a ..."
" \aSWITCH-FONT\a text \aSWITCH-FONT\a ... ) adds \atext\a as"
" a hot link to another portion of the document. \brefer\b and"
" \bsee\b are the default hot words. Case is ignored when"
" matching hot words.]"
" at the top of the document.]"
" [+mailto=address?Sets the email \aaddress\a to send comments and"
" suggestions.]"
" [+meta.name?Emits the \bhtml\b tag \b<META name=\b\"\aname\a\""
" \bcontent=\b\"\acontent\a\"\b>\b.]"
" [+package=text?\atext\a is prepended to the \bhtml\b document title.]"
" [+set=+-register?Traces each \bset\b for the named number"
" \aregister\a. \b-\b turns tracing off.]"
" [+title=text?Sets the document title.]"
"}"
"[+?Local URL links are generated for all top level headings. These can be"
" referenced by embedding the benign (albeit convoluted) \atroff\a"
" construct \\h'0*\\w\"label\"'text\\g'0', where \alabel\a is the"
" local link label and \atext\a is the hot link text. If \alabel\a"
" and \atext\a are the same then use \\h'0*1'text\\h'0'.]"
"\n"
"\n[ file ... ]\n"
"\n"
"[+SEE ALSO?\bgroff\b(1), \bhtml2rtf\b(1), \bman\b(1), \bmm\b(1),"
" \bmm2html\b(1), \btroff\b(1)]"
;
#include "troff2html.h"
#include <error.h>
#include <hashkey.h>
#include <ls.h>
#include <tm.h>
/*
* intermediate code
*
* CODE_0
* CODE_1 <op>
* CODE_2 <data> <op>
* CODE_n <length> <op> <length-data>
*/
#define EOF 0
/*
* sfstruse(sp) with fatal error check
*/
static char*
{
char* s;
return s;
}
/*
*/
static void
{
int n;
{
{
return;
}
}
else
{
{
return;
}
}
if (name)
{
{
}
}
if (line < 0)
else
{
if (line > 0)
}
if (arg)
{
}
else
}
static long expression(char*, char**, int);
/*
* return the next expression operand
*/
static long
{
register int c;
register long n;
register long f;
int abs;
int neg;
long d;
char* x;
while (isspace(*s))
s++;
if (abs = *s == '|')
s++;
if (neg = *s == '-')
s++;
else if (*s == '+')
s++;
d = 1;
if (*s == '(')
{
s = x;
if (*s == ')')
s++;
c = *s++;
}
else
{
n = 0;
while ((c = *s++) >= '0' && c <= '9')
n = n * 10 + c - '0';
if (c == '.')
{
f = 0;
while ((c = *s++) >= '0' && c <= '9')
{
d *= 10;
n *= 10;
f = f * 10 + c - '0';
}
n += f;
}
}
for (;;)
{
switch (c)
{
case 'P':
n *= 72;
break;
case 'c':
n *= 170;
break;
case 'i':
n *= 432;
break;
case 'm':
break;
case 'n':
case 'w':
break;
case 'p':
n *= 6;
break;
case 's':
case 'u':
case 'z':
break;
case 'v':
break;
default:
s--;
if (c = scale)
{
scale = 0;
continue;
}
break;
}
break;
}
n /= d;
if (e)
{
while (isspace(*s))
s++;
*e = s;
}
if (abs)
return 1;
if (neg)
n = -n;
return n;
}
/*
* convert units to scale
*/
static long
{
long m;
m = n;
switch (scale)
{
case 'M':
if (up)
else
break;
case 'P':
if (up)
n *= 72;
else
n /= 72;
break;
case 'c':
if (up)
n *= 170;
else
n /= 170;
break;
case 'i':
if (up)
n *= 432;
else
n /= 432;
break;
case 'm':
if (up)
else
break;
case 'n':
case 'w':
if (up)
else
break;
case 'p':
if (up)
n *= 6;
else
n /= 6;
break;
case 's':
case 'u':
case 'z':
break;
case 'v':
if (up)
else
break;
}
return n ? n : (m > 0) ? 1 : 0;
}
/*
* evaluate numeric expression in s
*/
static long
{
long n;
long m;
for (;;)
{
switch (*s++)
{
case CODE_2:
s++;
/*FALLTHROUGH*/
case CODE_1:
s++;
/*FALLTHROUGH*/
case CODE_0:
continue;
case '+':
continue;
case '-':
continue;
case '/':
n /= m;
else
n = 0;
continue;
case '*':
continue;
case '%':
n %= m;
else
n = 0;
continue;
case '<':
{
if (m < n)
n = m;
}
else if (*s == '=')
else
continue;
case '>':
{
if (m > n)
n = m;
}
else if (*s == '=')
else
continue;
case '=':
if (*s == '=')
s++;
continue;
case '&':
if (*s == '&')
s++;
continue;
case ':':
if (*s == ':')
s++;
continue;
default:
s--;
break;
}
break;
}
if (e)
{
while (isspace(*s))
s++;
*e = s;
}
if (scale)
return n;
}
/*
* evaluate a conditional expression
*/
static long
cond(register char* s, char** e)
{
register int c;
register int i;
register int q;
register long v;
register char* t;
char* u;
while (isspace(*s))
s++;
if (i = *s == '!')
s++;
while (isspace(*s))
s++;
switch (c = *s)
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '-':
case '+':
case '(':
v = expression(s, &u, 0) > 0;
s = u;
break;
case 'c':
s++;
if (*s == 'c' && *(s + 1) == 'h')
s += 2;
v = 0;
break;
case 'd':
case 'r':
t = s;
while (*++s && !isspace(*s));
q = *s;
*s = 0;
*t = c == 'd' ? '.' : 'n';
*t = c;
*s = q;
break;
case 'g':
GROFFINIT();
s++;
break;
case 'o':
case 't':
v = 1;
s++;
break;
default:
if (isalpha(c))
{
v = 0;
s++;
}
else
{
for (u = ++s; *s && *s != c; s++);
if (*s)
{
*s++ = 0;
for (t = s; *s && *s != c; s++);
if (*s)
*s++ = 0;
v = !strcmp(u, t);
}
else
v = 0;
}
break;
}
if (i)
v = !v;
while (isspace(*s))
s++;
if (e)
*e = s;
return v;
}
/*
* pop input stream
* return non-0 on EOF
*/
static int
popin(void)
{
int n;
{
return 1;
}
{
return 0;
}
{
}
{
return 0;
{
return 0;
}
}
{
}
{
}
return 0;
}
/*
* copy <type><name> into buf of size n
*/
static char*
{
register char* t = buf;
register char* e = t + n - 1;
*t++ = type;
{
while (t < e && (*t++ = *++name));
else
*t = 0;
}
return buf;
}
/*
* return number register pointer given name
* pointer created if not found
*/
static Num_t*
num(register char* s)
{
{
}
return np;
}
/*
* lookup or create (force!=0) io stream handle
*/
static Stream_t*
{
{
if (!force)
return 0;
}
return sp;
}
/*
* push output stream np
*/
static void
{
}
/*
* pop ouput stream
* if retain>0 then strdup() buffer
*/
static char*
popout(void)
{
char* s;
if (!DIVERTED())
return 0;
s = 0;
else
return s;
}
/*
* return next character with possible line join
*/
static int
nextchar(void)
{
int c;
int n;
for (;;)
{
{
if (popin())
break;
continue;
}
{
switch (n = GETC())
{
case EOF:
if (popin())
break;
goto escape;
case '\n':
error_info.line++;
continue;
case 't':
c = '\t';
break;
case '"':
for (;;)
{
switch (c = GETC())
{
case EOF:
if (popin())
break;
continue;
case '\n':
break;
default:
{
switch (n = GETC())
{
case EOF:
if (popin())
break;
goto escape_2;
case '\n':
error_info.line++;
continue;
default:
continue;
}
break;
}
continue;
}
break;
}
break;
default:
UNGETC(n);
break;
}
break;
}
break;
}
return c;
}
/*
* call a macro
*/
static void
{
}
/*
* set macro value
*/
static void
{
int n;
{
}
{
}
{
}
}
/*
* return macro pointer given name
* pointer created if not found
*/
static Tag_t*
{
{
}
return mp;
}
static Env_t*
env(char* s)
{
register Env_t* v;
char* e;
long n;
n = expression(s, &e, 0);
if (*e)
else
{
}
{
v->c2 = DEFAULT_c2;
v->cc = DEFAULT_cc;
v->nf = 0;
v->ss = 0;
}
return v;
}
/*
* open name for reading
* looking in state.dirs if needed
* verbose<0 for -m option
*/
static Sfio_t*
{
register char* s;
char* path;
char* t;
char* x;
int i;
static const char* pathdirs[] =
{
};
{
goto hit;
}
if (*name != '/')
{
{
goto hit;
}
{
if (verbose >= 0)
{
goto hit;
}
goto hit;
}
for (i = 0; i < elementsof(pathdirs); i++)
{
if (pathpath(path, "", PATH_REGULAR|PATH_READ, buf + 1, sizeof(buf) - 1) && (sp = sfopen(NiL, buf + 1, "r")))
{
goto hit;
}
}
}
if (verbose > 0)
{
/*
* some systems provide
* that references
* that is not provided
*/
if (*(s = name) == '/')
while (s = strchr(s, '/'))
{
t = s + strlen(s) - 1;
while (*s)
{
if (pathpath(path, "", PATH_REGULAR|PATH_READ, buf + 1, sizeof(buf) - 1) && (sp = sfopen(NiL, buf + 1, "r")))
{
goto hit;
}
if (*t != 't')
break;
*t-- = 0;
}
}
}
else if (verbose < 0)
return 0;
hit:
if (found)
while (s > path + 2)
if (*--s == '/')
{
if (!strcmp(s, "/lib"))
{
*s = 0;
break;
}
*s = 0;
}
return sp;
}
/*
* generate intermediate CODE_0
*/
static void
code_0(void)
{
}
/*
* generate intermediate CODE_1
*/
static void
{
}
/*
* generate intermediate CODE_2
*/
static void
{
}
/*
* generate intermediate CODE_n
*/
static void
{
int n;
if (n > 0177)
if (s)
else
}
/*
* join all args from n on into 1 arg
*/
static char*
{
return 0;
n++;
}
/*
* output error message line
*/
static void
notify(register char* s)
{
register int c;
Sfoff_t p;
for (;;)
{
switch (c = *s++)
{
case 0:
break;
case CODE_0:
continue;
case CODE_1:
s++;
continue;
case CODE_2:
c = *s++;
if (*s++ == OP_cc)
continue;
default:
continue;
}
break;
}
}
/*
* add trap s to xp
*/
static void
{
return;
if (pp)
else
}
/*
* trigger traps on xp
*/
static void
{
{
state.t = 1;
do
{
} while (ip);
*xp = 0;
}
}
/*
* return value for register name with type
*/
static char*
{
register char* b;
register char* x;
register long n;
register long m;
switch (type)
{
case 'g':
return "";
else
{
*b++ = '0';
*b++ = '1';
}
*b = 0;
case 'j':
return "";
case 'n':
break;
case '.':
return 0;
default:
return b;
}
if (!b)
{
return "0";
}
{
{
case INDEX('%',0):
break;
break;
GROFFINIT();
break;
n = 3000;
break;
n = 1;
break;
n = 1;
break;
n = 256;
break;
n = 6000;
break;
{
break;
}
/*FALLTHROUGH*/
break;
break;
break;
GROFFINIT();
break;
break;
n = 100;
break;
break;
n = state.n;
break;
n = 2;
else
break;
n = 0;
break;
else
break;
n = state.t;
break;
break;
n = 1;
else
break;
n = 0;
else
break;
n = 19980401;
break;
n = 1;
break;
break;
break;
break;
break;
default:
n = 0;
break;
}
}
if (i)
{
switch (i)
{
case '+':
break;
case '-':
break;
}
}
{
case '1':
break;
case 'A':
case 'a':
if (n < 0)
{
n = -n;
*b++ = '-';
}
for (m = 1; m > 0 && m < n; m *= 26);
if (m <= 0)
else
{
for (; m > 0; m /= 26)
{
i = n / m;
n -= m * i;
*b++ = x[i];
}
*b = 0;
}
break;
case 'I':
case 'i':
if (n <= -40000 || n >= 40000)
else if (!n)
else
{
if (n < 0)
{
n = -n;
*b++ = '-';
}
while (n >= 10000)
{
n -= 10000;
*b++ = x[0];
}
for (i = 1000; i > 0; i /= 10, x += 2)
{
m = n / i;
n -= m * i;
switch (m)
{
case 9:
*b++ = x[2];
*b++ = x[0];
break;
case 8:
*b++ = x[1];
*b++ = x[2];
*b++ = x[2];
*b++ = x[2];
break;
case 7:
*b++ = x[1];
*b++ = x[2];
*b++ = x[2];
break;
case 6:
*b++ = x[1];
*b++ = x[2];
break;
case 5:
*b++ = x[1];
break;
case 4:
*b++ = x[2];
*b++ = x[1];
break;
case 3:
*b++ = x[2];
/*FALLTHROUGH*/
case 2:
*b++ = x[2];
/*FALLTHROUGH*/
case 1:
*b++ = x[2];
break;
}
}
*b = 0;
}
break;
default:
break;
}
}
/*
* return the value for typed register
*/
static char*
{
register int c;
register char* b;
register char* x;
register char* t;
int i;
int k;
i = k = 0;
b = buf;
x = buf + 2;
do
{
switch (c = GETC())
{
case EOF:
if (popin())
return 0;
continue;
case '\n':
error_info.line++;
break;
case '(':
if (x == buf + 2)
{
x++;
continue;
}
break;
case '[':
{
k = 1;
continue;
}
break;
case ']':
if (k)
goto done;
break;
case '-':
case '+':
{
i = c;
continue;
}
break;
default:
{
switch (c = GETC())
{
case EOF:
if (popin())
return 0;
goto escape;
case '\n':
error_info.line++;
continue;
case '*':
c = '.';
/*FALLTHROUGH*/
case 'n':
if (t = interpolate(c))
while (b < x && (*b = *t++))
b++;
continue;
}
}
break;
}
*b++ = c;
} while (b < x);
done:
*b = 0;
}
/*
* switch to font s
*/
static void
ft(char* s)
{
int c;
if (!s || (c = *s) < '0' || c > '5')
c = 0;
else
c -= '0';
if (!c)
}
/*
* switch to point size n
*/
static void
ps(int n)
{
}
/*
* sync list state
*/
static void
{
{
return;
}
if (force)
{
{
message((-2, "DROP %d %d %d:%d %d:%d", state.list - state.list_stack, state.list->dl, state.list->ti, state.list->in, force ? state.env->ti.current : 0, state.env->in.current));
}
}
else
message((-2, "TEST %d %d %d:%d %d:%d ops=%d df=%d dc=%d dl=%d", state.list - state.list_stack, state.list->dl, state.list->ti, state.list->in, force ? state.env->ti.current : 0, state.env->in.current, state.list - list, force, state.it.dc, state.it.dl));
{
else
state.list->ti = state.env->in.current > state.list->in ? state.env->in.current : state.env->ti.current;
}
message((-2, "LIST %d %d %d:%d %d:%d ops=%d df=%d dc=%d dl=%d", state.list - state.list_stack, state.list->dl, state.list->ti, state.list->in, force ? state.env->ti.current : 0, state.env->in.current, state.list - list, force, state.it.dc, state.it.dl));
}
/*
* pop inline traps
*/
static void
it(void)
{
register List_t* p;
{
}
else if (!DIVERTED())
{
li(-1);
{
for (; p >= state.list_stack; p--)
if (!p->dl)
{
p->dl = 1;
break;
}
}
{
}
{
}
}
}
/*
* initialize number register
*/
static void
{
if (internal > 0)
}
/*
* set time vars to t
*/
static void
{
}
/*
* expand if expression s into op
*/
static void
{
int c;
int d;
int q;
int v;
int w;
int z;
char* t;
char* b;
for (;;)
{
switch (c = *s++)
{
case 0:
break;
case CODE_2:
c = *s++;
/*FALLTHROUGH*/
case CODE_1:
c = *s++;
/*FALLTHROUGH*/
case CODE_0:
continue;
default:
switch (w = c = *s++)
{
case 0:
s--;
break;
case 'A':
case 'C':
case 'L':
case 'N':
case 'R':
case 'V':
case 'X':
case 'Y':
case 'Z':
case 'b':
case 'h':
case 'l':
case 'o':
case 'w':
case 'x':
v = 0;
c = *s++;
if (c == '(')
z = 2;
else
{
z = -1;
c = ']';
}
b = s;
for (;;)
{
switch (d = *s++)
{
case 0:
s--;
break;
case CODE_2:
s++;
/*FALLTHROUGH*/
case CODE_1:
if (*s++ == OP_cc)
v++;
/*FALLTHROUGH*/
case CODE_0:
continue;
default:
{
switch (d = *s++)
{
case 0:
s--;
break;
case 'A':
case 'C':
case 'L':
case 'N':
case 'R':
case 'V':
case 'X':
case 'Y':
case 'Z':
case 'b':
case 'h':
case 'l':
case 'o':
case 'w':
case 'x':
q = *s++;
for (;;)
{
switch (d = *s++)
{
case 0:
s--;
break;
case CODE_2:
s++;
/*FALLTHROUGH*/
case CODE_1:
s++;
/*FALLTHROUGH*/
case CODE_0:
continue;
default:
if (d == q)
break;
continue;
}
break;
}
v++;
break;
case 'f':
case 's':
if (*s)
s++;
break;
case 'g':
case 'j':
t = buf;
*t++ = 'n';
if ((*t++ = *s++) == '(')
{
*(t - 1) = *s++;
*t++ = *s++;
}
*t = 0;
v += strlen(t);
break;
}
}
else if (z > 0)
z--;
else if (d == c || z == 0)
break;
v++;
continue;
}
break;
}
switch (w)
{
case 'A':
break;
case 'R':
case 'X':
case 'V':
c = *(s - 1);
*(s - 1) = 0;
switch (w)
{
case 'R':
/*HERE*/
break;
case 'V':
if (t = getenv(b))
break;
case 'X':
/*HERE*/
break;
}
*(s - 1) = c;
break;
case 'w':
break;
}
break;
case 'g':
case 'j':
t = buf;
*t++ = 'n';
if ((*t++ = *s++) == '(')
{
*(t - 1) = *s++;
*t++ = *s++;
}
*t = 0;
break;
default:
break;
}
else
continue;
}
break;
}
}
/*
*/
static void
rm(char* s)
{
{
}
{
}
}
/*
* skip one conditional block
* if op!=0 then copy block data to s
*/
static void
{
register int c;
register int n;
n = (f & COND_BLOCK) != 0;
if (s)
else if (!n)
return;
for (;;)
{
switch (c = GETC())
{
case EOF:
if (s && n <= 0)
break;
if (popin())
break;
continue;
case CODE_2:
if (op)
c = GETC();
/*FALLTHROUGH*/
case CODE_1:
if (op)
c = GETC();
/*FALLTHROUGH*/
case CODE_0:
if (op)
continue;
case '\n':
if (op)
error_info.line++;
if (n <= 0)
break;
continue;
default:
if (op)
{
switch (c = GETC())
{
case EOF:
if (popin())
break;
goto escape;
case '\n':
if (op)
error_info.line++;
continue;
case '{':
if (op)
n++;
continue;
case '}':
if (op)
if (--n <= 0)
{
switch (c = nextchar())
{
case '\n':
if (op)
error_info.line++;
break;
default:
UNGETC(c);
break;
}
break;
}
continue;
default:
if (op)
continue;
}
break;
}
continue;
}
break;
}
}
/*
* internal groff requests
*/
static void
{
else
}
static void
{
else
}
static void
{
static int warned;
if (!warned++)
}
static void
{
{
return;
}
}
static void
{
register char* s;
{
*(s + strlen(s) - 1) = 0;
}
}
static void
{
{
return;
}
{
return;
}
}
static void
{
{
return;
}
}
static void
{
else
}
static void
{
char* path;
char* mode;
{
return;
}
{
{
}
}
}
static void
{
char* s;
{
else
}
}
static void
{
char* s;
{
rm(s);
*--s = 'n';
}
}
static void
{
register int n;
register int i;
{
i = 0;
}
}
static void
{
char* s;
}
static void
{
register char* s;
register char* t;
{
t = s + strlen(s);
while (t > s && isspace(*--t));
}
}
static void
{
char* s;
{
return;
}
{
return;
}
s = "";
if (*s == '"')
s++;
}
/*
* internal troff requests
*/
static void
{
char* s;
s = "User abort";
notify(s);
exit(1);
}
static void
{
{
case 'b':
case 'B':
case 'n':
case 'N':
break;
case 'c':
case 'C':
break;
case 'l':
case 'L':
break;
case 'r':
case 'R':
break;
}
}
static void
{
char* s;
{
{
case '0':
break;
case 'a':
case 'A':
case 'i':
case 'I':
break;
case '1':
default:
break;
}
}
}
static void
{
{
}
}
static void
{
}
static void
{
}
static void
{
int n;
int r;
if (n >= 1)
{
{
}
{
if (r)
else
}
}
else
{
n = 0;
r = 0;
}
}
static void
{
{
}
}
static void
{
char* s;
{
}
{
}
}
static void
{
{
}
}
static void
{
int n;
{
{
}
}
else
{
}
}
static void
{
char* v;
}
static void
{
}
static void
{
{
}
}
static void
{
{
else
}
else
{
}
}
static void
{
int i;
}
static void
{
{
}
}
static void
{
char* s;
char* t;
{
*--s = 'f';
*--t = 'f';
}
}
static void
{
char* s;
{
*--s = 'f';
}
else s = 0;
ft(s);
}
static void
{
int f;
int q;
long v;
char* s;
char* t;
char* e;
{
{
}
f = COND_EL;
}
else
{
}
{
error(-5, "IE +++ %s level=%d |%s%s%s%s%s", tp->name, state.cond.level, (g & COND_IF) ? "IF|" : "", (g & COND_IE) ? "IE|" : "", (g & COND_BLOCK) ? "BLOCK|" : "", (g & COND_SKIP) ? "SKIP|" : "", (g & COND_KEPT) ? "KEPT|" : "");
}
{
{
t = s;
if (*++t != '{' && *t != '}')
break;
if (t)
{
}
}
for (;;)
{
if (f & COND_EL)
else
{
v = cond(s, &e);
s = e;
}
break;
q = f;
if (s[2] == 'e')
else if (s[2] == 'f')
else
break;
if (q & COND_EL)
}
{
s += 2;
f |= COND_BLOCK;
}
while (isspace(*s))
s++;
if (!*s)
s = 0;
else
*(s + strlen(s)) = '\n';
}
if (!v)
{
f |= COND_SKIP;
}
else
{
if (s)
{
error_info.line--;
}
f |= COND_KEPT;
}
if (f & COND_EL)
{
else
}
{
error(-5, "IE --- %s level=%d |%s%s%s%s%s", tp->name, state.cond.level, (g & COND_IF) ? "IF|" : "", (g & COND_IE) ? "IE|" : "", (g & COND_BLOCK) ? "BLOCK|" : "", (g & COND_SKIP) ? "SKIP|" : "", (g & COND_KEPT) ? "KEPT|" : "");
}
}
static void
{
char* s;
{
state.end = (s = (char*)hashget(state.symbols, tp->name)) ? (Tag_t*)hashget(state.symbols, s) : (Tag_t*)0;
{
}
}
}
static void
{
int n;
else
{
{
case '-':
case '+':
break;
}
}
li(0);
}
static void
{
char* s;
char* t;
{
*t++ = '.';
*t++ = *s++;
if (*s)
{
*t++ = *s;
t++;
}
*t++ = '\n';
*t = 0;
}
}
static void
{
int n;
else
{
{
case '-':
case '+':
break;
}
}
li(0);
}
static void
{
}
static void
{
{
it();
li(-1);
}
}
static void
{
int i;
long n;
char* s;
{
s++;
n = expression(s, NiL, 0);
switch (i)
{
case '-':
break;
case '+':
break;
}
{
else
error_info.line = n;
break;
break;
break;
break;
break;
}
}
}
static void
{
}
static void
{
int n;
else
{
{
case '-':
case '+':
break;
default:
if (!n)
break;
}
}
if (n > 0)
ps(n);
}
static void
{
int i;
}
static void
{
char* s;
{
rm(s);
*--s = '.';
}
}
static void
{
{
return;
}
}
static void
{
int i;
}
static void
{
char* path;
}
static void
{
{
}
}
static void
{
int i;
{
i = 1;
}
else
{
}
ta[i] = 0;
}
static void
{
int n;
else
{
{
case '-':
case '+':
break;
}
}
li(1);
}
static void
{
register int c;
register int q;
register char* s;
register char* t;
int n;
{
else
{
}
if (q = *s++)
for (n = 1; n <= 3; n++)
{
code_2(OP_tab_head, n);
if (n == 1)
while ((c = *s++) != q)
{
if (!c)
{
s--;
break;
}
}
if (n == 1)
}
}
}
static void
{
char* s;
notify(s);
}
static void
{
int n;
else
{
{
case '-':
case '+':
break;
default:
if (!n)
break;
}
}
if (n > 0)
{
}
}
/*
* return 1 if any non-diverted text escaped
*/
static int
text(void)
{
register char* s;
register char* e;
return 1;
while (s < e)
{
switch (*s++)
{
case CODE_2:
s++;
/*FALLTHROUGH*/
case CODE_1:
s++;
/*FALLTHROUGH*/
case ' ':
case '\t':
case '\n':
case CODE_0:
continue;
default:
return 1;
}
}
return 0;
}
static void
{
int i;
{
{
i = -1;
}
}
}
static void
{
register Dir_t* x;
register Dir_t* p;
{
if (!add)
{
if (p)
else
free(x);
}
return;
}
if (add)
{
}
}
typedef struct
{
const char* name;
char** value;
int index;
} Option_t;
{
"begin", 0, OPT_begin,
"debug", 0, OPT_debug,
"end", 0, OPT_end,
"footnote", 0, OPT_footnote,
"get", 0, OPT_get,
"hot", 0, OPT_hot,
"label", 0, OPT_label,
"link", 0, OPT_link,
"set", 0, OPT_set,
"test", 0, OPT_test,
0, 0, 0
};
/*
* called by stropt() to set name=value
*/
static int
setopt(void* a, const void* x, register int n, const char* v)
{
register char* s;
register char* t;
register int f;
if (p)
switch (p->index)
{
case OPT_begin:
break;
case OPT_debug:
break;
case OPT_end:
break;
case OPT_footnote:
else
{
/*
* NOTE: mm .FS/.FE is so convoluted that I
* punted to this; trying to decipher
* it prompted .xx [debug|get|set] in
* the first place; I'll get back to a
* real solution on a meetingless day.
*/
if (n)
{
register char* b;
long m;
s = b + m;
while (s > b)
if (!isspace(*--s))
{
s++;
break;
}
t = s;
while (s > b)
if (isspace(*--s))
{
s++;
break;
}
}
else
}
break;
case OPT_get:
case OPT_hot:
case OPT_set:
switch (p->index)
{
case OPT_get:
f = TAG_TRACE_GET;
break;
case OPT_hot:
f = 0;
break;
case OPT_set:
f = TAG_TRACE_SET;
break;
}
s = (char*)v;
do
{
while (isspace(*s))
s++;
for (t = s;; t++)
if (!*t)
{
t = 0;
break;
}
else if (isspace(*t))
{
*t++ = 0;
break;
}
if (!s[0])
break;
if (s[0] == '+' && !s[1])
n = 1;
else if (s[0] == '-' && !s[1])
n = 0;
else if (!f)
hot(s, n);
else if (n)
{
}
else
{
}
} while (s = t);
break;
case OPT_label:
else if (n)
{
}
break;
case OPT_link:
else if (n)
break;
case OPT_test:
if (n)
else
break;
case OPT_SWITCH:
break;
default:
if (*p->value)
break;
}
else if (a)
{
{
}
else
}
return 0;
}
static void
{
}
#define ONE() \
do \
{\
if (cc <= 0) \
{ \
if (cc < 0) \
cc++; \
it(); \
} \
cc++; \
} while (0)
/*
* convert troff file ip to intermediate file op
*/
static void
{
register int c;
register int cc;
register int lastc;
register char* s;
int argc;
int quote;
int n;
int m;
unsigned char* map;
state.generation++;
argc = 0;
argv[0] = 0;
cc = 0;
lastc = 0;
quote = 0;
for (;;)
{
switch (c = GETC())
{
case EOF:
if (popin())
goto done;
continue;
case CODE_n:
if (ISFILE())
{
cc++;
}
else
{
n = GETC();
if (n & 0200)
{
n = (n & 0177) << 8;
c = GETC();
n |= c;
}
do
{
c = GETC();
} while (n-- > 0);
}
continue;
case CODE_2:
if (ISFILE())
{
cc++;
}
else
{
m = GETC();
n = GETC();
ONE();
}
continue;
case CODE_1:
if (ISFILE())
{
cc++;
}
else
{
switch (c = GETC())
{
case OP_br:
case OP_p:
cc = 0;
break;
}
}
continue;
case CODE_0:
if (ISFILE())
{
cc++;
}
else
{
ONE();
}
continue;
case '"':
{
lastc = c;
{
case '"':
break;
default:
UNGETC(c);
/*FALLTHROUGH*/
case EOF:
continue;
}
}
break;
case '\n':
{
continue;
c = ' ';
break;
}
{
{
c = ' ';
}
popout();
}
if (argc)
{
cc = 0;
lastc = c;
quote = 0;
if (!(s = popout()))
{
argc = 0;
continue;
}
argc--;
argc = 0;
{
if (!tp)
}
if (tp)
{
error_info.line++;
{
}
}
{
{
case 0:
break;
case '#':
break;
/*FALLTHROUGH*/
default:
if (error_info.trace >= 0)
break;
}
error_info.line++;
}
continue;
}
error_info.line++;
if (!DIVERTED())
{
else
{
cc = 0;
continue;
}
}
{
else
}
{
cc = 0;
continue;
}
cc = -2;
break;
case ' ':
case '\t':
if (argc)
{
{
{
lastc = ' ';
}
continue;
}
}
break;
default:
{
switch (c = GETC())
{
case EOF:
if (popin())
{
c = '\n';
break;
}
goto escape;
case '\n':
if (ISFILE())
error_info.line++;
else
UNGETC(c);
continue;
case 'a':
goto passthrough;
c = 1;
break;
case 'c':
goto passthrough;
if ((c = nextchar()) == '\n')
{
message((-9, "INTERRUPT %s:%d: it.center=%d it.count=%d it.dt", error_info.file, error_info.line, state.it.center, state.it.count));
error_info.line++;
cc = 0;
continue;
}
UNGETC(c);
continue;
case 'd':
{
}
else
{
}
continue;
case 'e':
case 'E':
goto passthrough;
ONE();
continue;
case 'f':
goto passthrough;
continue;
case 'g':
case 'j':
goto passthrough;
continue;
case 'k':
nextchar();
continue;
case '*':
c = '.';
goto interp;
case '[':
goto passthrough;
case '(':
goto passthrough;
UNGETC(c);
/*FALLTHROUGH*/
case 'n':
goto passthrough;
if (s = interpolate(c))
continue;
case 'p':
case 'r':
case 'z':
continue;
case 's':
goto passthrough;
switch (c = nextchar())
{
case '-':
case '+':
m = c;
c = nextchar();
break;
default:
m = 0;
break;
}
switch (c)
{
case '(':
n = 1;
break;
case '\'':
n = c;
goto size_long;
case '[':
n = ']';
c = nextchar();
if (!m)
switch (c)
{
case '-':
case '+':
m = c;
c = nextchar();
break;
}
while (c != EOF && c != n)
{
c = nextchar();
}
goto size_eval;
default:
n = 0;
break;
}
if (c == '0' && m)
{
if ((n = nextchar()) == '\'')
{
continue;
}
UNGETC(n);
n = 0;
}
if (c != EOF)
{
if (n)
{
for (;; c = nextchar())
{
switch (c)
{
case EOF:
break;
case '(':
n++;
continue;
case ')':
if (--n <= 0)
break;
continue;
default:
continue;
}
break;
}
}
else
n = isdigit(c) ? (c - '0') : 0;
if (!n)
else switch (m)
{
case '-':
break;
case '+':
break;
}
if (n > 0)
ps(n);
}
continue;
case 't':
goto passthrough;
c = '\t';
break;
case 'u':
{
}
else
{
}
continue;
case 'v':
case 'w':
goto passthrough;
/*FALLTHROUGH*/
case 'b':
case 'h':
case 'l':
case 'L':
case 'o':
case 'x':
{
while ((m = nextchar()) != n)
switch (c)
{
case 'h':
if (*s++ == '0')
{
/*UNDENT...*/
if ((c = *s++) == '*' || c == '/')
{
if (*s++ == '\\' && *s++ == 'w' && *s++ == '"')
{
if ((c = strlen(s)) > 0 && s[--c] == '"')
s[c] = 0;
}
}
{
}
/*...INDENT*/
}
/* yep, this is a grade A hack, even for this file */
{
if ((n = nextchar()) == 'c')
break;
UNGETC(n);
}
UNGETC(c);
break;
case 'v':
break;
case 'w':
break;
}
}
continue;
case '$':
{
c = nextchar();
if (c == '(')
{
{
}
goto arg_eval;
}
else if (c == '[')
{
}
else if (c == '@')
{
}
else if (c < '0' || c > '9')
{
}
}
continue;
case '{':
for (;;)
{
{
if (popin())
break;
continue;
}
{
switch (m = GETC())
{
case EOF:
if (popin())
break;
goto escape_splice;
case '\n':
UNGETC(m);
break;
default:
UNGETC(m);
UNGETC(n);
break;
}
break;
}
else
UNGETC(n);
break;
}
goto passthrough;
continue;
case '}':
goto passthrough;
else
continue;
case '0':
case '|':
case '^':
case ' ':
case '/':
case ',':
case '~':
goto passthrough;
ONE();
continue;
case '&':
goto passthrough;
if (!cc)
cc = -1;
code_0();
continue;
case '-':
case '%':
goto passthrough;
ONE();
continue;
case '"':
if (!quote)
{
}
cc++;
continue;
case '#':
if (!quote)
{
}
cc++;
continue;
case '!':
if (!cc)
{
cc++;
continue;
}
break;
default:
break;
goto request;
goto passthrough;
break;
}
break;
ONE();
break;
}
{
n = c;
s = buf;
*s++ = '.';
{
while (c == ' ' || c == '\t')
c = nextchar();
UNGETC(c);
else if (c != EOF)
{
*s++ = c;
{
{
UNGETC(c);
break;
}
*s++ = c;
{
{
UNGETC(c);
if (!isspace(c))
}
break;
}
}
}
}
*s = 0;
{
c = n;
goto request;
}
{
{
s = popout();
{
state.define = 0;
}
}
else
{
c = n;
}
break;
}
if (tp)
{
{
{
message((-9, "BREAK %s:%d: it.center=%d it.count=%d", error_info.file, error_info.line, state.it.center, state.it.count));
ONE();
}
}
}
else
argc = 1;
continue;
}
{
ONE();
continue;
}
break;
}
ONE();
lastc = c;
}
done:
{
if (state.define)
{
state.define = 0;
}
else
}
while (DIVERTED())
popout();
}
{
".", 0, 0, 0,0,0,0,
".'", 0, 0, 0,0,0,0,
".''", 0, 0, 0,0,0,0,
"..", 0, 0, 0,0,0,0,
".EN", 0, 0, 0,0,0,0,
".EQ", troff_ignore, 0, 0,0,0,0,
".TE", 0, 0, 0,0,0,0,
".TS", troff_ignore, 0, 0,0,0,0,
".\"", 0, 0, 0,0,0,0,
".\\\"",0, 0, 0,0,0,0,
".ab", troff_ab, 0, 0,0,0,0,
".af", troff_af, 0, 0,0,0,0,
".al", 0, 0, 0,0,0,0,
".aln", groff_aln, 0, 0,0,0,0,
".als", groff_als, 0, 0,0,0,0,
".asciify", groff_asciify, 0, 0,0,0,0,
".backtrace", 0, 0, 0,0,0,0,
".bd", 0, 0, 0,0,0,0,
".blm", 0, 0, 0,0,0,0,
".bp", 0, TAG_BREAK, 0,0,0,0,
".break", groff_break, 0, 0,0,0,0,
".c2", troff_c2, 0, 0,0,0,0,
".cc", troff_cc, 0, 0,0,0,0,
".cf", troff_cf, 0, 0,0,0,0,
".cflags", 0, 0, 0,0,0,0,
".ch", troff_ch, 0, 0,0,0,0,
".char", 0, 0, 0,0,0,0,
".chop", groff_chop, 0, 0,0,0,0,
".close", groff_close, 0, 0,0,0,0,
".continue", groff_continue, 0, 0,0,0,0,
".cp", groff_cp, 0, 0,0,0,0,
".cs", 0, 0, 0,0,0,0,
".cu", 0, 0, 0,0,0,0,
".do", 0, TAG_DO, 0,0,0,0,
".ec", troff_ec, 0, 0,0,0,0,
".eo", troff_eo, 0, 0,0,0,0,
".fam", 0, 0, 0,0,0,0,
".fc", 0, 0, 0,0,0,0,
".fl", 0, TAG_BREAK, 0,0,0,0,
".fp", troff_fp, 0, 0,0,0,0,
".fspecial", 0, 0, 0,0,0,0,
".ft", troff_ft, 0, 0,0,0,0,
".ftr", 0, 0, 0,0,0,0,
".hcode", 0, 0, 0,0,0,0,
".hla", 0, 0, 0,0,0,0,
".hlm", 0, 0, 0,0,0,0,
".hpf", 0, 0, 0,0,0,0,
".hw", 0, 0, 0,0,0,0,
".hy", 0, 0, 0,0,0,0,
".hym", 0, 0, 0,0,0,0,
".hys", 0, 0, 0,0,0,0,
".it", troff_it, 0, 0,0,0,0,
".kern", 0, 0, 0,0,0,0,
".lc", 0, 0, 0,0,0,0,
".lf", 0, 0, 0,0,0,0,
".ll", troff_ll, 0, 0,0,0,0,
".ls", 0, 0, 0,0,0,0,
".lt", 0, 0, 0,0,0,0,
".mk", 0, 0, 0,0,0,0,
".mso", troff_so, 0, 0,0,0,0,
".na", 0, 0, 0,0,0,0,
".ne", troff_ne, 0, 0,0,0,0,
".nh", 0, 0, 0,0,0,0,
".nm", 0, 0, 0,0,0,0,
".nn", 0, 0, 0,0,0,0,
".nr", troff_nr, 0, 0,0,0,0,
".nroff", 0, 0, 0,0,0,0,
".ns", 0, 0, 0,0,0,0,
".open", groff_open, 0, 0,0,0,0,
".opena", groff_open, 0, 0,0,0,0,
".os", 0, 0, 0,0,0,0,
".pc", troff_pc, 0, 0,0,0,0,
".pl", 0, 0, 0,0,0,0,
".pm", 0, 0, 0,0,0,0,
".pn", 0, 0, 0,0,0,0,
".pnr", 0, 0, 0,0,0,0,
".po", 0, 0, 0,0,0,0,
".ps", troff_ps, 0, 0,0,0,0,
".pso", groff_pso, 0, 0,0,0,0,
".ptr", 0, 0, 0,0,0,0,
".rchar", 0, 0, 0,0,0,0,
".rj", troff_ce, 0, 0,0,0,0,
".rm", troff_rm, 0, 0,0,0,0,
".rn", troff_rn, 0, 0,0,0,0,
".rnn", groff_rnn, 0, 0,0,0,0,
".rr", troff_rr, 0, 0,0,0,0,
".rs", 0, 0, 0,0,0,0,
".rt", 0, 0, 0,0,0,0,
".shc", 0, 0, 0,0,0,0,
".shift", groff_shift, 0, 0,0,0,0,
".so", troff_so, 0, 0,0,0,0,
".special", 0, 0, 0,0,0,0,
".ss", 0, 0, 0,0,0,0,
".sty", 0, 0, 0,0,0,0,
".sv", 0, 0, 0,0,0,0,
".sy", groff_sy, 0, 0,0,0,0,
".tc", 0, 0, 0,0,0,0,
".tkf", 0, 0, 0,0,0,0,
".tl", troff_tl, 0, 0,0,0,0,
".tm", troff_tm, 0, 0,0,0,0,
".tr", 0, 0, 0,0,0,0,
".trf", 0, 0, 0,0,0,0,
".trnt", 0, 0, 0,0,0,0,
".troff", 0, 0, 0,0,0,0,
".uf", 0, 0, 0,0,0,0,
".ul", 0, 0, 0,0,0,0,
".vpt", 0, 0, 0,0,0,0,
".vs", troff_vs, 0, 0,0,0,0,
".warn", 0, 0, 0,0,0,0,
".write", groff_write, 0, 0,0,0,0,
};
{
"(**", "*",
"(+-", "\261",
"(ap", "~",
"(bu", "\267",
"(bv", "|",
"(co", "\251",
"(dg", "\247",
"(fm", "'",
"(lq", "``",
"(rg", "\256",
"(rq", "''",
"(sq", "\244",
"eEQ", ".EN",
"eTS", ".TE",
"eig", "..",
"f", "",
"f1", "1",
"f2", "2",
"f3", "3",
"f5", "5",
"fB", "3",
"fCW", "5",
"fF", "5",
"fI", "2",
"fL", "5",
"fM", "5",
"fR", "1",
"fX", "5",
};
{
0, ".",
};
/*
* initialize the global data
*/
static void
init(void)
{
register int i;
for (i = 0; i < elementsof(vars); i++)
for (i = 0; i < elementsof(tags); i++)
{
}
nr("systat", 0, 0, 0);
state.t = 1;
}
/*
* convert intermediate code in s to html on op
*/
static const char* opt_align[] =
{
"LEFT", "CENTER", "RIGHT",
};
static const char* opt_attribute[] =
{
"BACKGROUND", "HREF", "HREF", "ID", "NAME", "SIZE", "SRC",
};
static const char* tag_name[] =
{
0, /* unknown */
"A", /* OP_a */
"BODY", /* OP_body */
"BR", /* OP_br */
0, /* OP_cc */
"CENTER", /* OP_center */
0, /* OP_comment */
"DD", /* OP_dd */
"DIV", /* OP_div */
"DL", /* OP_dl */
"DT", /* OP_dt */
"FN", /* OP_fn */
0, /* OP_ft1 */
"EM", /* OP_ft2 */
"STRONG", /* OP_ft3 */
0, /* OP_ft4 */
"TT", /* OP_ft5 */
"H2", /* OP_h2 */
"H3", /* OP_h3 */
"H4", /* OP_h4 */
"HEAD", /* OP_head */
"HR", /* OP_hr */
"HTML", /* OP_html */
0, /* OP_link */
"P", /* OP_p */
"PRE", /* OP_pre */
"FONT", /* OP_ps */
"SUB", /* OP_sub */
"SUP", /* OP_sup */
"TABLE", /* OP_tab */
"TD", /* OP_tab_data */
"TH", /* OP_tab_head */
"TR", /* OP_tab_row */
"TITLE", /* OP_title */
};
/*
* emit tag and optionally check stack
*/
static void
{
register int n;
register int m;
register unsigned char* sp;
{
m = 1;
for (;;)
{
{
sfprintf(sfstderr, "\t<%s%s%s>\n", (*sp & OP_END) ? "/" : "", tag_name[OP(*sp)], (*sp & OP_LABEL) ? " label=1" : "");
return;
}
n = *--sp;
if (!(n & OP_END))
{
{
m = 0;
break;
}
{
}
*sp = n;
}
if (n == index)
{
break;
}
m = 0;
}
if (m)
{
}
}
else
{
{
}
{
{
if (att & ATT_NUMBER)
{
{
if (att_num < 0)
{
}
else
}
}
else
}
{
if (flags & ARG_compact)
}
{
if (state.background)
}
}
}
}
/*
* if OP_dl follows OP_ft,OP_ps then do it now
*/
static void
{
for (;;)
{
switch (*s++)
{
case 0:
break;
case CODE_0:
continue;
case CODE_2:
s++;
/*FALLTHROUGH*/
case CODE_1:
switch (*s++)
{
case OP_ft1:
case OP_ft2:
case OP_ft3:
case OP_ft4:
case OP_ft5:
case OP_ps:
continue;
case OP_dl:
*--s = CODE_0;
*--s = CODE_0;
continue;
}
break;
case ' ':
case '\t':
case '\n':
continue;
default:
break;
}
break;
}
}
#define P() \
#define DATA() \
do \
{ \
if (li) \
{ \
if (li == 1) \
li = 0; \
P(); \
} \
else if (p) \
{ \
P(); \
} \
else if (br) \
{ \
P(); \
} \
} while (0)
static void
{
register int c;
register int br = 0;
register int col = 0;
register int li = 0;
register int p = 0;
register int nf = 0;
register unsigned char* v;
unsigned char* t;
unsigned char* u;
int n;
int m;
int ta;
int ts;
int hot = 0;
int label = 0;
int ps_set = 0;
Dir_t* x;
char a[2];
else
{
{
t++;
else
}
}
{
}
for (;;)
{
switch (*s++)
{
case 0:
break;
case '&':
DATA();
col++;
continue;
case '<':
DATA();
col++;
continue;
case '>':
DATA();
col++;
continue;
case CODE_0:
continue;
case CODE_2:
c = *s++;
/*FALLTHROUGH*/
case CODE_1:
if (!nf)
{
n = *s ^ OP_END;
for (v = s + 1;;)
{
switch (*v++)
{
case '\n':
case ' ':
case '\t':
continue;
case CODE_0:
continue;
case CODE_1:
if ((m = *v++) == n)
{
n = 0;
s = v;
break;
}
break;
continue;
case CODE_2:
if (*v++ != ' ' || *v++ != OP_cc)
break;
continue;
default:
break;
}
break;
}
if (!n)
continue;
}
switch (m = *s++)
{
*--s = a[1];
*--s = a[0];
break;
case OP_body:
col = 0;
goto compact;
case OP_br:
while (*s == ' ')
s++;
if (!li)
{
if (nf)
goto compact;
else
br++;
}
break;
case OP_cc:
DATA();
switch (c)
{
case '&':
break;
case '<':
break;
case '>':
break;
case ' ':
break;
default:
break;
}
col++;
break;
case OP_center:
if (col)
{
col = 0;
}
{
for (;;)
{
switch (n = *s++)
{
case 0:
case '\n':
case CODE_1:
case CODE_2:
case CODE_n:
s--;
break;
default:
continue;
}
break;
}
}
break;
col = 0;
{
}
break;
/*FALLTHROUGH*/
case OP_dd:
li = 1;
if (col)
{
col = 0;
}
break;
case OP_div:
if (col)
{
col = 0;
}
break;
col = 0;
break;
case OP_dl:
li = 0;
if (col)
{
col = 0;
}
break;
v = s;
for (;;)
{
switch (*v++)
{
case CODE_0:
continue;
case CODE_1:
switch (*v++)
{
case OP_dl:
v = 0;
break;
default:
continue;
}
break;
case CODE_2:
v += 2;
continue;
default:
break;
}
break;
}
if (v)
{
li = 0;
col = 0;
}
break;
label = 1;
n = 1;
/*FALLTHROUGH*/
case OP_dt:
if (col)
{
col = 0;
}
if (p)
{
P();
}
v = s;
for (;;)
{
switch (*v++)
{
case CODE_0:
continue;
case CODE_2:
v++;
/*FALLTHROUGH*/
case CODE_1:
switch (*v++)
{
case OP_dl:
if (!label)
break;
continue;
case OP_dd:
if (label)
break;
default:
continue;
}
break;
case ' ':
case '\t':
case '\n':
if (!label)
break;
if (!n)
{
n = 1;
}
continue;
case '"':
if (!label)
break;
continue;
default:
if (!label)
break;
n = 0;
continue;
}
break;
}
li = 2;
if (label)
{
label = 0;
while (--n > 0 && (isspace(v[n]) || v[n] == '.'));
v[n + 1] = 0;
if (isdigit(*v))
}
break;
break;
case OP_ft1:
case OP_ft2:
case OP_ft3:
case OP_ft4:
case OP_ft5:
if (hot)
{
int ob = 0;
int cb = 0;
int p = 0;
int r = ATT_lref;
int z = 0;
v = s;
for (;;)
{
switch (n = *v++)
{
case 0:
hot = 0;
break;
case CODE_0:
continue;
case CODE_2:
v++;
/*FALLTHROUGH*/
case CODE_1:
n = *v++;
p = -1;
continue;
case '(':
case '[':
case '{':
case '<':
if (n == ob)
p++;
else if (p <= 0)
{
r = ATT_href;
p = 1;
switch (ob = n)
{
case '(':
cb = ')';
break;
case '[':
cb = ']';
break;
case '{':
cb = '}';
break;
case '<':
cb = '>';
break;
}
}
z = 0;
continue;
case ')':
case ']':
case '}':
case '>':
if (p <= 0)
{
v--;
break;
}
z = 0;
if (n == cb && !--p)
break;
continue;
case ' ':
case '\t':
case '\n':
if (!z)
{
z = 1;
}
continue;
case '"':
continue;
default:
if (p < 0)
{
v--;
break;
}
z = 0;
continue;
}
break;
}
hot = 0;
if (hot)
{
hot = 0;
while (--n > 0 && (isspace(t[n]) || t[n] == '.'));
t[n + 1] = 0;
a[0] = v[0];
v[0] = CODE_1;
a[1] = v[1];
}
}
c = m - OP_ft;
if (c != ft)
{
if (ft != 1)
ft = c;
if (ft != 1)
}
break;
case OP_h2:
case OP_h3:
case OP_h4:
break;
case OP_head:
col = 0;
goto compact;
case OP_hr:
col = 0;
goto compact;
case OP_p:
while (*s == ' ')
s++;
if (c)
{
if (col)
{
col = 0;
}
P();
}
else if (!li)
{
if (nf)
goto compact;
else
p++;
}
break;
col = 0;
break;
case OP_pre:
if (!nf)
{
nf = 03;
}
goto compact;
if (nf)
{
nf = 02;
}
goto compact;
case OP_ps:
if (c != ps)
{
if (ps_set)
{
ps_set = 0;
}
if (n = c - ps)
{
ps = c;
}
}
break;
case OP_sub:
case OP_sup:
break;
case OP_tab:
if (col)
{
col = 0;
}
goto compact;
break;
case OP_tab_data:
case OP_tab_head:
case OP_tab_row:
break;
default:
{
}
error(2, "internal error: <%s%s%s %d> ignored", (m & OP_END) ? "/" : "", v, (m & OP_LABEL) ? " label=" : "", c);
break;
if (col)
P();
v = s;
for (;;)
{
switch (*s++)
{
case 0:
break;
case '\n':
p++;
col = 0;
v = s;
continue;
case ' ':
case '\t':
if (!nf)
break;
col = 1;
continue;
case CODE_0:
continue;
case CODE_1:
switch (*s)
{
case OP_pre:
if (!nf)
break;
/*FALLTHROUGH*/
case OP_br:
case OP_p:
s++;
p++;
col = 0;
v = s;
continue;
case OP_body:
p = 0;
col = 0;
break;
}
break;
}
if (col)
{
col = 0;
s = v;
}
else
s--;
break;
}
if (nf > 1)
nf &= 01;
else if (nf && p)
p = 0;
break;
}
c = 0;
continue;
case CODE_n:
n = *s++;
if (n & 0200)
{
n = (n & 0177) << 8;
n |= *s++;
}
c = *s++;
v = s;
s += n;
switch (c)
{
case OP_comment:
if (col)
{
col = 0;
}
break;
case OP_fn:
break;
case OP_link:
DATA();
if (u = (unsigned char*)strchr((char*)v, '\t'))
*u++ = 0;
else
u = 0;
t = v;
while (isdigit(*v))
v++;
while (isalpha(*v))
v++;
if (*v == ':' || *v == '/' || *v == '.' || *(v + 1) == '/')
{
if (!u)
u = v + 1;
v = (unsigned char*)"";
}
else
{
if (!u)
u = t;
v = (unsigned char*)"#";
}
break;
DATA();
if (u = (unsigned char*)strchr((char*)v, '\t'))
*u++ = 0;
else
u = v;
break;
case OP_ta:
break;
case OP_RAW:
DATA();
if (col)
{
col = 0;
}
break;
}
continue;
case ' ':
if (nf)
{
col++;
}
else
{
while (isspace(*s))
s++;
if (col >= 70)
{
col = 0;
}
else if (col > 0)
{
col++;
}
}
continue;
case '\t':
if (nf)
{
{
ts++;
}
do
{
}
else
{
col++;
}
continue;
case '\n':
if (nf)
{
v = s;
col = 0;
for (;;)
{
switch (*v++)
{
case 0:
break;
case '\n':
continue;
case ' ':
case '\t':
continue;
case CODE_0:
continue;
case CODE_1:
switch (*v++)
{
case OP_br:
case OP_p:
case OP_pre:
continue;
col = 1;
s = v - 2;
break;
}
break;
}
break;
}
if (col)
{
col = 0;
continue;
}
}
else
{
while (isspace(*s))
s++;
if (col >= 70)
{
col = 0;
}
else if (col > 0)
{
col++;
}
}
continue;
case '(':
if (hot)
hot = 0;
else
{
v = s;
u = (unsigned char*)x->name;
do
{
if (!*u)
{
if (isspace(*v))
{
hot = 1;
goto data;
}
break;
}
} while (*u++ == *v++);
}
goto data;
case ')':
hot = 0;
goto data;
case '.':
{
while (isspace(*s))
s++;
col = 0;
continue;
}
/*FALLTHROUGH*/
default:
data:
DATA();
col++;
continue;
}
break;
}
if (col)
sfprintf(op, "<P>Send comments and suggestions to <A href=\"mailto:%s?subject=%s\">%s</A>.\n", state.mailto, state.mailto, sfstrbase(subject));
{
t = (unsigned char*)"<P>";
u = (unsigned char*)"<BR>";
{
t = u;
}
if (state.organization)
{
t = u;
}
{
t = u;
if (state.corporation)
}
{
t = u;
}
{
t = u;
}
{
t = u;
}
}
{
}
}
int
{
register int n;
register char* s;
char* v;
Dir_t* x;
init();
script = 0;
for (;;)
{
{
case 0:
break;
case 'i':
else
{
else
{
s[n] = 0;
}
}
continue;
case 'm':
else
continue;
case 'r':
{
s[1] = 0;
}
continue;
case 's':
continue;
case 'v':
continue;
case 'I':
else
{
}
continue;
case '?':
continue;
case ':':
{
continue;
}
else if (!(v = sfprints("%s=%s", opt_info.name + 2, fmtquote(v + 1, "\"", "\"", strlen(v + 1), FMT_ALWAYS))))
continue;
}
break;
}
if (error_info.errors)
if (script)
{
}
else
while (s = *argv++)
{
{
}
{
}
}
}