[BACK]Return to reorg.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / docbook2mdoc

Diff for /docbook2mdoc/reorg.c between version 1.4 and 1.6

version 1.4, 2019/04/28 20:26:49 version 1.6, 2019/05/01 11:03:31
Line 24 
Line 24 
  */   */
   
 static void  static void
 reorg_root(struct pnode *root)  reorg_root(struct pnode *root, const char *sec)
 {  {
         struct pnode    *date, *info, *name, *vol, *nc;          struct pnode    *date, *info, *name, *vol, *nc;
   
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. */
Line 210  default_title(struct pnode *n, const char *title)
Line 211  default_title(struct pnode *n, const char *title)
 }  }
   
 static void  static void
   reorg_function(struct pnode *n)
   {
           struct pnode    *nc;
           size_t           sz;
   
           if ((nc = TAILQ_FIRST(&n->childq)) != NULL &&
               nc->node == NODE_TEXT &&
               TAILQ_NEXT(nc, child) == NULL &&
               (sz = strlen(nc->b)) > 2 &&
               nc->b[sz - 2] == '(' && nc->b[sz - 1] == ')')
                   nc->b[sz - 2] = '\0';
   }
   
   static void
 reorg_recurse(struct pnode *n)  reorg_recurse(struct pnode *n)
 {  {
         struct pnode    *nc;          struct pnode    *nc;
Line 231  reorg_recurse(struct pnode *n)
Line 246  reorg_recurse(struct pnode *n)
                 default_title(n, "Caution");                  default_title(n, "Caution");
                 n->node = NODE_NOTE;                  n->node = NODE_NOTE;
                 break;                  break;
           case NODE_FUNCTION:
                   reorg_function(n);
                   break;
         case NODE_LEGALNOTICE:          case NODE_LEGALNOTICE:
                 default_title(n, "Legal Notice");                  default_title(n, "Legal Notice");
                 n->node = NODE_SIMPLESECT;                  n->node = NODE_SIMPLESECT;
Line 271  reorg_recurse(struct pnode *n)
Line 289  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);
 }  }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.6

CVSweb