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

Diff for /mandoc/mdoc.c between version 1.160 and 1.163

version 1.160, 2010/08/07 20:33:55 version 1.163, 2010/08/20 01:02:07
Line 22 
Line 22 
 #include <sys/types.h>  #include <sys/types.h>
   
 #include <assert.h>  #include <assert.h>
 #include <ctype.h>  
 #include <stdarg.h>  #include <stdarg.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
Line 99  static int    node_append(struct mdoc *, 
Line 98  static int    node_append(struct mdoc *, 
                                 struct mdoc_node *);                                  struct mdoc_node *);
 static  int               mdoc_ptext(struct mdoc *, int, char *, int);  static  int               mdoc_ptext(struct mdoc *, int, char *, int);
 static  int               mdoc_pmacro(struct mdoc *, int, char *, int);  static  int               mdoc_pmacro(struct mdoc *, int, char *, int);
 static  int               macrowarn(struct mdoc *, int,  
                                 const char *, int);  
   
   
 const struct mdoc_node *  const struct mdoc_node *
Line 192  mdoc_free(struct mdoc *mdoc)
Line 189  mdoc_free(struct mdoc *mdoc)
  * Allocate volatile and non-volatile parse resources.   * Allocate volatile and non-volatile parse resources.
  */   */
 struct mdoc *  struct mdoc *
 mdoc_alloc(struct regset *regs, void *data,  mdoc_alloc(struct regset *regs, void *data, mandocmsg msg)
                 int pflags, mandocmsg msg)  
 {  {
         struct mdoc     *p;          struct mdoc     *p;
   
Line 201  mdoc_alloc(struct regset *regs, void *data, 
Line 197  mdoc_alloc(struct regset *regs, void *data, 
   
         p->msg = msg;          p->msg = msg;
         p->data = data;          p->data = data;
         p->pflags = pflags;  
         p->regs = regs;          p->regs = regs;
   
         mdoc_hash_init();          mdoc_hash_init();
Line 728  mdoc_ptext(struct mdoc *m, int line, char *buf, int of
Line 723  mdoc_ptext(struct mdoc *m, int line, char *buf, int of
 }  }
   
   
 static int  
 macrowarn(struct mdoc *m, int ln, const char *buf, int offs)  
 {  
         int              rc;  
   
         rc = mdoc_vmsg(m, MANDOCERR_MACRO, ln, offs,  
                         "unknown macro: %s%s",  
                         buf, strlen(buf) > 3 ? "..." : "");  
   
         /* FIXME: logic should be in driver. */  
         /* FIXME: broken, will error out and not omit a message. */  
         return(MDOC_IGN_MACRO & m->pflags ? rc : 0);  
 }  
   
   
 /*  /*
  * Parse a macro line, that is, a line beginning with the control   * Parse a macro line, that is, a line beginning with the control
  * character.   * character.
Line 777  mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off
Line 757  mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off
         sv = i;          sv = i;
   
         /*          /*
          * Copy the first word into a nil-terminated buffer.  Stop           * Copy the first word into a nil-terminated buffer.
          * copying when a tab, space, or eoln is encountered.           * Stop copying when a tab, space, or eoln is encountered.
          */           */
   
         for (j = 0; j < 4; j++, i++) {          j = 0;
                 if ('\0' == (mac[j] = buf[i]))          while (j < 4 && '\0' != buf[i] && ' ' != buf[i] && '\t' != buf[i])
                         break;                  mac[j++] = buf[i++];
                 else if (' ' == buf[i] || '\t' == buf[i])  
                         break;  
   
                 /* Check for invalid characters. */  
                 /* TODO: remove me, already done in main.c. */  
   
                 if (isgraph((u_char)buf[i]))  
                         continue;  
                 if ( ! mdoc_pmsg(m, ln, i, MANDOCERR_BADCHAR))  
                         return(0);  
                 i--;  
         }  
   
         mac[j] = '\0';          mac[j] = '\0';
   
         if (j == 4 || j < 2) {          tok = (j > 1 || j < 4) ? mdoc_hash_find(mac) : MDOC_MAX;
                 if ( ! macrowarn(m, ln, mac, sv))          if (MDOC_MAX == tok) {
                         goto err;                  mdoc_vmsg(m, MANDOCERR_MACRO, ln, sv,
                 return(1);                      "unknown macro: %s%s",
         }                      buf, strlen(buf) > 3 ? "..." : "");
   
         if (MDOC_MAX == (tok = mdoc_hash_find(mac))) {  
                 if ( ! macrowarn(m, ln, mac, sv))  
                         goto err;  
                 return(1);                  return(1);
         }          }
   

Legend:
Removed from v.1.160  
changed lines
  Added in v.1.163

CVSweb