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

Diff for /mandoc/mdoc.c between version 1.187 and 1.188

version 1.187, 2011/03/22 14:33:05 version 1.188, 2011/03/28 23:52:13
Line 297  mdoc_parseln(struct mdoc *m, int ln, char *buf, int of
Line 297  mdoc_parseln(struct mdoc *m, int ln, char *buf, int of
                         m->flags &= ~MDOC_SYNOPSIS;                          m->flags &= ~MDOC_SYNOPSIS;
         }          }
   
         return(('.' == buf[offs] || '\'' == buf[offs]) ?          return(mandoc_getcontrol(buf, &offs) ?
                         mdoc_pmacro(m, ln, buf, offs) :                          mdoc_pmacro(m, ln, buf, offs) :
                         mdoc_ptext(m, ln, buf, offs));                          mdoc_ptext(m, ln, buf, offs));
 }  }
Line 661  mdoc_ptext(struct mdoc *m, int line, char *buf, int of
Line 661  mdoc_ptext(struct mdoc *m, int line, char *buf, int of
         char             *c, *ws, *end;          char             *c, *ws, *end;
         struct mdoc_node *n;          struct mdoc_node *n;
   
         /* Ignore bogus comments. */  
   
         if ('\\' == buf[offs] &&  
                         '.' == buf[offs + 1] &&  
                         '"' == buf[offs + 2]) {  
                 mdoc_pmsg(m, line, offs, MANDOCERR_BADCOMMENT);  
                 return(1);  
         }  
   
         /* No text before an initial macro. */          /* No text before an initial macro. */
   
         if (SEC_NONE == m->lastnamed) {          if (SEC_NONE == m->lastnamed) {
Line 796  static int
Line 787  static int
 mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs)  mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs)
 {  {
         enum mdoct        tok;          enum mdoct        tok;
         int               i, j, sv;          int               i, sv;
         char              mac[5];          char              mac[5];
         struct mdoc_node *n;          struct mdoc_node *n;
   
         /* Empty lines are ignored. */          /* Empty post-control lines are ignored. */
   
         offs++;          if ('"' == buf[offs]) {
                   mdoc_pmsg(m, ln, offs, MANDOCERR_BADCOMMENT);
         if ('\0' == buf[offs])  
                 return(1);                  return(1);
           } else if ('\0' == buf[offs])
                   return(1);
   
         i = offs;          sv = offs;
   
         /* Accept tabs/whitespace after the initial control char. */  
   
         if (' ' == buf[i] || '\t' == buf[i]) {  
                 i++;  
                 while (buf[i] && (' ' == buf[i] || '\t' == buf[i]))  
                         i++;  
                 if ('\0' == buf[i])  
                         return(1);  
         }  
   
         sv = 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 > 1 || j < 4) ? mdoc_hash_find(mac) : MDOC_MAX;          mac[i] = '\0';
   
           tok = (i > 1 || i < 4) ? mdoc_hash_find(mac) : MDOC_MAX;
   
         if (MDOC_MAX == tok) {          if (MDOC_MAX == tok) {
                 mandoc_vmsg(MANDOCERR_MACRO, m->parse,                  mandoc_vmsg(MANDOCERR_MACRO, m->parse,
                                 ln, sv, "%s", buf + sv - 1);                                  ln, sv, "%s", buf + sv - 1);
Line 840  mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off
Line 823  mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off
   
         /* Disregard the first trailing tab, if applicable. */          /* Disregard the first trailing tab, if applicable. */
   
         if ('\t' == buf[i])          if ('\t' == buf[offs])
                 i++;                  offs++;
   
         /* Jump to the next non-whitespace word. */          /* Jump to the next non-whitespace 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])
                 mdoc_pmsg(m, ln, i - 1, MANDOCERR_EOLNSPACE);                  mdoc_pmsg(m, ln, offs - 1, MANDOCERR_EOLNSPACE);
   
         /*          /*
          * If an initial macro or a list invocation, divert directly           * If an initial macro or a list invocation, divert directly
Line 862  mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off
Line 845  mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off
          */           */
   
         if (NULL == m->last || MDOC_It == tok || MDOC_El == tok) {          if (NULL == m->last || MDOC_It == tok || MDOC_El == tok) {
                 if ( ! mdoc_macro(m, tok, ln, sv, &i, buf))                  if ( ! mdoc_macro(m, tok, ln, sv, &offs, buf))
                         goto err;                          goto err;
                 return(1);                  return(1);
         }          }
Line 901  mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off
Line 884  mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off
   
         /* Normal processing of a macro. */          /* Normal processing of a macro. */
   
         if ( ! mdoc_macro(m, tok, ln, sv, &i, buf))          if ( ! mdoc_macro(m, tok, ln, sv, &offs, buf))
                 goto err;                  goto err;
   
         return(1);          return(1);

Legend:
Removed from v.1.187  
changed lines
  Added in v.1.188

CVSweb