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

Diff for /mandoc/roff.c between version 1.320 and 1.321

version 1.320, 2017/07/08 15:28:09 version 1.321, 2017/07/08 17:52:50
Line 153  static void   roffnode_cleanscope(struct roff *);
Line 153  static void   roffnode_cleanscope(struct roff *);
 static  void             roffnode_pop(struct roff *);  static  void             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  enum rofferr     roff_als(ROFF_ARGS);  static  enum rofferr     roff_als(ROFF_ARGS);
 static  enum rofferr     roff_block(ROFF_ARGS);  static  enum rofferr     roff_block(ROFF_ARGS);
 static  enum rofferr     roff_block_text(ROFF_ARGS);  static  enum rofferr     roff_block_text(ROFF_ARGS);
Line 979  roff_body_alloc(struct roff_man *man, int line, int po
Line 980  roff_body_alloc(struct roff_man *man, int line, int po
         return n;          return n;
 }  }
   
 void  static void
 roff_addtbl(struct roff_man *man, const struct tbl_span *tbl)  roff_addtbl(struct roff_man *man, struct tbl_node *tbl)
 {  {
         struct roff_node        *n;          struct roff_node        *n;
           const struct tbl_span   *span;
   
         if (man->macroset == MACROSET_MAN)          if (man->macroset == MACROSET_MAN)
                 man_breakscope(man, ROFF_TS);                  man_breakscope(man, ROFF_TS);
         n = roff_node_alloc(man, tbl->line, 0, ROFFT_TBL, TOKEN_NONE);          while ((span = tbl_span(tbl)) != NULL) {
         n->span = tbl;                  n = roff_node_alloc(man, tbl->line, 0, ROFFT_TBL, TOKEN_NONE);
         roff_node_append(man, n);                  n->span = span;
         n->flags |= NODE_VALID | NODE_ENDED;                  roff_node_append(man, n);
         man->next = ROFF_NEXT_SIBLING;                  n->flags |= NODE_VALID | NODE_ENDED;
                   man->next = ROFF_NEXT_SIBLING;
           }
 }  }
   
 void  void
Line 1501  roff_parseln(struct roff *r, int ln, struct buf *buf, 
Line 1505  roff_parseln(struct roff *r, int ln, struct buf *buf, 
                 eqn_read(r->eqn, buf->buf + ppos);                  eqn_read(r->eqn, buf->buf + ppos);
                 return ROFF_IGN;                  return ROFF_IGN;
         }          }
         if (r->tbl != NULL && ( ! ctl || buf->buf[pos] == '\0'))          if (r->tbl != NULL && (ctl == 0 || buf->buf[pos] == '\0')) {
                 return tbl_read(r->tbl, ln, buf->buf, ppos);                  tbl_read(r->tbl, ln, buf->buf, ppos);
                   roff_addtbl(r->man, r->tbl);
                   return ROFF_IGN;
           }
         if ( ! ctl)          if ( ! ctl)
                 return roff_parsetext(r, buf, pos, offs);                  return roff_parsetext(r, buf, pos, offs);
   
Line 1543  roff_parseln(struct roff *r, int ln, struct buf *buf, 
Line 1550  roff_parseln(struct roff *r, int ln, struct buf *buf, 
                         pos++;                          pos++;
                 while (buf->buf[pos] == ' ')                  while (buf->buf[pos] == ' ')
                         pos++;                          pos++;
                 return tbl_read(r->tbl, ln, buf->buf, pos);                  tbl_read(r->tbl, ln, buf->buf, pos);
                   roff_addtbl(r->man, r->tbl);
                   return ROFF_IGN;
         }          }
   
         /* For now, let high level macros abort .ce mode. */          /* For now, let high level macros abort .ce mode. */
Line 1572  roff_parseln(struct roff *r, int ln, struct buf *buf, 
Line 1581  roff_parseln(struct roff *r, int ln, struct buf *buf, 
 void  void
 roff_endparse(struct roff *r)  roff_endparse(struct roff *r)
 {  {
           if (r->last != NULL)
         if (r->last)  
                 mandoc_msg(MANDOCERR_BLK_NOEND, r->parse,                  mandoc_msg(MANDOCERR_BLK_NOEND, r->parse,
                     r->last->line, r->last->col,                      r->last->line, r->last->col,
                     roff_name[r->last->tok]);                      roff_name[r->last->tok]);
   
         if (r->eqn) {          if (r->eqn != NULL) {
                 mandoc_msg(MANDOCERR_BLK_NOEND, r->parse,                  mandoc_msg(MANDOCERR_BLK_NOEND, r->parse,
                     r->eqn->node->line, r->eqn->node->pos, "EQ");                      r->eqn->node->line, r->eqn->node->pos, "EQ");
                 eqn_parse(r->eqn);                  eqn_parse(r->eqn);
                 r->eqn = NULL;                  r->eqn = NULL;
         }          }
   
         if (r->tbl) {          if (r->tbl != NULL) {
                 mandoc_msg(MANDOCERR_BLK_NOEND, r->parse,                  mandoc_msg(MANDOCERR_BLK_NOEND, r->parse,
                     r->tbl->line, r->tbl->pos, "TS");                      r->tbl->line, r->tbl->pos, "TS");
                 tbl_end(&r->tbl);                  tbl_end(r->tbl);
                   r->tbl = NULL;
         }          }
 }  }
   
Line 2770  roff_Dd(ROFF_ARGS)
Line 2779  roff_Dd(ROFF_ARGS)
 static enum rofferr  static enum rofferr
 roff_TE(ROFF_ARGS)  roff_TE(ROFF_ARGS)
 {  {
           if (r->tbl == NULL) {
         if (NULL == r->tbl)  
                 mandoc_msg(MANDOCERR_BLK_NOTOPEN, r->parse,                  mandoc_msg(MANDOCERR_BLK_NOTOPEN, r->parse,
                     ln, ppos, "TE");                      ln, ppos, "TE");
         else if ( ! tbl_end(&r->tbl)) {                  return ROFF_IGN;
           }
           if (tbl_end(r->tbl) == 0) {
                   r->tbl = NULL;
                 free(buf->buf);                  free(buf->buf);
                 buf->buf = mandoc_strdup(".sp");                  buf->buf = mandoc_strdup(".sp");
                 buf->sz = 4;                  buf->sz = 4;
                 return ROFF_REPARSE;                  return ROFF_REPARSE;
         }          }
           r->tbl = NULL;
         return ROFF_IGN;          return ROFF_IGN;
 }  }
   
Line 2907  roff_EN(ROFF_ARGS)
Line 2919  roff_EN(ROFF_ARGS)
 static enum rofferr  static enum rofferr
 roff_TS(ROFF_ARGS)  roff_TS(ROFF_ARGS)
 {  {
         struct tbl_node *tbl;          if (r->tbl != NULL) {
   
         if (r->tbl) {  
                 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);
         }          }
           r->tbl = tbl_alloc(ppos, ln, r->parse);
         tbl = tbl_alloc(ppos, ln, r->parse);  
   
         if (r->last_tbl)          if (r->last_tbl)
                 r->last_tbl->next = tbl;                  r->last_tbl->next = r->tbl;
         else          else
                 r->first_tbl = r->last_tbl = tbl;                  r->first_tbl = r->tbl;
           r->last_tbl = r->tbl;
         r->tbl = r->last_tbl = tbl;  
         return ROFF_IGN;          return ROFF_IGN;
 }  }
   
Line 3600  roff_freestr(struct roffkv *r)
Line 3607  roff_freestr(struct roffkv *r)
 }  }
   
 /* --- accessors and utility functions ------------------------------------ */  /* --- accessors and utility functions ------------------------------------ */
   
 const struct tbl_span *  
 roff_span(const struct roff *r)  
 {  
   
         return r->tbl ? tbl_span(r->tbl) : NULL;  
 }  
   
 /*  /*
  * Duplicate an input string, making the appropriate character   * Duplicate an input string, making the appropriate character

Legend:
Removed from v.1.320  
changed lines
  Added in v.1.321

CVSweb