=================================================================== RCS file: /cvs/docbook2mdoc/node.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -p -r1.6 -r1.7 --- docbook2mdoc/node.c 2019/04/09 01:39:09 1.6 +++ docbook2mdoc/node.c 2019/04/10 14:22:37 1.7 @@ -1,4 +1,4 @@ -/* $Id: node.c,v 1.6 2019/04/09 01:39:09 schwarze Exp $ */ +/* $Id: node.c,v 1.7 2019/04/10 14:22:37 schwarze Exp $ */ /* * Copyright (c) 2014 Kristaps Dzonsons * Copyright (c) 2019 Ingo Schwarze @@ -78,48 +78,48 @@ attrval_parse(const char *name) * Recursively free a node (NULL is ok). */ static void -pnode_free(struct pnode *pn) +pnode_free(struct pnode *n) { - struct pnode *pch; - struct pattr *ap; + struct pnode *nc; + struct pattr *a; - if (pn == NULL) + if (n == NULL) return; - while ((pch = TAILQ_FIRST(&pn->childq)) != NULL) { - TAILQ_REMOVE(&pn->childq, pch, child); - pnode_free(pch); + while ((nc = TAILQ_FIRST(&n->childq)) != NULL) { + TAILQ_REMOVE(&n->childq, nc, child); + pnode_free(nc); } - while ((ap = TAILQ_FIRST(&pn->attrq)) != NULL) { - TAILQ_REMOVE(&pn->attrq, ap, child); - free(ap->rawval); - free(ap); + while ((a = TAILQ_FIRST(&n->attrq)) != NULL) { + TAILQ_REMOVE(&n->attrq, a, child); + free(a->rawval); + free(a); } - free(pn->real); - free(pn); + free(n->real); + free(n); } /* * Unlink a node from its parent and pnode_free() it. */ void -pnode_unlink(struct pnode *pn) +pnode_unlink(struct pnode *n) { - if (pn == NULL) + if (n == NULL) return; - if (pn->parent != NULL) - TAILQ_REMOVE(&pn->parent->childq, pn, child); - pnode_free(pn); + if (n->parent != NULL) + TAILQ_REMOVE(&n->parent->childq, n, child); + pnode_free(n); } /* * Unlink all children of a node and pnode_free() them. */ void -pnode_unlinksub(struct pnode *pn) +pnode_unlinksub(struct pnode *n) { - while (TAILQ_EMPTY(&pn->childq) == 0) - pnode_unlink(TAILQ_FIRST(&pn->childq)); + while (TAILQ_EMPTY(&n->childq) == 0) + pnode_unlink(TAILQ_FIRST(&n->childq)); } /* @@ -127,15 +127,15 @@ pnode_unlinksub(struct pnode *pn) * Return ATTRVAL__MAX if the node has no such attribute. */ enum attrval -pnode_getattr(struct pnode *pn, enum attrkey key) +pnode_getattr(struct pnode *n, enum attrkey key) { - struct pattr *ap; + struct pattr *a; - if (pn == NULL) + if (n == NULL) return ATTRVAL__MAX; - TAILQ_FOREACH(ap, &pn->attrq, child) - if (ap->key == key) - return ap->val; + TAILQ_FOREACH(a, &n->attrq, child) + if (a->key == key) + return a->val; return ATTRVAL__MAX; } @@ -144,16 +144,16 @@ pnode_getattr(struct pnode *pn, enum attrkey key) * Return defval if the node has no such attribute. */ const char * -pnode_getattr_raw(struct pnode *pn, enum attrkey key, const char *defval) +pnode_getattr_raw(struct pnode *n, enum attrkey key, const char *defval) { - struct pattr *ap; + struct pattr *a; - if (pn == NULL) + if (n == NULL) return defval; - TAILQ_FOREACH(ap, &pn->attrq, child) - if (ap->key == key) - return ap->val != ATTRVAL__MAX ? attrvals[ap->val] : - ap->rawval != NULL ? ap->rawval : defval; + TAILQ_FOREACH(a, &n->attrq, child) + if (a->key == key) + return a->val != ATTRVAL__MAX ? attrvals[a->val] : + a->rawval != NULL ? a->rawval : defval; return defval; } @@ -161,14 +161,14 @@ pnode_getattr_raw(struct pnode *pn, enum attrkey key, * Recursively search and return the first instance of "node". */ struct pnode * -pnode_findfirst(struct pnode *pn, enum nodeid node) +pnode_findfirst(struct pnode *n, enum nodeid node) { - struct pnode *pch, *res; + struct pnode *nc, *res; - if (pn->node == node) - return pn; - TAILQ_FOREACH(pch, &pn->childq, child) - if ((res = pnode_findfirst(pch, node)) != NULL) + if (n->node == node) + return n; + TAILQ_FOREACH(nc, &n->childq, child) + if ((res = pnode_findfirst(nc, node)) != NULL) return res; return NULL; }