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

Diff for /mandoc/roff.c between version 1.345 and 1.349

version 1.345, 2018/12/12 21:54:35 version 1.349, 2018/12/13 11:55:47
Line 32 
Line 32 
 #include "mandoc_ohash.h"  #include "mandoc_ohash.h"
 #include "mandoc.h"  #include "mandoc.h"
 #include "roff.h"  #include "roff.h"
 #include "tbl.h"  #include "mandoc_parse.h"
 #include "libmandoc.h"  #include "libmandoc.h"
 #include "roff_int.h"  #include "roff_int.h"
 #include "libroff.h"  #include "tbl_parse.h"
   #include "eqn_parse.h"
   
 /* Maximum number of string expansions per line, to break infinite loops. */  /* Maximum number of string expansions per line, to break infinite loops. */
 #define EXPAND_LIMIT    1000  #define EXPAND_LIMIT    1000
Line 168  static int   roffnode_cleanscope(struct roff *);
Line 169  static int   roffnode_cleanscope(struct roff *);
 static  int              roffnode_pop(struct roff *);  static  int              roffnode_pop(struct roff *);
 static  void             roffnode_push(struct roff *, enum roff_tok,  static  void             roffnode_push(struct roff *, enum roff_tok,
                                 const char *, int, int);                                  const char *, int, int);
 static  void             roff_addtbl(struct roff_man *, struct tbl_node *);  static  void             roff_addtbl(struct roff_man *, int, struct tbl_node *);
 static  int              roff_als(ROFF_ARGS);  static  int              roff_als(ROFF_ARGS);
 static  int              roff_block(ROFF_ARGS);  static  int              roff_block(ROFF_ARGS);
 static  int              roff_block_text(ROFF_ARGS);  static  int              roff_block_text(ROFF_ARGS);
Line 718  roffnode_push(struct roff *r, enum roff_tok tok, const
Line 719  roffnode_push(struct roff *r, enum roff_tok tok, const
 static void  static void
 roff_free1(struct roff *r)  roff_free1(struct roff *r)
 {  {
         struct tbl_node *tbl;  
         int              i;          int              i;
   
         while (NULL != (tbl = r->first_tbl)) {          tbl_free(r->first_tbl);
                 r->first_tbl = tbl->next;  
                 tbl_free(tbl);  
         }  
         r->first_tbl = r->last_tbl = r->tbl = NULL;          r->first_tbl = r->last_tbl = r->tbl = NULL;
   
         if (r->last_eqn != NULL)          eqn_free(r->last_eqn);
                 eqn_free(r->last_eqn);  
         r->last_eqn = r->eqn = NULL;          r->last_eqn = r->eqn = NULL;
   
         while (r->mstackpos >= 0)          while (r->mstackpos >= 0)
Line 1014  roff_body_alloc(struct roff_man *man, int line, int po
Line 1010  roff_body_alloc(struct roff_man *man, int line, int po
 }  }
   
 static void  static void
 roff_addtbl(struct roff_man *man, struct tbl_node *tbl)  roff_addtbl(struct roff_man *man, int line, struct tbl_node *tbl)
 {  {
         struct roff_node        *n;          struct roff_node        *n;
         const struct tbl_span   *span;          struct tbl_span         *span;
   
         if (man->macroset == MACROSET_MAN)          if (man->macroset == MACROSET_MAN)
                 man_breakscope(man, ROFF_TS);                  man_breakscope(man, ROFF_TS);
         while ((span = tbl_span(tbl)) != NULL) {          while ((span = tbl_span(tbl)) != NULL) {
                 n = roff_node_alloc(man, tbl->line, 0, ROFFT_TBL, TOKEN_NONE);                  n = roff_node_alloc(man, line, 0, ROFFT_TBL, TOKEN_NONE);
                 n->span = span;                  n->span = span;
                 roff_node_append(man, n);                  roff_node_append(man, n);
                 n->flags |= NODE_VALID | NODE_ENDED;                  n->flags |= NODE_VALID | NODE_ENDED;
Line 1083  roff_node_free(struct roff_node *n)
Line 1079  roff_node_free(struct roff_node *n)
                 mdoc_argv_free(n->args);                  mdoc_argv_free(n->args);
         if (n->type == ROFFT_BLOCK || n->type == ROFFT_ELEM)          if (n->type == ROFFT_BLOCK || n->type == ROFFT_ELEM)
                 free(n->norm);                  free(n->norm);
         if (n->eqn != NULL)          eqn_box_free(n->eqn);
                 eqn_box_free(n->eqn);  
         free(n->string);          free(n->string);
         free(n);          free(n);
 }  }
Line 1660  roff_parseln(struct roff *r, int ln, struct buf *buf, 
Line 1655  roff_parseln(struct roff *r, int ln, struct buf *buf, 
         }          }
         if (r->tbl != NULL && (ctl == 0 || buf->buf[pos] == '\0')) {          if (r->tbl != NULL && (ctl == 0 || buf->buf[pos] == '\0')) {
                 tbl_read(r->tbl, ln, buf->buf, ppos);                  tbl_read(r->tbl, ln, buf->buf, ppos);
                 roff_addtbl(r->man, r->tbl);                  roff_addtbl(r->man, ln, r->tbl);
                 return e;                  return e;
         }          }
         if ( ! ctl)          if ( ! ctl)
Line 1704  roff_parseln(struct roff *r, int ln, struct buf *buf, 
Line 1699  roff_parseln(struct roff *r, int ln, struct buf *buf, 
                 while (buf->buf[pos] == ' ')                  while (buf->buf[pos] == ' ')
                         pos++;                          pos++;
                 tbl_read(r->tbl, ln, buf->buf, pos);                  tbl_read(r->tbl, ln, buf->buf, pos);
                 roff_addtbl(r->man, r->tbl);                  roff_addtbl(r->man, ln, r->tbl);
                 return ROFF_IGN;                  return ROFF_IGN;
         }          }
   
Line 1767  roff_endparse(struct roff *r)
Line 1762  roff_endparse(struct roff *r)
         }          }
   
         if (r->tbl != NULL) {          if (r->tbl != NULL) {
                 mandoc_msg(MANDOCERR_BLK_NOEND, r->parse,                  tbl_end(r->tbl, 1);
                     r->tbl->line, r->tbl->pos, "TS");  
                 tbl_end(r->tbl);  
                 r->tbl = NULL;                  r->tbl = NULL;
         }          }
 }  }
Line 3060  roff_TE(ROFF_ARGS)
Line 3053  roff_TE(ROFF_ARGS)
                     ln, ppos, "TE");                      ln, ppos, "TE");
                 return ROFF_IGN;                  return ROFF_IGN;
         }          }
         if (tbl_end(r->tbl) == 0) {          if (tbl_end(r->tbl, 0) == 0) {
                 r->tbl = NULL;                  r->tbl = NULL;
                 free(buf->buf);                  free(buf->buf);
                 buf->buf = mandoc_strdup(".sp");                  buf->buf = mandoc_strdup(".sp");
Line 3161  roff_EQ(ROFF_ARGS)
Line 3154  roff_EQ(ROFF_ARGS)
         n = roff_node_alloc(r->man, ln, ppos, ROFFT_EQN, TOKEN_NONE);          n = roff_node_alloc(r->man, ln, ppos, ROFFT_EQN, TOKEN_NONE);
         if (ln > r->man->last->line)          if (ln > r->man->last->line)
                 n->flags |= NODE_LINE;                  n->flags |= NODE_LINE;
         n->eqn = mandoc_calloc(1, sizeof(*n->eqn));          n->eqn = eqn_box_new();
         n->eqn->expectargs = UINT_MAX;  
         roff_node_append(r->man, n);          roff_node_append(r->man, n);
         r->man->next = ROFF_NEXT_SIBLING;          r->man->next = ROFF_NEXT_SIBLING;
   
Line 3201  roff_TS(ROFF_ARGS)
Line 3193  roff_TS(ROFF_ARGS)
         if (r->tbl != NULL) {          if (r->tbl != NULL) {
                 mandoc_msg(MANDOCERR_BLK_BROKEN, r->parse,                  mandoc_msg(MANDOCERR_BLK_BROKEN, r->parse,
                     ln, ppos, "TS breaks TS");                      ln, ppos, "TS breaks TS");
                 tbl_end(r->tbl);                  tbl_end(r->tbl, 0);
         }          }
         r->tbl = tbl_alloc(ppos, ln, r->parse);          r->tbl = tbl_alloc(ppos, ln, r->parse, r->last_tbl);
         if (r->last_tbl)          if (r->last_tbl == NULL)
                 r->last_tbl->next = r->tbl;  
         else  
                 r->first_tbl = r->tbl;                  r->first_tbl = r->tbl;
         r->last_tbl = r->tbl;          r->last_tbl = r->tbl;
         return ROFF_IGN;          return ROFF_IGN;

Legend:
Removed from v.1.345  
changed lines
  Added in v.1.349

CVSweb