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

Diff for /mandoc/mdoc.c between version 1.12 and 1.13

version 1.12, 2008/12/30 19:06:03 version 1.13, 2009/01/01 20:40:16
Line 84  const char *const __mdoc_argnames[MDOC_ARG_MAX] = {   
Line 84  const char *const __mdoc_argnames[MDOC_ARG_MAX] = {   
   
 const   struct mdoc_macro __mdoc_macros[MDOC_MAX] = {  const   struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
         { NULL, 0 }, /* \" */          { NULL, 0 }, /* \" */
         { macro_prologue_ddate, 0 }, /* Dd */          { NULL, MDOC_PROLOGUE }, /* Dd */
         { macro_prologue_dtitle, 0 }, /* Dt */          { NULL, MDOC_PROLOGUE }, /* Dt */
         { macro_prologue_os, 0 }, /* Os */          { NULL, MDOC_PROLOGUE }, /* Os */
         { macro_scoped_implicit, 0 }, /* Sh */          { macro_scoped, 0 }, /* Sh */
         { macro_scoped_implicit, 0 }, /* Ss */          { macro_scoped, 0 }, /* Ss */
         { macro_text, 0 }, /* Pp */          { macro_text, 0 }, /* Pp */
         { macro_scoped_line, 0 }, /* D1 */          { macro_scoped_line, 0 }, /* D1 */
         { macro_scoped_line, 0 }, /* Dl */          { macro_scoped_line, 0 }, /* Dl */
         { macro_scoped_explicit, MDOC_EXPLICIT }, /* Bd */          { macro_scoped, MDOC_EXPLICIT }, /* Bd */
         { macro_scoped_explicit, 0 }, /* Ed */          { macro_close_explicit, 0 }, /* Ed */
         { macro_scoped_explicit, MDOC_EXPLICIT }, /* Bl */          { macro_scoped, MDOC_EXPLICIT }, /* Bl */
         { macro_scoped_explicit, 0 }, /* El */          { macro_close_explicit, 0 }, /* El */
         { NULL, 0 }, /* It */          { NULL, 0 }, /* It */
         { macro_text, MDOC_CALLABLE }, /* Ad */          { macro_text, MDOC_CALLABLE }, /* Ad */
         { NULL, 0 }, /* An */          { NULL, 0 }, /* An */
Line 105  const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
Line 105  const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
         { macro_text, MDOC_CALLABLE }, /* Dv */          { macro_text, MDOC_CALLABLE }, /* Dv */
         { macro_text, MDOC_CALLABLE }, /* Er */          { macro_text, MDOC_CALLABLE }, /* Er */
         { macro_text, MDOC_CALLABLE }, /* Ev */          { macro_text, MDOC_CALLABLE }, /* Ev */
         { macro_constant_argv, 0 }, /* Ex */          { macro_constant, 0 }, /* Ex */
         { macro_text, MDOC_CALLABLE }, /* Fa */          { macro_text, MDOC_CALLABLE }, /* Fa */
         { NULL, 0 }, /* Fd */          { macro_constant, 0 }, /* Fd */
         { macro_text, MDOC_CALLABLE }, /* Fl */          { macro_text, MDOC_CALLABLE }, /* Fl */
         { macro_text, MDOC_CALLABLE | MDOC_QUOTABLE }, /* Fn */          { macro_text, MDOC_CALLABLE | MDOC_QUOTABLE }, /* Fn */
         { macro_text, 0 }, /* Ft */          { macro_text, 0 }, /* Ft */
         { macro_text, MDOC_CALLABLE }, /* Ic */          { macro_text, MDOC_CALLABLE }, /* Ic */
         { NULL, 0 }, /* In */          { macro_constant, 0 }, /* In */
         { macro_text, MDOC_CALLABLE }, /* Li */          { macro_text, MDOC_CALLABLE }, /* Li */
         { macro_constant, 0 }, /* Nd */          { macro_constant, 0 }, /* Nd */
         { NULL, 0 }, /* Nm */          { NULL, 0 }, /* Nm */
         { NULL, 0 }, /* Op */          { macro_scoped_line, MDOC_CALLABLE }, /* Op */
         { NULL, 0 }, /* Ot */          { macro_obsolete, 0 }, /* Ot */
         { macro_text, MDOC_CALLABLE }, /* Pa */          { macro_text, MDOC_CALLABLE }, /* Pa */
         { macro_constant_argv, 0 }, /* Rv */          { macro_constant, 0 }, /* Rv */
         { NULL, 0 }, /* St */          { macro_constant, 0 }, /* St */
         { macro_text, MDOC_CALLABLE }, /* Va */          { macro_text, MDOC_CALLABLE }, /* Va */
         { macro_text, MDOC_CALLABLE }, /* Vt */          { macro_text, MDOC_CALLABLE }, /* Vt */
         { NULL, 0 }, /* Xr */          { macro_text, MDOC_CALLABLE }, /* Xr */
         { NULL, 0 }, /* %A */          { macro_constant, MDOC_QUOTABLE }, /* %A */
         { NULL, 0 }, /* %B */          { macro_constant, MDOC_QUOTABLE }, /* %B */
         { NULL, 0 }, /* %D */          { macro_constant, MDOC_QUOTABLE }, /* %D */
         { NULL, 0 }, /* %I */          { macro_constant, MDOC_QUOTABLE }, /* %I */
         { NULL, 0 }, /* %J */          { macro_constant, MDOC_QUOTABLE }, /* %J */
         { NULL, 0 }, /* %N */          { macro_constant, MDOC_QUOTABLE }, /* %N */
         { NULL, 0 }, /* %O */          { macro_constant, MDOC_QUOTABLE }, /* %O */
         { NULL, 0 }, /* %P */          { macro_constant, MDOC_QUOTABLE }, /* %P */
         { NULL, 0 }, /* %R */          { macro_constant, MDOC_QUOTABLE }, /* %R */
         { NULL, 0 }, /* %T */          { macro_constant, MDOC_QUOTABLE }, /* %T */
         { NULL, 0 }, /* %V */          { macro_constant, MDOC_QUOTABLE }, /* %V */
         { NULL, 0 }, /* Ac */          { NULL, 0 }, /* Ac */
         { NULL, 0 }, /* Ao */          { NULL, 0 }, /* Ao */
         { macro_scoped_pline, MDOC_CALLABLE }, /* Aq */          { macro_scoped_line, MDOC_CALLABLE }, /* Aq */
         { macro_constant, 0 }, /* At */          { macro_constant, 0 }, /* At */
         { NULL, 0 }, /* Bc */          { NULL, 0 }, /* Bc */
         { NULL, 0 }, /* Bf */          { NULL, 0 }, /* Bf */
         { NULL, 0 }, /* Bo */          { NULL, 0 }, /* Bo */
         { macro_scoped_pline, MDOC_CALLABLE }, /* Bq */          { macro_scoped_line, MDOC_CALLABLE }, /* Bq */
         { macro_constant_delimited, 0 }, /* Bsx */          { macro_constant_delimited, 0 }, /* Bsx */
         { macro_constant_delimited, 0 }, /* Bx */          { macro_constant_delimited, 0 }, /* Bx */
         { NULL, 0 }, /* Db */          { macro_constant, 0 }, /* Db */
         { NULL, 0 }, /* Dc */          { NULL, 0 }, /* Dc */
         { NULL, 0 }, /* Do */          { NULL, 0 }, /* Do */
         { macro_scoped_pline, MDOC_CALLABLE }, /* Dq */          { macro_scoped_line, MDOC_CALLABLE }, /* Dq */
         { NULL, 0 }, /* Ec */          { NULL, 0 }, /* Ec */
         { NULL, 0 }, /* Ef */          { NULL, 0 }, /* Ef */
         { macro_text, MDOC_CALLABLE }, /* Em */          { macro_text, MDOC_CALLABLE }, /* Em */
         { NULL, 0 }, /* Eo */          { NULL, 0 }, /* Eo */
         { macro_constant_delimited, 0 }, /* Fx */          { macro_constant_delimited, 0 }, /* Fx */
         { macro_text, 0 }, /* Ms */          { macro_text, 0 }, /* Ms */
         { NULL, 0 }, /* No */          { macro_constant_delimited, MDOC_CALLABLE }, /* No */
         { NULL, 0 }, /* Ns */          { macro_constant_delimited, MDOC_CALLABLE }, /* Ns */
         { macro_constant_delimited, 0 }, /* Nx */          { macro_constant_delimited, 0 }, /* Nx */
         { macro_constant_delimited, 0 }, /* Ox */          { macro_constant_delimited, 0 }, /* Ox */
         { NULL, 0 }, /* Pc */          { NULL, 0 }, /* Pc */
         { NULL, 0 }, /* Pf */          { NULL, 0 }, /* Pf */
         { NULL, 0 }, /* Po */          { NULL, 0 }, /* Po */
         { macro_scoped_pline, MDOC_CALLABLE }, /* Pq */          { macro_scoped_line, MDOC_CALLABLE }, /* Pq */
         { NULL, 0 }, /* Qc */          { NULL, 0 }, /* Qc */
         { macro_scoped_pline, MDOC_CALLABLE }, /* Ql */          { macro_scoped_line, MDOC_CALLABLE }, /* Ql */
         { NULL, 0 }, /* Qo */          { NULL, 0 }, /* Qo */
         { macro_scoped_pline, MDOC_CALLABLE }, /* Qq */          { macro_scoped_line, MDOC_CALLABLE }, /* Qq */
         { NULL, 0 }, /* Re */          { macro_scoped, MDOC_EXPLICIT }, /* Re */
         { NULL, 0 }, /* Rs */          { macro_scoped, MDOC_EXPLICIT }, /* Rs */
         { NULL, 0 }, /* Sc */          { NULL, 0 }, /* Sc */
         { NULL, 0 }, /* So */          { NULL, 0 }, /* So */
         { macro_scoped_pline, MDOC_CALLABLE }, /* Sq */          { macro_scoped_line, MDOC_CALLABLE }, /* Sq */
         { NULL, 0 }, /* Sm */          { macro_constant, 0 }, /* Sm */
         { macro_text, MDOC_CALLABLE }, /* Sx */          { macro_text, MDOC_CALLABLE }, /* Sx */
         { macro_text, MDOC_CALLABLE }, /* Sy */          { macro_text, MDOC_CALLABLE }, /* Sy */
         { macro_text, MDOC_CALLABLE }, /* Tn */          { macro_text, MDOC_CALLABLE }, /* Tn */
Line 254  mdoc_parseln(struct mdoc *mdoc, char *buf)
Line 254  mdoc_parseln(struct mdoc *mdoc, char *buf)
   
         if ('.' != *buf) {          if ('.' != *buf) {
                 mdoc_word_alloc(mdoc, 0, buf);                  mdoc_word_alloc(mdoc, 0, buf);
                   mdoc->next = MDOC_NEXT_SIBLING;
                 return(1);                  return(1);
         }          }
   
Line 326  int
Line 327  int
 mdoc_macro(struct mdoc *mdoc, int tok, int ppos, int *pos, char *buf)  mdoc_macro(struct mdoc *mdoc, int tok, int ppos, int *pos, char *buf)
 {  {
   
           if (MDOC_PROLOGUE & mdoc_macros[tok].flags &&
                           SEC_PROLOGUE == mdoc->sec_lastn)
                   return(macro_prologue(mdoc, tok, ppos, pos, buf));
   
           if (SEC_PROLOGUE == mdoc->sec_lastn)
                   return(mdoc_err(mdoc, tok, ppos, ERR_SEC_PROLOGUE));
   
         if (NULL == (mdoc_macros[tok].fp)) {          if (NULL == (mdoc_macros[tok].fp)) {
                 (void)mdoc_err(mdoc, tok, ppos, ERR_MACRO_NOTSUP);                  (void)mdoc_err(mdoc, tok, ppos, ERR_MACRO_NOTSUP);
                 return(0);                  return(0);
Line 336  mdoc_macro(struct mdoc *mdoc, int tok, int ppos, int *
Line 344  mdoc_macro(struct mdoc *mdoc, int tok, int ppos, int *
                 return(0);                  return(0);
         }          }
   
         /*mdoc_msg(mdoc, ppos, "calling `%s'", mdoc_macronames[tok]);*/  
   
         return((*mdoc_macros[tok].fp)(mdoc, tok, ppos, pos, buf));          return((*mdoc_macros[tok].fp)(mdoc, tok, ppos, pos, buf));
 }  }
   
Line 407  mdoc_node_append(struct mdoc *mdoc, int pos, struct md
Line 413  mdoc_node_append(struct mdoc *mdoc, int pos, struct md
                 /* NOTREACHED */                  /* NOTREACHED */
         }          }
   
         switch (p->type) {          switch (mdoc->next) {
         case (MDOC_BODY):          case (MDOC_NEXT_SIBLING):
                 p->parent = mdoc->last->parent;  
                 mdoc->last->next = p;                  mdoc->last->next = p;
                 p->prev = mdoc->last;                  p->prev = mdoc->last;
                   p->parent = mdoc->last->parent;
                 act = "sibling";                  act = "sibling";
                 break;                  break;
           case (MDOC_NEXT_CHILD):
         case (MDOC_HEAD):  
                 assert(mdoc->last->type == MDOC_BLOCK);  
                 p->parent = mdoc->last;  
                 mdoc->last->child = p;                  mdoc->last->child = p;
                   p->parent = mdoc->last;
                 act = "child";                  act = "child";
                 break;                  break;
   
         default:          default:
                 switch (mdoc->last->type) {                  abort();
                 case (MDOC_BODY):                  /* NOTREACHED */
                         /* FALLTHROUGH */  
                 case (MDOC_HEAD):  
                         p->parent = mdoc->last;  
                         mdoc->last->child = p;  
                         act = "child";  
                         break;  
                 default:  
                         p->parent = mdoc->last->parent;  
                         p->prev = mdoc->last;  
                         mdoc->last->next = p;  
                         act = "sibling";  
                         break;  
                 }  
                 break;  
         }          }
   
         mdoc_msg(mdoc, pos, "parse: %s `%s' %s %s `%s'",          mdoc_msg(mdoc, pos, "parse: %s `%s' %s of %s `%s'",
                         nt, nn, act, ot, on);                          nt, nn, act, ot, on);
   
         mdoc->last = p;          mdoc->last = p;
 }  }
   
   
 /* FIXME: deprecate paramsz, params. */  
 void  void
 mdoc_head_alloc(struct mdoc *mdoc, int pos, int tok,  mdoc_head_alloc(struct mdoc *mdoc, int pos, int tok)
                 size_t paramsz, const char **params)  
 {  {
         struct mdoc_node *p;          struct mdoc_node *p;
   
         assert(mdoc->first);          assert(mdoc->first);
         assert(mdoc->last);          assert(mdoc->last);
         assert(mdoc->last->type == MDOC_BLOCK);  
         assert(mdoc->last->data.block.tok == tok);  
   
         p = xcalloc(1, sizeof(struct mdoc_node));          p = xcalloc(1, sizeof(struct mdoc_node));
   
         p->type = MDOC_HEAD;          p->type = MDOC_HEAD;
         p->data.head.tok = tok;          p->data.head.tok = tok;
         p->data.head.sz = paramsz;  
         p->data.head.args = paramdup(paramsz, params);  
   
         mdoc_node_append(mdoc, pos, p);          mdoc_node_append(mdoc, pos, p);
 }  }
Line 476  mdoc_body_alloc(struct mdoc *mdoc, int pos, int tok)
Line 461  mdoc_body_alloc(struct mdoc *mdoc, int pos, int tok)
   
         assert(mdoc->first);          assert(mdoc->first);
         assert(mdoc->last);          assert(mdoc->last);
         assert((mdoc->last->type == MDOC_BLOCK) ||  
                         (mdoc->last->type == MDOC_HEAD));  
         if (mdoc->last->type == MDOC_BLOCK)  
                 assert(mdoc->last->data.block.tok == tok);  
         else  
                 assert(mdoc->last->data.head.tok == tok);  
   
         p = xcalloc(1, sizeof(struct mdoc_node));          p = xcalloc(1, sizeof(struct mdoc_node));
   
Line 588  mdoc_text_free(struct mdoc_text *p)
Line 567  mdoc_text_free(struct mdoc_text *p)
 }  }
   
   
 static void  
 mdoc_head_free(struct mdoc_head *p)  
 {  
   
         paramfree(p->sz, p->args);  
 }  
   
   
 void  void
 mdoc_node_free(struct mdoc_node *p)  mdoc_node_free(struct mdoc_node *p)
 {  {
Line 609  mdoc_node_free(struct mdoc_node *p)
Line 580  mdoc_node_free(struct mdoc_node *p)
                 break;                  break;
         case (MDOC_BLOCK):          case (MDOC_BLOCK):
                 mdoc_block_free(&p->data.block);                  mdoc_block_free(&p->data.block);
                 break;  
         case (MDOC_HEAD):  
                 mdoc_head_free(&p->data.head);  
                 break;                  break;
         default:          default:
                 break;                  break;

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

CVSweb