version 1.3, 2019/04/28 19:59:01 |
version 1.5, 2019/05/01 09:02:25 |
|
|
*/ |
*/ |
|
|
static void |
static void |
reorg_root(struct pnode *root) |
reorg_root(struct pnode *root, const char *sec) |
{ |
{ |
struct pnode *date, *descr, *name, *vol, *nc; |
struct pnode *date, *info, *name, *vol, *nc; |
|
|
if (root == NULL) |
if (root == NULL) |
return; |
return; |
Line 53 reorg_root(struct pnode *root) |
|
Line 53 reorg_root(struct pnode *root) |
|
pnode_alloc_text(name, |
pnode_alloc_text(name, |
pnode_getattr_raw(root, ATTRKEY_ID, "UNKNOWN")); |
pnode_getattr_raw(root, ATTRKEY_ID, "UNKNOWN")); |
} |
} |
if (vol == NULL) { |
if (vol == NULL || sec != NULL) { |
|
pnode_unlink(vol); |
vol = pnode_alloc(NULL); |
vol = pnode_alloc(NULL); |
vol->node = NODE_MANVOLNUM; |
vol->node = NODE_MANVOLNUM; |
vol->parent = root; |
vol->parent = root; |
pnode_alloc_text(vol, "1"); |
pnode_alloc_text(vol, sec == NULL ? "1" : sec); |
} |
} |
|
|
/* Insert prologue information at the beginning. */ |
/* Insert prologue information at the beginning. */ |
|
|
if (pnode_findfirst(root, NODE_REFNAMEDIV) == NULL && |
if (pnode_findfirst(root, NODE_REFNAMEDIV) == NULL && |
((nc = pnode_findfirst(root, NODE_BOOKINFO)) != NULL || |
((info = pnode_findfirst(root, NODE_BOOKINFO)) != NULL || |
(nc = pnode_findfirst(root, NODE_REFENTRYINFO)) != NULL) && |
(info = pnode_findfirst(root, NODE_REFENTRYINFO)) != NULL)) { |
(descr = pnode_takefirst(nc, NODE_TITLE)) != NULL) |
if ((nc = pnode_takefirst(info, NODE_ABSTRACT)) != NULL) |
TAILQ_INSERT_HEAD(&root->childq, descr, child); |
TAILQ_INSERT_HEAD(&root->childq, nc, child); |
|
if ((nc = pnode_takefirst(info, NODE_TITLE)) != NULL) |
|
TAILQ_INSERT_HEAD(&root->childq, nc, child); |
|
} |
TAILQ_INSERT_HEAD(&root->childq, vol, child); |
TAILQ_INSERT_HEAD(&root->childq, vol, child); |
TAILQ_INSERT_HEAD(&root->childq, name, child); |
TAILQ_INSERT_HEAD(&root->childq, name, child); |
TAILQ_INSERT_HEAD(&root->childq, date, child); |
TAILQ_INSERT_HEAD(&root->childq, date, child); |
Line 215 reorg_recurse(struct pnode *n) |
|
Line 219 reorg_recurse(struct pnode *n) |
|
return; |
return; |
|
|
switch (n->node) { |
switch (n->node) { |
|
case NODE_ABSTRACT: |
|
default_title(n, "Abstract"); |
|
n->node = NODE_SECTION; |
|
break; |
case NODE_APPENDIX: |
case NODE_APPENDIX: |
if (n->parent == NULL) |
if (n->parent == NULL) |
reorg_refentry(n); |
reorg_refentry(n); |
Line 264 reorg_recurse(struct pnode *n) |
|
Line 272 reorg_recurse(struct pnode *n) |
|
} |
} |
|
|
void |
void |
ptree_reorg(struct ptree *tree) |
ptree_reorg(struct ptree *tree, const char *sec) |
{ |
{ |
reorg_root(tree->root); |
reorg_root(tree->root, sec); |
reorg_recurse(tree->root); |
reorg_recurse(tree->root); |
} |
} |