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

Diff for /docbook2mdoc/docbook2mdoc.c between version 1.36 and 1.37

version 1.36, 2014/04/30 10:11:24 version 1.37, 2014/04/30 12:34:44
Line 64  struct pattr {
Line 64  struct pattr {
 struct  pnode {  struct  pnode {
         enum nodeid      node; /* node type */          enum nodeid      node; /* node type */
         char            *b; /* binary data buffer */          char            *b; /* binary data buffer */
           char            *real; /* store for "b" */
         size_t           bsz; /* data buffer size */          size_t           bsz; /* data buffer size */
         struct pnode    *parent; /* parent (or NULL if top) */          struct pnode    *parent; /* parent (or NULL if top) */
         struct pnodeq    childq; /* queue of children */          struct pnodeq    childq; /* queue of children */
Line 233  xml_char(void *arg, const XML_Char *p, int sz)
Line 234  xml_char(void *arg, const XML_Char *p, int sz)
         }          }
         memcpy(ps->cur->b + ps->cur->bsz, p, sz);          memcpy(ps->cur->b + ps->cur->bsz, p, sz);
         ps->cur->bsz += (size_t)sz;          ps->cur->bsz += (size_t)sz;
           ps->cur->real = ps->cur->b;
 }  }
   
 static void  static void
Line 436  pnode_free(struct pnode *pn)
Line 438  pnode_free(struct pnode *pn)
                 free(ap);                  free(ap);
         }          }
   
         free(pn->b);          free(pn->real);
         free(pn);          free(pn);
 }  }
   
Line 620  pnode_printmclose(struct parse *p, int sv)
Line 622  pnode_printmclose(struct parse *p, int sv)
 }  }
   
 /*  /*
    * Like pnode_printmclose() except we look to the next node, and, if
    * found, see if it starts with punctuation.
    * If it does, then we print that punctuation before the newline.
    */
   static void
   pnode_printmclosepunct(struct parse *p, struct pnode *pn, int sv)
   {
           /* We wouldn't have done anything anyway. */
           if ( ! (sv && ! p->newln))
                   return;
   
           /* No next node or it's not text. */
           if (NULL == (pn = TAILQ_NEXT(pn, child))) {
                   pnode_printmclose(p, sv);
                   return;
           } else if (NODE_TEXT != pn->node) {
                   pnode_printmclose(p, sv);
                   return;
           }
   
           /* Only do this for the comma/period. */
           if (pn->bsz > 0 &&
                   (',' == pn->b[0] || '.' == pn->b[0]) &&
                   (1 == pn->bsz || isspace((int)pn->b[1]))) {
                   putchar(' ');
                   putchar(pn->b[0]);
                   pn->b++;
                   pn->bsz--;
           }
   
           putchar('\n');
           p->newln = 1;
   }
   
   /*
  * If the SYNOPSIS macro has a superfluous title, kill it.   * If the SYNOPSIS macro has a superfluous title, kill it.
  */   */
 static void  static void
Line 1251  pnode_print(struct parse *p, struct pnode *pn)
Line 1288  pnode_print(struct parse *p, struct pnode *pn)
         case (NODE_TEXT):          case (NODE_TEXT):
                 if (0 == p->newln)                  if (0 == p->newln)
                         putchar(' ');                          putchar(' ');
   
                 bufclear(p);                  bufclear(p);
                 bufappend(p, pn);                  bufappend(p, pn);
   
                   if (0 == p->bsz) {
                           assert(pn->real != pn->b);
                           break;
                   }
   
                 /*                  /*
                  * Output all characters, squeezing out whitespace                   * Output all characters, squeezing out whitespace
                  * between newlines.                   * between newlines.
Line 1261  pnode_print(struct parse *p, struct pnode *pn)
Line 1305  pnode_print(struct parse *p, struct pnode *pn)
                  */                   */
                 assert(p->bsz);                  assert(p->bsz);
                 cp = p->b;                  cp = p->b;
   
                 /*                  /*
                  * There's often a superfluous "-" in its <option> tags                   * There's often a superfluous "-" in its <option> tags
                  * before the actual flags themselves.                   * before the actual flags themselves.
Line 1333  pnode_print(struct parse *p, struct pnode *pn)
Line 1378  pnode_print(struct parse *p, struct pnode *pn)
         case (NODE_TEXT):          case (NODE_TEXT):
         case (NODE_USERINPUT):          case (NODE_USERINPUT):
         case (NODE_VARNAME):          case (NODE_VARNAME):
                 pnode_printmclose(p, sv);                  pnode_printmclosepunct(p, pn, sv);
                 break;                  break;
         case (NODE_QUOTE):          case (NODE_QUOTE):
                 pnode_printmclose(p, sv);                  pnode_printmclose(p, sv);

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.37

CVSweb