=================================================================== RCS file: /cvs/docbook2mdoc/statistics.c,v retrieving revision 1.36 retrieving revision 1.39 diff -u -p -r1.36 -r1.39 --- docbook2mdoc/statistics.c 2019/04/25 17:57:59 1.36 +++ docbook2mdoc/statistics.c 2019/04/29 02:00:50 1.39 @@ -1,4 +1,4 @@ -/* $Id: statistics.c,v 1.36 2019/04/25 17:57:59 schwarze Exp $ */ +/* $Id: statistics.c,v 1.39 2019/04/29 02:00:50 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); } /* @@ -371,6 +366,7 @@ main(int argc, char *argv[]) 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"); @@ -378,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"); @@ -399,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"); @@ -466,6 +464,7 @@ main(int argc, char *argv[]) table_add("itemizedlist", "listitem"); table_add("keycap", "TEXT"); table_add("keycode", "TEXT"); + table_add("keycombo", "keycap"); table_add("keysym", "TEXT"); table_add("legalnotice", NULL); table_add("link", NULL);