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

Diff for /mandoc/roff.c between version 1.212 and 1.214

version 1.212, 2014/06/29 22:14:10 version 1.214, 2014/06/29 23:26:00
Line 200  static enum rofferr  roff_line_ignore(ROFF_ARGS);
Line 200  static enum rofferr  roff_line_ignore(ROFF_ARGS);
 static  enum rofferr     roff_nr(ROFF_ARGS);  static  enum rofferr     roff_nr(ROFF_ARGS);
 static  void             roff_openeqn(struct roff *, const char *,  static  void             roff_openeqn(struct roff *, const char *,
                                 int, int, const char *);                                  int, int, const char *);
 static  enum rofft       roff_parse(struct roff *, const char *, int *);  static  enum rofft       roff_parse(struct roff *, char *, int *,
                                   int, int);
 static  enum rofferr     roff_parsetext(char **, size_t *, int, int *);  static  enum rofferr     roff_parsetext(char **, size_t *, int, int *);
 static  enum rofferr     roff_res(struct roff *,  static  enum rofferr     roff_res(struct roff *,
                                 char **, size_t *, int, int);                                  char **, size_t *, int, int);
Line 764  roff_parseln(struct roff *r, int ln, char **bufp,
Line 765  roff_parseln(struct roff *r, int ln, char **bufp,
          * the compilers handle it.           * the compilers handle it.
          */           */
   
         if (ROFF_MAX == (t = roff_parse(r, *bufp, &pos)))          if (ROFF_MAX == (t = roff_parse(r, *bufp, &pos, ln, ppos)))
                 return(ROFF_CONT);                  return(ROFF_CONT);
   
         assert(roffs[t].proc);          assert(roffs[t].proc);
Line 797  roff_endparse(struct roff *r)
Line 798  roff_endparse(struct roff *r)
  * form of ".foo xxx" in the usual way.   * form of ".foo xxx" in the usual way.
  */   */
 static enum rofft  static enum rofft
 roff_parse(struct roff *r, const char *buf, int *pos)  roff_parse(struct roff *r, char *buf, int *pos, int ln, int ppos)
 {  {
           char            *cp;
         const char      *mac;          const char      *mac;
         size_t           maclen;          size_t           maclen;
         enum rofft       t;          enum rofft       t;
   
         if ('\0' == buf[*pos] || '"' == buf[*pos] ||          cp = buf + *pos;
             '\t' == buf[*pos] || ' ' == buf[*pos])  
           if ('\0' == *cp || '"' == *cp || '\t' == *cp || ' ' == *cp)
                 return(ROFF_MAX);                  return(ROFF_MAX);
   
         /* We stop the macro parse at an escape, tab, space, or nil. */          mac = cp;
           maclen = roff_getname(r, &cp, ln, ppos);
   
         mac = buf + *pos;  
         maclen = strcspn(mac, " \\\t\0");  
   
         t = (r->current_string = roff_getstrn(r, mac, maclen))          t = (r->current_string = roff_getstrn(r, mac, maclen))
             ? ROFF_USERDEF : roffhash_find(mac, maclen);              ? ROFF_USERDEF : roffhash_find(mac, maclen);
   
         *pos += (int)maclen;          if (ROFF_MAX != t)
                   *pos = cp - buf;
   
         while (buf[*pos] && ' ' == buf[*pos])  
                 (*pos)++;  
   
         return(t);          return(t);
 }  }
   
Line 910  roff_ccond(struct roff *r, int ln, int ppos)
Line 909  roff_ccond(struct roff *r, int ln, int ppos)
 static enum rofferr  static enum rofferr
 roff_block(ROFF_ARGS)  roff_block(ROFF_ARGS)
 {  {
         int             sv;          char            *name, *cp;
         size_t          sz;          size_t           namesz;
         char            *name;  
   
         name = NULL;          name = cp = *bufp + pos;
           namesz = 0;
   
         if (ROFF_ig != tok) {          if (ROFF_ig != tok) {
                 if ('\0' == (*bufp)[pos]) {                  if ('\0' == *cp) {
                         mandoc_msg(MANDOCERR_NOARGS, r->parse, ln, ppos, NULL);                          mandoc_msg(MANDOCERR_NOARGS, r->parse, ln, ppos, NULL);
                         return(ROFF_IGN);                          return(ROFF_IGN);
                 }                  }
Line 929  roff_block(ROFF_ARGS)
Line 928  roff_block(ROFF_ARGS)
   
                 if (ROFF_de1 == tok)                  if (ROFF_de1 == tok)
                         tok = ROFF_de;                          tok = ROFF_de;
                 if (ROFF_de == tok)                  else if (ROFF_de != tok)
                         name = *bufp + pos;  
                 else  
                         mandoc_msg(MANDOCERR_REQUEST, r->parse, ln, ppos,                          mandoc_msg(MANDOCERR_REQUEST, r->parse, ln, ppos,
                             roffs[tok].name);                              roffs[tok].name);
   
                 while ((*bufp)[pos] && ! isspace((unsigned char)(*bufp)[pos]))                  namesz = roff_getname(r, &cp, ln, ppos);
                         pos++;                  name[namesz] = '\0';
           } else
                   name = NULL;
   
                 while (isspace((unsigned char)(*bufp)[pos]))  
                         (*bufp)[pos++] = '\0';  
         }  
   
         roffnode_push(r, tok, name, ln, ppos);          roffnode_push(r, tok, name, ln, ppos);
   
         /*          /*
Line 950  roff_block(ROFF_ARGS)
Line 945  roff_block(ROFF_ARGS)
          * appended from roff_block_text() in multiline mode.           * appended from roff_block_text() in multiline mode.
          */           */
   
         if (ROFF_de == tok)          if (namesz && ROFF_de == tok)
                 roff_setstr(r, name, "", 0);                  roff_setstrn(&r->strtab, name, namesz, "", 0, 0);
   
         if ('\0' == (*bufp)[pos])          if ('\0' == *cp)
                 return(ROFF_IGN);                  return(ROFF_IGN);
   
         /* If present, process the custom end-of-line marker. */          /* If present, process the custom end-of-line marker. */
   
         sv = pos;          name = cp;
         while ((*bufp)[pos] && ! isspace((unsigned char)(*bufp)[pos]))          namesz = roff_getname(r, &cp, ln, ppos);
                 pos++;          if (namesz)
                   r->last->end = mandoc_strndup(name, namesz);
   
         /*          if ('\0' != *cp)
          * Note: groff does NOT like escape characters in the input.  
          * Instead of detecting this, we're just going to let it fly and  
          * to hell with it.  
          */  
   
         assert(pos > sv);  
         sz = (size_t)(pos - sv);  
   
         if (1 == sz && '.' == (*bufp)[sv])  
                 return(ROFF_IGN);  
   
         r->last->end = mandoc_malloc(sz + 1);  
   
         memcpy(r->last->end, *bufp + sv, sz);  
         r->last->end[(int)sz] = '\0';  
   
         if ((*bufp)[pos])  
                 mandoc_msg(MANDOCERR_ARGSLOST, r->parse, ln, pos, NULL);                  mandoc_msg(MANDOCERR_ARGSLOST, r->parse, ln, pos, NULL);
   
         return(ROFF_IGN);          return(ROFF_IGN);
Line 1016  roff_block_sub(ROFF_ARGS)
Line 995  roff_block_sub(ROFF_ARGS)
                                 i++;                                  i++;
   
                         pos = i;                          pos = i;
                         if (ROFF_MAX != roff_parse(r, *bufp, &pos))                          if (ROFF_MAX != roff_parse(r, *bufp, &pos, ln, ppos))
                                 return(ROFF_RERUN);                                  return(ROFF_RERUN);
                         return(ROFF_IGN);                          return(ROFF_IGN);
                 }                  }
Line 1027  roff_block_sub(ROFF_ARGS)
Line 1006  roff_block_sub(ROFF_ARGS)
          * pulling it out of the hashtable.           * pulling it out of the hashtable.
          */           */
   
         t = roff_parse(r, *bufp, &pos);          t = roff_parse(r, *bufp, &pos, ln, ppos);
   
         /*          /*
          * Macros other than block-end are only significant           * Macros other than block-end are only significant
Line 1062  roff_cond_sub(ROFF_ARGS)
Line 1041  roff_cond_sub(ROFF_ARGS)
   
         rr = r->last->rule;          rr = r->last->rule;
         roffnode_cleanscope(r);          roffnode_cleanscope(r);
         t = roff_parse(r, *bufp, &pos);          t = roff_parse(r, *bufp, &pos, ln, ppos);
   
         /*          /*
          * Fully handle known macros when they are structurally           * Fully handle known macros when they are structurally

Legend:
Removed from v.1.212  
changed lines
  Added in v.1.214

CVSweb