=================================================================== RCS file: /cvs/docbook2mdoc/statistics.c,v retrieving revision 1.35 retrieving revision 1.38 diff -u -p -r1.35 -r1.38 --- docbook2mdoc/statistics.c 2019/04/16 21:21:27 1.35 +++ docbook2mdoc/statistics.c 2019/04/28 20:26:49 1.38 @@ -1,4 +1,4 @@ -/* $Id: statistics.c,v 1.35 2019/04/16 21:21:27 schwarze Exp $ */ +/* $Id: statistics.c,v 1.38 2019/04/28 20:26:49 schwarze Exp $ */ /* * Copyright (c) 2019 Ingo Schwarze * @@ -14,6 +14,8 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include + #include #include #include @@ -24,6 +26,8 @@ #include #include +#include "xmalloc.h" + /* * Count parent-child element relations in a corpus of DocBook documents. * @@ -125,19 +129,13 @@ table_add(const char *parent, const char *child) if (tablei == tablesz) { tablesz += 64; - table = reallocarray(table, tablesz, sizeof(*table)); - if (table == NULL) - err(1, NULL); + table = xreallocarray(table, tablesz, sizeof(*table)); } /* Add a new entry to the table. */ - if ((table[tablei].parent = strdup(parent)) == NULL) - err(1, NULL); - if (child == NULL) - table[tablei].child = NULL; - else if ((table[tablei].child = strdup(child)) == NULL) - err(1, NULL); + table[tablei].parent = xstrdup(parent); + table[tablei].child = child == NULL ? NULL : xstrdup(child); table[tablei++].count = init_done ? 1 : -1; } @@ -152,12 +150,9 @@ stack_push(const char *name) if (stacki == stacksz) { stacksz += 8; - stack = reallocarray(stack, stacksz, sizeof(*stack)); - if (stack == NULL) - err(1, NULL); + stack = xreallocarray(stack, stacksz, sizeof(*stack)); } - if ((stack[stacki++] = strdup(name)) == NULL) - err(1, NULL); + stack[stacki++] = xstrdup(name); } /* @@ -368,8 +363,10 @@ main(int argc, char *argv[]) table_add("ROOT", "part"); table_add("ROOT", "preface"); table_add("ROOT", "refentry"); + table_add("ROOT", "reference"); table_add("ROOT", "sect1"); table_add("ROOT", "sect2"); + table_add("abstract", NULL); table_add("acronym", "TEXT"); table_add("affiliation", "orgdiv"); table_add("affiliation", "orgname"); @@ -377,6 +374,7 @@ main(int argc, char *argv[]) table_add("application", "TEXT"); table_add("arg", "option"); table_add("article", NULL); + table_add("articleinfo", "abstract"); table_add("articleinfo", "author"); table_add("articleinfo", "authorgroup"); table_add("articleinfo", "copyright"); @@ -398,6 +396,7 @@ main(int argc, char *argv[]) table_add("authorgroup", "othercredit"); table_add("blockquote", NULL); table_add("book", NULL); + table_add("bookinfo", "abstract"); table_add("bookinfo", "authorgroup"); table_add("bookinfo", "copyright"); table_add("bookinfo", "legalnotice"); @@ -527,6 +526,7 @@ main(int argc, char *argv[]) table_add("refentryinfo", "date"); table_add("refentryinfo", "productname"); table_add("refentrytitle", "TEXT"); + table_add("reference", "refentry"); table_add("refmeta", "manvolnum"); table_add("refmeta", "refentrytitle"); table_add("refmeta", "refmiscinfo");