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

Diff for /docbook2mdoc/macro.c between version 1.1 and 1.2

version 1.1, 2019/03/26 19:17:29 version 1.2, 2019/03/28 20:41:33
Line 157  macro_addnode(struct format *f, struct pnode *pn, int 
Line 157  macro_addnode(struct format *f, struct pnode *pn, int 
         assert(f->linestate == LINE_MACRO);          assert(f->linestate == LINE_MACRO);
   
         /*          /*
          * If the only child is a text node, just add that text,           * If this node or its only child is a text node, just add
          * letting macro_addarg() decide about quoting.           * that text, letting macro_addarg() decide about quoting.
          */           */
   
         pn = TAILQ_FIRST(&pn->childq);          if (pn->node == NODE_TEXT ||
         if (pn != NULL && pn->node == NODE_TEXT &&              ((pn = TAILQ_FIRST(&pn->childq)) != NULL &&
             TAILQ_NEXT(pn, child) == NULL) {               pn->node == NODE_TEXT && TAILQ_NEXT(pn, child) == NULL)) {
                 macro_addarg(f, pn->b, flags);                  macro_addarg(f, pn->b, flags);
                 return;                  return;
         }          }
Line 193  macro_addnode(struct format *f, struct pnode *pn, int 
Line 193  macro_addnode(struct format *f, struct pnode *pn, int 
          */           */
   
         while (pn != NULL) {          while (pn != NULL) {
                 if (pn->node == NODE_TEXT)                  macro_addnode(f, pn, flags);
                         macro_addarg(f, pn->b, flags);  
                 else  
                         macro_addnode(f, pn, flags);  
                 pn = TAILQ_NEXT(pn, child);                  pn = TAILQ_NEXT(pn, child);
                 flags |= ARG_SPACE;                  flags |= ARG_SPACE;
         }          }
Line 210  macro_nodeline(struct format *f, const char *name, str
Line 207  macro_nodeline(struct format *f, const char *name, str
         macro_open(f, name);          macro_open(f, name);
         macro_addnode(f, pn, ARG_SPACE | flags);          macro_addnode(f, pn, ARG_SPACE | flags);
         macro_close(f);          macro_close(f);
   }
   
   
   /*
    * Print a word on the current text line if one is open, or on a new text
    * line otherwise.  The flag ARG_SPACE inserts spaces between words.
    */
   void
   print_text(struct format *f, const char *word, int flags) {
           switch (f->linestate) {
           case LINE_NEW:
                   break;
           case LINE_TEXT:
                   if (flags & ARG_SPACE)
                           putchar(' ');
                   break;
           case LINE_MACRO:
                   macro_close(f);
                   break;
           }
           fputs(word, stdout);
           f->linestate = LINE_TEXT;
   }
   
   /*
    * Recursively print the content of a node on a text line.
    */
   void
   print_textnode(struct format *f, struct pnode *n)
   {
           struct pnode    *nc;
   
           if (n->node == NODE_TEXT)
                   print_text(f, n->b, ARG_SPACE);
           else
                   TAILQ_FOREACH(nc, &n->childq, child)
                           print_textnode(f, nc);
 }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

CVSweb