=================================================================== RCS file: /cvs/docbook2mdoc/docbook2mdoc.c,v retrieving revision 1.29 retrieving revision 1.34 diff -u -p -r1.29 -r1.34 --- docbook2mdoc/docbook2mdoc.c 2014/04/02 10:59:07 1.29 +++ docbook2mdoc/docbook2mdoc.c 2014/04/30 09:37:26 1.34 @@ -1,4 +1,4 @@ -/* $Id: docbook2mdoc.c,v 1.29 2014/04/02 10:59:07 kristaps Exp $ */ +/* $Id: docbook2mdoc.c,v 1.34 2014/04/30 09:37:26 kristaps Exp $ */ /* * Copyright (c) 2014 Kristaps Dzonsons * @@ -88,6 +88,7 @@ static const char *attrvals[ATTRVAL__MAX] = { static const struct node nodes[NODE__MAX] = { { NULL, 0 }, { "acronym", 0 }, + { "anchor", NODE_IGNTEXT }, { "application", 0 }, { "arg", 0 }, { "caution", NODE_IGNTEXT }, @@ -95,6 +96,8 @@ static const struct node nodes[NODE__MAX] = { { "cmdsynopsis", NODE_IGNTEXT }, { "code", 0 }, { "command", 0 }, + { "constant", 0 }, + { "copyright", NODE_IGNTEXT }, { "date", 0 }, { "emphasis", 0 }, { "entry", 0 }, @@ -105,8 +108,10 @@ static const struct node nodes[NODE__MAX] = { { "funcsynopsis", NODE_IGNTEXT }, { "funcsynopsisinfo", 0 }, { "function", 0 }, - { "itemizedlist", NODE_IGNTEXT }, { "group", NODE_IGNTEXT }, + { "holder", NODE_IGNTEXT }, + { "info", NODE_IGNTEXT }, + { "itemizedlist", NODE_IGNTEXT }, { "link", 0 }, { "listitem", NODE_IGNTEXT }, { "literal", 0 }, @@ -139,6 +144,7 @@ static const struct node nodes[NODE__MAX] = { { "row", NODE_IGNTEXT }, { "sbr", NODE_IGNTEXT }, { "screen", NODE_IGNTEXT }, + { "sgmltag", 0 }, { "structname", 0 }, { "synopsis", 0 }, { "table", NODE_IGNTEXT }, @@ -150,12 +156,15 @@ static const struct node nodes[NODE__MAX] = { { "thead", NODE_IGNTEXT }, { "tip", NODE_IGNTEXT }, { "title", 0 }, + { "trademark", 0 }, { "ulink", 0 }, { "userinput", 0 }, { "variablelist", NODE_IGNTEXT }, { "varlistentry", NODE_IGNTEXT }, { "varname", 0 }, { "warning", NODE_IGNTEXT }, + { "wordasword", 0 }, + { "year", NODE_IGNTEXT }, }; static void @@ -332,15 +341,17 @@ xml_elem_start(void *arg, const XML_Char *name, const if (0 == strcmp(*att, attrkeys[key])) break; if (ATTRKEY__MAX == key) { - fprintf(stderr, "%s:%zu:%zu: unknown " - "attribute \"%s\"\n", ps->fname, + fprintf(stderr, "%s:%zu:%zu: warning: " + "unknown attribute \"%s\"\n", + ps->fname, XML_GetCurrentLineNumber(ps->xml), XML_GetCurrentColumnNumber(ps->xml), *att); continue; } else if ( ! isattrkey(node, key)) { - fprintf(stderr, "%s:%zu:%zu: bad " - "attribute \"%s\"\n", ps->fname, + fprintf(stderr, "%s:%zu:%zu: warning: " + "bad attribute \"%s\"\n", + ps->fname, XML_GetCurrentLineNumber(ps->xml), XML_GetCurrentColumnNumber(ps->xml), *att); @@ -350,8 +361,9 @@ xml_elem_start(void *arg, const XML_Char *name, const if (0 == strcmp(*(att + 1), attrvals[val])) break; if (ATTRVAL__MAX != val && ! isattrval(key, val)) { - fprintf(stderr, "%s:%zu:%zu: bad " - "value \"%s\"\n", ps->fname, + fprintf(stderr, "%s:%zu:%zu: warning: " + "bad attribute value \"%s\"\n", + ps->fname, XML_GetCurrentLineNumber(ps->xml), XML_GetCurrentColumnNumber(ps->xml), *(att + 1)); @@ -515,6 +527,7 @@ pnode_findfirst(struct pnode *pn, enum nodeid node) #define MACROLINE_NORM 0 #define MACROLINE_UPPER 1 +#define MACROLINE_NOWS 2 /* * Recursively print text presumably on a macro line. * Convert all whitespace to regular spaces. @@ -524,7 +537,7 @@ pnode_printmacrolinetext(struct parse *p, struct pnode { char *cp; - if (0 == p->newln) + if (0 == p->newln && ! (MACROLINE_NOWS & fl)) putchar(' '); bufclear(p); @@ -680,16 +693,12 @@ pnode_printciterefentry(struct parse *p, struct pnode struct pnode *pp, *title, *manvol; title = manvol = NULL; - assert(p->newln); TAILQ_FOREACH(pp, &pn->childq, child) if (NODE_MANVOLNUM == pp->node) manvol = pp; else if (NODE_REFENTRYTITLE == pp->node) title = pp; - fputs(".Xr", stdout); - p->newln = 0; - if (NULL != title) { pnode_printmacrolinepart(p, title); } else @@ -699,7 +708,7 @@ pnode_printciterefentry(struct parse *p, struct pnode puts(" 1"); p->newln = 1; } else - pnode_printmacroline(p, manvol); + pnode_printmacrolinepart(p, manvol); } static void @@ -778,7 +787,7 @@ pnode_printparamdef(struct parse *p, struct pnode *pn) fputs(".Fa \"", stdout); p->newln = 0; if (NULL != ptype) { - pnode_printmacrolinepart(p, ptype); + pnode_printmacrolinetext(p, ptype, MACROLINE_NOWS); putchar(' '); } @@ -932,6 +941,7 @@ pnode_printvarlistentry(struct parse *p, struct pnode assert(p->newln); TAILQ_FOREACH(pp, &pn->childq, child) if (NODE_TERM == pp->node) { + assert(p->newln); fputs(".It", stdout); p->newln = 0; pnode_print(p, pp); @@ -1065,12 +1075,16 @@ pnode_print(struct parse *p, struct pnode *pn) pnode_printmopen(p); fputs("Nm", stdout); break; + case (NODE_ANCHOR): + /* Don't print anything! */ + return; case (NODE_ARG): pnode_printarg(p, pn); pnode_unlinksub(pn); break; case (NODE_CITEREFENTRY): - assert(p->newln); + pnode_printmopen(p); + fputs("Xr", stdout); pnode_printciterefentry(p, pn); pnode_unlinksub(pn); break; @@ -1082,6 +1096,10 @@ pnode_print(struct parse *p, struct pnode *pn) pnode_printmopen(p); fputs("Nm", stdout); break; + case (NODE_CONSTANT): + pnode_printmopen(p); + fputs("Dv", stdout); + break; case (NODE_EMPHASIS): pnode_printmopen(p); fputs("Em", stdout); @@ -1140,8 +1158,8 @@ pnode_print(struct parse *p, struct pnode *pn) /* Suppress non-text children... */ pnode_printmopen(p); fputs("Fa \"", stdout); - pnode_printmacrolinepart(p, pn); - puts("\""); + pnode_printmacrolinetext(p, pn, MACROLINE_NOWS); + fputs("\"", stdout); pnode_unlinksub(pn); break; case (NODE_QUOTE): @@ -1209,6 +1227,10 @@ pnode_print(struct parse *p, struct pnode *pn) assert(p->newln); puts(".br"); break; + case (NODE_SGMLTAG): + pnode_printmopen(p); + fputs("Li", stdout); + break; case (NODE_STRUCTNAME): pnode_printmopen(p); fputs("Vt", stdout); @@ -1284,8 +1306,10 @@ pnode_print(struct parse *p, struct pnode *pn) switch (pn->node) { case (NODE_APPLICATION): case (NODE_ARG): + case (NODE_CITEREFENTRY): case (NODE_CODE): case (NODE_COMMAND): + case (NODE_CONSTANT): case (NODE_EMPHASIS): case (NODE_ENVAR): case (NODE_FILENAME): @@ -1296,6 +1320,7 @@ pnode_print(struct parse *p, struct pnode *pn) case (NODE_PARAMETER): case (NODE_REPLACEABLE): case (NODE_REFPURPOSE): + case (NODE_SGMLTAG): case (NODE_STRUCTNAME): case (NODE_TEXT): case (NODE_USERINPUT): @@ -1358,7 +1383,9 @@ readfile(XML_Parser xp, int fd, while ((ssz = read(fd, b, bsz)) >= 0) { if (0 == (rc = XML_Parse(xp, b, ssz, 0 == ssz))) - fprintf(stderr, "%s: %s\n", fn, + fprintf(stderr, "%s:%zu:%zu: %s\n", fn, + XML_GetCurrentLineNumber(xp), + XML_GetCurrentColumnNumber(xp), XML_ErrorString (XML_GetErrorCode(xp))); else if ( ! p.stop && ssz > 0)