=================================================================== RCS file: /cvs/docbook2mdoc/docbook2mdoc.c,v retrieving revision 1.37 retrieving revision 1.39 diff -u -p -r1.37 -r1.39 --- docbook2mdoc/docbook2mdoc.c 2014/04/30 12:34:44 1.37 +++ docbook2mdoc/docbook2mdoc.c 2014/04/30 13:18:38 1.39 @@ -1,4 +1,4 @@ -/* $Id: docbook2mdoc.c,v 1.37 2014/04/30 12:34:44 kristaps Exp $ */ +/* $Id: docbook2mdoc.c,v 1.39 2014/04/30 13:18:38 kristaps Exp $ */ /* * Copyright (c) 2014 Kristaps Dzonsons * @@ -96,6 +96,7 @@ static const struct node nodes[NODE__MAX] = { { "citerefentry", NODE_IGNTEXT }, { "cmdsynopsis", NODE_IGNTEXT }, { "code", 0 }, + { "colspec", NODE_IGNTEXT }, { "command", 0 }, { "constant", 0 }, { "copyright", NODE_IGNTEXT }, @@ -103,6 +104,7 @@ static const struct node nodes[NODE__MAX] = { { "emphasis", 0 }, { "entry", 0 }, { "envar", 0 }, + { "fieldsynopsis", NODE_IGNTEXT }, { "filename", 0 }, { "funcdef", 0 }, { "funcprototype", NODE_IGNTEXT }, @@ -118,6 +120,7 @@ static const struct node nodes[NODE__MAX] = { { "listitem", NODE_IGNTEXT }, { "literal", 0 }, { "manvolnum", 0 }, + { "modifier", 0 }, { "note", NODE_IGNTEXT }, { "option", 0 }, { "orderedlist", NODE_IGNTEXT }, @@ -133,6 +136,7 @@ static const struct node nodes[NODE__MAX] = { { "refentryinfo", NODE_IGNTEXT }, { "refentrytitle", 0 }, { "refmeta", NODE_IGNTEXT }, + { "refmetainfo", NODE_IGNTEXT }, { "refmiscinfo", NODE_IGNTEXT }, { "refname", 0 }, { "refnamediv", NODE_IGNTEXT }, @@ -159,6 +163,7 @@ static const struct node nodes[NODE__MAX] = { { "tip", NODE_IGNTEXT }, { "title", 0 }, { "trademark", 0 }, + { "type", 0 }, { "ulink", 0 }, { "userinput", 0 }, { "variablelist", NODE_IGNTEXT }, @@ -169,6 +174,8 @@ static const struct node nodes[NODE__MAX] = { { "year", NODE_IGNTEXT }, }; +static int warn = 0; + static void pnode_print(struct parse *p, struct pnode *pn); @@ -346,32 +353,35 @@ 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: warning: " - "unknown attribute \"%s\"\n", - ps->fname, - XML_GetCurrentLineNumber(ps->xml), - XML_GetCurrentColumnNumber(ps->xml), - *att); + if (warn) + 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: warning: " - "bad attribute \"%s\"\n", - ps->fname, - XML_GetCurrentLineNumber(ps->xml), - XML_GetCurrentColumnNumber(ps->xml), - *att); + if (warn) + fprintf(stderr, "%s:%zu:%zu: warning: " + "bad attribute \"%s\"\n", + ps->fname, + XML_GetCurrentLineNumber(ps->xml), + XML_GetCurrentColumnNumber(ps->xml), + *att); continue; } for (val = 0; val < ATTRVAL__MAX; val++) if (0 == strcmp(*(att + 1), attrvals[val])) break; if (ATTRVAL__MAX != val && ! isattrval(key, val)) { - fprintf(stderr, "%s:%zu:%zu: warning: " - "bad attribute value \"%s\"\n", - ps->fname, - XML_GetCurrentLineNumber(ps->xml), - XML_GetCurrentColumnNumber(ps->xml), - *(att + 1)); + if (warn) + fprintf(stderr, "%s:%zu:%zu: warning: " + "bad attribute value \"%s\"\n", + ps->fname, + XML_GetCurrentLineNumber(ps->xml), + XML_GetCurrentColumnNumber(ps->xml), + *(att + 1)); continue; } pattr = calloc(1, sizeof(struct pattr)); @@ -1332,6 +1342,10 @@ pnode_print(struct parse *p, struct pnode *pn) } p->newln = 0; break; + case (NODE_TYPE): + pnode_printmopen(p); + fputs("Vt", stdout); + break; case (NODE_USERINPUT): pnode_printmopen(p); fputs("Li", stdout); @@ -1376,6 +1390,7 @@ pnode_print(struct parse *p, struct pnode *pn) case (NODE_SGMLTAG): case (NODE_STRUCTNAME): case (NODE_TEXT): + case (NODE_TYPE): case (NODE_USERINPUT): case (NODE_VARNAME): pnode_printmclosepunct(p, pn, sv); @@ -1468,15 +1483,28 @@ main(int argc, char *argv[]) XML_Parser xp; const char *fname; char *buf; - int fd, rc; + int fd, rc, ch; + const char *progname; + progname = strrchr(argv[0], '/'); + if (progname == NULL) + progname = argv[0]; + else + ++progname; + fname = "-"; xp = NULL; buf = NULL; rc = 0; - if (-1 != getopt(argc, argv, "")) - return(EXIT_FAILURE); + while (-1 != (ch = getopt(argc, argv, "W"))) + switch (ch) { + case ('W'): + warn = 1; + break; + default: + goto usage; + } argc -= optind; argv += optind; @@ -1510,4 +1538,8 @@ main(int argc, char *argv[]) if (STDIN_FILENO != fd) close(fd); return(rc ? EXIT_SUCCESS : EXIT_FAILURE); + +usage: + fprintf(stderr, "usage: %s [-W]\n", progname); + return(EXIT_FAILURE); }