[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.271 and 1.274

version 1.271, 2015/02/05 01:46:56 version 1.274, 2015/02/06 03:38:45
Line 67  static enum mdoc_sec a2sec(const char *);
Line 67  static enum mdoc_sec a2sec(const char *);
 static  size_t          macro2len(enum mdoct);  static  size_t          macro2len(enum mdoct);
 static  void     rewrite_macro2len(char **);  static  void     rewrite_macro2len(char **);
   
 static  void     bwarn_ge1(POST_ARGS);  
 static  void     ewarn_eq1(POST_ARGS);  static  void     ewarn_eq1(POST_ARGS);
 static  void     ewarn_ge1(POST_ARGS);  static  void     ewarn_ge1(POST_ARGS);
   
Line 151  static const struct valids mdoc_valids[MDOC_MAX] = {
Line 150  static const struct valids mdoc_valids[MDOC_MAX] = {
         { NULL, NULL },                         /* Ev */          { NULL, NULL },                         /* Ev */
         { pre_std, post_ex },                   /* Ex */          { pre_std, post_ex },                   /* Ex */
         { NULL, post_fa },                      /* Fa */          { NULL, post_fa },                      /* Fa */
         { NULL, ewarn_ge1 },                    /* Fd */          { NULL, NULL },                         /* Fd */
         { NULL, NULL },                         /* Fl */          { NULL, NULL },                         /* Fl */
         { NULL, post_fn },                      /* Fn */          { NULL, post_fn },                      /* Fn */
         { NULL, NULL },                         /* Ft */          { NULL, NULL },                         /* Ft */
         { NULL, NULL },                         /* Ic */          { NULL, NULL },                         /* Ic */
         { NULL, ewarn_eq1 },                    /* In */          { NULL, NULL },                         /* In */
         { NULL, post_defaults },                /* Li */          { NULL, post_defaults },                /* Li */
         { NULL, post_nd },                      /* Nd */          { NULL, post_nd },                      /* Nd */
         { NULL, post_nm },                      /* Nm */          { NULL, post_nm },                      /* Nm */
Line 167  static const struct valids mdoc_valids[MDOC_MAX] = {
Line 166  static const struct valids mdoc_valids[MDOC_MAX] = {
         { NULL, post_st },                      /* St */          { NULL, post_st },                      /* St */
         { NULL, NULL },                         /* Va */          { NULL, NULL },                         /* Va */
         { NULL, post_vt },                      /* Vt */          { NULL, post_vt },                      /* Vt */
         { NULL, ewarn_ge1 },                    /* Xr */          { NULL, NULL },                         /* Xr */
         { NULL, ewarn_ge1 },                    /* %A */          { NULL, ewarn_ge1 },                    /* %A */
         { NULL, post_hyphtext },                /* %B */ /* FIXME: can be used outside Rs/Re. */          { NULL, post_hyphtext },                /* %B */ /* FIXME: can be used outside Rs/Re. */
         { NULL, ewarn_ge1 },                    /* %D */          { NULL, ewarn_ge1 },                    /* %D */
Line 402  check_count(struct mdoc *mdoc, enum mdoc_type type,
Line 401  check_count(struct mdoc *mdoc, enum mdoc_type type,
 }  }
   
 static void  static void
 bwarn_ge1(POST_ARGS)  
 {  
         check_count(mdoc, MDOC_BODY, CHECK_GT, 0);  
 }  
   
 static void  
 ewarn_eq1(POST_ARGS)  ewarn_eq1(POST_ARGS)
 {  {
         check_count(mdoc, MDOC_ELEM, CHECK_EQ, 1);          check_count(mdoc, MDOC_ELEM, CHECK_EQ, 1);
Line 980  post_fn(POST_ARGS)
Line 973  post_fn(POST_ARGS)
 static void  static void
 post_fo(POST_ARGS)  post_fo(POST_ARGS)
 {  {
           const struct mdoc_node  *n;
   
         check_count(mdoc, MDOC_HEAD, CHECK_EQ, 1);          n = mdoc->last;
         bwarn_ge1(mdoc);  
         if (mdoc->last->type == MDOC_HEAD && mdoc->last->nchild)          if (n->type != MDOC_HEAD)
                 post_fname(mdoc);                  return;
   
           if (n->child == NULL) {
                   mandoc_msg(MANDOCERR_FO_NOHEAD, mdoc->parse,
                       n->line, n->pos, "Fo");
                   return;
           }
           if (n->child != n->last) {
                   mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse,
                       n->child->next->line, n->child->next->pos,
                       "Fo ... %s", n->child->next->string);
                   while (n->child != n->last)
                           mdoc_node_delete(mdoc, n->last);
           }
   
           post_fname(mdoc);
 }  }
   
 static void  static void
Line 1072  post_nd(POST_ARGS)
Line 1081  post_nd(POST_ARGS)
 static void  static void
 post_d1(POST_ARGS)  post_d1(POST_ARGS)
 {  {
           struct mdoc_node        *n;
   
         bwarn_ge1(mdoc);          n = mdoc->last;
   
           if (n->type != MDOC_BODY)
                   return;
   
           if (n->child == NULL)
                   mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,
                       n->line, n->pos, "D1");
   
         post_hyph(mdoc);          post_hyph(mdoc);
 }  }
   
 static void  static void
 post_literal(POST_ARGS)  post_literal(POST_ARGS)
 {  {
           struct mdoc_node        *n;
   
         bwarn_ge1(mdoc);          n = mdoc->last;
   
         /*          if (n->type != MDOC_BODY)
          * The `Dl' (note "el" not "one") and `Bd' macros unset the                  return;
          * MDOC_LITERAL flag as they leave.  Note that `Bd' only sets  
          * this in literal mode, but it doesn't hurt to just switch it  
          * off in general since displays can't be nested.  
          */  
   
         if (MDOC_BODY == mdoc->last->type)          if (n->child == NULL)
                 mdoc->flags &= ~MDOC_LITERAL;                  mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,
                       n->line, n->pos, mdoc_macronames[n->tok]);
   
           if (n->tok == MDOC_Bd &&
               n->norm->Bd.type != DISP_literal &&
               n->norm->Bd.type != DISP_unfilled)
                   return;
   
           mdoc->flags &= ~MDOC_LITERAL;
 }  }
   
 static void  static void
Line 1488  post_bl(POST_ARGS)
Line 1511  post_bl(POST_ARGS)
                 return;                  return;
         }          }
   
         bwarn_ge1(mdoc);  
   
         nchild = nbody->child;          nchild = nbody->child;
         while (NULL != nchild) {          if (nchild == NULL) {
                   mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,
                       nbody->line, nbody->pos, "Bl");
                   return;
           }
           while (nchild != NULL) {
                 if (nchild->tok == MDOC_It ||                  if (nchild->tok == MDOC_It ||
                     (nchild->tok == MDOC_Sm &&                      (nchild->tok == MDOC_Sm &&
                      nchild->next != NULL &&                       nchild->next != NULL &&
Line 1640  post_st(POST_ARGS)
Line 1666  post_st(POST_ARGS)
         n = mdoc->last;          n = mdoc->last;
         nch = n->child;          nch = n->child;
   
         if (NULL == nch) {  
                 mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,  
                     n->line, n->pos, mdoc_macronames[n->tok]);  
                 mdoc_node_delete(mdoc, n);  
                 return;  
         }  
   
         assert(MDOC_TEXT == nch->type);          assert(MDOC_TEXT == nch->type);
   
         if (NULL == (p = mdoc_a2st(nch->string))) {          if (NULL == (p = mdoc_a2st(nch->string))) {
Line 1756  post_rs(POST_ARGS)
Line 1775  post_rs(POST_ARGS)
 static void  static void
 post_hyph(POST_ARGS)  post_hyph(POST_ARGS)
 {  {
         struct mdoc_node        *n, *nch;          struct mdoc_node        *nch;
         char                    *cp;          char                    *cp;
   
         n = mdoc->last;          for (nch = mdoc->last->child; nch != NULL; nch = nch->next) {
         switch (n->type) {                  if (nch->type != MDOC_TEXT)
         case MDOC_HEAD:  
                 if (MDOC_Sh == n->tok || MDOC_Ss == n->tok)  
                         break;  
                 return;  
         case MDOC_BODY:  
                 if (MDOC_D1 == n->tok || MDOC_Nd == n->tok)  
                         break;  
                 return;  
         case MDOC_ELEM:  
                 break;  
         default:  
                 return;  
         }  
   
         for (nch = n->child; nch; nch = nch->next) {  
                 if (MDOC_TEXT != nch->type)  
                         continue;                          continue;
                 cp = nch->string;                  cp = nch->string;
                 if ('\0' == *cp)                  if (*cp == '\0')
                         continue;                          continue;
                 while ('\0' != *(++cp))                  while (*(++cp) != '\0')
                         if ('-' == *cp &&                          if (*cp == '-' &&
                             isalpha((unsigned char)cp[-1]) &&                              isalpha((unsigned char)cp[-1]) &&
                             isalpha((unsigned char)cp[1]))                              isalpha((unsigned char)cp[1]))
                                 *cp = ASCII_HYPH;                                  *cp = ASCII_HYPH;
Line 2076  post_ignpar(POST_ARGS)
Line 2079  post_ignpar(POST_ARGS)
 {  {
         struct mdoc_node *np;          struct mdoc_node *np;
   
         check_count(mdoc, MDOC_HEAD, CHECK_GT, 0);          switch (mdoc->last->type) {
         post_hyph(mdoc);          case MDOC_HEAD:
                   post_hyph(mdoc);
         if (MDOC_BODY != mdoc->last->type)  
                 return;                  return;
           case MDOC_BODY:
                   break;
           default:
                   return;
           }
   
         if (NULL != (np = mdoc->last->child))          if (NULL != (np = mdoc->last->child))
                 if (MDOC_Pp == np->tok || MDOC_Lp == np->tok) {                  if (MDOC_Pp == np->tok || MDOC_Lp == np->tok) {

Legend:
Removed from v.1.271  
changed lines
  Added in v.1.274

CVSweb