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

Diff for /mandoc/roff.c between version 1.295 and 1.302

version 1.295, 2017/04/29 12:45:42 version 1.302, 2017/05/08 20:33:53
Line 77  struct roffreq {
Line 77  struct roffreq {
   
 struct  roff {  struct  roff {
         struct mparse   *parse; /* parse point */          struct mparse   *parse; /* parse point */
           struct roff_man *man; /* mdoc or man parser */
         struct roffnode *last; /* leaf of stack */          struct roffnode *last; /* leaf of stack */
         int             *rstack; /* stack of inverted `ie' values */          int             *rstack; /* stack of inverted `ie' values */
         struct ohash    *reqtab; /* request lookup table */          struct ohash    *reqtab; /* request lookup table */
Line 146  static void   roffnode_push(struct roff *, enum roff_t
Line 147  static void   roffnode_push(struct roff *, enum roff_t
 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);
 static  enum rofferr     roff_block_sub(ROFF_ARGS);  static  enum rofferr     roff_block_sub(ROFF_ARGS);
 static  enum rofferr     roff_brp(ROFF_ARGS);  static  enum rofferr     roff_br(ROFF_ARGS);
 static  enum rofferr     roff_cblock(ROFF_ARGS);  static  enum rofferr     roff_cblock(ROFF_ARGS);
 static  enum rofferr     roff_cc(ROFF_ARGS);  static  enum rofferr     roff_cc(ROFF_ARGS);
 static  void             roff_ccond(struct roff *, int, int);  static  void             roff_ccond(struct roff *, int, int);
Line 180  static enum rofferr  roff_it(ROFF_ARGS);
Line 181  static enum rofferr  roff_it(ROFF_ARGS);
 static  enum rofferr     roff_line_ignore(ROFF_ARGS);  static  enum rofferr     roff_line_ignore(ROFF_ARGS);
 static  void             roff_man_alloc1(struct roff_man *);  static  void             roff_man_alloc1(struct roff_man *);
 static  void             roff_man_free1(struct roff_man *);  static  void             roff_man_free1(struct roff_man *);
   static  enum rofferr     roff_manyarg(ROFF_ARGS);
 static  enum rofferr     roff_nr(ROFF_ARGS);  static  enum rofferr     roff_nr(ROFF_ARGS);
   static  enum rofferr     roff_onearg(ROFF_ARGS);
 static  enum roff_tok    roff_parse(struct roff *, char *, int *,  static  enum roff_tok    roff_parse(struct roff *, char *, int *,
                                 int, int);                                  int, int);
 static  enum rofferr     roff_parsetext(struct buf *, int, int *);  static  enum rofferr     roff_parsetext(struct buf *, int, int *);
Line 209  static enum rofferr  roff_userdef(ROFF_ARGS);
Line 212  static enum rofferr  roff_userdef(ROFF_ARGS);
 #define ROFFNUM_WHITE   (1 << 1)  /* Skip whitespace in roff_evalnum(). */  #define ROFFNUM_WHITE   (1 << 1)  /* Skip whitespace in roff_evalnum(). */
   
 const char *__roff_name[MAN_MAX + 1] = {  const char *__roff_name[MAN_MAX + 1] = {
           "br",           "ft",           "ll",           "sp",
           "ta",           "ti",           NULL,
         "ab",           "ad",           "af",           "aln",          "ab",           "ad",           "af",           "aln",
         "als",          "am",           "am1",          "ami",          "als",          "am",           "am1",          "ami",
         "ami1",         "as",           "as1",          "asciify",          "ami1",         "as",           "as1",          "asciify",
Line 258  const char *__roff_name[MAN_MAX + 1] = {
Line 263  const char *__roff_name[MAN_MAX + 1] = {
         "shc",          "shift",        "sizes",        "so",          "shc",          "shift",        "sizes",        "so",
         "spacewidth",   "special",      "spreadwarn",   "ss",          "spacewidth",   "special",      "spreadwarn",   "ss",
         "sty",          "substring",    "sv",           "sy",          "sty",          "substring",    "sv",           "sy",
         "T&",           "ta",           "tc",           "TE",          "T&",           "tc",           "TE",
         "TH",           "ti",           "tkf",          "tl",          "TH",           "tkf",          "tl",
         "tm",           "tm1",          "tmc",          "tr",          "tm",           "tm1",          "tmc",          "tr",
         "track",        "transchar",    "trf",          "trimat",          "track",        "transchar",    "trf",          "trimat",
         "trin",         "trnt",         "troff",        "TS",          "trin",         "trnt",         "troff",        "TS",
Line 298  const char *__roff_name[MAN_MAX + 1] = {
Line 303  const char *__roff_name[MAN_MAX + 1] = {
         "Fr",           "Ud",           "Lb",           "Lp",          "Fr",           "Ud",           "Lb",           "Lp",
         "Lk",           "Mt",           "Brq",          "Bro",          "Lk",           "Mt",           "Brq",          "Bro",
         "Brc",          "%C",           "Es",           "En",          "Brc",          "%C",           "Es",           "En",
         "Dx",           "%Q",           "br",           "sp",          "Dx",           "%Q",           "%U",           "Ta",
         "%U",           "Ta",           "ll",           NULL,          NULL,
         "TH",           "SH",           "SS",           "TP",          "TH",           "SH",           "SS",           "TP",
         "LP",           "PP",           "P",            "IP",          "LP",           "PP",           "P",            "IP",
         "HP",           "SM",           "SB",           "BI",          "HP",           "SM",           "SB",           "BI",
         "IB",           "BR",           "RB",           "R",          "IB",           "BR",           "RB",           "R",
         "B",            "I",            "IR",           "RI",          "B",            "I",            "IR",           "RI",
         "br",           "sp",           "nf",           "fi",          "nf",           "fi",
         "RE",           "RS",           "DT",           "UC",          "RE",           "RS",           "DT",           "UC",
         "PD",           "AT",           "in",           "ft",          "PD",           "AT",           "in",
         "OP",           "EX",           "EE",           "UR",          "OP",           "EX",           "EE",           "UR",
         "UE",           "ll",           NULL          "UE",           NULL
 };  };
 const   char *const *roff_name = __roff_name;  const   char *const *roff_name = __roff_name;
   
 static  struct roffmac   roffs[TOKEN_NONE] = {  static  struct roffmac   roffs[TOKEN_NONE] = {
           { roff_br, NULL, NULL, 0 },  /* br */
           { roff_onearg, NULL, NULL, 0 },  /* ft */
           { roff_onearg, NULL, NULL, 0 },  /* ll */
           { roff_onearg, NULL, NULL, 0 },  /* sp */
           { roff_manyarg, NULL, NULL, 0 },  /* ta */
           { roff_onearg, NULL, NULL, 0 },  /* ti */
           { NULL, NULL, NULL, 0 },  /* ROFF_MAX */
         { roff_unsupp, NULL, NULL, 0 },  /* ab */          { roff_unsupp, NULL, NULL, 0 },  /* ab */
         { roff_line_ignore, NULL, NULL, 0 },  /* ad */          { roff_line_ignore, NULL, NULL, 0 },  /* ad */
         { roff_line_ignore, NULL, NULL, 0 },  /* af */          { roff_line_ignore, NULL, NULL, 0 },  /* af */
Line 337  static struct roffmac  roffs[TOKEN_NONE] = {
Line 349  static struct roffmac  roffs[TOKEN_NONE] = {
         { roff_unsupp, NULL, NULL, 0 },  /* break */          { roff_unsupp, NULL, NULL, 0 },  /* break */
         { roff_line_ignore, NULL, NULL, 0 },  /* breakchar */          { roff_line_ignore, NULL, NULL, 0 },  /* breakchar */
         { roff_line_ignore, NULL, NULL, 0 },  /* brnl */          { roff_line_ignore, NULL, NULL, 0 },  /* brnl */
         { roff_brp, NULL, NULL, 0 },  /* brp */          { roff_br, NULL, NULL, 0 },  /* brp */
         { roff_line_ignore, NULL, NULL, 0 },  /* brpnl */          { roff_line_ignore, NULL, NULL, 0 },  /* brpnl */
         { roff_unsupp, NULL, NULL, 0 },  /* c2 */          { roff_unsupp, NULL, NULL, 0 },  /* c2 */
         { roff_cc, NULL, NULL, 0 },  /* cc */          { roff_cc, NULL, NULL, 0 },  /* cc */
Line 511  static struct roffmac  roffs[TOKEN_NONE] = {
Line 523  static struct roffmac  roffs[TOKEN_NONE] = {
         { roff_line_ignore, NULL, NULL, 0 },  /* sv */          { roff_line_ignore, NULL, NULL, 0 },  /* sv */
         { roff_insec, NULL, NULL, 0 },  /* sy */          { roff_insec, NULL, NULL, 0 },  /* sy */
         { roff_T_, NULL, NULL, 0 },  /* T& */          { roff_T_, NULL, NULL, 0 },  /* T& */
         { roff_unsupp, NULL, NULL, 0 },  /* ta */  
         { roff_unsupp, NULL, NULL, 0 },  /* tc */          { roff_unsupp, NULL, NULL, 0 },  /* tc */
         { roff_TE, NULL, NULL, 0 },  /* TE */          { roff_TE, NULL, NULL, 0 },  /* TE */
         { roff_TH, NULL, NULL, 0 },  /* TH */          { roff_TH, NULL, NULL, 0 },  /* TH */
         { roff_unsupp, NULL, NULL, 0 },  /* ti */  
         { roff_line_ignore, NULL, NULL, 0 },  /* tkf */          { roff_line_ignore, NULL, NULL, 0 },  /* tkf */
         { roff_unsupp, NULL, NULL, 0 },  /* tl */          { roff_unsupp, NULL, NULL, 0 },  /* tl */
         { roff_line_ignore, NULL, NULL, 0 },  /* tm */          { roff_line_ignore, NULL, NULL, 0 },  /* tm */
Line 610  roffhash_alloc(enum roff_tok mintok, enum roff_tok max
Line 620  roffhash_alloc(enum roff_tok mintok, enum roff_tok max
         mandoc_ohash_init(htab, 8, offsetof(struct roffreq, name));          mandoc_ohash_init(htab, 8, offsetof(struct roffreq, name));
   
         for (tok = mintok; tok < maxtok; tok++) {          for (tok = mintok; tok < maxtok; tok++) {
                   if (roff_name[tok] == NULL)
                           continue;
                 sz = strlen(roff_name[tok]);                  sz = strlen(roff_name[tok]);
                 req = mandoc_malloc(sizeof(*req) + sz + 1);                  req = mandoc_malloc(sizeof(*req) + sz + 1);
                 req->tok = tok;                  req->tok = tok;
Line 824  roff_man_alloc(struct roff *roff, struct mparse *parse
Line 836  roff_man_alloc(struct roff *roff, struct mparse *parse
         man->defos = defos;          man->defos = defos;
         man->quick = quick;          man->quick = quick;
         roff_man_alloc1(man);          roff_man_alloc1(man);
           roff->man = man;
         return man;          return man;
 }  }
   
Line 996  roff_addtbl(struct roff_man *man, const struct tbl_spa
Line 1009  roff_addtbl(struct roff_man *man, const struct tbl_spa
         struct roff_node        *n;          struct roff_node        *n;
   
         if (man->macroset == MACROSET_MAN)          if (man->macroset == MACROSET_MAN)
                 man_breakscope(man, TOKEN_NONE);                  man_breakscope(man, ROFF_TS);
         n = roff_node_alloc(man, tbl->line, 0, ROFFT_TBL, TOKEN_NONE);          n = roff_node_alloc(man, tbl->line, 0, ROFFT_TBL, TOKEN_NONE);
         n->span = tbl;          n->span = tbl;
         roff_node_append(man, n);          roff_node_append(man, n);
Line 1473  roff_parseln(struct roff *r, int ln, struct buf *buf, 
Line 1486  roff_parseln(struct roff *r, int ln, struct buf *buf, 
   
         /* Execute a roff request or a user defined macro. */          /* Execute a roff request or a user defined macro. */
   
         return (*roffs[t].proc)(r, t, buf, ln, ppos, pos, offs);          return (*roffs[t].proc)(r, t, buf, ln, spos, pos, offs);
 }  }
   
 void  void
Line 2633  roff_T_(ROFF_ARGS)
Line 2646  roff_T_(ROFF_ARGS)
                 mandoc_msg(MANDOCERR_BLK_NOTOPEN, r->parse,                  mandoc_msg(MANDOCERR_BLK_NOTOPEN, r->parse,
                     ln, ppos, "T&");                      ln, ppos, "T&");
         else          else
                 tbl_restart(ppos, ln, r->tbl);                  tbl_restart(ln, ppos, r->tbl);
   
         return ROFF_IGN;          return ROFF_IGN;
 }  }
Line 2760  roff_TS(ROFF_ARGS)
Line 2773  roff_TS(ROFF_ARGS)
 }  }
   
 static enum rofferr  static enum rofferr
 roff_brp(ROFF_ARGS)  roff_onearg(ROFF_ARGS)
 {  {
           struct roff_node        *n;
           char                    *cp;
   
         buf->buf[pos - 1] = '\0';          if (r->man->flags & (MAN_BLINE | MAN_ELINE) &&
         return ROFF_CONT;              (tok == ROFF_sp || tok == ROFF_ti))
                   man_breakscope(r->man, tok);
   
           roff_elem_alloc(r->man, ln, ppos, tok);
           n = r->man->last;
   
           cp = buf->buf + pos;
           if (*cp != '\0') {
                   while (*cp != '\0' && *cp != ' ')
                           cp++;
                   while (*cp == ' ')
                           *cp++ = '\0';
                   if (*cp != '\0')
                           mandoc_vmsg(MANDOCERR_ARG_EXCESS,
                               r->parse, ln, cp - buf->buf,
                               "%s ... %s", roff_name[tok], cp);
                   roff_word_alloc(r->man, ln, pos, buf->buf + pos);
           }
   
           n->flags |= NODE_LINE | NODE_VALID | NODE_ENDED;
           r->man->last = n;
           r->man->next = ROFF_NEXT_SIBLING;
           return ROFF_IGN;
   }
   
   static enum rofferr
   roff_manyarg(ROFF_ARGS)
   {
           struct roff_node        *n;
           char                    *sp, *ep;
   
           roff_elem_alloc(r->man, ln, ppos, tok);
           n = r->man->last;
   
           for (sp = ep = buf->buf + pos; *sp != '\0'; sp = ep) {
                   while (*ep != '\0' && *ep != ' ')
                           ep++;
                   while (*ep == ' ')
                           *ep++ = '\0';
                   roff_word_alloc(r->man, ln, sp - buf->buf, sp);
           }
   
           n->flags |= NODE_LINE | NODE_VALID | NODE_ENDED;
           r->man->last = n;
           r->man->next = ROFF_NEXT_SIBLING;
           return ROFF_IGN;
   }
   
   static enum rofferr
   roff_br(ROFF_ARGS)
   {
           if (r->man->flags & (MAN_BLINE | MAN_ELINE))
                   man_breakscope(r->man, ROFF_br);
           roff_elem_alloc(r->man, ln, ppos, ROFF_br);
           if (buf->buf[pos] != '\0')
                   mandoc_vmsg(MANDOCERR_ARG_SKIP, r->parse, ln, pos,
                       "%s %s", roff_name[tok], buf->buf + pos);
           r->man->last->flags |= NODE_LINE | NODE_VALID | NODE_ENDED;
           r->man->next = ROFF_NEXT_SIBLING;
           return ROFF_IGN;
 }  }
   
 static enum rofferr  static enum rofferr

Legend:
Removed from v.1.295  
changed lines
  Added in v.1.302

CVSweb