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

Diff for /mandoc/roff.c between version 1.141 and 1.146

version 1.141, 2011/05/24 21:18:06 version 1.146, 2011/07/17 12:13:37
Line 150  static const char *roff_getstrn(const struct roff *, 
Line 150  static const char *roff_getstrn(const struct roff *, 
 static  enum rofferr     roff_line_ignore(ROFF_ARGS);  static  enum rofferr     roff_line_ignore(ROFF_ARGS);
 static  enum rofferr     roff_nr(ROFF_ARGS);  static  enum rofferr     roff_nr(ROFF_ARGS);
 static  int              roff_res(struct roff *,  static  int              roff_res(struct roff *,
                                 char **, size_t *, int);                                  char **, size_t *, int, int);
 static  enum rofferr     roff_rm(ROFF_ARGS);  static  enum rofferr     roff_rm(ROFF_ARGS);
 static  void             roff_setstr(struct roff *,  static  void             roff_setstr(struct roff *,
                                 const char *, const char *, int);                                  const char *, const char *, int);
Line 347  roff_free1(struct roff *r)
Line 347  roff_free1(struct roff *r)
 void  void
 roff_reset(struct roff *r)  roff_reset(struct roff *r)
 {  {
           int              i;
   
         roff_free1(r);          roff_free1(r);
   
           for (i = 0; i < PREDEFS_MAX; i++)
                   roff_setstr(r, predefs[i].name, predefs[i].str, 0);
 }  }
   
   
Line 387  roff_alloc(struct regset *regs, struct mparse *parse)
Line 391  roff_alloc(struct regset *regs, struct mparse *parse)
  * is processed.   * is processed.
  */   */
 static int  static int
 roff_res(struct roff *r, char **bufp, size_t *szp, int pos)  roff_res(struct roff *r, char **bufp, size_t *szp, int ln, int pos)
 {  {
         const char      *stesc; /* start of an escape sequence ('\\') */          const char      *stesc; /* start of an escape sequence ('\\') */
         const char      *stnam; /* start of the name, after "[(*" */          const char      *stnam; /* start of the name, after "[(*" */
Line 454  roff_res(struct roff *r, char **bufp, size_t *szp, int
Line 458  roff_res(struct roff *r, char **bufp, size_t *szp, int
                 res = roff_getstrn(r, stnam, (size_t)i);                  res = roff_getstrn(r, stnam, (size_t)i);
   
                 if (NULL == res) {                  if (NULL == res) {
                         cp -= maxl ? 1 : 0;                          /* TODO: keep track of the correct position. */
                         continue;                          mandoc_msg(MANDOCERR_BADESCAPE, r->parse, ln, pos, NULL);
                           res = "";
                 }                  }
   
                 /* Replace the escape sequence by the string. */                  /* Replace the escape sequence by the string. */
Line 491  roff_parseln(struct roff *r, int ln, char **bufp, 
Line 496  roff_parseln(struct roff *r, int ln, char **bufp, 
          * words to fill in.           * words to fill in.
          */           */
   
         if (r->first_string && ! roff_res(r, bufp, szp, pos))          if (r->first_string && ! roff_res(r, bufp, szp, ln, pos))
                 return(ROFF_REPARSE);                  return(ROFF_REPARSE);
   
         ppos = pos;          ppos = pos;
Line 514  roff_parseln(struct roff *r, int ln, char **bufp, 
Line 519  roff_parseln(struct roff *r, int ln, char **bufp, 
                 if (ROFF_CONT != e)                  if (ROFF_CONT != e)
                         return(e);                          return(e);
                 if (r->eqn)                  if (r->eqn)
                         return(eqn_read(&r->eqn, ln, *bufp, pos));                          return(eqn_read(&r->eqn, ln, *bufp, pos, offs));
                 if (r->tbl)                  if (r->tbl)
                         return(tbl_read(r->tbl, ln, *bufp, pos));                          return(tbl_read(r->tbl, ln, *bufp, pos));
                 return(ROFF_CONT);                  return(ROFF_CONT);
         } else if ( ! ctl) {          } else if ( ! ctl) {
                 if (r->eqn)                  if (r->eqn)
                         return(eqn_read(&r->eqn, ln, *bufp, pos));                          return(eqn_read(&r->eqn, ln, *bufp, pos, offs));
                 if (r->tbl)                  if (r->tbl)
                         return(tbl_read(r->tbl, ln, *bufp, pos));                          return(tbl_read(r->tbl, ln, *bufp, pos));
                 return(ROFF_CONT);                  return(ROFF_CONT);
         } else if (r->eqn)          } else if (r->eqn)
                 return(eqn_read(&r->eqn, ln, *bufp, ppos));                  return(eqn_read(&r->eqn, ln, *bufp, ppos, offs));
   
         /*          /*
          * If a scope is open, go to the child handler for that macro,           * If a scope is open, go to the child handler for that macro,
Line 591  roff_parse(struct roff *r, const char *buf, int *pos)
Line 596  roff_parse(struct roff *r, const char *buf, int *pos)
         size_t           maclen;          size_t           maclen;
         enum rofft       t;          enum rofft       t;
   
         if ('\0' == buf[*pos] || '"' == buf[*pos])          if ('\0' == buf[*pos] || '"' == buf[*pos] ||
                           '\t' == buf[*pos] || ' ' == buf[*pos])
                 return(ROFF_MAX);                  return(ROFF_MAX);
   
           /*
            * We stop the macro parse at an escape, tab, space, or nil.
            * However, `\}' is also a valid macro, so make sure we don't
            * clobber it by seeing the `\' as the end of token.
            */
   
         mac = buf + *pos;          mac = buf + *pos;
         maclen = strcspn(mac, " \\\t\0");          maclen = strcspn(mac + 1, " \\\t\0") + 1;
   
         t = (r->current_string = roff_getstrn(r, mac, maclen))          t = (r->current_string = roff_getstrn(r, mac, maclen))
             ? ROFF_USERDEF : roff_hash_find(mac, maclen);              ? ROFF_USERDEF : roff_hash_find(mac, maclen);
Line 877  roff_cond_sub(ROFF_ARGS)
Line 889  roff_cond_sub(ROFF_ARGS)
                         ep++;                          ep++;
                         if ('}' != *ep)                          if ('}' != *ep)
                                 continue;                                  continue;
                         *ep = '&';  
                           /*
                            * Make the \} go away.
                            * This is a little haphazard, as it's not quite
                            * clear how nroff does this.
                            * If we're at the end of line, then just chop
                            * off the \} and resize the buffer.
                            * If we aren't, then conver it to spaces.
                            */
   
                           if ('\0' == *(ep + 1)) {
                                   *--ep = '\0';
                                   *szp -= 2;
                           } else
                                   *(ep - 1) = *ep = ' ';
   
                         roff_ccond(r, ROFF_ccond, bufp, szp,                          roff_ccond(r, ROFF_ccond, bufp, szp,
                                         ln, pos, pos + 2, offs);                                          ln, pos, pos + 2, offs);
                         break;                          break;
Line 1152  roff_EQ(ROFF_ARGS)
Line 1179  roff_EQ(ROFF_ARGS)
         struct eqn_node *e;          struct eqn_node *e;
   
         assert(NULL == r->eqn);          assert(NULL == r->eqn);
         e = eqn_alloc(ppos, ln);          e = eqn_alloc(ppos, ln, r->parse);
   
         if (r->last_eqn)          if (r->last_eqn)
                 r->last_eqn->next = e;                  r->last_eqn->next = e;

Legend:
Removed from v.1.141  
changed lines
  Added in v.1.146

CVSweb