[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.5 and 1.6

version 1.5, 2009/07/12 20:30:27 version 1.6, 2009/07/12 21:08:29
Line 229 
Line 229 
  * one mandatory value, an optional single value, or no value.   * one mandatory value, an optional single value, or no value.
  */   */
 int  int
 mdoc_argv(struct mdoc *mdoc, int line, int tok,  mdoc_argv(struct mdoc *m, int line, int tok,
                 struct mdoc_arg **v, int *pos, char *buf)                  struct mdoc_arg **v, int *pos, char *buf)
 {  {
         int               i;          int               i;
Line 278 
Line 278 
                 /* XXX - restore saved zeroed byte. */                  /* XXX - restore saved zeroed byte. */
                 if (sv)                  if (sv)
                         buf[*pos - 1] = sv;                          buf[*pos - 1] = sv;
                 if ( ! pwarn(mdoc, line, i, WARGVPARM))                  if ( ! pwarn(m, line, i, WARGVPARM))
                         return(ARGV_ERROR);                          return(ARGV_ERROR);
                 return(ARGV_WORD);                  return(ARGV_WORD);
         }          }
Line 286 
Line 286 
         while (buf[*pos] && ' ' == buf[*pos])          while (buf[*pos] && ' ' == buf[*pos])
                 (*pos)++;                  (*pos)++;
   
         if ( ! argv(mdoc, line, &tmp, pos, buf))          if ( ! argv(m, line, &tmp, pos, buf))
                 return(ARGV_ERROR);                  return(ARGV_ERROR);
   
         if (NULL == (arg = *v)) {          if (NULL == (arg = *v)) {
                 *v = calloc(1, sizeof(struct mdoc_arg));                  *v = calloc(1, sizeof(struct mdoc_arg));
                 if (NULL == *v) {                  if (NULL == *v) {
                         (void)verr(mdoc, EMALLOC);                          (void)mdoc_nerr(m, m->last, EMALLOC);
                         return(ARGV_ERROR);                          return(ARGV_ERROR);
                 }                  }
                 arg = *v;                  arg = *v;
Line 303 
Line 303 
                         sizeof(struct mdoc_argv));                          sizeof(struct mdoc_argv));
   
         if (NULL == arg->argv) {          if (NULL == arg->argv) {
                 (void)verr(mdoc, EMALLOC);                  (void)mdoc_nerr(m, m->last, EMALLOC);
                 return(ARGV_ERROR);                  return(ARGV_ERROR);
         }          }
   
Line 747 
Line 747 
   
   
 static int  static int
 argv_multi(struct mdoc *mdoc, int line,  argv_multi(struct mdoc *m, int line,
                 struct mdoc_argv *v, int *pos, char *buf)                  struct mdoc_argv *v, int *pos, char *buf)
 {  {
         int              c;          int              c;
Line 756 
Line 756 
         for (v->sz = 0; ; v->sz++) {          for (v->sz = 0; ; v->sz++) {
                 if ('-' == buf[*pos])                  if ('-' == buf[*pos])
                         break;                          break;
                 c = args(mdoc, line, pos, buf, ARGS_QUOTED, &p);                  c = args(m, line, pos, buf, ARGS_QUOTED, &p);
                 if (ARGS_ERROR == c)                  if (ARGS_ERROR == c)
                         return(0);                          return(0);
                 else if (ARGS_EOLN == c)                  else if (ARGS_EOLN == c)
Line 766 
Line 766 
                         v->value = realloc(v->value,                          v->value = realloc(v->value,
                                 (v->sz + MULTI_STEP) * sizeof(char *));                                  (v->sz + MULTI_STEP) * sizeof(char *));
                         if (NULL == v->value) {                          if (NULL == v->value) {
                                 (void)verr(mdoc, EMALLOC);                                  (void)mdoc_nerr(m, m->last, EMALLOC);
                                 return(ARGV_ERROR);                                  return(ARGV_ERROR);
                         }                          }
                 }                  }
                 if (NULL == (v->value[(int)v->sz] = strdup(p)))                  if (NULL == (v->value[(int)v->sz] = strdup(p)))
                         return(verr(mdoc, EMALLOC));                          return(mdoc_nerr(m, m->last, EMALLOC));
         }          }
   
         return(1);          return(1);
Line 779 
Line 779 
   
   
 static int  static int
 argv_opt_single(struct mdoc *mdoc, int line,  argv_opt_single(struct mdoc *m, int line,
                 struct mdoc_argv *v, int *pos, char *buf)                  struct mdoc_argv *v, int *pos, char *buf)
 {  {
         int              c;          int              c;
Line 788 
Line 788 
         if ('-' == buf[*pos])          if ('-' == buf[*pos])
                 return(1);                  return(1);
   
         c = args(mdoc, line, pos, buf, ARGS_QUOTED, &p);          c = args(m, line, pos, buf, ARGS_QUOTED, &p);
         if (ARGS_ERROR == c)          if (ARGS_ERROR == c)
                 return(0);                  return(0);
         if (ARGS_EOLN == c)          if (ARGS_EOLN == c)
Line 796 
Line 796 
   
         v->sz = 1;          v->sz = 1;
         if (NULL == (v->value = calloc(1, sizeof(char *))))          if (NULL == (v->value = calloc(1, sizeof(char *))))
                 return(verr(mdoc, EMALLOC));                  return(mdoc_nerr(m, m->last, EMALLOC));
         if (NULL == (v->value[0] = strdup(p)))          if (NULL == (v->value[0] = strdup(p)))
                 return(verr(mdoc, EMALLOC));                  return(mdoc_nerr(m, m->last, EMALLOC));
   
         return(1);          return(1);
 }  }
Line 808 
Line 808 
  * Parse a single, mandatory value from the stream.   * Parse a single, mandatory value from the stream.
  */   */
 static int  static int
 argv_single(struct mdoc *mdoc, int line,  argv_single(struct mdoc *m, int line,
                 struct mdoc_argv *v, int *pos, char *buf)                  struct mdoc_argv *v, int *pos, char *buf)
 {  {
         int              c, ppos;          int              c, ppos;
Line 816 
Line 816 
   
         ppos = *pos;          ppos = *pos;
   
         c = args(mdoc, line, pos, buf, ARGS_QUOTED, &p);          c = args(m, line, pos, buf, ARGS_QUOTED, &p);
         if (ARGS_ERROR == c)          if (ARGS_ERROR == c)
                 return(0);                  return(0);
         if (ARGS_EOLN == c)          if (ARGS_EOLN == c)
                 return(perr(mdoc, line, ppos, EARGVAL));                  return(perr(m, line, ppos, EARGVAL));
   
         v->sz = 1;          v->sz = 1;
         if (NULL == (v->value = calloc(1, sizeof(char *))))          if (NULL == (v->value = calloc(1, sizeof(char *))))
                 return(verr(mdoc, EMALLOC));                  return(mdoc_nerr(m, m->last, EMALLOC));
         if (NULL == (v->value[0] = strdup(p)))          if (NULL == (v->value[0] = strdup(p)))
                 return(verr(mdoc, EMALLOC));                  return(mdoc_nerr(m, m->last, EMALLOC));
   
         return(1);          return(1);
 }  }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6