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

Diff for /mandoc/mdoc_argv.c between version 1.20 and 1.23

version 1.20, 2009/07/20 14:09:38 version 1.23, 2009/08/20 08:59:12
Line 32 
Line 32 
  * There's no limit to the number or arguments that may be allocated.   * There's no limit to the number or arguments that may be allocated.
  */   */
   
 /* FIXME .Bf Li raises "macro-like parameter". */  
   
 #define ARGS_DELIM      (1 << 1)  
 #define ARGS_TABSEP     (1 << 2)  
   
 #define ARGV_NONE       (1 << 0)  #define ARGV_NONE       (1 << 0)
 #define ARGV_SINGLE     (1 << 1)  #define ARGV_SINGLE     (1 << 1)
 #define ARGV_MULTI      (1 << 2)  #define ARGV_MULTI      (1 << 2)
Line 327  mdoc_argv_free(struct mdoc_arg *p)
Line 322  mdoc_argv_free(struct mdoc_arg *p)
   
   
 int  int
 mdoc_zargs(struct mdoc *m, int line, int *pos, char *buf, char **v)  mdoc_zargs(struct mdoc *m, int line, int *pos,
                   char *buf, int flags, char **v)
 {  {
   
         return(args(m, line, pos, buf, 0, v));          return(args(m, line, pos, buf, flags, v));
 }  }
   
   
Line 376  static int
Line 372  static int
 args(struct mdoc *m, int line, int *pos,  args(struct mdoc *m, int line, int *pos,
                 char *buf, int fl, char **v)                  char *buf, int fl, char **v)
 {  {
         int               i, psv;          int               i;
         char             *p, *pp;          char             *p, *pp;
   
         assert(*pos);          assert(*pos);
Line 403  args(struct mdoc *m, int line, int *pos, 
Line 399  args(struct mdoc *m, int line, int *pos, 
                                 i++;                                  i++;
                 }                  }
   
                 /* FIXME: warn about trailing whitespace. */  
   
                 if (0 == buf[i]) {                  if (0 == buf[i]) {
                         *v = &buf[*pos];                          *v = &buf[*pos];
                           if (' ' != buf[i - 1])
                                   return(ARGS_PUNCT);
                           if (ARGS_NOWARN & fl)
                                   return(ARGS_PUNCT);
                           if ( ! mdoc_pwarn(m, line, *pos, ETAILWS))
                                   return(ARGS_ERROR);
                         return(ARGS_PUNCT);                          return(ARGS_PUNCT);
                 }                  }
         }          }
Line 421  args(struct mdoc *m, int line, int *pos, 
Line 421  args(struct mdoc *m, int line, int *pos, 
          */           */
   
         if (ARGS_TABSEP & fl) {          if (ARGS_TABSEP & fl) {
                 psv = *pos;  
   
                 /* Scan ahead to tab (can't be escaped). */                  /* Scan ahead to tab (can't be escaped). */
                 p = strchr(*v, '\t');                  p = strchr(*v, '\t');
   
Line 436  args(struct mdoc *m, int line, int *pos, 
Line 434  args(struct mdoc *m, int line, int *pos, 
                                 break;                                  break;
                 }                  }
   
                   /*
                    * Adjust new-buffer position to be beyond delimiter
                    * mark (e.g., Ta -> end + 2).
                    */
                 if (p && pp) {                  if (p && pp) {
                         *pos += pp < p ? 2 : 1;                          *pos += pp < p ? 2 : 1;
                         p = pp < p ? pp : p;                          p = pp < p ? pp : p;
Line 447  args(struct mdoc *m, int line, int *pos, 
Line 449  args(struct mdoc *m, int line, int *pos, 
                 } else                  } else
                         p = strchr(*v, 0);                          p = strchr(*v, 0);
   
                 if (0 == *p && ' ' == *(p - 1))                  /* Whitespace check for eoln case... */
                   if (0 == *p && ' ' == *(p - 1) && ! (ARGS_NOWARN & fl))
                         if ( ! mdoc_pwarn(m, line, *pos, ETAILWS))                          if ( ! mdoc_pwarn(m, line, *pos, ETAILWS))
                                 return(ARGS_ERROR);                                  return(ARGS_ERROR);
   
                 *p = 0;  
                 *pos += (int)(p - *v);                  *pos += (int)(p - *v);
   
                 /* Strip delimiter's preceding whitespace. */                  /* Strip delimiter's preceding whitespace. */
   
                 pp = p - 1;                  pp = p - 1;
                 while (pp > *v && ' ' == *pp) {                  while (pp > *v && ' ' == *pp) {
                         if (pp > *v && '\\' == *(pp - 1))                          if (pp > *v && '\\' == *(pp - 1))
Line 465  args(struct mdoc *m, int line, int *pos, 
Line 466  args(struct mdoc *m, int line, int *pos, 
                 *(pp + 1) = 0;                  *(pp + 1) = 0;
   
                 /* Strip delimiter's proceeding whitespace. */                  /* Strip delimiter's proceeding whitespace. */
   
                 for (pp = &buf[*pos]; ' ' == *pp; pp++, (*pos)++)                  for (pp = &buf[*pos]; ' ' == *pp; pp++, (*pos)++)
                         /* Skip ahead. */ ;                          /* Skip ahead. */ ;
   
Line 490  args(struct mdoc *m, int line, int *pos, 
Line 490  args(struct mdoc *m, int line, int *pos, 
                 }                  }
   
                 if (0 == buf[*pos]) {                  if (0 == buf[*pos]) {
                           if (ARGS_NOWARN & fl)
                                   return(ARGS_QWORD);
                         if ( ! mdoc_pwarn(m, line, *pos, EQUOTTERM))                          if ( ! mdoc_pwarn(m, line, *pos, EQUOTTERM))
                                 return(ARGS_ERROR);                                  return(ARGS_ERROR);
                         return(ARGS_QWORD);                          return(ARGS_QWORD);
Line 503  args(struct mdoc *m, int line, int *pos, 
Line 505  args(struct mdoc *m, int line, int *pos, 
                 while (' ' == buf[*pos])                  while (' ' == buf[*pos])
                         (*pos)++;                          (*pos)++;
   
                 if (0 == buf[*pos])                  if (0 == buf[*pos] && ! (ARGS_NOWARN & fl))
                         if ( ! mdoc_pwarn(m, line, *pos, ETAILWS))                          if ( ! mdoc_pwarn(m, line, *pos, ETAILWS))
                                 return(ARGS_ERROR);                                  return(ARGS_ERROR);
   
Line 527  args(struct mdoc *m, int line, int *pos, 
Line 529  args(struct mdoc *m, int line, int *pos, 
         while (' ' == buf[*pos])          while (' ' == buf[*pos])
                 (*pos)++;                  (*pos)++;
   
         if (0 == buf[*pos])          if (0 == buf[*pos] && ! (ARGS_NOWARN & fl))
                 if ( ! mdoc_pwarn(m, line, *pos, ETAILWS))                  if ( ! mdoc_pwarn(m, line, *pos, ETAILWS))
                         return(ARGS_ERROR);                          return(ARGS_ERROR);
   

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.23

CVSweb