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

Diff for /mandoc/roff.c between version 1.53 and 1.54

version 1.53, 2008/12/08 20:32:49 version 1.54, 2008/12/09 00:27:17
Line 127  roff_free(struct rofftree *tree, int flush)
Line 127  roff_free(struct rofftree *tree, int flush)
         error = 1;          error = 1;
   
         if (ROFF_PRELUDE & tree->state) {          if (ROFF_PRELUDE & tree->state) {
                 roff_err(tree, NULL, "prelude never finished");                  (void)roff_err(tree, NULL, "prelude never finished");
                 goto end;                  goto end;
         } else if ( ! (ROFFSec_NAME & tree->asec)) {          } else if ( ! (ROFFSec_NAME & tree->asec)) {
                 roff_err(tree, NULL, "missing `NAME' section");                  (void)roff_err(tree, NULL, "missing `NAME' section");
                 goto end;                  goto end;
         } else if ( ! (ROFFSec_NMASK & tree->asec))          } else if ( ! (ROFFSec_NMASK & tree->asec))
                 roff_warn(tree, NULL, "missing suggested `NAME', "                  roff_warn(tree, NULL, "missing suggested `NAME', "
Line 139  roff_free(struct rofftree *tree, int flush)
Line 139  roff_free(struct rofftree *tree, int flush)
         for (n = tree->last; n; n = n->parent) {          for (n = tree->last; n; n = n->parent) {
                 if (0 != tokens[n->tok].ctx)                  if (0 != tokens[n->tok].ctx)
                         continue;                          continue;
                 roff_err(tree, NULL, "closing explicit scope `%s'",                  (void)roff_err(tree, NULL, "closing explicit scope "
                                 toknames[n->tok]);                                  "`%s'", toknames[n->tok]);
                 goto end;                  goto end;
         }          }
   
Line 194  roff_engine(struct rofftree *tree, char *buf)
Line 194  roff_engine(struct rofftree *tree, char *buf)
         tree->cur = buf;          tree->cur = buf;
         assert(buf);          assert(buf);
   
         if (0 == *buf) {          if (0 == *buf)
                 roff_err(tree, buf, "blank line");                  return(roff_err(tree, buf, "blank line"));
                 return(0);          else if ('.' != *buf)
         } else if ('.' != *buf)  
                 return(textparse(tree, buf));                  return(textparse(tree, buf));
   
         return(roffparse(tree, buf));          return(roffparse(tree, buf));
Line 211  textparse(struct rofftree *tree, char *buf)
Line 210  textparse(struct rofftree *tree, char *buf)
   
         /* TODO: literal parsing. */          /* TODO: literal parsing. */
   
         if ( ! (ROFF_BODY & tree->state)) {          if ( ! (ROFF_BODY & tree->state))
                 roff_err(tree, buf, "data not in body");                  return(roff_err(tree, buf, "data not in body"));
                 return(0);  
         }  
   
         /* LINTED */          /* LINTED */
         while (*buf) {          while (*buf) {
Line 270  roffargs(const struct rofftree *tree, 
Line 267  roffargs(const struct rofftree *tree, 
                         argv[i] = ++buf;                          argv[i] = ++buf;
                         while (*buf && '\"' != *buf)                          while (*buf && '\"' != *buf)
                                 buf++;                                  buf++;
                         if (0 == *buf) {                          if (0 == *buf)
                                 roff_err(tree, argv[i], "unclosed "                                  return(roff_err(tree, argv[i],
                                                 "quote in argument "                                          "unclosed quote in arg list"));
                                                 "list for `%s'",  
                                                 toknames[tok]);  
                                 return(0);  
                         }  
                 } else {                  } else {
                         argv[i] = buf++;                          argv[i] = buf++;
                         while (*buf) {                          while (*buf) {
Line 299  roffargs(const struct rofftree *tree, 
Line 292  roffargs(const struct rofftree *tree, 
         }          }
   
         assert(i > 0);          assert(i > 0);
         if (ROFF_MAXLINEARG == i && *buf) {          if (ROFF_MAXLINEARG == i && *buf)
                 roff_err(tree, p, "too many arguments for `%s'", toknames                  return(roff_err(tree, p, "too many args"));
                                 [tok]);  
                 return(0);  
         }  
   
         argv[i] = NULL;          argv[i] = NULL;
         return(1);          return(1);
Line 337  roffparse(struct rofftree *tree, char *buf)
Line 327  roffparse(struct rofftree *tree, char *buf)
                 if (0 == strncmp(buf, ".\\\"", 3))                  if (0 == strncmp(buf, ".\\\"", 3))
                         return(1);                          return(1);
   
         if (ROFF_MAX == (tok = rofffindtok(buf + 1))) {          if (ROFF_MAX == (tok = rofffindtok(buf + 1)))
                 roff_err(tree, buf, "bogus line macro");                  return(roff_err(tree, buf, "bogus line macro"));
           else if ( ! roffargs(tree, tok, buf, argv))
                 return(0);                  return(0);
         } else if ( ! roffargs(tree, tok, buf, argv))  
                 return(0);  
   
         argvp = (char **)argv;          argvp = (char **)argv;
   
Line 362  roffparse(struct rofftree *tree, char *buf)
Line 351  roffparse(struct rofftree *tree, char *buf)
          */           */
   
         if (tree->last && ! roffscan          if (tree->last && ! roffscan
                         (tree->last->tok, tokens[tok].parents)) {                          (tree->last->tok, tokens[tok].parents))
                 roff_err(tree, *argvp, "`%s' has invalid parent `%s'",                  return(roff_err(tree, *argvp, "`%s' has invalid "
                                 toknames[tok],                                          "parent `%s'", toknames[tok],
                                 toknames[tree->last->tok]);                                          toknames[tree->last->tok]));
                 return(0);  
         }  
   
         if (tree->last && ! roffscan          if (tree->last && ! roffscan
                         (tok, tokens[tree->last->tok].children)) {                          (tok, tokens[tree->last->tok].children))
                 roff_err(tree, *argvp, "`%s' is invalid child of `%s'",                  return(roff_err(tree, *argvp, "`%s' has invalid "
                                 toknames[tok],                                          "child `%s'", toknames[tok],
                                 toknames[tree->last->tok]);                                          toknames[tree->last->tok]));
                 return(0);  
         }  
   
         /*          /*
          * Branch if we're not a layout token.           * Branch if we're not a layout token.
Line 415  roffparse(struct rofftree *tree, char *buf)
Line 400  roffparse(struct rofftree *tree, char *buf)
                         }                          }
                         if (tokens[n->tok].ctx == n->tok)                          if (tokens[n->tok].ctx == n->tok)
                                 continue;                                  continue;
                         roff_err(tree, *argv, "`%s' breaks `%s' scope",                          return(roff_err(tree, *argv, "`%s' breaks "
                                         toknames[tok], toknames[n->tok]);                                                  "scope of prior`%s'",
                         return(0);                                                  toknames[tok],
                                                   toknames[n->tok]));
                 }                  }
   
                 /*                  /*
Line 458  roffparse(struct rofftree *tree, char *buf)
Line 444  roffparse(struct rofftree *tree, char *buf)
                 if (n->tok != tokens[tok].ctx) {                  if (n->tok != tokens[tok].ctx) {
                         if (n->tok == tokens[n->tok].ctx)                          if (n->tok == tokens[n->tok].ctx)
                                 continue;                                  continue;
                         roff_err(tree, *argv, "`%s' breaks `%s' scope",                          return(roff_err(tree, *argv, "`%s' breaks "
                                         toknames[tok], toknames[n->tok]);                                                  "scope of prior `%s'",
                         return(0);                                                  toknames[tok],
                                                   toknames[n->tok]));
                 } else                  } else
                         break;                          break;
   
           if (NULL == n)
                   return(roff_err(tree, *argv, "`%s' has no starting "
                                           "tag `%s'", toknames[tok],
                                           toknames[tokens[tok].ctx]));
   
         if (NULL == n) {  
                 roff_err(tree, *argv, "`%s' has no starting tag `%s'",  
                                 toknames[tok],  
                                 toknames[tokens[tok].ctx]);  
                 return(0);  
         }  
   
         /* LINTED */          /* LINTED */
         do {          do {
                 t = tree->last->tok;                  t = tree->last->tok;
Line 597  roffchecksec(struct rofftree *tree, const char *start,
Line 581  roffchecksec(struct rofftree *tree, const char *start,
 }  }
   
   
   /* FIXME: move this into literals.c. */
 static int  static int
 roffissec(const char **p)  roffissec(const char **p)
 {  {
Line 645  roffissec(const char **p)
Line 630  roffissec(const char **p)
 }  }
   
   
   /* FIXME: move this into literals.c. */
 static int  static int
 roffismsec(const char *p)  roffismsec(const char *p)
 {  {
Line 680  roffismsec(const char *p)
Line 666  roffismsec(const char *p)
 }  }
   
   
   /* FIXME: move this into literals.c. */
 static int  static int
 roffisatt(const char *p)  roffisatt(const char *p)
 {  {
Line 706  roffisatt(const char *p)
Line 693  roffisatt(const char *p)
 }  }
   
   
   /* FIXME: move this into literals.c (or similar). */
 static int  static int
 roffispunct(const char *p)  roffispunct(const char *p)
 {  {
Line 817  roffspecial(struct rofftree *tree, int tok, const char
Line 805  roffspecial(struct rofftree *tree, int tok, const char
                         break;                          break;
                 if (roffisatt(*ordp))                  if (roffisatt(*ordp))
                         break;                          break;
                 roff_err(tree, *ordp, "invalid `At' arg");                  return(roff_err(tree, *ordp, "invalid `At' arg"));
                 return(0);  
   
         case (ROFF_Xr):          case (ROFF_Xr):
                 if (2 == sz) {                  if (2 == sz) {
Line 835  roffspecial(struct rofftree *tree, int tok, const char
Line 822  roffspecial(struct rofftree *tree, int tok, const char
         case (ROFF_Fn):          case (ROFF_Fn):
                 if (0 != sz)                  if (0 != sz)
                         break;                          break;
                 roff_err(tree, start, "`%s' expects at least "                  return(roff_err(tree, start, "`%s' expects at least "
                                 "one arg", toknames[tok]);                                          "one arg", toknames[tok]));
                 return(0);  
   
         case (ROFF_Nm):          case (ROFF_Nm):
                 if (0 == sz) {                  if (0 == sz) {

Legend:
Removed from v.1.53  
changed lines
  Added in v.1.54

CVSweb