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

Diff for /mandoc/roff.c between version 1.16 and 1.17

version 1.16, 2008/11/28 18:15:29 version 1.17, 2008/11/29 14:14:21
Line 130  static int    roffargs(const struct rofftree *,
Line 130  static int    roffargs(const struct rofftree *,
 static  int               roffargok(int, int);  static  int               roffargok(int, int);
 static  int               roffnextopt(const struct rofftree *,  static  int               roffnextopt(const struct rofftree *,
                                 int, const char ***, char **);                                  int, const char ***, char **);
 static  int               roffparse(struct rofftree *, char *, size_t);  static  int               roffparse(struct rofftree *, char *);
 static  int               textparse(const struct rofftree *,  static  int               textparse(const struct rofftree *, char *);
                                 const char *, size_t);  
   
   
 static  const int roffarg_An[] = { ROFF_Split, ROFF_Nosplit,  static  const int roffarg_An[] = { ROFF_Split, ROFF_Nosplit,
Line 360  roff_free(struct rofftree *tree, int flush)
Line 359  roff_free(struct rofftree *tree, int flush)
         int              error, t;          int              error, t;
         struct roffnode *n;          struct roffnode *n;
   
           error = 0;
   
         if ( ! flush)          if ( ! flush)
                 goto end;                  goto end;
   
Line 372  roff_free(struct rofftree *tree, int flush)
Line 373  roff_free(struct rofftree *tree, int flush)
   
         for (n = tree->last; n->parent; n = n->parent) {          for (n = tree->last; n->parent; n = n->parent) {
                 if (0 != tokens[n->tok].ctx)                  if (0 != tokens[n->tok].ctx)
                         break;                          continue;
                 roff_warn(tree, NULL, "closing explicit scope `%s'",                  roff_warn(tree, NULL, "closing explicit scope `%s'",
                                 toknames[n->tok]);                                  toknames[n->tok]);
                 goto end;                  goto end;
Line 384  roff_free(struct rofftree *tree, int flush)
Line 385  roff_free(struct rofftree *tree, int flush)
                         goto end;                          goto end;
         }          }
   
         if ( ! (*tree->cb.roffhead)(tree->arg))          if ( ! (*tree->cb.rofftail)(tree->arg))
                 goto end;                  goto end;
   
         error = 0;          error = 0;
Line 395  end:
Line 396  end:
                 roffnode_free(tree);                  roffnode_free(tree);
   
         free(tree);          free(tree);
   
         return(error ? 0 : 1);          return(error ? 0 : 1);
 }  }
   
Line 404  roff_alloc(const struct roffcb *cb, void *args)
Line 406  roff_alloc(const struct roffcb *cb, void *args)
 {  {
         struct rofftree *tree;          struct rofftree *tree;
   
           assert(args);
           assert(cb);
   
         if (NULL == (tree = calloc(1, sizeof(struct rofftree))))          if (NULL == (tree = calloc(1, sizeof(struct rofftree))))
                 err(1, "calloc");                  err(1, "calloc");
   
Line 422  roff_alloc(const struct roffcb *cb, void *args)
Line 427  roff_alloc(const struct roffcb *cb, void *args)
   
   
 int  int
 roff_engine(struct rofftree *tree, char *buf, size_t sz)  roff_engine(struct rofftree *tree, char *buf)
 {  {
   
         tree->cur = NULL;          tree->cur = buf;
           assert(buf);
   
         if (0 == sz) {          if (0 == *buf) {
                 roff_warn(tree, buf, "blank line");                  roff_warn(tree, buf, "blank line");
                 return(0);                  return(0);
         } else if ('.' != *buf)          } else if ('.' != *buf)
                 return(textparse(tree, buf, sz));                  return(textparse(tree, buf));
   
         return(roffparse(tree, buf, sz));          return(roffparse(tree, buf));
 }  }
   
   
 static int  static int
 textparse(const struct rofftree *tree, const char *buf, size_t sz)  textparse(const struct rofftree *tree, char *buf)
 {  {
   
         /* Print text. */          return((*tree->cb.roffdata)(tree->arg, buf));
         return(1);  
 }  }
   
   
Line 512  roffscan(int tok, const int *tokv)
Line 517  roffscan(int tok, const int *tokv)
   
   
 static int  static int
 roffparse(struct rofftree *tree, char *buf, size_t sz)  roffparse(struct rofftree *tree, char *buf)
 {  {
         int               tok, t;          int               tok, t;
         struct roffnode  *n;          struct roffnode  *n;
         char             *argv[ROFF_MAXARG];          char             *argv[ROFF_MAXARG];
         const char      **argvp;          const char      **argvp;
   
         assert(sz > 0);  
   
         if (ROFF_MAX == (tok = rofffindtok(buf + 1))) {          if (ROFF_MAX == (tok = rofffindtok(buf + 1))) {
                 roff_err(tree, buf + 1, "bogus line macro");                  roff_err(tree, buf + 1, "bogus line macro");
                 return(0);                  return(0);
Line 959  roff_layout(ROFFCALL_ARGS) 
Line 962  roff_layout(ROFFCALL_ARGS) 
                         break;                          break;
                 }                  }
   
                   assert(tree->arg);
                 if ( ! (*tree->cb.roffdata)(tree->arg, *argv++))                  if ( ! (*tree->cb.roffdata)(tree->arg, *argv++))
                         return(0);                          return(0);
         }          }

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

CVSweb