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

Diff for /mandoc/roff.c between version 1.327 and 1.335

version 1.327, 2018/04/10 00:52:30 version 1.335, 2018/08/18 22:05:43
Line 197  static enum rofferr  roff_line_ignore(ROFF_ARGS);
Line 197  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_manyarg(ROFF_ARGS);
   static  enum rofferr     roff_nop(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 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 *,
Line 326  const char *__roff_name[MAN_MAX + 1] = {
Line 327  const char *__roff_name[MAN_MAX + 1] = {
         "Dx",           "%Q",           "%U",           "Ta",          "Dx",           "%Q",           "%U",           "Ta",
         NULL,          NULL,
         "TH",           "SH",           "SS",           "TP",          "TH",           "SH",           "SS",           "TP",
           "TQ",
         "LP",           "PP",           "P",            "IP",          "LP",           "PP",           "P",            "IP",
         "HP",           "SM",           "SB",           "BI",          "HP",           "SM",           "SB",           "BI",
         "IB",           "BR",           "RB",           "R",          "IB",           "BR",           "RB",           "R",
Line 333  const char *__roff_name[MAN_MAX + 1] = {
Line 335  const char *__roff_name[MAN_MAX + 1] = {
         "nf",           "fi",          "nf",           "fi",
         "RE",           "RS",           "DT",           "UC",          "RE",           "RS",           "DT",           "UC",
         "PD",           "AT",           "in",          "PD",           "AT",           "in",
         "OP",           "EX",           "EE",           "UR",          "SY",           "YS",           "OP",
           "EX",           "EE",           "UR",
         "UE",           "MT",           "ME",           NULL          "UE",           "MT",           "ME",           NULL
 };  };
 const   char *const *roff_name = __roff_name;  const   char *const *roff_name = __roff_name;
Line 490  static struct roffmac  roffs[TOKEN_NONE] = {
Line 493  static struct roffmac  roffs[TOKEN_NONE] = {
         { roff_line_ignore, NULL, NULL, 0 },  /* nhychar */          { roff_line_ignore, NULL, NULL, 0 },  /* nhychar */
         { roff_unsupp, NULL, NULL, 0 },  /* nm */          { roff_unsupp, NULL, NULL, 0 },  /* nm */
         { roff_unsupp, NULL, NULL, 0 },  /* nn */          { roff_unsupp, NULL, NULL, 0 },  /* nn */
         { roff_unsupp, NULL, NULL, 0 },  /* nop */          { roff_nop, NULL, NULL, 0 },  /* nop */
         { roff_nr, NULL, NULL, 0 },  /* nr */          { roff_nr, NULL, NULL, 0 },  /* nr */
         { roff_unsupp, NULL, NULL, 0 },  /* nrf */          { roff_unsupp, NULL, NULL, 0 },  /* nrf */
         { roff_line_ignore, NULL, NULL, 0 },  /* nroff */          { roff_line_ignore, NULL, NULL, 0 },  /* nroff */
Line 762  roff_alloc(struct mparse *parse, int options)
Line 765  roff_alloc(struct mparse *parse, int options)
   
         r = mandoc_calloc(1, sizeof(struct roff));          r = mandoc_calloc(1, sizeof(struct roff));
         r->parse = parse;          r->parse = parse;
         r->reqtab = roffhash_alloc(0, ROFF_USERDEF);          r->reqtab = roffhash_alloc(0, ROFF_RENAMED);
         r->options = options;          r->options = options;
         r->format = options & (MPARSE_MDOC | MPARSE_MAN);          r->format = options & (MPARSE_MDOC | MPARSE_MAN);
         r->rstackpos = -1;          r->rstackpos = -1;
Line 1122  static enum rofferr
Line 1125  static enum rofferr
 roff_res(struct roff *r, struct buf *buf, int ln, int pos)  roff_res(struct roff *r, struct buf *buf, int ln, int pos)
 {  {
         char             ubuf[24]; /* buffer to print the number */          char             ubuf[24]; /* buffer to print the number */
           struct roff_node *n;    /* used for header comments */
         const char      *start; /* start of the string to process */          const char      *start; /* start of the string to process */
         char            *stesc; /* start of an escape sequence ('\\') */          char            *stesc; /* start of an escape sequence ('\\') */
           char            *ep;    /* end of comment string */
         const char      *stnam; /* start of the name, after "[(*" */          const char      *stnam; /* start of the name, after "[(*" */
         const char      *cp;    /* end of the name, e.g. before ']' */          const char      *cp;    /* end of the name, e.g. before ']' */
         const char      *res;   /* the string to be substituted */          const char      *res;   /* the string to be substituted */
Line 1173  roff_res(struct roff *r, struct buf *buf, int ln, int 
Line 1178  roff_res(struct roff *r, struct buf *buf, int ln, int 
   
                 /* Handle trailing whitespace. */                  /* Handle trailing whitespace. */
   
                 cp = strchr(stesc--, '\0') - 1;                  ep = strchr(stesc--, '\0') - 1;
                 if (*cp == '\n') {                  if (*ep == '\n') {
                         done = 1;                          done = 1;
                         cp--;                          ep--;
                 }                  }
                 if (*cp == ' ' || *cp == '\t')                  if (*ep == ' ' || *ep == '\t')
                         mandoc_msg(MANDOCERR_SPACE_EOL, r->parse,                          mandoc_msg(MANDOCERR_SPACE_EOL, r->parse,
                             ln, cp - buf->buf, NULL);                              ln, ep - buf->buf, NULL);
                 while (stesc > start && stesc[-1] == ' ')  
                   /*
                    * Save comments preceding the title macro
                    * in the syntax tree.
                    */
   
                   if (r->format == 0) {
                           while (*ep == ' ' || *ep == '\t')
                                   ep--;
                           ep[1] = '\0';
                           n = roff_node_alloc(r->man,
                               ln, stesc + 1 - buf->buf,
                               ROFFT_COMMENT, TOKEN_NONE);
                           n->string = mandoc_strdup(stesc + 2);
                           roff_node_append(r->man, n);
                           n->flags |= NODE_VALID | NODE_ENDED;
                           r->man->next = ROFF_NEXT_SIBLING;
                   }
   
                   /* Line continuation with comment. */
   
                   if (stesc[1] == '#') {
                           *stesc = '\0';
                           return ROFF_APPEND;
                   }
   
                   /* Discard normal comments. */
   
                   while (stesc > start && stesc[-1] == ' ' &&
                       (stesc == start + 1 || stesc[-2] != '\\'))
                         stesc--;                          stesc--;
                 *stesc = '\0';                  *stesc = '\0';
                 break;                  break;
Line 1343  roff_res(struct roff *r, struct buf *buf, int ln, int 
Line 1377  roff_res(struct roff *r, struct buf *buf, int ln, int 
                         if (arg_complete) {                          if (arg_complete) {
                                 deftype = ROFFDEF_USER | ROFFDEF_PRE;                                  deftype = ROFFDEF_USER | ROFFDEF_PRE;
                                 res = roff_getstrn(r, stnam, naml, &deftype);                                  res = roff_getstrn(r, stnam, naml, &deftype);
   
                                   /*
                                    * If not overriden, let \*(.T
                                    * through to the formatters.
                                    */
   
                                   if (res == NULL && naml == 2 &&
                                       stnam[0] == '.' && stnam[1] == 'T') {
                                           roff_setstrn(&r->strtab,
                                               ".T", 2, NULL, 0, 0);
                                           stesc--;
                                           continue;
                                   }
                         }                          }
                         break;                          break;
                 case 'B':                  case 'B':
Line 2822  roff_TE(ROFF_ARGS)
Line 2869  roff_TE(ROFF_ARGS)
                 free(buf->buf);                  free(buf->buf);
                 buf->buf = mandoc_strdup(".sp");                  buf->buf = mandoc_strdup(".sp");
                 buf->sz = 4;                  buf->sz = 4;
                   *offs = 0;
                 return ROFF_REPARSE;                  return ROFF_REPARSE;
         }          }
         r->tbl = NULL;          r->tbl = NULL;
Line 3137  roff_eo(ROFF_ARGS)
Line 3185  roff_eo(ROFF_ARGS)
 }  }
   
 static enum rofferr  static enum rofferr
   roff_nop(ROFF_ARGS)
   {
           while (buf->buf[pos] == ' ')
                   pos++;
           *offs = pos;
           return ROFF_RERUN;
   }
   
   static enum rofferr
 roff_tr(ROFF_ARGS)  roff_tr(ROFF_ARGS)
 {  {
         const char      *p, *first, *second;          const char      *p, *first, *second;
Line 3341  roff_userdef(ROFF_ARGS)
Line 3398  roff_userdef(ROFF_ARGS)
                             ln, (int)(cp - n1), NULL);                              ln, (int)(cp - n1), NULL);
                         free(buf->buf);                          free(buf->buf);
                         buf->buf = n1;                          buf->buf = n1;
                           *offs = 0;
                         return ROFF_IGN;                          return ROFF_IGN;
                 }                  }
   
Line 3435  roff_renamed(ROFF_ARGS)
Line 3493  roff_renamed(ROFF_ARGS)
             buf->buf[pos] == '\0' ? "" : " ", buf->buf + pos) + 1;              buf->buf[pos] == '\0' ? "" : " ", buf->buf + pos) + 1;
         free(buf->buf);          free(buf->buf);
         buf->buf = nbuf;          buf->buf = nbuf;
           *offs = 0;
         return ROFF_CONT;          return ROFF_CONT;
 }  }
   

Legend:
Removed from v.1.327  
changed lines
  Added in v.1.335

CVSweb