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

Diff for /mandoc/roff.c between version 1.241 and 1.245

version 1.241, 2014/12/16 01:22:59 version 1.245, 2014/12/25 17:23:32
Line 21 
Line 21 
   
 #include <assert.h>  #include <assert.h>
 #include <ctype.h>  #include <ctype.h>
   #include <limits.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
Line 658  roff_res(struct roff *r, struct buf *buf, int ln, int 
Line 659  roff_res(struct roff *r, struct buf *buf, int ln, int 
                 buf->sz = mandoc_asprintf(&nbuf, "%s%s%s",                  buf->sz = mandoc_asprintf(&nbuf, "%s%s%s",
                     buf->buf, res, cp) + 1;                      buf->buf, res, cp) + 1;
   
                   if (buf->sz > SHRT_MAX) {
                           mandoc_msg(MANDOCERR_ROFFLOOP, r->parse,
                               ln, (int)(stesc - buf->buf), NULL);
                           return(ROFF_IGN);
                   }
   
                 /* Prepare for the next replacement. */                  /* Prepare for the next replacement. */
   
                 start = nbuf + pos;                  start = nbuf + pos;
Line 730  roff_parseln(struct roff *r, int ln, struct buf *buf, 
Line 737  roff_parseln(struct roff *r, int ln, struct buf *buf, 
         enum rofft       t;          enum rofft       t;
         enum rofferr     e;          enum rofferr     e;
         int              pos;   /* parse point */          int              pos;   /* parse point */
           int              spos;  /* saved parse point for messages */
         int              ppos;  /* original offset in buf->buf */          int              ppos;  /* original offset in buf->buf */
         int              ctl;   /* macro line (boolean) */          int              ctl;   /* macro line (boolean) */
   
Line 800  roff_parseln(struct roff *r, int ln, struct buf *buf, 
Line 808  roff_parseln(struct roff *r, int ln, struct buf *buf, 
                 return((*roffs[t].sub)(r, t, buf, ln, ppos, pos, offs));                  return((*roffs[t].sub)(r, t, buf, ln, ppos, pos, offs));
         }          }
   
           /* No scope is open.  This is a new request or macro. */
   
           spos = pos;
           t = roff_parse(r, buf->buf, &pos, ln, ppos);
   
           /* Tables ignore most macros. */
   
           if (r->tbl != NULL && (t == ROFF_MAX || t == ROFF_TS)) {
                   mandoc_msg(MANDOCERR_TBLMACRO, r->parse,
                       ln, pos, buf->buf + spos);
                   return(ROFF_IGN);
           }
   
         /*          /*
          * Lastly, as we've no scope open, try to look up and execute           * This is neither a roff request nor a user-defined macro.
          * the new macro.  If no macro is found, simply return and let           * Let the standard macro set parsers handle it.
          * the compilers handle it.  
          */           */
   
         if ((t = roff_parse(r, buf->buf, &pos, ln, ppos)) == ROFF_MAX)          if (t == ROFF_MAX)
                 return(ROFF_CONT);                  return(ROFF_CONT);
   
           /* Execute a roff request or a user defined macro. */
   
         assert(roffs[t].proc);          assert(roffs[t].proc);
         return((*roffs[t].proc)(r, t, buf, ln, ppos, pos, offs));          return((*roffs[t].proc)(r, t, buf, ln, ppos, pos, offs));
 }  }
Line 1236  roff_evalstrcond(const char *v, int *pos)
Line 1258  roff_evalstrcond(const char *v, int *pos)
 out:  out:
         if (NULL == s3)          if (NULL == s3)
                 s3 = strchr(s2, '\0');                  s3 = strchr(s2, '\0');
         else          else if (*s3 != '\0')
                 s3++;                  s3++;
         *pos = s3 - v;          *pos = s3 - v;
         return(match);          return(match);
Line 1561  roff_evalnum(struct roff *r, int ln, const char *v,
Line 1583  roff_evalnum(struct roff *r, int ln, const char *v,
                         *res *= operand2;                          *res *= operand2;
                         break;                          break;
                 case '/':                  case '/':
                         if (0 == operand2) {                          if (operand2 == 0) {
                                 mandoc_msg(MANDOCERR_DIVZERO,                                  mandoc_msg(MANDOCERR_DIVZERO,
                                         r->parse, ln, *pos, v);                                          r->parse, ln, *pos, v);
                                 *res = 0;                                  *res = 0;
Line 1570  roff_evalnum(struct roff *r, int ln, const char *v,
Line 1592  roff_evalnum(struct roff *r, int ln, const char *v,
                         *res /= operand2;                          *res /= operand2;
                         break;                          break;
                 case '%':                  case '%':
                           if (operand2 == 0) {
                                   mandoc_msg(MANDOCERR_DIVZERO,
                                           r->parse, ln, *pos, v);
                                   *res = 0;
                                   break;
                           }
                         *res %= operand2;                          *res %= operand2;
                         break;                          break;
                 case '<':                  case '<':

Legend:
Removed from v.1.241  
changed lines
  Added in v.1.245

CVSweb