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

Diff for /mandoc/man.c between version 1.106 and 1.107

version 1.106, 2011/03/23 12:33:01 version 1.107, 2011/03/29 08:30:49
Line 130  man_parseln(struct man *m, int ln, char *buf, int offs
Line 130  man_parseln(struct man *m, int ln, char *buf, int offs
         m->flags |= MAN_NEWLINE;          m->flags |= MAN_NEWLINE;
   
         assert( ! (MAN_HALT & m->flags));          assert( ! (MAN_HALT & m->flags));
         return(('.' == buf[offs] || '\'' == buf[offs]) ?  
           return (mandoc_getcontrol(buf, &offs) ?
                         man_pmacro(m, ln, buf, offs) :                          man_pmacro(m, ln, buf, offs) :
                         man_ptext(m, ln, buf, offs));                          man_ptext(m, ln, buf, offs));
 }  }
Line 421  man_descope(struct man *m, int line, int offs)
Line 422  man_descope(struct man *m, int line, int offs)
         return(man_body_alloc(m, line, offs, m->last->tok));          return(man_body_alloc(m, line, offs, m->last->tok));
 }  }
   
   
 static int  static int
 man_ptext(struct man *m, int line, char *buf, int offs)  man_ptext(struct man *m, int line, char *buf, int offs)
 {  {
         int              i;          int              i;
   
         /* Ignore bogus comments. */  
   
         if ('\\' == buf[offs] &&  
                         '.' == buf[offs + 1] &&  
                         '"' == buf[offs + 2]) {  
                 man_pmsg(m, line, offs, MANDOCERR_BADCOMMENT);  
                 return(1);  
         }  
   
         /* Literal free-form text whitespace is preserved. */          /* Literal free-form text whitespace is preserved. */
   
         if (MAN_LITERAL & m->flags) {          if (MAN_LITERAL & m->flags) {
Line 493  man_ptext(struct man *m, int line, char *buf, int offs
Line 484  man_ptext(struct man *m, int line, char *buf, int offs
         return(man_descope(m, line, offs));          return(man_descope(m, line, offs));
 }  }
   
   
 static int  static int
 man_pmacro(struct man *m, int ln, char *buf, int offs)  man_pmacro(struct man *m, int ln, char *buf, int offs)
 {  {
         int              i, j, ppos;          int              i, ppos;
         enum mant        tok;          enum mant        tok;
         char             mac[5];          char             mac[5];
         struct man_node *n;          struct man_node *n;
   
         /* Comments and empties are quickly ignored. */          if ('"' == buf[offs]) {
                   man_pmsg(m, ln, offs, MANDOCERR_BADCOMMENT);
         offs++;  
   
         if ('\0' == buf[offs])  
                 return(1);                  return(1);
           } else if ('\0' == buf[offs])
                   return(1);
   
         i = offs;          ppos = offs;
   
         /*          /*
          * Skip whitespace between the control character and initial  
          * text.  "Whitespace" is both spaces and tabs.  
          */  
   
         if (' ' == buf[i] || '\t' == buf[i]) {  
                 i++;  
                 while (buf[i] && (' ' == buf[i] || '\t' == buf[i]))  
                         i++;  
                 if ('\0' == buf[i])  
                         goto out;  
         }  
   
         ppos = i;  
   
         /*  
          * Copy the first word into a nil-terminated buffer.           * Copy the first word into a nil-terminated buffer.
          * Stop copying when a tab, space, or eoln is encountered.           * Stop copying when a tab, space, or eoln is encountered.
          */           */
   
         j = 0;          i = 0;
         while (j < 4 && '\0' != buf[i] && ' ' != buf[i] && '\t' != buf[i])          while (i < 4 && '\0' != buf[offs] &&
                 mac[j++] = buf[i++];                          ' ' != buf[offs] && '\t' != buf[offs])
         mac[j] = '\0';                  mac[i++] = buf[offs++];
   
         tok = (j > 0 && j < 4) ? man_hash_find(mac) : MAN_MAX;          mac[i] = '\0';
   
           tok = (i > 0 && i < 4) ? man_hash_find(mac) : MAN_MAX;
   
         if (MAN_MAX == tok) {          if (MAN_MAX == tok) {
                 mandoc_vmsg(MANDOCERR_MACRO, m->parse, ln,                  mandoc_vmsg(MANDOCERR_MACRO, m->parse, ln,
                                 ppos, "%s", buf + ppos - 1);                                  ppos, "%s", buf + ppos - 1);
Line 545  man_pmacro(struct man *m, int ln, char *buf, int offs)
Line 522  man_pmacro(struct man *m, int ln, char *buf, int offs)
   
         /* The macro is sane.  Jump to the next word. */          /* The macro is sane.  Jump to the next word. */
   
         while (buf[i] && ' ' == buf[i])          while (buf[offs] && ' ' == buf[offs])
                 i++;                  offs++;
   
         /*          /*
          * Trailing whitespace.  Note that tabs are allowed to be passed           * Trailing whitespace.  Note that tabs are allowed to be passed
          * into the parser as "text", so we only warn about spaces here.           * into the parser as "text", so we only warn about spaces here.
          */           */
   
         if ('\0' == buf[i] && ' ' == buf[i - 1])          if ('\0' == buf[offs] && ' ' == buf[offs - 1])
                 man_pmsg(m, ln, i - 1, MANDOCERR_EOLNSPACE);                  man_pmsg(m, ln, offs - 1, MANDOCERR_EOLNSPACE);
   
         /*          /*
          * Remove prior ELINE macro, as it's being clobbered by a new           * Remove prior ELINE macro, as it's being clobbered by a new
Line 591  man_pmacro(struct man *m, int ln, char *buf, int offs)
Line 568  man_pmacro(struct man *m, int ln, char *buf, int offs)
         /* Call to handler... */          /* Call to handler... */
   
         assert(man_macros[tok].fp);          assert(man_macros[tok].fp);
         if ( ! (*man_macros[tok].fp)(m, tok, ln, ppos, &i, buf))          if ( ! (*man_macros[tok].fp)(m, tok, ln, ppos, &offs, buf))
                 goto err;                  goto err;
   
 out:  
         /*          /*
          * We weren't in a block-line scope when entering the           * We weren't in a block-line scope when entering the
          * above-parsed macro, so return.           * above-parsed macro, so return.
Line 631  out:
Line 607  out:
   
         if ( ! man_unscope(m, m->last->parent, MANDOCERR_MAX))          if ( ! man_unscope(m, m->last->parent, MANDOCERR_MAX))
                 return(0);                  return(0);
         return(man_body_alloc(m, ln, offs, m->last->tok));          return(man_body_alloc(m, ln, ppos, m->last->tok));
   
 err:    /* Error out. */  err:    /* Error out. */
   

Legend:
Removed from v.1.106  
changed lines
  Added in v.1.107

CVSweb