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

Diff for /mandoc/roff.c between version 1.151 and 1.153

version 1.151, 2011/07/25 15:37:00 version 1.153, 2011/07/26 14:24:06
Line 395  roff_alloc(struct mparse *parse)
Line 395  roff_alloc(struct mparse *parse)
         return(r);          return(r);
 }  }
   
   
 /*  /*
  * Pre-filter each and every line for reserved words (one beginning with   * Pre-filter each and every line for reserved words (one beginning with
  * `\*', e.g., `\*(ab').  These must be handled before the actual line   * `\*', e.g., `\*(ab').  These must be handled before the actual line
  * is processed.   * is processed.
  */   * This also checks the syntax of regular escapes.
   */
 static int  static int
 roff_res(struct roff *r, char **bufp, size_t *szp, int ln, int pos)  roff_res(struct roff *r, char **bufp, size_t *szp, int ln, int pos)
 {  {
           enum mandoc_esc  esc;
         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 "[(*" */
         const char      *cp;    /* end of the name, e.g. before ']' */          const char      *cp;    /* end of the name, e.g. before ']' */
Line 426  roff_res(struct roff *r, char **bufp, size_t *szp, int
Line 427  roff_res(struct roff *r, char **bufp, size_t *szp, int
   
                 if ('\0' == *cp)                  if ('\0' == *cp)
                         return(1);                          return(1);
                 if ('*' != *cp++)  
                   if ('*' != *cp) {
                           res = cp;
                           esc = mandoc_escape(&cp, NULL, NULL);
                           if (ESCAPE_ERROR != esc)
                                   continue;
                           cp = res;
                           mandoc_msg
                                   (MANDOCERR_BADESCAPE, r->parse,
                                    ln, (int)(stesc - *bufp), NULL);
                         continue;                          continue;
                   }
   
                   cp++;
   
                 /*                  /*
                  * The third character decides the length                   * The third character decides the length
                  * of the name of the string.                   * of the name of the string.
Line 455  roff_res(struct roff *r, char **bufp, size_t *szp, int
Line 468  roff_res(struct roff *r, char **bufp, size_t *szp, int
                 /* Advance to the end of the name. */                  /* Advance to the end of the name. */
   
                 for (i = 0; 0 == maxl || i < maxl; i++, cp++) {                  for (i = 0; 0 == maxl || i < maxl; i++, cp++) {
                         if ('\0' == *cp)                          if ('\0' == *cp) {
                                 return(1); /* Error. */                                  mandoc_msg
                                           (MANDOCERR_BADESCAPE,
                                            r->parse, ln,
                                            (int)(stesc - *bufp), NULL);
                                   return(1);
                           }
                         if (0 == maxl && ']' == *cp)                          if (0 == maxl && ']' == *cp)
                                 break;                                  break;
                 }                  }
Line 469  roff_res(struct roff *r, char **bufp, size_t *szp, int
Line 487  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) {
                         /* TODO: keep track of the correct position. */                          mandoc_msg
                         mandoc_msg(MANDOCERR_BADESCAPE, r->parse, ln, pos, NULL);                                  (MANDOCERR_BADESCAPE, r->parse,
                                    ln, (int)(stesc - *bufp), NULL);
                         res = "";                          res = "";
                 }                  }
   
Line 493  roff_res(struct roff *r, char **bufp, size_t *szp, int
Line 512  roff_res(struct roff *r, char **bufp, size_t *szp, int
         return(1);          return(1);
 }  }
   
   
 enum rofferr  enum rofferr
 roff_parseln(struct roff *r, int ln, char **bufp,  roff_parseln(struct roff *r, int ln, char **bufp,
                 size_t *szp, int pos, int *offs)                  size_t *szp, int pos, int *offs)
Line 507  roff_parseln(struct roff *r, int ln, char **bufp, 
Line 525  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, ln, pos))          if ( ! roff_res(r, bufp, szp, ln, pos))
                 return(ROFF_REPARSE);                  return(ROFF_REPARSE);
   
         ppos = pos;          ppos = pos;

Legend:
Removed from v.1.151  
changed lines
  Added in v.1.153

CVSweb