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

Diff for /mandoc/Attic/argv.c between version 1.14 and 1.20

version 1.14, 2009/01/16 11:50:54 version 1.20, 2009/01/20 13:44:05
Line 25 
Line 25 
   
 #include "private.h"  #include "private.h"
   
   /*
    * Parse arguments and parameters of macros.  Arguments follow the
    * syntax of `-arg [val [valN...]]', while parameters are free-form text
    * following arguments (if any).  This file must correctly handle the
    * strange punctuation rules dictated by groff.
    */
   
   /* FIXME: .It called with -column and quoted arguments. */
   
 static  int              lookup(int, const char *);  static  int              lookup(int, const char *);
 static  int              parse(struct mdoc *, int, int,  static  int              parse(struct mdoc *, int,
                                 struct mdoc_arg *, int *, char *);                                  struct mdoc_arg *, int *, char *);
 static  int              parse_single(struct mdoc *, int,  static  int              parse_single(struct mdoc *, int,
                                 struct mdoc_arg *, int *, char *);                                  struct mdoc_arg *, int *, char *);
Line 76  mdoc_args(struct mdoc *mdoc, int line, int *pos, char 
Line 84  mdoc_args(struct mdoc *mdoc, int line, int *pos, char 
   
         /* Parse routine for non-quoted string. */          /* Parse routine for non-quoted string. */
   
         if ('\"' != buf[*pos]) {          assert(*pos > 0);
           if ('\"' != buf[*pos] || ! (ARGS_QUOTED & fl)) {
                 *v = &buf[*pos];                  *v = &buf[*pos];
   
                 /* FIXME: UGLY tab-sep processing. */                  /* FIXME: UGLY tab-sep processing. */
Line 96  mdoc_args(struct mdoc *mdoc, int line, int *pos, char 
Line 105  mdoc_args(struct mdoc *mdoc, int line, int *pos, char 
                                 }                                  }
                                 (*pos)++;                                  (*pos)++;
                         }                          }
                 else                  else {
                         while (buf[*pos] && ! isspace(buf[*pos]))                          while (buf[*pos]) {
                                   if (isspace(buf[*pos]))
                                           if ('\\' != buf[*pos - 1])
                                                   break;
                                 (*pos)++;                                  (*pos)++;
                           }
                   }
   
                 if (0 == buf[*pos])                  if (0 == buf[*pos])
                         return(ARGS_WORD);                          return(ARGS_WORD);
Line 139  mdoc_args(struct mdoc *mdoc, int line, int *pos, char 
Line 153  mdoc_args(struct mdoc *mdoc, int line, int *pos, char 
   
         buf[(*pos)++] = 0;          buf[(*pos)++] = 0;
         if (0 == buf[*pos])          if (0 == buf[*pos])
                 return(ARGS_WORD);                  return(ARGS_QWORD);
   
         while (buf[*pos] && isspace(buf[*pos]))          while (buf[*pos] && isspace(buf[*pos]))
                 (*pos)++;                  (*pos)++;
   
         if (buf[*pos])          if (buf[*pos])
                 return(ARGS_WORD);                  return(ARGS_QWORD);
   
         if ( ! mdoc_pwarn(mdoc, line, *pos, WARN_COMPAT, "whitespace at end-of-line"))          if ( ! mdoc_pwarn(mdoc, line, *pos, WARN_COMPAT, "whitespace at end-of-line"))
                 return(ARGS_ERROR);                  return(ARGS_ERROR);
   
         return(ARGS_WORD);          return(ARGS_QWORD);
 }  }
   
   
Line 402  parse_single(struct mdoc *mdoc, int line, 
Line 416  parse_single(struct mdoc *mdoc, int line, 
   
   
 static int  static int
 parse(struct mdoc *mdoc, int line, int tok,  parse(struct mdoc *mdoc, int line,
                 struct mdoc_arg *v, int *pos, char *buf)                  struct mdoc_arg *v, int *pos, char *buf)
 {  {
   
Line 449  mdoc_argv(struct mdoc *mdoc, int line, int tok,
Line 463  mdoc_argv(struct mdoc *mdoc, int line, int tok,
         v->line = line;          v->line = line;
         v->pos = *pos;          v->pos = *pos;
   
         while (buf[*pos] && ! isspace(buf[*pos]))          assert(*pos > 0);
           while (buf[*pos]) {
                   if (isspace(buf[*pos]))
                           if ('\\' != buf[*pos - 1])
                                   break;
                 (*pos)++;                  (*pos)++;
           }
   
         if (buf[*pos])          if (buf[*pos])
                 buf[(*pos)++] = 0;                  buf[(*pos)++] = 0;
Line 467  mdoc_argv(struct mdoc *mdoc, int line, int tok,
Line 486  mdoc_argv(struct mdoc *mdoc, int line, int tok,
         /* FIXME: whitespace if no value. */          /* FIXME: whitespace if no value. */
   
         ppos = *pos;          ppos = *pos;
         if ( ! parse(mdoc, line, tok, v, pos, buf))          if ( ! parse(mdoc, line, v, pos, buf))
                 return(ARGV_ERROR);                  return(ARGV_ERROR);
         if ( ! postparse(mdoc, line, v, ppos))          if ( ! postparse(mdoc, line, v, ppos))
                 return(ARGV_ERROR);                  return(ARGV_ERROR);

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

CVSweb