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

Diff for /mandoc/read.c between version 1.110 and 1.111

version 1.110, 2015/01/15 02:29:26 version 1.111, 2015/01/15 04:26:40
Line 80  static const enum mandocerr mandoclimits[MANDOCLEVEL_M
Line 80  static const enum mandocerr mandoclimits[MANDOCLEVEL_M
         MANDOCERR_WARNING,          MANDOCERR_WARNING,
         MANDOCERR_WARNING,          MANDOCERR_WARNING,
         MANDOCERR_ERROR,          MANDOCERR_ERROR,
         MANDOCERR_FATAL,  
         MANDOCERR_MAX,          MANDOCERR_MAX,
           MANDOCERR_MAX,
         MANDOCERR_MAX          MANDOCERR_MAX
 };  };
   
Line 192  static const char * const mandocerrs[MANDOCERR_MAX] = 
Line 192  static const char * const mandocerrs[MANDOCERR_MAX] = 
   
         /* related to document structure and macros */          /* related to document structure and macros */
         NULL,          NULL,
           "input too large",
         "input stack limit exceeded, infinite loop?",          "input stack limit exceeded, infinite loop?",
         "skipping bad character",          "skipping bad character",
         "skipping unknown macro",          "skipping unknown macro",
Line 215  static const char * const mandocerrs[MANDOCERR_MAX] = 
Line 216  static const char * const mandocerrs[MANDOCERR_MAX] = 
         "skipping all arguments",          "skipping all arguments",
         "skipping excess arguments",          "skipping excess arguments",
         "divide by zero",          "divide by zero",
   
         "generic fatal error",  
   
         "input too large",  
 };  };
   
 static  const char * const      mandoclevels[MANDOCLEVEL_MAX] = {  static  const char * const      mandoclevels[MANDOCLEVEL_MAX] = {
Line 545  rerun:
Line 542  rerun:
                 }                  }
   
                 /*                  /*
                  * If we encounter errors in the recursive parse, make  
                  * sure we don't continue parsing.  
                  */  
   
                 if (MANDOCLEVEL_FATAL <= curp->file_status)  
                         break;  
   
                 /*  
                  * If input parsers have not been allocated, do so now.                   * If input parsers have not been allocated, do so now.
                  * We keep these instanced between parsers, but set them                   * We keep these instanced between parsers, but set them
                  * locally per parse routine since we can use different                   * locally per parse routine since we can use different
Line 623  read_whole_file(struct mparse *curp, const char *file,
Line 612  read_whole_file(struct mparse *curp, const char *file,
   
         if (S_ISREG(st.st_mode)) {          if (S_ISREG(st.st_mode)) {
                 if (st.st_size >= (1U << 31)) {                  if (st.st_size >= (1U << 31)) {
                         curp->file_status = MANDOCLEVEL_FATAL;                          mandoc_msg(MANDOCERR_TOOLARGE, curp, 0, 0, NULL);
                         if (curp->mmsg)  
                                 (*curp->mmsg)(MANDOCERR_TOOLARGE,  
                                     curp->file_status, file, 0, 0, NULL);  
                         return(0);                          return(0);
                 }                  }
                 *with_mmap = 1;                  *with_mmap = 1;
Line 649  read_whole_file(struct mparse *curp, const char *file,
Line 635  read_whole_file(struct mparse *curp, const char *file,
         for (;;) {          for (;;) {
                 if (off == fb->sz) {                  if (off == fb->sz) {
                         if (fb->sz == (1U << 31)) {                          if (fb->sz == (1U << 31)) {
                                 curp->file_status = MANDOCLEVEL_FATAL;                                  mandoc_msg(MANDOCERR_TOOLARGE, curp,
                                 if (curp->mmsg)                                      0, 0, NULL);
                                         (*curp->mmsg)(MANDOCERR_TOOLARGE,  
                                             curp->file_status,  
                                             file, 0, 0, NULL);  
                                 break;                                  break;
                         }                          }
                         resize_buf(fb, 65536);                          resize_buf(fb, 65536);
Line 679  static void
Line 662  static void
 mparse_end(struct mparse *curp)  mparse_end(struct mparse *curp)
 {  {
   
         if (MANDOCLEVEL_FATAL <= curp->file_status)  
                 return;  
   
         if (curp->mdoc == NULL &&          if (curp->mdoc == NULL &&
             curp->man == NULL &&              curp->man == NULL &&
             curp->sodest == NULL) {              curp->sodest == NULL) {
Line 695  mparse_end(struct mparse *curp)
Line 675  mparse_end(struct mparse *curp)
                         curp->man = curp->pman;                          curp->man = curp->pman;
                 }                  }
         }          }
           if (curp->mdoc)
         if (curp->mdoc && ! mdoc_endparse(curp->mdoc)) {                  mdoc_endparse(curp->mdoc);
                 assert(MANDOCLEVEL_FATAL <= curp->file_status);          if (curp->man)
                 return;                  man_endparse(curp->man);
         }  
   
         if (curp->man && ! man_endparse(curp->man)) {  
                 assert(MANDOCLEVEL_FATAL <= curp->file_status);  
                 return;  
         }  
   
         roff_endparse(curp->roff);          roff_endparse(curp->roff);
 }  }
   
Line 742  mparse_parse_buffer(struct mparse *curp, struct buf bl
Line 715  mparse_parse_buffer(struct mparse *curp, struct buf bl
   
         mparse_buf_r(curp, blk, offset, 1);          mparse_buf_r(curp, blk, offset, 1);
   
         if (0 == --recursion_depth && MANDOCLEVEL_FATAL > curp->file_status)          if (--recursion_depth == 0)
                 mparse_end(curp);                  mparse_end(curp);
   
         curp->primary = svprimary;          curp->primary = svprimary;
Line 889  mparse_alloc(int options, enum mandoclevel wlevel, man
Line 862  mparse_alloc(int options, enum mandoclevel wlevel, man
 {  {
         struct mparse   *curp;          struct mparse   *curp;
   
         assert(wlevel <= MANDOCLEVEL_FATAL);  
   
         curp = mandoc_calloc(1, sizeof(struct mparse));          curp = mandoc_calloc(1, sizeof(struct mparse));
   
         curp->options = options;          curp->options = options;
Line 987  mandoc_msg(enum mandocerr er, struct mparse *m,
Line 958  mandoc_msg(enum mandocerr er, struct mparse *m,
 {  {
         enum mandoclevel level;          enum mandoclevel level;
   
         level = MANDOCLEVEL_FATAL;          level = MANDOCLEVEL_ERROR;
         while (er < mandoclimits[level])          while (er < mandoclimits[level])
                 level--;                  level--;
   

Legend:
Removed from v.1.110  
changed lines
  Added in v.1.111

CVSweb