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

Diff for /mandoc/mdoc_validate.c between version 1.283 and 1.284

version 1.283, 2015/02/23 13:55:55 version 1.284, 2015/04/02 21:36:50
Line 8 
Line 8 
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
  * copyright notice and this permission notice appear in all copies.   * copyright notice and this permission notice appear in all copies.
  *   *
  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES   * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF   * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR   * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES   * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN   * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF   * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
Line 31 
Line 31 
 #include <string.h>  #include <string.h>
 #include <time.h>  #include <time.h>
   
 #include "mdoc.h"  
 #include "mandoc.h"  
 #include "mandoc_aux.h"  #include "mandoc_aux.h"
 #include "libmdoc.h"  #include "mandoc.h"
   #include "roff.h"
   #include "mdoc.h"
 #include "libmandoc.h"  #include "libmandoc.h"
   #include "libmdoc.h"
   
 /* FIXME: .Bl -diag can't have non-text children in HEAD. */  /* FIXME: .Bl -diag can't have non-text children in HEAD. */
   
Line 297  mdoc_valid_pre(struct mdoc *mdoc, struct mdoc_node *n)
Line 298  mdoc_valid_pre(struct mdoc *mdoc, struct mdoc_node *n)
         v_pre    p;          v_pre    p;
   
         switch (n->type) {          switch (n->type) {
         case MDOC_TEXT:          case ROFFT_TEXT:
                 if (n->sec != SEC_SYNOPSIS || n->parent->tok != MDOC_Fd)                  if (n->sec != SEC_SYNOPSIS || n->parent->tok != MDOC_Fd)
                         check_text(mdoc, n->line, n->pos, n->string);                          check_text(mdoc, n->line, n->pos, n->string);
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case MDOC_TBL:          case ROFFT_TBL:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case MDOC_EQN:          case ROFFT_EQN:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case MDOC_ROOT:          case ROFFT_ROOT:
                 return;                  return;
         default:          default:
                 break;                  break;
Line 329  mdoc_valid_post(struct mdoc *mdoc)
Line 330  mdoc_valid_post(struct mdoc *mdoc)
         n->flags |= MDOC_VALID | MDOC_ENDED;          n->flags |= MDOC_VALID | MDOC_ENDED;
   
         switch (n->type) {          switch (n->type) {
         case MDOC_TEXT:          case ROFFT_TEXT:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case MDOC_EQN:          case ROFFT_EQN:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case MDOC_TBL:          case ROFFT_TBL:
                 break;                  break;
         case MDOC_ROOT:          case ROFFT_ROOT:
                 post_root(mdoc);                  post_root(mdoc);
                 break;                  break;
         default:          default:
Line 400  pre_display(PRE_ARGS)
Line 401  pre_display(PRE_ARGS)
 {  {
         struct mdoc_node *node;          struct mdoc_node *node;
   
         if (MDOC_BLOCK != n->type)          if (n->type != ROFFT_BLOCK)
                 return;                  return;
   
         for (node = mdoc->last->parent; node; node = node->parent)          for (node = mdoc->last->parent; node; node = node->parent)
                 if (MDOC_BLOCK == node->type)                  if (node->type == ROFFT_BLOCK)
                         if (MDOC_Bd == node->tok)                          if (MDOC_Bd == node->tok)
                                 break;                                  break;
   
Line 422  pre_bl(PRE_ARGS)
Line 423  pre_bl(PRE_ARGS)
         enum mdocargt     mdoclt;          enum mdocargt     mdoclt;
         enum mdoc_list    lt;          enum mdoc_list    lt;
   
         if (n->type != MDOC_BLOCK)          if (n->type != ROFFT_BLOCK)
                 return;                  return;
   
         /*          /*
Line 605  pre_bd(PRE_ARGS)
Line 606  pre_bd(PRE_ARGS)
   
         pre_literal(mdoc, n);          pre_literal(mdoc, n);
   
         if (n->type != MDOC_BLOCK)          if (n->type != ROFFT_BLOCK)
                 return;                  return;
   
         for (i = 0; n->args && i < (int)n->args->argc; i++) {          for (i = 0; n->args && i < (int)n->args->argc; i++) {
Line 718  static void
Line 719  static void
 pre_obsolete(PRE_ARGS)  pre_obsolete(PRE_ARGS)
 {  {
   
         if (MDOC_ELEM == n->type || MDOC_BLOCK == n->type)          if (n->type == ROFFT_ELEM || n->type == ROFFT_BLOCK)
                 mandoc_msg(MANDOCERR_MACRO_OBS, mdoc->parse,                  mandoc_msg(MANDOCERR_MACRO_OBS, mdoc->parse,
                     n->line, n->pos, mdoc_macronames[n->tok]);                      n->line, n->pos, mdoc_macronames[n->tok]);
 }  }
Line 777  post_bf(POST_ARGS)
Line 778  post_bf(POST_ARGS)
          */           */
   
         np = mdoc->last;          np = mdoc->last;
         if (MDOC_HEAD != np->type)          if (np->type != ROFFT_HEAD)
                 return;                  return;
   
         assert(MDOC_BLOCK == np->parent->type);          assert(np->parent->type == ROFFT_BLOCK);
         assert(MDOC_Bf == np->parent->tok);          assert(MDOC_Bf == np->parent->tok);
   
         /* Check the number of arguments. */          /* Check the number of arguments. */
Line 835  post_lb(POST_ARGS)
Line 836  post_lb(POST_ARGS)
         char                    *libname;          char                    *libname;
   
         n = mdoc->last->child;          n = mdoc->last->child;
         assert(MDOC_TEXT == n->type);          assert(n->type == ROFFT_TEXT);
   
         if (NULL == (stdlibname = mdoc_a2lib(n->string)))          if (NULL == (stdlibname = mdoc_a2lib(n->string)))
                 mandoc_asprintf(&libname,                  mandoc_asprintf(&libname,
Line 890  post_fo(POST_ARGS)
Line 891  post_fo(POST_ARGS)
   
         n = mdoc->last;          n = mdoc->last;
   
         if (n->type != MDOC_HEAD)          if (n->type != ROFFT_HEAD)
                 return;                  return;
   
         if (n->child == NULL) {          if (n->child == NULL) {
Line 943  post_vt(POST_ARGS)
Line 944  post_vt(POST_ARGS)
          * specifically the BODY, should only have TEXT children.           * specifically the BODY, should only have TEXT children.
          */           */
   
         if (MDOC_BODY != mdoc->last->type)          if (mdoc->last->type != ROFFT_BODY)
                 return;                  return;
   
         for (n = mdoc->last->child; n; n = n->next)          for (n = mdoc->last->child; n; n = n->next)
                 if (MDOC_TEXT != n->type)                  if (n->type != ROFFT_TEXT)
                         mandoc_msg(MANDOCERR_VT_CHILD, mdoc->parse,                          mandoc_msg(MANDOCERR_VT_CHILD, mdoc->parse,
                             n->line, n->pos, mdoc_macronames[n->tok]);                              n->line, n->pos, mdoc_macronames[n->tok]);
 }  }
Line 981  post_nd(POST_ARGS)
Line 982  post_nd(POST_ARGS)
   
         n = mdoc->last;          n = mdoc->last;
   
         if (n->type != MDOC_BODY)          if (n->type != ROFFT_BODY)
                 return;                  return;
   
         if (n->child == NULL)          if (n->child == NULL)
Line 998  post_d1(POST_ARGS)
Line 999  post_d1(POST_ARGS)
   
         n = mdoc->last;          n = mdoc->last;
   
         if (n->type != MDOC_BODY)          if (n->type != ROFFT_BODY)
                 return;                  return;
   
         if (n->child == NULL)          if (n->child == NULL)
Line 1015  post_literal(POST_ARGS)
Line 1016  post_literal(POST_ARGS)
   
         n = mdoc->last;          n = mdoc->last;
   
         if (n->type != MDOC_BODY)          if (n->type != ROFFT_BODY)
                 return;                  return;
   
         if (n->child == NULL)          if (n->child == NULL)
Line 1086  post_at(POST_ARGS)
Line 1087  post_at(POST_ARGS)
          */           */
   
         n = n->child;          n = n->child;
         assert(MDOC_TEXT == n->type);          assert(n->type == ROFFT_TEXT);
         if (NULL == (std_att = mdoc_a2att(n->string))) {          if (NULL == (std_att = mdoc_a2att(n->string))) {
                 mandoc_vmsg(MANDOCERR_AT_BAD, mdoc->parse,                  mandoc_vmsg(MANDOCERR_AT_BAD, mdoc->parse,
                     n->line, n->pos, "At %s", n->string);                      n->line, n->pos, "At %s", n->string);
Line 1118  static void
Line 1119  static void
 post_en(POST_ARGS)  post_en(POST_ARGS)
 {  {
   
         if (MDOC_BLOCK == mdoc->last->type)          if (mdoc->last->type == ROFFT_BLOCK)
                 mdoc->last->norm->Es = mdoc->last_es;                  mdoc->last->norm->Es = mdoc->last_es;
 }  }
   
Line 1137  post_it(POST_ARGS)
Line 1138  post_it(POST_ARGS)
         struct mdoc_node *nbl, *nit, *nch;          struct mdoc_node *nbl, *nit, *nch;
   
         nit = mdoc->last;          nit = mdoc->last;
         if (nit->type != MDOC_BLOCK)          if (nit->type != ROFFT_BLOCK)
                 return;                  return;
   
         nbl = nit->parent->parent;          nbl = nit->parent->parent;
Line 1184  post_it(POST_ARGS)
Line 1185  post_it(POST_ARGS)
                 assert(nit->head->child == NULL);                  assert(nit->head->child == NULL);
   
                 for (i = 0, nch = nit->child; nch; nch = nch->next)                  for (i = 0, nch = nit->child; nch; nch = nch->next)
                         if (nch->type == MDOC_BODY)                          if (nch->type == ROFFT_BODY)
                                 i++;                                  i++;
   
                 if (i < cols || i > cols + 1)                  if (i < cols || i > cols + 1)
Line 1298  post_bl_block_tag(POST_ARGS)
Line 1299  post_bl_block_tag(POST_ARGS)
                 if (MDOC_It != nn->tok)                  if (MDOC_It != nn->tok)
                         continue;                          continue;
   
                 assert(MDOC_BLOCK == nn->type);                  assert(nn->type == ROFFT_BLOCK);
                 nn = nn->head->child;                  nn = nn->head->child;
   
                 if (nn == NULL)                  if (nn == NULL)
                         break;                          break;
   
                 if (MDOC_TEXT == nn->type) {                  if (nn->type == ROFFT_TEXT) {
                         sz = strlen(nn->string) + 1;                          sz = strlen(nn->string) + 1;
                         break;                          break;
                 }                  }
Line 1412  post_bl(POST_ARGS)
Line 1413  post_bl(POST_ARGS)
   
         nbody = mdoc->last;          nbody = mdoc->last;
         switch (nbody->type) {          switch (nbody->type) {
         case MDOC_BLOCK:          case ROFFT_BLOCK:
                 post_bl_block(mdoc);                  post_bl_block(mdoc);
                 return;                  return;
         case MDOC_HEAD:          case ROFFT_HEAD:
                 post_bl_head(mdoc);                  post_bl_head(mdoc);
                 return;                  return;
         case MDOC_BODY:          case ROFFT_BODY:
                 break;                  break;
         default:          default:
                 return;                  return;
Line 1493  post_bk(POST_ARGS)
Line 1494  post_bk(POST_ARGS)
   
         n = mdoc->last;          n = mdoc->last;
   
         if (n->type == MDOC_BLOCK && n->body->child == NULL) {          if (n->type == ROFFT_BLOCK && n->body->child == NULL) {
                 mandoc_msg(MANDOCERR_BLK_EMPTY,                  mandoc_msg(MANDOCERR_BLK_EMPTY,
                     mdoc->parse, n->line, n->pos, "Bk");                      mdoc->parse, n->line, n->pos, "Bk");
                 mdoc_node_delete(mdoc, n);                  mdoc_node_delete(mdoc, n);
Line 1512  post_sm(struct mdoc *mdoc)
Line 1513  post_sm(struct mdoc *mdoc)
                 return;                  return;
         }          }
   
         assert(nch->type == MDOC_TEXT);          assert(nch->type == ROFFT_TEXT);
   
         if ( ! strcmp(nch->string, "on")) {          if ( ! strcmp(nch->string, "on")) {
                 mdoc->flags &= ~MDOC_SMOFF;                  mdoc->flags &= ~MDOC_SMOFF;
Line 1579  post_st(POST_ARGS)
Line 1580  post_st(POST_ARGS)
         n = mdoc->last;          n = mdoc->last;
         nch = n->child;          nch = n->child;
   
         assert(MDOC_TEXT == nch->type);          assert(nch->type == ROFFT_TEXT);
   
         if (NULL == (p = mdoc_a2st(nch->string))) {          if (NULL == (p = mdoc_a2st(nch->string))) {
                 mandoc_vmsg(MANDOCERR_ST_BAD, mdoc->parse,                  mandoc_vmsg(MANDOCERR_ST_BAD, mdoc->parse,
Line 1599  post_rs(POST_ARGS)
Line 1600  post_rs(POST_ARGS)
   
         np = mdoc->last;          np = mdoc->last;
   
         if (np->type != MDOC_BODY)          if (np->type != ROFFT_BODY)
                 return;                  return;
   
         if (np->child == NULL) {          if (np->child == NULL) {
Line 1692  post_hyph(POST_ARGS)
Line 1693  post_hyph(POST_ARGS)
         char                    *cp;          char                    *cp;
   
         for (nch = mdoc->last->child; nch != NULL; nch = nch->next) {          for (nch = mdoc->last->child; nch != NULL; nch = nch->next) {
                 if (nch->type != MDOC_TEXT)                  if (nch->type != ROFFT_TEXT)
                         continue;                          continue;
                 cp = nch->string;                  cp = nch->string;
                 if (*cp == '\0')                  if (*cp == '\0')
Line 1721  post_sh(POST_ARGS)
Line 1722  post_sh(POST_ARGS)
         post_ignpar(mdoc);          post_ignpar(mdoc);
   
         switch (mdoc->last->type) {          switch (mdoc->last->type) {
         case MDOC_HEAD:          case ROFFT_HEAD:
                 post_sh_head(mdoc);                  post_sh_head(mdoc);
                 break;                  break;
         case MDOC_BODY:          case ROFFT_BODY:
                 switch (mdoc->lastsec)  {                  switch (mdoc->lastsec)  {
                 case SEC_NAME:                  case SEC_NAME:
                         post_sh_name(mdoc);                          post_sh_name(mdoc);
Line 1830  post_sh_see_also(POST_ARGS)
Line 1831  post_sh_see_also(POST_ARGS)
                         lastpunct = "none";                          lastpunct = "none";
                         continue;                          continue;
                 }                  }
                 if (n->type != MDOC_TEXT)                  if (n->type != ROFFT_TEXT)
                         break;                          break;
                 for (name = n->string; *name != '\0'; name++)                  for (name = n->string; *name != '\0'; name++)
                         if (isalpha((const unsigned char)*name))                          if (isalpha((const unsigned char)*name))
Line 1989  post_ignpar(POST_ARGS)
Line 1990  post_ignpar(POST_ARGS)
         struct mdoc_node *np;          struct mdoc_node *np;
   
         switch (mdoc->last->type) {          switch (mdoc->last->type) {
         case MDOC_HEAD:          case ROFFT_HEAD:
                 post_hyph(mdoc);                  post_hyph(mdoc);
                 return;                  return;
         case MDOC_BODY:          case ROFFT_BODY:
                 break;                  break;
         default:          default:
                 return;                  return;
Line 2023  pre_par(PRE_ARGS)
Line 2024  pre_par(PRE_ARGS)
   
         if (NULL == mdoc->last)          if (NULL == mdoc->last)
                 return;                  return;
         if (MDOC_ELEM != n->type && MDOC_BLOCK != n->type)          if (n->type != ROFFT_ELEM && n->type != ROFFT_BLOCK)
                 return;                  return;
   
         /*          /*
Line 2088  pre_literal(PRE_ARGS)
Line 2089  pre_literal(PRE_ARGS)
   
         pre_display(mdoc, n);          pre_display(mdoc, n);
   
         if (MDOC_BODY != n->type)          if (n->type != ROFFT_BODY)
                 return;                  return;
   
         /*          /*

Legend:
Removed from v.1.283  
changed lines
  Added in v.1.284

CVSweb