version 1.43, 2014/10/19 19:11:29 |
version 1.46, 2019/03/08 15:09:54 |
Line 91 static const char *attrvals[ATTRVAL__MAX] = { |
|
Line 91 static const char *attrvals[ATTRVAL__MAX] = { |
|
}; |
}; |
|
|
static const struct node nodes[NODE__MAX] = { |
static const struct node nodes[NODE__MAX] = { |
{ NULL, 0 }, |
{ NULL, 0 }, |
{ "acronym", 0 }, |
{ "acronym", 0 }, |
{ "anchor", NODE_IGNTEXT }, |
{ "anchor", NODE_IGNTEXT }, |
{ "application", 0 }, |
{ "application", 0 }, |
{ "arg", 0 }, |
{ "arg", 0 }, |
{ "caution", NODE_IGNTEXT }, |
{ "caution", NODE_IGNTEXT }, |
{ "citerefentry", NODE_IGNTEXT }, |
{ "citerefentry", NODE_IGNTEXT }, |
{ "cmdsynopsis", NODE_IGNTEXT }, |
{ "cmdsynopsis", NODE_IGNTEXT }, |
{ "code", 0 }, |
{ "code", 0 }, |
{ "colspec", NODE_IGNTEXT }, |
{ "colspec", NODE_IGNTEXT }, |
{ "command", 0 }, |
{ "command", 0 }, |
{ "constant", 0 }, |
{ "constant", 0 }, |
{ "copyright", NODE_IGNTEXT }, |
{ "copyright", NODE_IGNTEXT }, |
{ "date", 0 }, |
{ "date", 0 }, |
{ "emphasis", 0 }, |
{ "emphasis", 0 }, |
{ "entry", 0 }, |
{ "entry", 0 }, |
{ "envar", 0 }, |
{ "envar", 0 }, |
{ "fieldsynopsis", NODE_IGNTEXT }, |
{ "fieldsynopsis", NODE_IGNTEXT }, |
{ "filename", 0 }, |
{ "filename", 0 }, |
{ "funcdef", 0 }, |
{ "funcdef", 0 }, |
{ "funcprototype", NODE_IGNTEXT }, |
{ "funcprototype", NODE_IGNTEXT }, |
{ "funcsynopsis", NODE_IGNTEXT }, |
{ "funcsynopsis", NODE_IGNTEXT }, |
{ "funcsynopsisinfo", 0 }, |
{ "funcsynopsisinfo", 0 }, |
{ "function", 0 }, |
{ "function", 0 }, |
{ "group", NODE_IGNTEXT }, |
{ "group", NODE_IGNTEXT }, |
{ "holder", NODE_IGNTEXT }, |
{ "holder", NODE_IGNTEXT }, |
{ "info", NODE_IGNTEXT }, |
{ "info", NODE_IGNTEXT }, |
{ "informalequation", NODE_IGNTEXT }, |
{ "informalequation", NODE_IGNTEXT }, |
{ "informaltable", NODE_IGNTEXT }, |
{ "informaltable", NODE_IGNTEXT }, |
{ "inlineequation", NODE_IGNTEXT }, |
{ "inlineequation", NODE_IGNTEXT }, |
{ "itemizedlist", NODE_IGNTEXT }, |
{ "itemizedlist", NODE_IGNTEXT }, |
{ "link", 0 }, |
{ "link", 0 }, |
{ "listitem", NODE_IGNTEXT }, |
{ "listitem", NODE_IGNTEXT }, |
{ "literal", 0 }, |
{ "literal", 0 }, |
{ "manvolnum", 0 }, |
{ "manvolnum", 0 }, |
{ "mml:math", NODE_IGNTEXT }, |
{ "mml:math", NODE_IGNTEXT }, |
{ "mml:mfenced", 0 }, |
{ "mml:mfenced", 0 }, |
{ "mml:mfrac", 0 }, |
{ "mml:mfrac", 0 }, |
{ "mml:mi", 0 }, |
{ "mml:mi", 0 }, |
{ "mml:mn", 0 }, |
{ "mml:mn", 0 }, |
{ "mml:mo", 0 }, |
{ "mml:mo", 0 }, |
{ "mml:mrow", 0 }, |
{ "mml:mrow", 0 }, |
{ "mml:msub", 0 }, |
{ "mml:msub", 0 }, |
{ "mml:msup", 0 }, |
{ "mml:msup", 0 }, |
{ "modifier", 0 }, |
{ "modifier", 0 }, |
{ "note", NODE_IGNTEXT }, |
{ "note", NODE_IGNTEXT }, |
{ "option", 0 }, |
{ "option", 0 }, |
{ "orderedlist", NODE_IGNTEXT }, |
{ "orderedlist", NODE_IGNTEXT }, |
{ "para", 0 }, |
{ "para", 0 }, |
{ "paramdef", 0 }, |
{ "paramdef", 0 }, |
{ "parameter", 0 }, |
{ "parameter", 0 }, |
{ "programlisting", 0 }, |
{ "programlisting", 0 }, |
{ "prompt", 0 }, |
{ "prompt", 0 }, |
{ "quote", 0 }, |
{ "quote", 0 }, |
{ "refclass", NODE_IGNTEXT }, |
{ "refclass", NODE_IGNTEXT }, |
{ "refdescriptor", NODE_IGNTEXT }, |
{ "refdescriptor", NODE_IGNTEXT }, |
{ "refentry", NODE_IGNTEXT }, |
{ "refentry", NODE_IGNTEXT }, |
{ "refentryinfo", NODE_IGNTEXT }, |
{ "refentryinfo", NODE_IGNTEXT }, |
{ "refentrytitle", 0 }, |
{ "refentrytitle", 0 }, |
{ "refmeta", NODE_IGNTEXT }, |
{ "refmeta", NODE_IGNTEXT }, |
{ "refmetainfo", NODE_IGNTEXT }, |
{ "refmetainfo", NODE_IGNTEXT }, |
{ "refmiscinfo", NODE_IGNTEXT }, |
{ "refmiscinfo", NODE_IGNTEXT }, |
{ "refname", 0 }, |
{ "refname", 0 }, |
{ "refnamediv", NODE_IGNTEXT }, |
{ "refnamediv", NODE_IGNTEXT }, |
{ "refpurpose", 0 }, |
{ "refpurpose", 0 }, |
{ "refsect1", NODE_IGNTEXT }, |
{ "refsect1", NODE_IGNTEXT }, |
{ "refsect2", NODE_IGNTEXT }, |
{ "refsect2", NODE_IGNTEXT }, |
{ "refsect3", NODE_IGNTEXT }, |
{ "refsect3", NODE_IGNTEXT }, |
{ "refsection", NODE_IGNTEXT }, |
{ "refsection", NODE_IGNTEXT }, |
{ "refsynopsisdiv", NODE_IGNTEXT }, |
{ "refsynopsisdiv", NODE_IGNTEXT }, |
{ "replaceable", 0 }, |
{ "replaceable", 0 }, |
{ "row", NODE_IGNTEXT }, |
{ "row", NODE_IGNTEXT }, |
{ "sbr", NODE_IGNTEXT }, |
{ "sbr", NODE_IGNTEXT }, |
{ "screen", NODE_IGNTEXT }, |
{ "screen", NODE_IGNTEXT }, |
{ "sgmltag", 0 }, |
{ "sgmltag", 0 }, |
{ "structname", 0 }, |
{ "structname", 0 }, |
{ "synopsis", 0 }, |
{ "synopsis", 0 }, |
{ "table", NODE_IGNTEXT }, |
{ "table", NODE_IGNTEXT }, |
{ "tbody", NODE_IGNTEXT }, |
{ "tbody", NODE_IGNTEXT }, |
{ "term", 0 }, |
{ "term", 0 }, |
{ NULL, 0 }, |
{ NULL, 0 }, |
{ "tfoot", NODE_IGNTEXT }, |
{ "tfoot", NODE_IGNTEXT }, |
{ "tgroup", NODE_IGNTEXT }, |
{ "tgroup", NODE_IGNTEXT }, |
{ "thead", NODE_IGNTEXT }, |
{ "thead", NODE_IGNTEXT }, |
{ "tip", NODE_IGNTEXT }, |
{ "tip", NODE_IGNTEXT }, |
{ "title", 0 }, |
{ "title", 0 }, |
{ "trademark", 0 }, |
{ "trademark", 0 }, |
{ "type", 0 }, |
{ "type", 0 }, |
{ "ulink", 0 }, |
{ "ulink", 0 }, |
{ "userinput", 0 }, |
{ "userinput", 0 }, |
{ "variablelist", NODE_IGNTEXT }, |
{ "variablelist", NODE_IGNTEXT }, |
{ "varlistentry", NODE_IGNTEXT }, |
{ "varlistentry", NODE_IGNTEXT }, |
{ "varname", 0 }, |
{ "varname", 0 }, |
{ "warning", NODE_IGNTEXT }, |
{ "warning", NODE_IGNTEXT }, |
{ "wordasword", 0 }, |
{ "wordasword", 0 }, |
{ "year", NODE_IGNTEXT }, |
{ "year", NODE_IGNTEXT }, |
}; |
}; |
|
|
static int warn = 0; |
static int warn = 0; |
Line 225 xml_char(void *arg, const XML_Char *p, int sz) |
|
Line 225 xml_char(void *arg, const XML_Char *p, int sz) |
|
*/ |
*/ |
if (NODE_TEXT != ps->node) { |
if (NODE_TEXT != ps->node) { |
for (i = 0; i < sz; i++) |
for (i = 0; i < sz; i++) |
if ( ! isspace((int)p[i])) |
if ( ! isspace((unsigned char)p[i])) |
break; |
break; |
if (i == sz) |
if (i == sz) |
return; |
return; |
Line 248 xml_char(void *arg, const XML_Char *p, int sz) |
|
Line 248 xml_char(void *arg, const XML_Char *p, int sz) |
|
|
|
/* Append to current buffer. */ |
/* Append to current buffer. */ |
assert(sz >= 0); |
assert(sz >= 0); |
ps->cur->b = realloc(ps->cur->b, |
ps->cur->b = realloc(ps->cur->b, |
ps->cur->bsz + (size_t)sz); |
ps->cur->bsz + (size_t)sz); |
if (NULL == ps->cur->b) { |
if (NULL == ps->cur->b) { |
perror(NULL); |
perror(NULL); |
Line 265 pnode_trim(struct pnode *pn) |
|
Line 265 pnode_trim(struct pnode *pn) |
|
|
|
assert(NODE_TEXT == pn->node); |
assert(NODE_TEXT == pn->node); |
for ( ; pn->bsz > 0; pn->bsz--) |
for ( ; pn->bsz > 0; pn->bsz--) |
if ( ! isspace((int)pn->b[pn->bsz - 1])) |
if ( ! isspace((unsigned char)pn->b[pn->bsz - 1])) |
break; |
break; |
} |
} |
|
|
Line 316 xml_elem_start(void *arg, const XML_Char *name, const |
|
Line 316 xml_elem_start(void *arg, const XML_Char *name, const |
|
if (NODE__MAX == node && NODE_ROOT == ps->node) { |
if (NODE__MAX == node && NODE_ROOT == ps->node) { |
return; |
return; |
} else if (NODE__MAX == node) { |
} else if (NODE__MAX == node) { |
fprintf(stderr, "%s:%zu:%zu: unknown node \"%s\"\n", |
fprintf(stderr, "%s:%zu:%zu: unknown node \"%s\"\n", |
ps->fname, XML_GetCurrentLineNumber(ps->xml), |
ps->fname, XML_GetCurrentLineNumber(ps->xml), |
XML_GetCurrentColumnNumber(ps->xml), name); |
XML_GetCurrentColumnNumber(ps->xml), name); |
ps->stop = 1; |
ps->stop = 1; |
Line 370 xml_elem_start(void *arg, const XML_Char *name, const |
|
Line 370 xml_elem_start(void *arg, const XML_Char *name, const |
|
if (0 == strcmp(*att, attrkeys[key])) |
if (0 == strcmp(*att, attrkeys[key])) |
break; |
break; |
if (ATTRKEY__MAX == key) { |
if (ATTRKEY__MAX == key) { |
if (warn) |
if (warn) |
fprintf(stderr, "%s:%zu:%zu: warning: " |
fprintf(stderr, "%s:%zu:%zu: warning: " |
"unknown attribute \"%s\"\n", |
"unknown attribute \"%s\"\n", |
ps->fname, |
ps->fname, |
XML_GetCurrentLineNumber(ps->xml), |
XML_GetCurrentLineNumber(ps->xml), |
XML_GetCurrentColumnNumber(ps->xml), |
XML_GetCurrentColumnNumber(ps->xml), |
*att); |
*att); |
continue; |
continue; |
} else if ( ! isattrkey(node, key)) { |
} else if ( ! isattrkey(node, key)) { |
if (warn) |
if (warn) |
fprintf(stderr, "%s:%zu:%zu: warning: " |
fprintf(stderr, "%s:%zu:%zu: warning: " |
"bad attribute \"%s\"\n", |
"bad attribute \"%s\"\n", |
ps->fname, |
ps->fname, |
XML_GetCurrentLineNumber(ps->xml), |
XML_GetCurrentLineNumber(ps->xml), |
XML_GetCurrentColumnNumber(ps->xml), |
XML_GetCurrentColumnNumber(ps->xml), |
*att); |
*att); |
continue; |
continue; |
} |
} |
Line 394 xml_elem_start(void *arg, const XML_Char *name, const |
|
Line 394 xml_elem_start(void *arg, const XML_Char *name, const |
|
if (ATTRVAL__MAX != val && ! isattrval(key, val)) { |
if (ATTRVAL__MAX != val && ! isattrval(key, val)) { |
if (warn) |
if (warn) |
fprintf(stderr, "%s:%zu:%zu: warning: " |
fprintf(stderr, "%s:%zu:%zu: warning: " |
"bad attribute value \"%s\"\n", |
"bad attribute value \"%s\"\n", |
ps->fname, |
ps->fname, |
XML_GetCurrentLineNumber(ps->xml), |
XML_GetCurrentLineNumber(ps->xml), |
XML_GetCurrentColumnNumber(ps->xml), |
XML_GetCurrentColumnNumber(ps->xml), |
*(att + 1)); |
*(att + 1)); |
continue; |
continue; |
} |
} |
Line 541 bufappend_r(struct parse *p, struct pnode *pn) |
|
Line 541 bufappend_r(struct parse *p, struct pnode *pn) |
|
bufappend_r(p, pp); |
bufappend_r(p, pp); |
} |
} |
|
|
/* |
/* |
* Recursively search and return the first instance of "node". |
* Recursively search and return the first instance of "node". |
*/ |
*/ |
static struct pnode * |
static struct pnode * |
Line 580 pnode_printmacrolinetext(struct parse *p, struct pnode |
|
Line 580 pnode_printmacrolinetext(struct parse *p, struct pnode |
|
|
|
/* Convert all space to spaces. */ |
/* Convert all space to spaces. */ |
for (cp = p->b; '\0' != *cp; cp++) |
for (cp = p->b; '\0' != *cp; cp++) |
if (isspace((int)*cp)) |
if (isspace((unsigned char)*cp)) |
*cp = ' '; |
*cp = ' '; |
|
|
for (cp = p->b; isspace((int)*cp); cp++) |
for (cp = p->b; isspace((unsigned char)*cp); cp++) |
/* Spin past whitespace (XXX: necessary?) */ ; |
/* Spin past whitespace (XXX: necessary?) */ ; |
for ( ; '\0' != *cp; cp++) { |
for ( ; '\0' != *cp; cp++) { |
/* Escape us if we look like a macro. */ |
/* Escape us if we look like a macro. */ |
if ((cp == p->b || ' ' == *(cp - 1)) && |
if ((cp == p->b || ' ' == *(cp - 1)) && |
isupper((int)*cp) && |
isupper((unsigned char)*cp) && |
'\0' != *(cp + 1) && |
'\0' != *(cp + 1) && |
islower((int)*(cp + 1)) && |
islower((unsigned char)*(cp + 1)) && |
('\0' == *(cp + 2) || |
('\0' == *(cp + 2) || |
' ' == *(cp + 2) || |
' ' == *(cp + 2) || |
(islower((int)*(cp + 2)) && |
(islower((unsigned char)*(cp + 2)) && |
('\0' == *(cp + 3) || |
('\0' == *(cp + 3) || |
' ' == *(cp + 3))))) |
' ' == *(cp + 3))))) |
fputs("\\&", stdout); |
fputs("\\&", stdout); |
if (MACROLINE_UPPER & fl) |
if (MACROLINE_UPPER & fl) |
putchar(toupper((int)*cp)); |
putchar(toupper((unsigned char)*cp)); |
else |
else |
putchar((int)*cp); |
putchar(*cp); |
/* If we're a character escape, escape us. */ |
/* If we're a character escape, escape us. */ |
if ('\\' == *cp) |
if ('\\' == *cp) |
putchar('e'); |
putchar('e'); |
|
|
pnode_printmclosepunct(struct parse *p, struct pnode *pn, int sv) |
pnode_printmclosepunct(struct parse *p, struct pnode *pn, int sv) |
{ |
{ |
/* We wouldn't have done anything anyway. */ |
/* We wouldn't have done anything anyway. */ |
if ( ! (sv && ! p->newln)) |
if ( ! (sv && ! p->newln)) |
return; |
return; |
|
|
/* No next node or it's not text. */ |
/* No next node or it's not text. */ |
Line 667 pnode_printmclosepunct(struct parse *p, struct pnode * |
|
Line 667 pnode_printmclosepunct(struct parse *p, struct pnode * |
|
} else if (NODE_TEXT != pn->node) { |
} else if (NODE_TEXT != pn->node) { |
pnode_printmclose(p, sv); |
pnode_printmclose(p, sv); |
return; |
return; |
} |
} |
|
|
/* Only do this for the comma/period. */ |
/* Only do this for the comma/period. */ |
if (pn->bsz > 0 && |
if (pn->bsz > 0 && |
(',' == pn->b[0] || '.' == pn->b[0]) && |
(',' == pn->b[0] || '.' == pn->b[0]) && |
(1 == pn->bsz || isspace((int)pn->b[1]))) { |
(1 == pn->bsz || isspace((unsigned char)pn->b[1]))) { |
putchar(' '); |
putchar(' '); |
putchar(pn->b[0]); |
putchar(pn->b[0]); |
pn->b++; |
pn->b++; |
pn->bsz--; |
pn->bsz--; |
} |
} |
|
|
putchar('\n'); |
putchar('\n'); |
p->newln = 1; |
p->newln = 1; |
Line 691 pnode_printrefsynopsisdiv(struct parse *p, struct pnod |
|
Line 691 pnode_printrefsynopsisdiv(struct parse *p, struct pnod |
|
{ |
{ |
struct pnode *pp; |
struct pnode *pp; |
|
|
TAILQ_FOREACH(pp, &pn->childq, child) |
TAILQ_FOREACH(pp, &pn->childq, child) |
if (NODE_TITLE == pp->node) { |
if (NODE_TITLE == pp->node) { |
pnode_unlink(pp); |
pnode_unlink(pp); |
return; |
return; |
Line 742 pnode_printrefsect(struct parse *p, struct pnode *pn) |
|
Line 742 pnode_printrefsect(struct parse *p, struct pnode *pn) |
|
p->newln = 0; |
p->newln = 0; |
|
|
if (NULL != pp) { |
if (NULL != pp) { |
pnode_printmacrolinetext(p, pp, |
pnode_printmacrolinetext(p, pp, |
NODE_REFSECT1 == pn->node ? |
NODE_REFSECT1 == pn->node ? |
MACROLINE_UPPER : 0); |
MACROLINE_UPPER : 0); |
pnode_printmclose(p, 1); |
pnode_printmclose(p, 1); |
Line 944 pnode_printfuncprototype(struct parse *p, struct pnode |
|
Line 944 pnode_printfuncprototype(struct parse *p, struct pnode |
|
|
|
assert(p->newln); |
assert(p->newln); |
TAILQ_FOREACH(fdef, &pn->childq, child) |
TAILQ_FOREACH(fdef, &pn->childq, child) |
if (NODE_FUNCDEF == fdef->node) |
if (NODE_FUNCDEF == fdef->node) |
break; |
break; |
|
|
if (NULL != fdef) |
if (NULL != fdef) |
Line 952 pnode_printfuncprototype(struct parse *p, struct pnode |
|
Line 952 pnode_printfuncprototype(struct parse *p, struct pnode |
|
else |
else |
puts(".Fo UNKNOWN"); |
puts(".Fo UNKNOWN"); |
|
|
TAILQ_FOREACH(pp, &pn->childq, child) |
TAILQ_FOREACH(pp, &pn->childq, child) |
if (NODE_PARAMDEF == pp->node) |
if (NODE_PARAMDEF == pp->node) |
pnode_printparamdef(p, pp); |
pnode_printparamdef(p, pp); |
|
|
Line 960 pnode_printfuncprototype(struct parse *p, struct pnode |
|
Line 960 pnode_printfuncprototype(struct parse *p, struct pnode |
|
p->newln = 1; |
p->newln = 1; |
} |
} |
|
|
/* |
/* |
* The <arg> element is more complicated than it should be because text |
* The <arg> element is more complicated than it should be because text |
* nodes are treated like ".Ar foo", but non-text nodes need to be |
* nodes are treated like ".Ar foo", but non-text nodes need to be |
* re-sent into the printer (i.e., without the preceding ".Ar"). |
* re-sent into the printer (i.e., without the preceding ".Ar"). |
Line 976 pnode_printarg(struct parse *p, struct pnode *pn) |
|
Line 976 pnode_printarg(struct parse *p, struct pnode *pn) |
|
|
|
isop = 1; |
isop = 1; |
isrep = 0; |
isrep = 0; |
TAILQ_FOREACH(ap, &pn->attrq, child) |
TAILQ_FOREACH(ap, &pn->attrq, child) |
if (ATTRKEY_CHOICE == ap->key && |
if (ATTRKEY_CHOICE == ap->key && |
(ATTRVAL_PLAIN == ap->val || |
(ATTRVAL_PLAIN == ap->val || |
ATTRVAL_REQ == ap->val)) |
ATTRVAL_REQ == ap->val)) |
isop = 0; |
isop = 0; |
else if (ATTRKEY_REP == ap->key && |
else if (ATTRKEY_REP == ap->key && |
(ATTRVAL_REPEAT == ap->val)) |
(ATTRVAL_REPEAT == ap->val)) |
Line 994 pnode_printarg(struct parse *p, struct pnode *pn) |
|
Line 994 pnode_printarg(struct parse *p, struct pnode *pn) |
|
if (NODE_TEXT == pp->node) { |
if (NODE_TEXT == pp->node) { |
pnode_printmopen(p); |
pnode_printmopen(p); |
fputs("Ar", stdout); |
fputs("Ar", stdout); |
} |
} |
pnode_print(p, pp); |
pnode_print(p, pp); |
if (NODE_TEXT == pp->node && isrep) |
if (NODE_TEXT == pp->node && isrep) |
fputs("...", stdout); |
fputs("...", stdout); |
} |
} |
} |
} |
Line 1009 pnode_printgroup(struct parse *p, struct pnode *pn) |
|
Line 1009 pnode_printgroup(struct parse *p, struct pnode *pn) |
|
int isop, sv; |
int isop, sv; |
|
|
isop = 1; |
isop = 1; |
TAILQ_FOREACH(ap, &pn->attrq, child) |
TAILQ_FOREACH(ap, &pn->attrq, child) |
if (ATTRKEY_CHOICE == ap->key && |
if (ATTRKEY_CHOICE == ap->key && |
(ATTRVAL_PLAIN == ap->val || |
(ATTRVAL_PLAIN == ap->val || |
ATTRVAL_REQ == ap->val)) { |
ATTRVAL_REQ == ap->val)) { |
Line 1017 pnode_printgroup(struct parse *p, struct pnode *pn) |
|
Line 1017 pnode_printgroup(struct parse *p, struct pnode *pn) |
|
break; |
break; |
} |
} |
|
|
/* |
/* |
* Make sure we're on a macro line. |
* Make sure we're on a macro line. |
* This will prevent pnode_print() for putting us on a |
* This will prevent pnode_print() for putting us on a |
* subsequent line. |
* subsequent line. |
*/ |
*/ |
sv = p->newln; |
sv = p->newln; |
pnode_printmopen(p); |
pnode_printmopen(p); |
if (isop) |
if (isop) |
fputs("Op", stdout); |
fputs("Op", stdout); |
else if (sv) |
else if (sv) |
fputs("No", stdout); |
fputs("No", stdout); |
Line 1329 pnode_print(struct parse *p, struct pnode *pn) |
|
Line 1329 pnode_print(struct parse *p, struct pnode *pn) |
|
break; |
break; |
case (NODE_PARA): |
case (NODE_PARA): |
assert(p->newln); |
assert(p->newln); |
if (NULL != pn->parent && |
if (NULL != pn->parent && |
NODE_LISTITEM == pn->parent->node) |
NODE_LISTITEM == pn->parent->node) |
break; |
break; |
puts(".Pp"); |
puts(".Pp"); |
break; |
break; |
Line 1436 pnode_print(struct parse *p, struct pnode *pn) |
|
Line 1436 pnode_print(struct parse *p, struct pnode *pn) |
|
|
|
/* |
/* |
* Output all characters, squeezing out whitespace |
* Output all characters, squeezing out whitespace |
* between newlines. |
* between newlines. |
* XXX: all whitespace, including tabs (?). |
* XXX: all whitespace, including tabs (?). |
* Remember to escape control characters and escapes. |
* Remember to escape control characters and escapes. |
*/ |
*/ |
Line 1455 pnode_print(struct parse *p, struct pnode *pn) |
|
Line 1455 pnode_print(struct parse *p, struct pnode *pn) |
|
for (last = '\n'; '\0' != *cp; ) { |
for (last = '\n'; '\0' != *cp; ) { |
if ('\n' == last) { |
if ('\n' == last) { |
/* Consume all whitespace. */ |
/* Consume all whitespace. */ |
if (isspace((int)*cp)) { |
if (isspace((unsigned char)*cp)) { |
while (isspace((int)*cp)) |
while (isspace((unsigned char)*cp)) |
cp++; |
cp++; |
continue; |
continue; |
} else if ('\'' == *cp || '.' == *cp) |
} else if ('\'' == *cp || '.' == *cp) |
Line 1553 pnode_print(struct parse *p, struct pnode *pn) |
|
Line 1553 pnode_print(struct parse *p, struct pnode *pn) |
|
* <refname> macros in sequence, then print out a |
* <refname> macros in sequence, then print out a |
* trailing comma before the newline. |
* trailing comma before the newline. |
*/ |
*/ |
if (NULL != pn->parent && |
if (NULL != pn->parent && |
NODE_REFNAMEDIV == pn->parent->node && |
NODE_REFNAMEDIV == pn->parent->node && |
NULL != TAILQ_NEXT(pn, child) && |
NULL != TAILQ_NEXT(pn, child) && |
NODE_REFNAME == TAILQ_NEXT(pn, child)->node) |
NODE_REFNAME == TAILQ_NEXT(pn, child)->node) |
fputs(" ,", stdout); |
fputs(" ,", stdout); |
pnode_printmclose(p, sv); |
pnode_printmclose(p, sv); |
break; |
break; |
Line 1577 pnode_print(struct parse *p, struct pnode *pn) |
|
Line 1577 pnode_print(struct parse *p, struct pnode *pn) |
|
* Invoke the parser context with each buffer fill. |
* Invoke the parser context with each buffer fill. |
*/ |
*/ |
static int |
static int |
readfile(XML_Parser xp, int fd, |
readfile(XML_Parser xp, int fd, |
char *b, size_t bsz, const char *fn) |
char *b, size_t bsz, const char *fn) |
{ |
{ |
struct parse p; |
struct parse p; |
Line 1598 readfile(XML_Parser xp, int fd, |
|
Line 1598 readfile(XML_Parser xp, int fd, |
|
if (0 == (rc = XML_Parse(xp, b, ssz, 0 == ssz))) |
if (0 == (rc = XML_Parse(xp, b, ssz, 0 == ssz))) |
fprintf(stderr, "%s:%zu:%zu: %s\n", fn, |
fprintf(stderr, "%s:%zu:%zu: %s\n", fn, |
XML_GetCurrentLineNumber(xp), |
XML_GetCurrentLineNumber(xp), |
XML_GetCurrentColumnNumber(xp), |
XML_GetCurrentColumnNumber(xp), |
XML_ErrorString |
XML_ErrorString |
(XML_GetErrorCode(xp))); |
(XML_GetErrorCode(xp))); |
else if ( ! p.stop && ssz > 0) |
else if ( ! p.stop && ssz > 0) |
continue; |
continue; |
/* |
/* |
* Exit when we've read all or errors have occured |
* Exit when we've read all or errors have occured |
* during the parse sequence. |
* during the parse sequence. |
*/ |
*/ |
Line 1654 main(int argc, char *argv[]) |
|
Line 1654 main(int argc, char *argv[]) |
|
argc -= optind; |
argc -= optind; |
argv += optind; |
argv += optind; |
|
|
if (argc > 1) |
if (argc > 1) { |
return(EXIT_FAILURE); |
fprintf(stderr, "%s: Too many arguments\n", argv[1]); |
else if (argc > 0) |
goto usage; |
|
} else if (argc > 0) |
fname = argv[0]; |
fname = argv[0]; |
|
|
/* Read from stdin or a file. */ |
/* Read from stdin or a file. */ |
fd = 0 == strcmp(fname, "-") ? |
fd = 0 == strcmp(fname, "-") ? |
STDIN_FILENO : open(fname, O_RDONLY, 0); |
STDIN_FILENO : open(fname, O_RDONLY, 0); |
|
|
/* |
/* |
Line 1685 main(int argc, char *argv[]) |
|
Line 1686 main(int argc, char *argv[]) |
|
return(rc ? EXIT_SUCCESS : EXIT_FAILURE); |
return(rc ? EXIT_SUCCESS : EXIT_FAILURE); |
|
|
usage: |
usage: |
fprintf(stderr, "usage: %s [-W]\n", progname); |
fprintf(stderr, "usage: %s [-W] [input_filename]\n", progname); |
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |