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

Diff for /docbook2mdoc/docbook2mdoc.c between version 1.145 and 1.148

version 1.145, 2019/05/01 12:52:05 version 1.148, 2019/05/02 04:15:40
Line 40  pnode_printtext(struct format *f, struct pnode *n)
Line 40  pnode_printtext(struct format *f, struct pnode *n)
         char            *cp;          char            *cp;
         int              accept_arg;          int              accept_arg;
   
           para_check(f);
         cp = n->b;          cp = n->b;
         accept_arg = f->flags & FMT_ARG;          accept_arg = f->flags & FMT_ARG;
         if (f->linestate == LINE_MACRO && !accept_arg &&          if (f->linestate == LINE_MACRO && !accept_arg &&
Line 54  pnode_printtext(struct format *f, struct pnode *n)
Line 55  pnode_printtext(struct format *f, struct pnode *n)
                 if (isspace((unsigned char)*cp)) {                  if (isspace((unsigned char)*cp)) {
                         while (isspace((unsigned char)*cp))                          while (isspace((unsigned char)*cp))
                                 cp++;                                  cp++;
                         macro_close(f);                          n->flags |= NFLAG_SPC;
                 } else {                  } else {
                         fputs(" Ns", stdout);                          f->flags &= ~FMT_NOSPC;
                         f->flags &= FMT_IMPL;                          f->flags |= FMT_CHILD;
                           macro_open(f, "Ns");
                           f->flags &= ~FMT_ARG;
                           f->flags |= FMT_CHILD;
                         accept_arg = 1;                          accept_arg = 1;
                 }                  }
         }          }
         if (f->linestate == LINE_MACRO && !accept_arg &&          if (f->linestate == LINE_MACRO && f->nofill == 0 &&
             (f->flags & (FMT_CHILD | FMT_IMPL)) == 0)              !accept_arg && (f->flags & FMT_IMPL) == 0)
                 macro_close(f);                  macro_close(f);
   
         /*          /*
Line 71  pnode_printtext(struct format *f, struct pnode *n)
Line 75  pnode_printtext(struct format *f, struct pnode *n)
          * Set the spacing flag to avoid a redundant .Ns macro.           * Set the spacing flag to avoid a redundant .Ns macro.
          */           */
   
         if (f->linestate != LINE_MACRO &&          if ((f->nofill || f->linestate != LINE_MACRO) &&
             (nn = TAILQ_NEXT(n, child)) != NULL &&              (nn = TAILQ_NEXT(n, child)) != NULL &&
              (nn->flags & NFLAG_SPC) == 0) {               (nn->flags & NFLAG_SPC) == 0) {
                 switch (pnode_class(nn->node)) {                  switch (pnode_class(nn->node)) {
Line 100  pnode_printtext(struct format *f, struct pnode *n)
Line 104  pnode_printtext(struct format *f, struct pnode *n)
                 }                  }
                 break;                  break;
         case LINE_MACRO:          case LINE_MACRO:
                 if (accept_arg == 0)                  if (accept_arg == 0) {
                         macro_close(f);                          if (f->nofill) {
                 else if (n->flags & NFLAG_SPC ||                                  f->flags &= ~FMT_NOSPC;
                                   f->flags |= FMT_CHILD;
                                   macro_open(f, "No ");
                                   f->flags &= ~FMT_ARG;
                                   f->flags |= FMT_CHILD;
                           } else
                                   macro_close(f);
                   } else if (n->flags & NFLAG_SPC ||
                     (f->flags & FMT_ARG) == 0 ||                      (f->flags & FMT_ARG) == 0 ||
                     (nn = TAILQ_PREV(n, pnodeq, child)) == NULL ||                      (nn = TAILQ_PREV(n, pnodeq, child)) == NULL ||
                     pnode_class(nn->node) != CLASS_TEXT)                      pnode_class(nn->node) != CLASS_TEXT)
Line 930  pnode_print(struct format *f, struct pnode *n)
Line 941  pnode_print(struct format *f, struct pnode *n)
         if (n == NULL)          if (n == NULL)
                 return;                  return;
   
           if (n->flags & NFLAG_LINE &&
               (f->nofill || (f->flags & (FMT_ARG | FMT_IMPL)) == 0))
                   macro_close(f);
   
         was_impl = f->flags & FMT_IMPL;          was_impl = f->flags & FMT_IMPL;
         if (n->flags & NFLAG_SPC)          if (n->flags & NFLAG_SPC)
                 f->flags &= ~FMT_NOSPC;                  f->flags &= ~FMT_NOSPC;
Line 1193  pnode_print(struct format *f, struct pnode *n)
Line 1208  pnode_print(struct format *f, struct pnode *n)
                 break;                  break;
         }          }
   
           if (pnode_class(n->node) == CLASS_NOFILL)
                   f->nofill++;
   
         TAILQ_FOREACH(nc, &n->childq, child)          TAILQ_FOREACH(nc, &n->childq, child)
                 pnode_print(f, nc);                  pnode_print(f, nc);
   
Line 1306  pnode_print(struct format *f, struct pnode *n)
Line 1324  pnode_print(struct format *f, struct pnode *n)
                 break;                  break;
         }          }
         f->flags &= ~FMT_ARG;          f->flags &= ~FMT_ARG;
           if (pnode_class(n->node) == CLASS_NOFILL)
                   f->nofill--;
 }  }
   
 void  void
Line 1313  ptree_print_mdoc(struct ptree *tree)
Line 1333  ptree_print_mdoc(struct ptree *tree)
 {  {
         struct format    formatter;          struct format    formatter;
   
         formatter.level = 0;          formatter.level = formatter.nofill = 0;
         formatter.linestate = LINE_NEW;          formatter.linestate = LINE_NEW;
         formatter.parastate = PARA_HAVE;          formatter.parastate = PARA_HAVE;
         pnode_printprologue(&formatter, tree->root);          pnode_printprologue(&formatter, tree->root);

Legend:
Removed from v.1.145  
changed lines
  Added in v.1.148

CVSweb