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

Diff for /mandoc/read.c between version 1.169 and 1.170

version 1.169, 2017/06/03 15:55:24 version 1.170, 2017/06/04 00:13:15
Line 326  mparse_buf_r(struct mparse *curp, struct buf blk, size
Line 326  mparse_buf_r(struct mparse *curp, struct buf blk, size
         const char      *save_file;          const char      *save_file;
         char            *cp;          char            *cp;
         size_t           pos; /* byte number in the ln buffer */          size_t           pos; /* byte number in the ln buffer */
         size_t           j;  /* auxiliary byte number in the blk buffer */  
         enum rofferr     rr;          enum rofferr     rr;
         int              of;          int              of;
         int              lnn; /* line number in the real file */          int              lnn; /* line number in the real file */
Line 408  mparse_buf_r(struct mparse *curp, struct buf blk, size
Line 407  mparse_buf_r(struct mparse *curp, struct buf blk, size
                                 continue;                                  continue;
                         }                          }
   
                         /* Trailing backslash = a plain char. */  
   
                         if (blk.buf[i] != '\\' || i + 1 == blk.sz) {  
                                 ln.buf[pos++] = blk.buf[i++];  
                                 continue;  
                         }  
   
                         /*  
                          * Found escape and at least one other character.  
                          * When it's a newline character, skip it.  
                          * When there is a carriage return in between,  
                          * skip that one as well.  
                          */  
   
                         if ('\r' == blk.buf[i + 1] && i + 2 < blk.sz &&  
                             '\n' == blk.buf[i + 2])  
                                 ++i;  
                         if ('\n' == blk.buf[i + 1]) {  
                                 i += 2;  
                                 ++lnn;  
                                 continue;  
                         }  
   
                         if ('"' == blk.buf[i + 1] || '#' == blk.buf[i + 1]) {  
                                 j = i;  
                                 i += 2;  
                                 /* Comment, skip to end of line */  
                                 for (; i < blk.sz; ++i) {  
                                         if (blk.buf[i] != '\n')  
                                                 continue;  
                                         if (blk.buf[i - 1] == ' ' ||  
                                             blk.buf[i - 1] == '\t')  
                                                 mandoc_msg(  
                                                     MANDOCERR_SPACE_EOL,  
                                                     curp, curp->line,  
                                                     pos + i-1 - j, NULL);  
                                         ++i;  
                                         ++lnn;  
                                         break;  
                                 }  
   
                                 /* Backout trailing whitespaces */  
                                 for (; pos > 0; --pos) {  
                                         if (ln.buf[pos - 1] != ' ')  
                                                 break;  
                                         if (pos > 2 && ln.buf[pos - 2] == '\\')  
                                                 break;  
                                 }  
                                 break;  
                         }  
   
                         /* Catch escaped bogus characters. */  
   
                         c = (unsigned char) blk.buf[i+1];  
   
                         if ( ! (isascii(c) &&  
                             (isgraph(c) || isblank(c)))) {  
                                 mandoc_vmsg(MANDOCERR_CHAR_BAD, curp,  
                                     curp->line, pos, "0x%x", c);  
                                 i += 2;  
                                 ln.buf[pos++] = '?';  
                                 continue;  
                         }  
   
                         /* Some other escape sequence, copy & cont. */  
   
                         ln.buf[pos++] = blk.buf[i++];                          ln.buf[pos++] = blk.buf[i++];
                         ln.buf[pos++] = blk.buf[i++];  
                 }                  }
   
                 if (pos >= ln.sz)                  if (pos + 1 >= ln.sz)
                         resize_buf(&ln, 256);                          resize_buf(&ln, 256);
   
                   if (i == blk.sz || blk.buf[i] == '\0')
                           ln.buf[pos++] = '\n';
                 ln.buf[pos] = '\0';                  ln.buf[pos] = '\0';
   
                 /*                  /*

Legend:
Removed from v.1.169  
changed lines
  Added in v.1.170

CVSweb