[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.277 and 1.284

version 1.277, 2015/02/10 08:05:30 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:
                 check_text(mdoc, n->line, n->pos, n->string);                  if (n->sec != SEC_SYNOPSIS || n->parent->tok != MDOC_Fd)
                           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 325  mdoc_valid_post(struct mdoc *mdoc)
Line 327  mdoc_valid_post(struct mdoc *mdoc)
         n = mdoc->last;          n = mdoc->last;
         if (n->flags & MDOC_VALID)          if (n->flags & MDOC_VALID)
                 return;                  return;
         n->flags |= MDOC_VALID;          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 399  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 416  pre_display(PRE_ARGS)
Line 418  pre_display(PRE_ARGS)
 static void  static void
 pre_bl(PRE_ARGS)  pre_bl(PRE_ARGS)
 {  {
         struct mdoc_node *np;  
         struct mdoc_argv *argv, *wa;          struct mdoc_argv *argv, *wa;
         int               i;          int               i;
         enum mdocargt     mdoclt;          enum mdocargt     mdoclt;
         enum mdoc_list    lt;          enum mdoc_list    lt;
   
         if (MDOC_BLOCK != n->type) {          if (n->type != ROFFT_BLOCK)
                 if (ENDBODY_NOT != n->end) {  
                         assert(n->pending);  
                         np = n->pending->parent;  
                 } else  
                         np = n->parent;  
   
                 assert(np);  
                 assert(MDOC_BLOCK == np->type);  
                 assert(MDOC_Bl == np->tok);  
                 return;                  return;
         }  
   
         /*          /*
          * First figure out which kind of list to use: bind ourselves to           * First figure out which kind of list to use: bind ourselves to
Line 609  pre_bl(PRE_ARGS)
Line 600  pre_bl(PRE_ARGS)
 static void  static void
 pre_bd(PRE_ARGS)  pre_bd(PRE_ARGS)
 {  {
         struct mdoc_node *np;  
         struct mdoc_argv *argv;          struct mdoc_argv *argv;
         int               i;          int               i;
         enum mdoc_disp    dt;          enum mdoc_disp    dt;
   
         pre_literal(mdoc, n);          pre_literal(mdoc, n);
   
         if (MDOC_BLOCK != n->type) {          if (n->type != ROFFT_BLOCK)
                 if (ENDBODY_NOT != n->end) {  
                         assert(n->pending);  
                         np = n->pending->parent;  
                 } else  
                         np = n->parent;  
   
                 assert(np);  
                 assert(MDOC_BLOCK == np->type);  
                 assert(MDOC_Bd == np->tok);  
                 return;                  return;
         }  
   
         for (i = 0; n->args && i < (int)n->args->argc; i++) {          for (i = 0; n->args && i < (int)n->args->argc; i++) {
                 argv = n->args->argv + i;                  argv = n->args->argv + i;
Line 739  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 797  post_bf(POST_ARGS)
Line 777  post_bf(POST_ARGS)
          * element, which contains the goods.           * element, which contains the goods.
          */           */
   
         if (MDOC_HEAD != mdoc->last->type) {          np = mdoc->last;
                 if (ENDBODY_NOT != mdoc->last->end) {          if (np->type != ROFFT_HEAD)
                         assert(mdoc->last->pending);  
                         np = mdoc->last->pending->parent->head;  
                 } else if (MDOC_BLOCK != mdoc->last->type) {  
                         np = mdoc->last->parent->head;  
                 } else  
                         np = mdoc->last->head;  
   
                 assert(np);  
                 assert(MDOC_HEAD == np->type);  
                 assert(MDOC_Bf == np->tok);  
                 return;                  return;
         }  
   
         np = mdoc->last;          assert(np->parent->type == ROFFT_BLOCK);
         assert(MDOC_BLOCK == np->parent->type);  
         assert(MDOC_Bf == np->parent->tok);          assert(MDOC_Bf == np->parent->tok);
   
         /* Check the number of arguments. */          /* Check the number of arguments. */
Line 868  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,
                     "library \\(lq%s\\(rq", n->string);                      "library \\(Lq%s\\(Rq", n->string);
         else          else
                 libname = mandoc_strdup(stdlibname);                  libname = mandoc_strdup(stdlibname);
   
Line 923  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 976  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 1014  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 1031  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 1048  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 1119  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 1151  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 1170  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 1217  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 1331  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 1445  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 1526  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 1545  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 1612  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 1632  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 1725  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 1754  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 1781  static void
Line 1749  static void
 post_sh_name(POST_ARGS)  post_sh_name(POST_ARGS)
 {  {
         struct mdoc_node *n;          struct mdoc_node *n;
           int hasnm, hasnd;
   
         /*          hasnm = hasnd = 0;
          * Warn if the NAME section doesn't contain the `Nm' and `Nd'  
          * macros (can have multiple `Nm' and one `Nd').  Note that the  
          * children of the BODY declaration can also be "text".  
          */  
   
         if (NULL == (n = mdoc->last->child)) {          for (n = mdoc->last->child; n != NULL; n = n->next) {
                 mandoc_msg(MANDOCERR_NAMESEC_BAD, mdoc->parse,                  switch (n->tok) {
                     mdoc->last->line, mdoc->last->pos, "empty");                  case MDOC_Nm:
                 return;                          hasnm = 1;
                           break;
                   case MDOC_Nd:
                           hasnd = 1;
                           if (n->next != NULL)
                                   mandoc_msg(MANDOCERR_NAMESEC_ND,
                                       mdoc->parse, n->line, n->pos, NULL);
                           break;
                   case MDOC_MAX:
                           if (hasnm)
                                   break;
                           /* FALLTHROUGH */
                   default:
                           mandoc_msg(MANDOCERR_NAMESEC_BAD, mdoc->parse,
                               n->line, n->pos, mdoc_macronames[n->tok]);
                           break;
                   }
         }          }
   
         for ( ; n && n->next; n = n->next) {          if ( ! hasnm)
                 if (MDOC_ELEM == n->type && MDOC_Nm == n->tok)                  mandoc_msg(MANDOCERR_NAMESEC_NONM, mdoc->parse,
                         continue;                      mdoc->last->line, mdoc->last->pos, NULL);
                 if (MDOC_TEXT == n->type)          if ( ! hasnd)
                         continue;                  mandoc_msg(MANDOCERR_NAMESEC_NOND, mdoc->parse,
                 mandoc_msg(MANDOCERR_NAMESEC_BAD, mdoc->parse,                      mdoc->last->line, mdoc->last->pos, NULL);
                     n->line, n->pos, mdoc_macronames[n->tok]);  
         }  
   
         assert(n);  
         if (MDOC_BLOCK == n->type && MDOC_Nd == n->tok)  
                 return;  
   
         mandoc_msg(MANDOCERR_NAMESEC_BAD, mdoc->parse,  
             n->line, n->pos, mdoc_macronames[n->tok]);  
 }  }
   
 static void  static void
Line 1859  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 2018  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 2052  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 2117  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;
   
         /*          /*
Line 2189  post_dt(POST_ARGS)
Line 2161  post_dt(POST_ARGS)
         mdoc->meta.vol = NULL;          mdoc->meta.vol = NULL;
         mdoc->meta.arch = NULL;          mdoc->meta.arch = NULL;
   
         /* First check that all characters are uppercase. */          /* Mandatory first argument: title. */
   
         if (NULL != (nn = n->child))          nn = n->child;
                 for (p = nn->string; *p; p++) {          if (nn == NULL || *nn->string == '\0') {
                         if (toupper((unsigned char)*p) == *p)  
                                 continue;  
                         mandoc_vmsg(MANDOCERR_TITLE_CASE,  
                             mdoc->parse, nn->line,  
                             nn->pos + (p - nn->string),  
                             "Dt %s", nn->string);  
                         break;  
                 }  
   
         /* No argument: msec and arch remain NULL. */  
   
         if (NULL == (nn = n->child)) {  
                 mandoc_msg(MANDOCERR_DT_NOTITLE,                  mandoc_msg(MANDOCERR_DT_NOTITLE,
                     mdoc->parse, n->line, n->pos, "Dt");                      mdoc->parse, n->line, n->pos, "Dt");
                 mdoc->meta.title = mandoc_strdup("UNTITLED");                  mdoc->meta.title = mandoc_strdup("UNTITLED");
                 mdoc->meta.vol = mandoc_strdup("LOCAL");          } else {
                 goto out;                  mdoc->meta.title = mandoc_strdup(nn->string);
   
                   /* Check that all characters are uppercase. */
   
                   for (p = nn->string; *p != '\0'; p++)
                           if (islower((unsigned char)*p)) {
                                   mandoc_vmsg(MANDOCERR_TITLE_CASE,
                                       mdoc->parse, nn->line,
                                       nn->pos + (p - nn->string),
                                       "Dt %s", nn->string);
                                   break;
                           }
         }          }
   
         /* One argument: msec and arch remain NULL. */          /* Mandatory second argument: section. */
   
         mdoc->meta.title = mandoc_strdup(          if (nn != NULL)
             '\0' == nn->string[0] ? "UNTITLED" : nn->string);                  nn = nn->next;
   
         if (NULL == (nn = nn->next)) {          if (nn == NULL) {
                 mandoc_vmsg(MANDOCERR_MSEC_MISSING,                  mandoc_vmsg(MANDOCERR_MSEC_MISSING,
                     mdoc->parse, n->line, n->pos,                      mdoc->parse, n->line, n->pos,
                     "Dt %s", mdoc->meta.title);                      "Dt %s", mdoc->meta.title);
                 mdoc->meta.vol = mandoc_strdup("LOCAL");                  mdoc->meta.vol = mandoc_strdup("LOCAL");
                 goto out;                  goto out;  /* msec and arch remain NULL. */
         }          }
   
         /* Handles: `.Dt TITLE SEC'          mdoc->meta.msec = mandoc_strdup(nn->string);
          * title = TITLE,  
          * volume = SEC is msec ? format(msec) : SEC,  
          * msec = SEC is msec ? atoi(msec) : 0,  
          * arch = NULL  
          */  
   
           /* Infer volume title from section number. */
   
         cp = mandoc_a2msec(nn->string);          cp = mandoc_a2msec(nn->string);
         if (cp) {          if (cp == NULL) {
                 mdoc->meta.vol = mandoc_strdup(cp);  
                 mdoc->meta.msec = mandoc_strdup(nn->string);  
         } else {  
                 mandoc_vmsg(MANDOCERR_MSEC_BAD, mdoc->parse,                  mandoc_vmsg(MANDOCERR_MSEC_BAD, mdoc->parse,
                     nn->line, nn->pos, "Dt ... %s", nn->string);                      nn->line, nn->pos, "Dt ... %s", nn->string);
                 mdoc->meta.vol = mandoc_strdup(nn->string);                  mdoc->meta.vol = mandoc_strdup(nn->string);
                 mdoc->meta.msec = mandoc_strdup(nn->string);          } else
         }                  mdoc->meta.vol = mandoc_strdup(cp);
   
         /* Handle an optional architecture */          /* Optional third argument: architecture. */
   
         if ((nn = nn->next) != NULL) {          if ((nn = nn->next) == NULL)
                 for (p = nn->string; *p; p++)                  goto out;
                         *p = tolower((unsigned char)*p);  
                 mdoc->meta.arch = mandoc_strdup(nn->string);  
         }  
   
         /* Ignore any subsequent parameters... */          for (p = nn->string; *p != '\0'; p++)
         /* FIXME: warn about subsequent parameters. */                  *p = tolower((unsigned char)*p);
           mdoc->meta.arch = mandoc_strdup(nn->string);
   
           /* Ignore fourth and later arguments. */
   
           if ((nn = nn->next) != NULL)
                   mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse,
                       nn->line, nn->pos, "Dt ... %s", nn->string);
   
 out:  out:
         mdoc_node_delete(mdoc, n);          mdoc_node_delete(mdoc, n);
 }  }

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

CVSweb