[BACK]Return to mdoc_argv.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mandoc

Diff for /src/usr.bin/mandoc/mdoc_argv.c between version 1.7 and 1.8

version 1.7, 2009/07/12 21:45:44 version 1.8, 2009/07/12 22:35:08
Line 47 
Line 47 
   
 #define MULTI_STEP       5  #define MULTI_STEP       5
   
 enum    mwarn {  
         WQUOTPARM,  
         WARGVPARM,  
         WCOLEMPTY,  
         WTAILWS  
 };  
   
 static  int              argv_a2arg(int, const char *);  static  int              argv_a2arg(int, const char *);
 static  int              args(struct mdoc *, int, int *,  static  int              args(struct mdoc *, int, int *,
                                 char *, int, char **);                                  char *, int, char **);
Line 65 
Line 58 
                                 struct mdoc_argv *, int *, char *);                                  struct mdoc_argv *, int *, char *);
 static  int              argv_multi(struct mdoc *, int,  static  int              argv_multi(struct mdoc *, int,
                                 struct mdoc_argv *, int *, char *);                                  struct mdoc_argv *, int *, char *);
 static  int              pwarn(struct mdoc *, int, int, enum mwarn);  
   
 /* Per-argument flags. */  /* Per-argument flags. */
   
Line 275 
Line 267 
                 /* XXX - restore saved zeroed byte. */                  /* XXX - restore saved zeroed byte. */
                 if (sv)                  if (sv)
                         buf[*pos - 1] = sv;                          buf[*pos - 1] = sv;
                 if ( ! pwarn(m, line, i, WARGVPARM))                  if ( ! mdoc_pwarn(m, line, i, EARGVPARM))
                         return(ARGV_ERROR);                          return(ARGV_ERROR);
                 return(ARGV_WORD);                  return(ARGV_WORD);
         }          }
Line 342 
Line 334 
 }  }
   
   
 static int  
 pwarn(struct mdoc *mdoc, int line, int pos, enum mwarn code)  
 {  
         char            *p;  
         int              c;  
   
         p = NULL;  
         c = WARN_SYNTAX;  
         switch (code) {  
         case (WQUOTPARM):  
                 p = "unexpected quoted parameter";  
                 break;  
         case (WARGVPARM):  
                 p = "argument-like parameter";  
                 break;  
         case (WCOLEMPTY):  
                 p = "last list column is empty";  
                 c = WARN_COMPAT;  
                 break;  
         case (WTAILWS):  
                 p = "trailing whitespace";  
                 c = WARN_COMPAT;  
                 break;  
         }  
         assert(p);  
         return(mdoc_pwarn(mdoc, line, pos, c, p));  
 }  
   
   
 int  int
 mdoc_args(struct mdoc *mdoc, int line,  mdoc_args(struct mdoc *m, int line,
                 int *pos, char *buf, int tok, char **v)                  int *pos, char *buf, int tok, char **v)
 {  {
         int               fl, c, i;          int               fl, c, i;
Line 388 
Line 351 
   
         switch (tok) {          switch (tok) {
         case (MDOC_It):          case (MDOC_It):
                 for (n = mdoc->last; n; n = n->parent)                  for (n = m->last; n; n = n->parent)
                         if (MDOC_BLOCK == n->type && MDOC_Bl == n->tok)                          if (MDOC_BLOCK == n->type && MDOC_Bl == n->tok)
                                 break;                                  break;
   
Line 423 
Line 386 
                 break;                  break;
         }          }
   
         return(args(mdoc, line, pos, buf, fl, v));          return(args(m, line, pos, buf, fl, v));
 }  }
   
   
 static int  static int
 args(struct mdoc *mdoc, int line,  args(struct mdoc *m, int line,
                 int *pos, char *buf, int fl, char **v)                  int *pos, char *buf, int fl, char **v)
 {  {
         int               i;          int               i;
Line 440 
Line 403 
                 return(ARGS_EOLN);                  return(ARGS_EOLN);
   
         if ('\"' == buf[*pos] && ! (fl & ARGS_QUOTED))          if ('\"' == buf[*pos] && ! (fl & ARGS_QUOTED))
                 if ( ! pwarn(mdoc, line, *pos, WQUOTPARM))                  if ( ! mdoc_pwarn(m, line, *pos, EQUOTPARM))
                         return(ARGS_ERROR);                          return(ARGS_ERROR);
   
         if ( ! (fl & ARGS_ARGVLIKE) && '-' == buf[*pos])          if ( ! (fl & ARGS_ARGVLIKE) && '-' == buf[*pos])
                 if ( ! pwarn(mdoc, line, *pos, WARGVPARM))                  if ( ! mdoc_pwarn(m, line, *pos, EARGVPARM))
                         return(ARGS_ERROR);                          return(ARGS_ERROR);
   
         /*          /*
Line 536 
Line 499 
                         }                          }
   
                         if (p && 0 == *p)                          if (p && 0 == *p)
                                 if ( ! pwarn(mdoc, line, *pos, WCOLEMPTY))                                  if ( ! mdoc_pwarn(m, line, *pos, ECOLEMPTY))
                                         return(0);                                          return(0);
                         if (p && 0 == *p && p > *v && ' ' == *(p - 1))                          if (p && 0 == *p && p > *v && ' ' == *(p - 1))
                                 if ( ! pwarn(mdoc, line, *pos, WTAILWS))                                  if ( ! mdoc_pwarn(m, line, *pos, ETAILWS))
                                         return(0);                                          return(0);
   
                         if (p)                          if (p)
Line 551 
Line 514 
                         assert(p);                          assert(p);
   
                         if (p > *v && ' ' == *(p - 1))                          if (p > *v && ' ' == *(p - 1))
                                 if ( ! pwarn(mdoc, line, *pos, WTAILWS))                                  if ( ! mdoc_pwarn(m, line, *pos, ETAILWS))
                                         return(0);                                          return(0);
                         *pos += (int)(p - *v);                          *pos += (int)(p - *v);
   
Line 583 
Line 546 
                 if (buf[*pos])                  if (buf[*pos])
                         return(ARGS_WORD);                          return(ARGS_WORD);
   
                 if ( ! pwarn(mdoc, line, *pos, WTAILWS))                  if ( ! mdoc_pwarn(m, line, *pos, ETAILWS))
                         return(ARGS_ERROR);                          return(ARGS_ERROR);
   
                 return(ARGS_WORD);                  return(ARGS_WORD);
Line 601 
Line 564 
                 (*pos)++;                  (*pos)++;
   
         if (0 == buf[*pos]) {          if (0 == buf[*pos]) {
                 (void)mdoc_perr(mdoc, line, *pos, EQUOTTERM);                  (void)mdoc_perr(m, line, *pos, EQUOTTERM);
                 return(ARGS_ERROR);                  return(ARGS_ERROR);
         }          }
   
Line 615 
Line 578 
         if (buf[*pos])          if (buf[*pos])
                 return(ARGS_QWORD);                  return(ARGS_QWORD);
   
         if ( ! pwarn(mdoc, line, *pos, WTAILWS))          if ( ! mdoc_pwarn(m, line, *pos, ETAILWS))
                 return(ARGS_ERROR);                  return(ARGS_ERROR);
   
         return(ARGS_QWORD);          return(ARGS_QWORD);

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8