=================================================================== RCS file: /cvs/docbook2mdoc/statistics.c,v retrieving revision 1.33 retrieving revision 1.37 diff -u -p -r1.33 -r1.37 --- docbook2mdoc/statistics.c 2019/04/14 23:07:05 1.33 +++ docbook2mdoc/statistics.c 2019/04/28 15:03:29 1.37 @@ -1,4 +1,4 @@ -/* $Id: statistics.c,v 1.33 2019/04/14 23:07:05 schwarze Exp $ */ +/* $Id: statistics.c,v 1.37 2019/04/28 15:03:29 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,6 +363,7 @@ 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("acronym", "TEXT"); @@ -482,6 +478,9 @@ main(int argc, char *argv[]) table_add("member", "symbol"); table_add("member", "TEXT"); table_add("note", NULL); + table_add("olink", "citetitle"); + table_add("olink", "function"); + table_add("olink", "TEXT"); table_add("option", "parameter"); table_add("option", "replaceable"); table_add("option", "TEXT"); @@ -505,6 +504,7 @@ main(int argc, char *argv[]) table_add("phrase", "TEXT"); table_add("preface", NULL); table_add("primary", NULL); + table_add("productname", "TEXT"); table_add("programlisting", NULL); table_add("property", "TEXT"); table_add("pubdate", "TEXT"); @@ -521,7 +521,9 @@ main(int argc, char *argv[]) table_add("refentryinfo", "authorgroup"); table_add("refentryinfo", "copyright"); 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");