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

Diff for /mandoc/read.c between version 1.82 and 1.83

version 1.82, 2014/09/03 23:21:47 version 1.83, 2014/09/06 22:39:36
Line 51  struct buf {
Line 51  struct buf {
 };  };
   
 struct  mparse {  struct  mparse {
         enum mandoclevel  file_status; /* status of current parse */  
         enum mandoclevel  wlevel; /* ignore messages below this */  
         int               line; /* line number in the file */  
         int               options; /* parser options */  
         struct man       *pman; /* persistent man parser */          struct man       *pman; /* persistent man parser */
         struct mdoc      *pmdoc; /* persistent mdoc parser */          struct mdoc      *pmdoc; /* persistent mdoc parser */
         struct man       *man; /* man parser */          struct man       *man; /* man parser */
         struct mdoc      *mdoc; /* mdoc parser */          struct mdoc      *mdoc; /* mdoc parser */
         struct roff      *roff; /* roff parser (!NULL) */          struct roff      *roff; /* roff parser (!NULL) */
         char             *sodest; /* filename pointed to by .so */          char             *sodest; /* filename pointed to by .so */
         int               reparse_count; /* finite interp. stack */          const char       *file; /* filename of current input file */
         mandocmsg         mmsg; /* warning/error message handler */          struct buf       *primary; /* buffer currently being parsed */
         const char       *file;          struct buf       *secondary; /* preprocessed copy of input */
         struct buf       *secondary;  
         const char       *defos; /* default operating system */          const char       *defos; /* default operating system */
           mandocmsg         mmsg; /* warning/error message handler */
           enum mandoclevel  file_status; /* status of current parse */
           enum mandoclevel  wlevel; /* ignore messages below this */
           int               options; /* parser options */
           int               reparse_count; /* finite interp. stack */
           int               line; /* line number in the file */
 };  };
   
 static  void      resize_buf(struct buf *, size_t);  static  void      resize_buf(struct buf *, size_t);
Line 248  resize_buf(struct buf *buf, size_t initial)
Line 249  resize_buf(struct buf *buf, size_t initial)
 static void  static void
 pset(const char *buf, int pos, struct mparse *curp)  pset(const char *buf, int pos, struct mparse *curp)
 {  {
           char            *cp, *ep;
           int              format;
         int              i;          int              i;
   
         /*  
          * Try to intuit which kind of manual parser should be used.  If  
          * passed in by command-line (-man, -mdoc), then use that  
          * explicitly.  If passed as -mandoc, then try to guess from the  
          * line: either skip dot-lines, use -mdoc when finding `.Dt', or  
          * default to -man, which is more lenient.  
          *  
          * Separate out pmdoc/pman from mdoc/man: the first persists  
          * through all parsers, while the latter is used per-parse.  
          */  
   
         if ('.' == buf[0] || '\'' == buf[0]) {          if ('.' == buf[0] || '\'' == buf[0]) {
                 for (i = 1; buf[i]; i++)                  for (i = 1; buf[i]; i++)
                         if (' ' != buf[i] && '\t' != buf[i])                          if (' ' != buf[i] && '\t' != buf[i])
Line 269  pset(const char *buf, int pos, struct mparse *curp)
Line 261  pset(const char *buf, int pos, struct mparse *curp)
                         return;                          return;
         }          }
   
         if (MPARSE_MDOC & curp->options) {          /*
                 curp->mdoc = curp->pmdoc;           * If neither command line arguments -mdoc or -man select
                 return;           * a parser nor the roff parser found a .Dd or .TH macro
         } else if (MPARSE_MAN & curp->options) {           * yet, look ahead in the main input buffer.
                 curp->man = curp->pman;           */
                 return;  
           if ((format = roff_getformat(curp->roff)) == 0) {
                   cp = curp->primary->buf;
                   ep = cp + curp->primary->sz;
                   while (cp < ep) {
                           if (*cp == '.' || *cp != '\'') {
                                   cp++;
                                   if (cp[0] == 'D' && cp[1] == 'd') {
                                           format = MPARSE_MDOC;
                                           break;
                                   }
                                   if (cp[0] == 'T' && cp[1] == 'H') {
                                           format = MPARSE_MAN;
                                           break;
                                   }
                           }
                           cp = memchr(cp, '\n', ep - cp);
                           if (cp == NULL)
                                   break;
                           cp++;
                   }
         }          }
   
         if (pos >= 3 && 0 == memcmp(buf, ".Dd", 3))  {          if (format == MPARSE_MDOC) {
                 if (NULL == curp->pmdoc)                  if (NULL == curp->pmdoc)
                         curp->pmdoc = mdoc_alloc(                          curp->pmdoc = mdoc_alloc(
                             curp->roff, curp, curp->defos,                              curp->roff, curp, curp->defos,
Line 287  pset(const char *buf, int pos, struct mparse *curp)
Line 299  pset(const char *buf, int pos, struct mparse *curp)
                 return;                  return;
         }          }
   
           /* Fall back to man(7) as a last resort. */
   
         if (NULL == curp->pman)          if (NULL == curp->pman)
                 curp->pman = man_alloc(curp->roff, curp,                  curp->pman = man_alloc(curp->roff, curp,
                     MPARSE_QUICK & curp->options ? 1 : 0);                      MPARSE_QUICK & curp->options ? 1 : 0);
Line 720  mparse_parse_buffer(struct mparse *curp, struct buf bl
Line 734  mparse_parse_buffer(struct mparse *curp, struct buf bl
         /* Line number is per-file. */          /* Line number is per-file. */
         svfile = curp->file;          svfile = curp->file;
         curp->file = file;          curp->file = file;
           curp->primary = &blk;
         curp->line = 1;          curp->line = 1;
         recursion_depth++;          recursion_depth++;
   

Legend:
Removed from v.1.82  
changed lines
  Added in v.1.83

CVSweb